tUse Win32 RichEdit rather than EDIT controls for GtkText widgets, when availab… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 40fda169b1bdaece0e8a1e621c7643de658227a9 | |
parent d9c94eab146b61d69ab2f028fe913e79bb3acb25 | |
Author: Ben Webb <[email protected]> | |
Date: Thu, 29 Aug 2002 15:56:45 +0000 | |
Use Win32 RichEdit rather than EDIT controls for GtkText widgets, when | |
available; added partial support for GtkTextBuffer tags under Win32. | |
Diffstat: | |
M src/gtkport/gtkport.c | 35 +++++++++++++++++++++++++++++… | |
1 file changed, 34 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/src/gtkport/gtkport.c b/src/gtkport/gtkport.c | |
t@@ -56,6 +56,7 @@ const gchar *GTK_STOCK_HELP = N_("_Help"); | |
#include <windows.h> | |
#include <winsock.h> | |
#include <commctrl.h> | |
+#include <richedit.h> | |
#define LISTITEMVPACK 0 | |
t@@ -63,6 +64,7 @@ const gchar *GTK_STOCK_HELP = N_("_Help"); | |
HICON mainIcon = NULL; | |
static WNDPROC customWndProc = NULL; | |
+static gboolean HaveRichEdit = FALSE; | |
static guint RecurseLevel = 0; | |
t@@ -1145,6 +1147,9 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
} | |
InitCommonControls(); | |
+ LoadLibrary("RICHED32.DLL"); | |
+ HaveRichEdit = GetClassInfo(hInstance, "RichEdit", &wc); | |
+ | |
if (!hPrevInstance) { | |
wc.style = 0; | |
wc.lpfnWndProc = MainWndProc; | |
t@@ -1928,6 +1933,30 @@ void gtk_editable_insert_text(GtkEditable *editable, co… | |
g_string_free(newstr, TRUE); | |
} | |
+static void gtk_text_view_set_format(GtkTextView *textview, | |
+ const gchar *tagname, guint len, | |
+ gint endpos) | |
+{ | |
+ CHARFORMAT cf; | |
+ GtkWidget *widget = GTK_WIDGET(textview); | |
+ | |
+ if (!GTK_WIDGET_REALIZED(widget)) { | |
+ return; | |
+ } | |
+ | |
+ mySendMessage(widget->hWnd, EM_SETSEL, (WPARAM)(endpos - len), | |
+ (LPARAM)endpos); | |
+ cf.cbSize = sizeof(CHARFORMAT); | |
+ cf.dwMask = CFM_COLOR; | |
+ if (tagname) { | |
+ cf.crTextColor = RGB(0, 0, 255); | |
+ cf.dwEffects = 0; | |
+ } else { | |
+ cf.dwEffects = CFE_AUTOCOLOR; | |
+ } | |
+ mySendMessage(widget->hWnd, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); | |
+} | |
+ | |
void gtk_editable_delete_text(GtkEditable *editable, | |
gint start_pos, gint end_pos) | |
{ | |
t@@ -2427,7 +2456,8 @@ void gtk_text_realize(GtkWidget *widget) | |
Parent = gtk_get_parent_hwnd(widget); | |
editable = GTK_EDITABLE(widget)->is_editable; | |
GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS); | |
- widget->hWnd = myCreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", | |
+ widget->hWnd = myCreateWindowEx(WS_EX_CLIENTEDGE, | |
+ HaveRichEdit ? "RichEdit" : "EDIT", "", | |
WS_CHILD | (editable ? WS_TABSTOP : 0) | | |
ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL | | |
(GTK_TEXT(widget)->word_wrap ? | |
t@@ -5470,6 +5500,9 @@ void TextViewAppend(GtkTextView *textview, const gchar *… | |
editpos = gtk_text_get_length(GTK_TEXT(textview)); | |
gtk_editable_insert_text(GTK_EDITABLE(textview), text, strlen(text), | |
&editpos); | |
+#ifdef CYGWIN | |
+ gtk_text_view_set_format(textview, tagname, strlen(text), editpos); | |
+#endif | |
if (scroll) { | |
gtk_editable_set_position(GTK_EDITABLE(textview), editpos); | |
} |