tVirtually complete UTF-8/Unicode support under Win32: - All message translatio… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 0aff4201e5efe42b1dbbd2088a1c9fc658a114d7 | |
parent 301b18e94011e4d83919e8385fde8b908a7f501c | |
Author: Ben Webb <[email protected]> | |
Date: Mon, 26 Aug 2002 13:07:06 +0000 | |
Virtually complete UTF-8/Unicode support under Win32: | |
- All message translation avoided by using wrapper functions for GetMessage, | |
SendMesage, DispatchMessage, IsDialogMessage, CallWindowProc, DefWindowProc, | |
GetWindowLong and SetWindowLong | |
- Wrappers for Header_InsertItem and TabCtrl_InsertItem which use the correct | |
message for Unicode or ANSI | |
- Relevant calls to strlen replaced with myw32strlen() which calls | |
g_utf8_strlen when running in Unicode mode | |
Diffstat: | |
M src/gtkport/clist.c | 68 +++++++++++++++++++----------… | |
M src/gtkport/gtkport.c | 129 ++++++++++++++++-------------… | |
M src/gtkport/unicodewrap.c | 158 +++++++++++++++++++++++++++++… | |
M src/gtkport/unicodewrap.h | 14 ++++++++++++++ | |
4 files changed, 272 insertions(+), 97 deletions(-) | |
--- | |
diff --git a/src/gtkport/clist.c b/src/gtkport/clist.c | |
t@@ -75,7 +75,8 @@ gboolean gtk_clist_wndproc(GtkWidget *widget, UINT msg, WPAR… | |
LPARAM lParam, gboolean *dodef) | |
{ | |
LPDRAWITEMSTRUCT lpdis; | |
- HD_NOTIFY FAR *phdr; | |
+ HD_NOTIFYA FAR *phdr; | |
+ HD_NOTIFYW FAR *phdrw; | |
NMHDR *nmhdr; | |
switch(msg) { | |
t@@ -94,14 +95,29 @@ gboolean gtk_clist_wndproc(GtkWidget *widget, UINT msg, WP… | |
break; | |
case WM_NOTIFY: | |
nmhdr = (NMHDR *)lParam; | |
- phdr = (HD_NOTIFY FAR *)lParam; | |
- if (nmhdr && nmhdr->code == HDN_ENDTRACK) { | |
- gtk_clist_set_column_width_full(GTK_CLIST(widget), phdr->iItem, | |
- phdr->pitem->cxy, FALSE); | |
- return FALSE; | |
- } else if (nmhdr && nmhdr->code == HDN_ITEMCLICK) { | |
- gtk_signal_emit(GTK_OBJECT(widget), "click-column", (gint)phdr->iItem); | |
- return FALSE; | |
+ if (nmhdr) { | |
+ switch(nmhdr->code) { | |
+ case HDN_ENDTRACKA: | |
+ phdr = (HD_NOTIFYA FAR *)lParam; | |
+ gtk_clist_set_column_width_full(GTK_CLIST(widget), phdr->iItem, | |
+ phdr->pitem->cxy, FALSE); | |
+ return FALSE; | |
+ case HDN_ENDTRACKW: | |
+ phdrw = (HD_NOTIFYW FAR *)lParam; | |
+ gtk_clist_set_column_width_full(GTK_CLIST(widget), phdrw->iItem, | |
+ phdrw->pitem->cxy, FALSE); | |
+ return FALSE; | |
+ case HDN_ITEMCLICKA: | |
+ phdr = (HD_NOTIFYA FAR *)lParam; | |
+ gtk_signal_emit(GTK_OBJECT(widget), "click-column", (gint)phdr->iItem); | |
+ return FALSE; | |
+ case HDN_ITEMCLICKW: | |
+ phdrw = (HD_NOTIFYW FAR *)lParam; | |
+ gtk_signal_emit(GTK_OBJECT(widget), "click-column", (gint)phdrw->iItem… | |
+ return FALSE; | |
+ default: | |
+ break; | |
+ } | |
} | |
break; | |
} | |
t@@ -180,7 +196,7 @@ void gtk_clist_realize(GtkWidget *widget) | |
gtk_set_default_font(header); | |
hdl.prc = &rcParent; | |
hdl.pwpos = ℘ | |
- SendMessage(header, HDM_LAYOUT, 0, (LPARAM)&hdl); | |
+ mySendMessage(header, HDM_LAYOUT, 0, (LPARAM)&hdl); | |
clist->header_size = wp.cy; | |
widget->hWnd = myCreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "", | |
WS_CHILD | WS_TABSTOP | WS_VSCROLL | |
t@@ -193,7 +209,7 @@ void gtk_clist_realize(GtkWidget *widget) | |
for (rows = clist->rowdata; rows; rows = g_slist_next(rows)) { | |
row = (GtkCListRow *)rows->data; | |
if (row) { | |
- SendMessage(widget->hWnd, LB_ADDSTRING, 0, 1); | |
+ mySendMessage(widget->hWnd, LB_ADDSTRING, 0, 1); | |
} | |
} | |
t@@ -305,7 +321,7 @@ static void gtk_clist_set_extent(GtkCList *clist) | |
for (i = 0; i < clist->cols; i++) { | |
width += clist->coldata[i].width; | |
} | |
- SendMessage(hWnd, LB_SETHORIZONTALEXTENT, (WPARAM)width, 0); | |
+ mySendMessage(hWnd, LB_SETHORIZONTALEXTENT, (WPARAM)width, 0); | |
} | |
} | |
t@@ -392,7 +408,7 @@ gint gtk_clist_insert(GtkCList *clist, gint row, gchar *te… | |
if (GTK_WIDGET_REALIZED(widget)) { | |
hWnd = widget->hWnd; | |
- SendMessage(hWnd, LB_INSERTSTRING, (WPARAM)row, 1); | |
+ mySendMessage(hWnd, LB_INSERTSTRING, (WPARAM)row, 1); | |
} | |
return row; | |
t@@ -440,7 +456,7 @@ void gtk_clist_remove(GtkCList *clist, gint row) | |
if (GTK_WIDGET_REALIZED(GTK_WIDGET(clist))) { | |
HWND hWnd = GTK_WIDGET(clist)->hWnd; | |
- SendMessage(hWnd, LB_DELETESTRING, (WPARAM)row, 0); | |
+ mySendMessage(hWnd, LB_DELETESTRING, (WPARAM)row, 0); | |
} | |
} | |
} | |
t@@ -543,11 +559,11 @@ void gtk_clist_set_column_width_full(GtkCList *clist, gi… | |
if (column == clist->cols - 1) | |
width = 9000; | |
hdi.cxy = width; | |
- if (SendMessage(header, HDM_GETITEM, (WPARAM)column, (LPARAM)&hdi) && | |
- hdi.cxy != width) { | |
+ if (mySendMessage(header, HDM_GETITEM, (WPARAM)column, (LPARAM)&hdi) | |
+ && hdi.cxy != width) { | |
hdi.mask = HDI_WIDTH; | |
hdi.cxy = width; | |
- SendMessage(header, HDM_SETITEM, (WPARAM)column, (LPARAM)&hdi); | |
+ mySendMessage(header, HDM_SETITEM, (WPARAM)column, (LPARAM)&hdi); | |
} | |
} | |
gtk_clist_set_extent(clist); | |
t@@ -598,14 +614,14 @@ void gtk_clist_sort(GtkCList *clist) | |
rowind = GPOINTER_TO_INT(sel->data); | |
else | |
rowind = -1; | |
- SendMessage(hWnd, LB_SETCURSEL, (WPARAM)rowind, 0); | |
+ mySendMessage(hWnd, LB_SETCURSEL, (WPARAM)rowind, 0); | |
} else { | |
for (rowind = 0; rowind < clist->rows; rowind++) { | |
- SendMessage(hWnd, LB_SETSEL, (WPARAM)FALSE, (LPARAM)rowind); | |
+ mySendMessage(hWnd, LB_SETSEL, (WPARAM)FALSE, (LPARAM)rowind); | |
} | |
for (sel = clist->selection; sel; sel = g_list_next(sel)) { | |
rowind = GPOINTER_TO_INT(sel->data); | |
- SendMessage(hWnd, LB_SETSEL, (WPARAM)TRUE, (LPARAM)rowind); | |
+ mySendMessage(hWnd, LB_SETSEL, (WPARAM)TRUE, (LPARAM)rowind); | |
} | |
} | |
InvalidateRect(hWnd, NULL, FALSE); | |
t@@ -643,7 +659,7 @@ void gtk_clist_clear(GtkCList *clist) | |
gtk_clist_update_all_widths(clist); | |
hWnd = GTK_WIDGET(clist)->hWnd; | |
if (hWnd) { | |
- SendMessage(hWnd, LB_RESETCONTENT, 0, 0); | |
+ mySendMessage(hWnd, LB_RESETCONTENT, 0, 0); | |
} | |
} | |
t@@ -686,9 +702,9 @@ void gtk_clist_select_row(GtkCList *clist, gint row, gint … | |
hWnd = GTK_WIDGET(clist)->hWnd; | |
if (hWnd) { | |
if (clist->mode == GTK_SELECTION_SINGLE) { | |
- SendMessage(hWnd, LB_SETCURSEL, (WPARAM)row, 0); | |
+ mySendMessage(hWnd, LB_SETCURSEL, (WPARAM)row, 0); | |
} else { | |
- SendMessage(hWnd, LB_SETSEL, (WPARAM)TRUE, (LPARAM)row); | |
+ mySendMessage(hWnd, LB_SETSEL, (WPARAM)TRUE, (LPARAM)row); | |
} | |
gtk_clist_update_selection(GTK_WIDGET(clist)); | |
} | |
t@@ -701,9 +717,9 @@ void gtk_clist_unselect_row(GtkCList *clist, gint row, gin… | |
hWnd = GTK_WIDGET(clist)->hWnd; | |
if (hWnd) { | |
if (clist->mode == GTK_SELECTION_SINGLE) { | |
- SendMessage(hWnd, LB_SETCURSEL, (WPARAM)(-1), 0); | |
+ mySendMessage(hWnd, LB_SETCURSEL, (WPARAM)(-1), 0); | |
} else { | |
- SendMessage(hWnd, LB_SETSEL, (WPARAM)FALSE, (LPARAM)row); | |
+ mySendMessage(hWnd, LB_SETSEL, (WPARAM)FALSE, (LPARAM)row); | |
} | |
gtk_clist_update_selection(GTK_WIDGET(clist)); | |
} | |
t@@ -744,7 +760,7 @@ void gtk_clist_update_selection(GtkWidget *widget) | |
clist->selection = NULL; | |
if (widget->hWnd) { | |
for (i = 0; i < clist->rows; i++) { | |
- if (SendMessage(widget->hWnd, LB_GETSEL, (WPARAM)i, 0) > 0) { | |
+ if (mySendMessage(widget->hWnd, LB_GETSEL, (WPARAM)i, 0) > 0) { | |
clist->selection = g_list_append(clist->selection, GINT_TO_POINTER(i)); | |
} | |
} | |
diff --git a/src/gtkport/gtkport.c b/src/gtkport/gtkport.c | |
t@@ -634,7 +634,7 @@ static WNDPROC wpOrigEntryProc, wpOrigTextProc; | |
void gtk_set_default_font(HWND hWnd) | |
{ | |
- SendMessage(hWnd, WM_SETFONT, (WPARAM)defFont, MAKELPARAM(FALSE, 0)); | |
+ mySendMessage(hWnd, WM_SETFONT, (WPARAM)defFont, MAKELPARAM(FALSE, 0)); | |
} | |
GtkObject *GtkNewObject(GtkClass *klass) | |
t@@ -741,7 +741,7 @@ LRESULT CALLBACK GtkPanedProc(HWND hwnd, UINT msg, UINT wP… | |
gint newpos; | |
GtkPaned *paned; | |
- paned = GTK_PANED(GetWindowLong(hwnd, GWL_USERDATA)); | |
+ paned = GTK_PANED(myGetWindowLong(hwnd, GWL_USERDATA)); | |
switch (msg) { | |
case WM_PAINT: | |
if (GetUpdateRect(hwnd, NULL, TRUE)) { | |
t@@ -809,7 +809,7 @@ LRESULT CALLBACK GtkPanedProc(HWND hwnd, UINT msg, UINT wP… | |
gtk_paned_set_position(paned, newpos); | |
return TRUE; | |
default: | |
- return DefWindowProc(hwnd, msg, wParam, lParam); | |
+ return myDefWindowProc(hwnd, msg, wParam, lParam); | |
} | |
return FALSE; | |
} | |
t@@ -830,7 +830,7 @@ LRESULT CALLBACK GtkUrlProc(HWND hwnd, UINT msg, UINT wPar… | |
HDC hDC; | |
HFONT oldFont; | |
- widget = GTK_WIDGET(GetWindowLong(hwnd, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(hwnd, GWL_USERDATA)); | |
text = GTK_LABEL(widget)->text; | |
if (text && BeginPaint(hwnd, &ps)) { | |
hDC = ps.hdc; | |
t@@ -845,12 +845,12 @@ LRESULT CALLBACK GtkUrlProc(HWND hwnd, UINT msg, UINT wP… | |
} | |
return TRUE; | |
} else if (msg == WM_LBUTTONUP) { | |
- widget = GTK_WIDGET(GetWindowLong(hwnd, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(hwnd, GWL_USERDATA)); | |
DisplayHTML(widget, NULL, GTK_URL(widget)->target); | |
return FALSE; | |
} else | |
- return DefWindowProc(hwnd, msg, wParam, lParam); | |
+ return myDefWindowProc(hwnd, msg, wParam, lParam); | |
} | |
LRESULT CALLBACK GtkSepProc(HWND hwnd, UINT msg, UINT wParam, LONG lParam) | |
t@@ -895,7 +895,7 @@ LRESULT CALLBACK GtkSepProc(HWND hwnd, UINT msg, UINT wPar… | |
} | |
return TRUE; | |
} else | |
- return DefWindowProc(hwnd, msg, wParam, lParam); | |
+ return myDefWindowProc(hwnd, msg, wParam, lParam); | |
} | |
gboolean gtk_window_wndproc(GtkWidget *widget, UINT msg, WPARAM wParam, | |
t@@ -975,10 +975,10 @@ static BOOL HandleWinMessage(HWND hwnd, UINT msg, WPARAM… | |
*dodef = TRUE; | |
if (customWndProc | |
- && CallWindowProc(customWndProc, hwnd, msg, wParam, lParam)) | |
+ && myCallWindowProc(customWndProc, hwnd, msg, wParam, lParam)) | |
return TRUE; | |
- widget = GTK_WIDGET(GetWindowLong(hwnd, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(hwnd, GWL_USERDATA)); | |
if (widget && (klass = GTK_OBJECT(widget)->klass) | |
&& klass->wndproc) { | |
retval = klass->wndproc(widget, msg, wParam, lParam, dodef); | |
t@@ -987,7 +987,7 @@ static BOOL HandleWinMessage(HWND hwnd, UINT msg, WPARAM w… | |
switch (msg) { | |
case WM_DRAWITEM: | |
if ((lpdis = (LPDRAWITEMSTRUCT)lParam) | |
- && (widget = GTK_WIDGET(GetWindowLong(lpdis->hwndItem, GWL_USERDATA))) | |
+ && (widget = GTK_WIDGET(myGetWindowLong(lpdis->hwndItem, GWL_USERDATA)… | |
&& (klass = GTK_OBJECT(widget)->klass) | |
&& klass->wndproc) { | |
retval = klass->wndproc(widget, msg, wParam, lParam, dodef); | |
t@@ -1005,7 +1005,7 @@ static BOOL HandleWinMessage(HWND hwnd, UINT msg, WPARAM… | |
} | |
break; | |
case WM_COMMAND: | |
- widget = GTK_WIDGET(GetWindowLong((HWND)lParam, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong((HWND)lParam, GWL_USERDATA)); | |
klass = NULL; | |
if (widget && (klass = GTK_OBJECT(widget)->klass) | |
&& klass->wndproc) { | |
t@@ -1026,7 +1026,7 @@ static BOOL HandleWinMessage(HWND hwnd, UINT msg, WPARAM… | |
if (!nmhdr) | |
break; | |
- widget = GTK_WIDGET(GetWindowLong(nmhdr->hwndFrom, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(nmhdr->hwndFrom, GWL_USERDATA)); | |
if (widget && (klass = GTK_OBJECT(widget)->klass) | |
&& klass->wndproc) { | |
retval = klass->wndproc(widget, msg, wParam, lParam, dodef); | |
t@@ -1061,7 +1061,7 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM… | |
retval = HandleWinMessage(hwnd, msg, wParam, lParam, &dodef); | |
if (dodef) { | |
- return DefWindowProc(hwnd, msg, wParam, lParam); | |
+ return myDefWindowProc(hwnd, msg, wParam, lParam); | |
} else { | |
return retval; | |
} | |
t@@ -1084,12 +1084,12 @@ LRESULT APIENTRY EntryWndProc(HWND hwnd, UINT msg, WPA… | |
GtkWidget *widget; | |
if (msg == WM_KEYUP && wParam == VK_RETURN) { | |
- widget = GTK_WIDGET(GetWindowLong(hwnd, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(hwnd, GWL_USERDATA)); | |
if (widget) | |
gtk_signal_emit(GTK_OBJECT(widget), "activate"); | |
return FALSE; | |
} | |
- return CallWindowProc(wpOrigEntryProc, hwnd, msg, wParam, lParam); | |
+ return myCallWindowProc(wpOrigEntryProc, hwnd, msg, wParam, lParam); | |
} | |
LRESULT APIENTRY TextWndProc(HWND hwnd, UINT msg, WPARAM wParam, | |
t@@ -1098,12 +1098,12 @@ LRESULT APIENTRY TextWndProc(HWND hwnd, UINT msg, WPAR… | |
GtkWidget *widget; | |
if (msg == WM_GETDLGCODE) { | |
- widget = GTK_WIDGET(GetWindowLong(hwnd, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(hwnd, GWL_USERDATA)); | |
if (!GTK_EDITABLE(widget)->is_editable) { | |
return DLGC_HASSETSEL | DLGC_WANTARROWS; | |
} | |
} | |
- return CallWindowProc(wpOrigTextProc, hwnd, msg, wParam, lParam); | |
+ return myCallWindowProc(wpOrigTextProc, hwnd, msg, wParam, lParam); | |
} | |
void SetCustomWndProc(WNDPROC wndproc) | |
t@@ -1131,6 +1131,8 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
} else { | |
mainIcon = LoadIcon(NULL, IDI_APPLICATION); | |
} | |
+ | |
+ InitCommonControls(); | |
if (!hPrevInstance) { | |
wc.style = 0; | |
wc.lpfnWndProc = MainWndProc; | |
t@@ -1204,8 +1206,6 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
wc.lpszClassName = WC_GTKURL; | |
myRegisterClass(&wc); | |
} | |
- | |
- InitCommonControls(); | |
} | |
guint gtk_main_level(void) | |
t@@ -1341,7 +1341,7 @@ static BOOL CALLBACK SetFocusEnum(HWND hWnd, LPARAM data) | |
GtkWidget *widget; | |
GtkWindow *window = GTK_WINDOW(data); | |
- widget = GTK_WIDGET(GetWindowLong(hWnd, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(hWnd, GWL_USERDATA)); | |
if (!widget || !GTK_WIDGET_CAN_FOCUS(widget) || | |
!GTK_WIDGET_SENSITIVE(widget) || !GTK_WIDGET_VISIBLE(widget) || | |
window->focus == widget) { | |
t@@ -1384,7 +1384,7 @@ void gtk_window_update_focus(GtkWindow *window) | |
FocusWnd = GetFocus(); | |
window->focus = NULL; | |
if (FocusWnd) { | |
- widget = GTK_WIDGET(GetWindowLong(FocusWnd, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(FocusWnd, GWL_USERDATA)); | |
if (widget && GTK_WIDGET(window)->hWnd && | |
GetParent(FocusWnd) == GTK_WIDGET(window)->hWnd) { | |
window->focus = widget; | |
t@@ -1400,7 +1400,7 @@ void gtk_widget_realize(GtkWidget *widget) | |
return; | |
gtk_signal_emit(GTK_OBJECT(widget), "realize", &req); | |
if (widget->hWnd) | |
- SetWindowLong(widget->hWnd, GWL_USERDATA, (LONG)widget); | |
+ mySetWindowLong(widget->hWnd, GWL_USERDATA, (LONG)widget); | |
GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); | |
gtk_widget_set_sensitive(widget, GTK_WIDGET_SENSITIVE(widget)); | |
t@@ -1908,8 +1908,8 @@ void gtk_editable_insert_text(GtkEditable *editable, con… | |
hWnd = widget->hWnd; | |
if (hWnd) { | |
- SendMessage(hWnd, EM_SETSEL, (WPARAM)*position, (LPARAM)*position); | |
- SendMessage(hWnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)newstr->str); | |
+ mySendMessage(hWnd, EM_SETSEL, (WPARAM)*position, (LPARAM)*position); | |
+ myEditReplaceSel(hWnd, FALSE, newstr->str); | |
*position += newstr->len; | |
gtk_editable_set_position(editable, *position); | |
} | |
t@@ -1958,7 +1958,7 @@ void gtk_editable_set_editable(GtkEditable *editable, gb… | |
editable->is_editable = is_editable; | |
hWnd = widget->hWnd; | |
if (hWnd) | |
- SendMessage(hWnd, EM_SETREADONLY, (WPARAM)(!is_editable), (LPARAM)0); | |
+ mySendMessage(hWnd, EM_SETREADONLY, (WPARAM)(!is_editable), (LPARAM)0); | |
} | |
void gtk_editable_set_position(GtkEditable *editable, gint position) | |
t@@ -1969,8 +1969,8 @@ void gtk_editable_set_position(GtkEditable *editable, gi… | |
if (!GTK_WIDGET_REALIZED(widget)) | |
return; | |
hWnd = widget->hWnd; | |
- SendMessage(hWnd, EM_SETSEL, (WPARAM)position, (LPARAM)position); | |
- SendMessage(hWnd, EM_SCROLLCARET, 0, 0); | |
+ mySendMessage(hWnd, EM_SETSEL, (WPARAM)position, (LPARAM)position); | |
+ mySendMessage(hWnd, EM_SCROLLCARET, 0, 0); | |
} | |
gint gtk_editable_get_position(GtkEditable *editable) | |
t@@ -1982,7 +1982,7 @@ gint gtk_editable_get_position(GtkEditable *editable) | |
if (!GTK_WIDGET_REALIZED(widget)) | |
return 0; | |
hWnd = widget->hWnd; | |
- SendMessage(hWnd, EM_GETSEL, (WPARAM)NULL, (LPARAM)&EndPos); | |
+ mySendMessage(hWnd, EM_GETSEL, (WPARAM)NULL, (LPARAM)&EndPos); | |
return (gint)EndPos; | |
} | |
t@@ -2396,9 +2396,9 @@ void gtk_entry_realize(GtkWidget *widget) | |
hInst, NULL); | |
/* Subclass the window (we assume that all edit boxes have the same | |
* window procedure) */ | |
- wpOrigEntryProc = (WNDPROC)SetWindowLong(widget->hWnd, | |
- GWL_WNDPROC, | |
- (LONG)EntryWndProc); | |
+ wpOrigEntryProc = (WNDPROC)mySetWindowLong(widget->hWnd, | |
+ GWL_WNDPROC, | |
+ (LONG)EntryWndProc); | |
gtk_set_default_font(widget->hWnd); | |
gtk_editable_set_editable(GTK_EDITABLE(widget), | |
GTK_EDITABLE(widget)->is_editable); | |
t@@ -2423,9 +2423,9 @@ void gtk_text_realize(GtkWidget *widget) | |
0, Parent, NULL, hInst, NULL); | |
/* Subclass the window (we assume that all multiline edit boxes have the | |
* same window procedure) */ | |
- wpOrigTextProc = (WNDPROC)SetWindowLong(widget->hWnd, | |
- GWL_WNDPROC, | |
- (LONG)TextWndProc); | |
+ wpOrigTextProc = (WNDPROC)mySetWindowLong(widget->hWnd, | |
+ GWL_WNDPROC, | |
+ (LONG)TextWndProc); | |
gtk_set_default_font(widget->hWnd); | |
gtk_editable_set_editable(GTK_EDITABLE(widget), | |
GTK_EDITABLE(widget)->is_editable); | |
t@@ -3062,8 +3062,8 @@ void gtk_check_button_toggled(GtkCheckButton *check_butt… | |
hWnd = GTK_WIDGET(check_button)->hWnd; | |
if (hWnd) { | |
- SendMessage(hWnd, BM_SETCHECK, | |
- is_active ? BST_CHECKED : BST_UNCHECKED, 0); | |
+ mySendMessage(hWnd, BM_SETCHECK, | |
+ is_active ? BST_CHECKED : BST_UNCHECKED, 0); | |
} | |
} | |
t@@ -3086,8 +3086,8 @@ void gtk_radio_button_toggled(GtkRadioButton *radio_butt… | |
hWnd = GTK_WIDGET(radio_button)->hWnd; | |
if (hWnd) { | |
- SendMessage(hWnd, BM_SETCHECK, | |
- is_active ? BST_CHECKED : BST_UNCHECKED, 0); | |
+ mySendMessage(hWnd, BM_SETCHECK, | |
+ is_active ? BST_CHECKED : BST_UNCHECKED, 0); | |
} | |
if (is_active) { | |
for (group = radio_button->group; group; group = g_slist_next(group)) { | |
t@@ -3096,7 +3096,7 @@ void gtk_radio_button_toggled(GtkRadioButton *radio_butt… | |
GTK_TOGGLE_BUTTON(radio)->toggled = FALSE; | |
hWnd = GTK_WIDGET(radio)->hWnd; | |
if (hWnd) | |
- SendMessage(hWnd, BM_SETCHECK, BST_UNCHECKED, 0); | |
+ mySendMessage(hWnd, BM_SETCHECK, BST_UNCHECKED, 0); | |
} | |
} | |
} | |
t@@ -3131,9 +3131,9 @@ void gtk_main() | |
RecurseLevel++; | |
- while (GetMessage(&msg, NULL, 0, 0)) { | |
+ while (myGetMessage(&msg, NULL, 0, 0)) { | |
MsgDone = FALSE; | |
- widget = GTK_WIDGET(GetWindowLong(msg.hwnd, GWL_USERDATA)); | |
+ widget = GTK_WIDGET(myGetWindowLong(msg.hwnd, GWL_USERDATA)); | |
window = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW); | |
if (window) { | |
hAccel = GTK_WINDOW(window)->hAccel; | |
t@@ -3145,12 +3145,12 @@ void gtk_main() | |
for (list = WindowList; list && !MsgDone; list = g_slist_next(list)) { | |
widget = GTK_WIDGET(list->data); | |
if (widget && widget->hWnd | |
- && (MsgDone = IsDialogMessage(widget->hWnd, &msg)) == TRUE) | |
+ && (MsgDone = myIsDialogMessage(widget->hWnd, &msg)) == TRUE) | |
break; | |
} | |
if (!MsgDone) { | |
TranslateMessage(&msg); | |
- DispatchMessage(&msg); | |
+ myDispatchMessage(&msg); | |
} | |
} | |
RecurseLevel--; | |
t@@ -3812,7 +3812,7 @@ void gtk_menu_item_realize(GtkWidget *widget) | |
} | |
mii.wID = menu_item->ID; | |
mii.dwTypeData = (LPTSTR)menu_item->text; | |
- mii.cch = strlen(menu_item->text); | |
+ mii.cch = myw32strlen(menu_item->text); | |
myInsertMenuItem(parent_menu, pos, TRUE, &mii); | |
} | |
t@@ -3962,7 +3962,7 @@ void gtk_notebook_realize(GtkWidget *widget) | |
tie.pszText = GTK_LABEL(note_child->tab_label)->text; | |
else | |
tie.pszText = "No label"; | |
- TabCtrl_InsertItem(widget->hWnd, tab_pos++, &tie); | |
+ myTabCtrl_InsertItem(widget->hWnd, tab_pos++, &tie); | |
if (note_child->child) { | |
gtk_widget_realize(note_child->child); | |
} | |
t@@ -4139,7 +4139,7 @@ gint gtk_spin_button_get_value_as_int(GtkSpinButton *spi… | |
hWnd = spin_button->updown; | |
if (hWnd) { | |
- lres = SendMessage(hWnd, UDM_GETPOS, 0, 0); | |
+ lres = mySendMessage(hWnd, UDM_GETPOS, 0, 0); | |
if (HIWORD(lres) != 0) | |
return 0; | |
else | |
t@@ -4155,7 +4155,7 @@ void gtk_spin_button_set_value(GtkSpinButton *spin_butto… | |
spin_button->adj->value = value; | |
hWnd = spin_button->updown; | |
if (hWnd) | |
- SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)value, 0)); | |
+ mySendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)value, 0)); | |
} | |
void gtk_spin_button_set_adjustment(GtkSpinButton *spin_button, | |
t@@ -4166,11 +4166,11 @@ void gtk_spin_button_set_adjustment(GtkSpinButton *spi… | |
spin_button->adj = adjustment; | |
hWnd = spin_button->updown; | |
if (hWnd) { | |
- SendMessage(hWnd, UDM_SETRANGE, 0, | |
- (LPARAM)MAKELONG((short)adjustment->upper, | |
- (short)adjustment->lower)); | |
- SendMessage(hWnd, UDM_SETPOS, 0, | |
- (LPARAM)MAKELONG((short)adjustment->value, 0)); | |
+ mySendMessage(hWnd, UDM_SETRANGE, 0, | |
+ (LPARAM)MAKELONG((short)adjustment->upper, | |
+ (short)adjustment->lower)); | |
+ mySendMessage(hWnd, UDM_SETPOS, 0, | |
+ (LPARAM)MAKELONG((short)adjustment->value, 0)); | |
} | |
} | |
t@@ -4368,7 +4368,7 @@ void gtk_entry_set_visibility(GtkEntry *entry, gboolean … | |
entry->is_visible = visible; | |
hWnd = GTK_WIDGET(entry)->hWnd; | |
if (hWnd) | |
- SendMessage(hWnd, EM_SETPASSWORDCHAR, visible ? 0 : (WPARAM)'*', 0); | |
+ mySendMessage(hWnd, EM_SETPASSWORDCHAR, visible ? 0 : (WPARAM)'*', 0); | |
} | |
guint SetAccelerator(GtkWidget *labelparent, gchar *Text, | |
t@@ -4654,14 +4654,14 @@ void gtk_option_menu_set_menu(GtkOptionMenu *option_me… | |
hWnd = GTK_WIDGET(option_menu)->hWnd; | |
if (hWnd) { | |
- SendMessage(hWnd, CB_RESETCONTENT, 0, 0); | |
+ mySendMessage(hWnd, CB_RESETCONTENT, 0, 0); | |
for (list = GTK_MENU_SHELL(menu)->children; list; | |
list = g_slist_next(list)) { | |
menu_item = GTK_MENU_ITEM(list->data); | |
if (menu_item && menu_item->text) | |
- SendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)menu_item->text); | |
+ mySendMessage(hWnd, CB_ADDSTRING, 0, (LPARAM)menu_item->text); | |
} | |
- SendMessage(hWnd, CB_SETCURSEL, (WPARAM)GTK_MENU(menu)->active, 0); | |
+ mySendMessage(hWnd, CB_SETCURSEL, (WPARAM)GTK_MENU(menu)->active, 0); | |
} | |
} | |
t@@ -4750,7 +4750,7 @@ static void gtk_menu_item_set_text(GtkMenuItem *menuitem… | |
mii.fMask = MIIM_TYPE; | |
mii.fType = MFT_STRING; | |
mii.dwTypeData = (LPTSTR)menuitem->text; | |
- mii.cch = strlen(menuitem->text); | |
+ mii.cch = myw32strlen(menuitem->text); | |
mySetMenuItemInfo(parent_menu, menuitem->ID, FALSE, &mii); | |
} | |
} | |
t@@ -4802,7 +4802,7 @@ void gtk_option_menu_update_selection(GtkWidget *widget) | |
if (widget->hWnd == NULL) | |
return; | |
- lres = SendMessage(widget->hWnd, CB_GETCURSEL, 0, 0); | |
+ lres = mySendMessage(widget->hWnd, CB_GETCURSEL, 0, 0); | |
if (lres == CB_ERR) | |
return; | |
t@@ -4917,8 +4917,8 @@ void gtk_progress_bar_update(GtkProgressBar *pbar, gfloa… | |
widget = GTK_WIDGET(pbar); | |
pbar->position = percentage; | |
if (GTK_WIDGET_REALIZED(widget)) { | |
- SendMessage(widget->hWnd, PBM_SETPOS, | |
- (WPARAM)(10000.0 * pbar->position), 0); | |
+ mySendMessage(widget->hWnd, PBM_SETPOS, | |
+ (WPARAM)(10000.0 * pbar->position), 0); | |
} | |
} | |
t@@ -4947,8 +4947,9 @@ void gtk_progress_bar_realize(GtkWidget *widget) | |
widget->allocation.height, Parent, NULL, | |
hInst, NULL); | |
gtk_set_default_font(widget->hWnd); | |
- SendMessage(widget->hWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 10000)); | |
- SendMessage(widget->hWnd, PBM_SETPOS, (WPARAM)(10000.0 * prog->position), 0); | |
+ mySendMessage(widget->hWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 10000)); | |
+ mySendMessage(widget->hWnd, PBM_SETPOS, (WPARAM)(10000.0 * prog->position), | |
+ 0); | |
} | |
gint GtkMessageBox(GtkWidget *parent, const gchar *Text, | |
t@@ -4968,8 +4969,8 @@ gint GtkMessageBox(GtkWidget *parent, const gchar *Text, | |
default: | |
} | |
- retval = MessageBox(parent && parent->hWnd ? parent->hWnd : NULL, | |
- Text, Title, Options); | |
+ retval = myMessageBox(parent && parent->hWnd ? parent->hWnd : NULL, | |
+ Text, Title, Options); | |
RecurseLevel--; | |
return retval; | |
diff --git a/src/gtkport/unicodewrap.c b/src/gtkport/unicodewrap.c | |
t@@ -253,8 +253,7 @@ static BOOL makeHeaderItemW(HD_ITEMW *phdiw, const HD_ITEM… | |
{ | |
BOOL strdata; | |
-//strdata = phdi->mask & HDI_TEXT; | |
- strdata = FALSE; | |
+ strdata = phdi->mask & HDI_TEXT; | |
phdiw->mask = phdi->mask; | |
phdiw->cxy = phdi->cxy; | |
t@@ -267,6 +266,20 @@ static BOOL makeHeaderItemW(HD_ITEMW *phdiw, const HD_ITE… | |
return strdata; | |
} | |
+static BOOL makeTabItemW(TC_ITEMW *tiew, const TC_ITEM *tie) | |
+{ | |
+ BOOL strdata; | |
+ | |
+ strdata = tie->mask & TCIF_TEXT; | |
+ tiew->mask = tie->mask; | |
+ tiew->pszText = strdata ? strtow32(tie->pszText, -1) | |
+ : (LPWSTR)tie->pszText; | |
+ tiew->cchTextMax = tie->cchTextMax; | |
+ tiew->iImage = tie->iImage; | |
+ tiew->lParam = tie->lParam; | |
+ return strdata; | |
+} | |
+ | |
int myHeader_InsertItem(HWND hWnd, int index, const HD_ITEM *phdi) | |
{ | |
int retval; | |
t@@ -275,14 +288,33 @@ int myHeader_InsertItem(HWND hWnd, int index, const HD_I… | |
BOOL strdata; | |
strdata = makeHeaderItemW(&hdiw, phdi); | |
- retval = (int)SendMessage(hWnd, HDM_INSERTITEM, (WPARAM)index, | |
- (LPARAM)&hdiw); | |
+ retval = (int)SendMessageW(hWnd, HDM_INSERTITEMW, (WPARAM)index, | |
+ (LPARAM)&hdiw); | |
if (strdata) { | |
g_free(hdiw.pszText); | |
} | |
} else { | |
- retval = (int)SendMessage(hWnd, HDM_INSERTITEM, (WPARAM)index, | |
- (LPARAM)phdi); | |
+ retval = (int)SendMessageA(hWnd, HDM_INSERTITEM, (WPARAM)index, | |
+ (LPARAM)phdi); | |
+ } | |
+ return retval; | |
+} | |
+ | |
+int myTabCtrl_InsertItem(HWND hWnd, int index, const TC_ITEM *pitem) | |
+{ | |
+ int retval; | |
+ if (unicode_support) { | |
+ TC_ITEMW tiew; | |
+ BOOL strdata; | |
+ strdata = makeTabItemW(&tiew, pitem); | |
+ retval = (int)SendMessageW(hWnd, TCM_INSERTITEMW, (WPARAM)index, | |
+ (LPARAM)&tiew); | |
+ if (strdata) { | |
+ g_free(tiew.pszText); | |
+ } | |
+ } else { | |
+ retval = (int)SendMessageA(hWnd, TCM_INSERTITEMW, (WPARAM)index, | |
+ (LPARAM)pitem); | |
} | |
return retval; | |
} | |
t@@ -291,7 +323,7 @@ ATOM myRegisterClass(CONST WNDCLASS *lpWndClass) | |
{ | |
ATOM retval; | |
- if (0 && unicode_support) { | |
+ if (unicode_support) { | |
WNDCLASSW wcw; | |
wcw.style = lpWndClass->style; | |
t@@ -329,4 +361,116 @@ HWND myCreateDialog(HINSTANCE hInstance, LPCTSTR lpTempl… | |
return retval; | |
} | |
+LRESULT mySendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) | |
+{ | |
+ if (unicode_support) { | |
+ return SendMessageW(hWnd, Msg, wParam, lParam); | |
+ } else { | |
+ return SendMessageA(hWnd, Msg, wParam, lParam); | |
+ } | |
+} | |
+ | |
+void myEditReplaceSel(HWND hWnd, BOOL fCanUndo, LPCSTR lParam) | |
+{ | |
+ if (unicode_support) { | |
+ gunichar2 *text; | |
+ text = strtow32(lParam, -1); | |
+ SendMessageW(hWnd, EM_REPLACESEL, (WPARAM)fCanUndo, (LPARAM)text); | |
+ g_free(text); | |
+ } else { | |
+ SendMessageA(hWnd, EM_REPLACESEL, (WPARAM)fCanUndo, (LPARAM)lParam); | |
+ } | |
+} | |
+ | |
+LONG mySetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong) | |
+{ | |
+ if (unicode_support) { | |
+ return SetWindowLongW(hWnd, nIndex, dwNewLong); | |
+ } else { | |
+ return SetWindowLongA(hWnd, nIndex, dwNewLong); | |
+ } | |
+} | |
+ | |
+LONG myGetWindowLong(HWND hWnd, int nIndex) | |
+{ | |
+ if (unicode_support) { | |
+ return GetWindowLongW(hWnd, nIndex); | |
+ } else { | |
+ return GetWindowLongA(hWnd, nIndex); | |
+ } | |
+} | |
+ | |
+LRESULT myCallWindowProc(WNDPROC lpPrevWndProc, HWND hWnd, UINT Msg, | |
+ WPARAM wParam, LPARAM lParam) | |
+{ | |
+ if (unicode_support) { | |
+ return CallWindowProcW(lpPrevWndProc, hWnd, Msg, wParam, lParam); | |
+ } else { | |
+ return CallWindowProcA(lpPrevWndProc, hWnd, Msg, wParam, lParam); | |
+ } | |
+} | |
+ | |
+LRESULT myDefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) | |
+{ | |
+ if (unicode_support) { | |
+ return DefWindowProcW(hWnd, Msg, wParam, lParam); | |
+ } else { | |
+ return DefWindowProcA(hWnd, Msg, wParam, lParam); | |
+ } | |
+} | |
+ | |
+int myMessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) | |
+{ | |
+ int retval; | |
+ | |
+ if (unicode_support) { | |
+ gunichar2 *text, *caption; | |
+ text = strtow32(lpText, -1); | |
+ caption = strtow32(lpCaption, -1); | |
+ retval = MessageBoxW(hWnd, text, caption, uType); | |
+ g_free(text); | |
+ g_free(caption); | |
+ } else { | |
+ retval = MessageBoxA(hWnd, lpText, lpCaption, uType); | |
+ } | |
+ return retval; | |
+} | |
+ | |
+BOOL myGetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, | |
+ UINT wMsgFilterMax) | |
+{ | |
+ if (unicode_support) { | |
+ return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
+ } else { | |
+ return GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); | |
+ } | |
+} | |
+ | |
+LONG myDispatchMessage(CONST MSG *lpmsg) | |
+{ | |
+ if (unicode_support) { | |
+ return DispatchMessageW(lpmsg); | |
+ } else { | |
+ return DispatchMessageA(lpmsg); | |
+ } | |
+} | |
+ | |
+BOOL myIsDialogMessage(HWND hDlg, LPMSG lpMsg) | |
+{ | |
+ if (unicode_support) { | |
+ return IsDialogMessageW(hDlg, lpMsg); | |
+ } else { | |
+ return IsDialogMessageA(hDlg, lpMsg); | |
+ } | |
+} | |
+ | |
+size_t myw32strlen(const char *str) | |
+{ | |
+ if (unicode_support) { | |
+ return g_utf8_strlen(str, -1); | |
+ } else { | |
+ return strlen(str); | |
+ } | |
+} | |
+ | |
#endif /* CYGWIN */ | |
diff --git a/src/gtkport/unicodewrap.h b/src/gtkport/unicodewrap.h | |
t@@ -49,9 +49,23 @@ BOOL WINAPI mySetMenuItemInfo(HMENU hMenu, UINT uItem, BOOL… | |
BOOL WINAPI myInsertMenuItem(HMENU hMenu, UINT uItem, BOOL fByPosition, | |
LPMENUITEMINFO lpmii); | |
int myHeader_InsertItem(HWND hWnd, int index, const HD_ITEM *phdi); | |
+int myTabCtrl_InsertItem(HWND hWnd, int index, const TC_ITEM *pitem); | |
ATOM myRegisterClass(CONST WNDCLASS *lpWndClass); | |
HWND myCreateDialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, | |
DLGPROC lpDialogFunc); | |
+LRESULT mySendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); | |
+void myEditReplaceSel(HWND hWnd, BOOL fCanUndo, LPCSTR lParam); | |
+LONG mySetWindowLong(HWND hWnd, int nIndex, LONG dwNewLong); | |
+LONG myGetWindowLong(HWND hWnd, int nIndex); | |
+LRESULT myCallWindowProc(WNDPROC lpPrevWndProc, HWND hWnd, UINT Msg, | |
+ WPARAM wParam, LPARAM lParam); | |
+LRESULT myDefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); | |
+int myMessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType); | |
+BOOL myGetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, | |
+ UINT wMsgFilterMax); | |
+LONG myDispatchMessage(CONST MSG *lpmsg); | |
+BOOL myIsDialogMessage(HWND hDlg, LPMSG lpMsg); | |
+size_t myw32strlen(const char *str); | |
#endif /* CYGWIN */ | |