tImproved Win32 Unicode support; menu items, clists and GetWindowText are now U… | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 5840ac9f9788cc197aa9ddc02411d03bc96906ab | |
parent 1dc52b6615f65f064246b23e9bc1633c9f5c9866 | |
Author: Ben Webb <[email protected]> | |
Date: Fri, 23 Aug 2002 16:16:34 +0000 | |
Improved Win32 Unicode support; menu items, clists and GetWindowText | |
are now Unicode-aware. Work-around for the apparent API change in | |
Windows XP common controls of LB_INSERTSTRING and LB_ADDSTRING so | |
tthat GtkCLists work again. | |
Diffstat: | |
M src/gtkport/clist.c | 38 +++++++++++++++++------------… | |
M src/gtkport/gtkport.c | 28 +++++++++++++--------------- | |
M src/gtkport/gtkport.h | 3 +-- | |
M src/gtkport/unicodewrap.c | 220 +++++++++++++++++++++++++++++… | |
M src/gtkport/unicodewrap.h | 17 ++++++++++++++--- | |
5 files changed, 259 insertions(+), 47 deletions(-) | |
--- | |
diff --git a/src/gtkport/clist.c b/src/gtkport/clist.c | |
t@@ -31,6 +31,8 @@ | |
#include <windows.h> | |
#include <commctrl.h> | |
+#include "unicodewrap.h" | |
+ | |
#define LISTITEMHPACK 3 | |
#define LISTHEADERPACK 6 | |
t@@ -167,11 +169,11 @@ void gtk_clist_realize(GtkWidget *widget) | |
GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_FOCUS); | |
rcParent.left = rcParent.top = 0; | |
rcParent.right = rcParent.bottom = 800; | |
- header = CreateWindowEx(0, WC_HEADER, NULL, | |
- WS_CHILD | WS_BORDER | HDS_HORZ | |
- | (GTK_CLIST(widget)->coldata[0].button_passive ? | |
- 0 : HDS_BUTTONS), | |
- 0, 0, 0, 0, Parent, NULL, hInst, NULL); | |
+ header = myCreateWindowEx(0, WC_HEADER, NULL, | |
+ WS_CHILD | WS_BORDER | HDS_HORZ | |
+ | (GTK_CLIST(widget)->coldata[0].button_passive ? | |
+ 0 : HDS_BUTTONS), | |
+ 0, 0, 0, 0, Parent, NULL, hInst, NULL); | |
SetWindowLong(header, GWL_USERDATA, (LONG)widget); | |
GTK_CLIST(widget)->header = header; | |
gtk_set_default_font(header); | |
t@@ -179,18 +181,19 @@ void gtk_clist_realize(GtkWidget *widget) | |
hdl.pwpos = ℘ | |
SendMessage(header, HDM_LAYOUT, 0, (LPARAM)&hdl); | |
clist->header_size = wp.cy; | |
- widget->hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "", | |
- WS_CHILD | WS_TABSTOP | WS_VSCROLL | |
- | WS_HSCROLL | LBS_OWNERDRAWFIXED | |
- | LBS_NOTIFY, 0, 0, 0, 0, Parent, NULL, | |
- hInst, NULL); | |
+ widget->hWnd = myCreateWindowEx(WS_EX_CLIENTEDGE, "LISTBOX", "", | |
+ WS_CHILD | WS_TABSTOP | WS_VSCROLL | |
+ | WS_HSCROLL | LBS_OWNERDRAWFIXED | |
+ | LBS_NOTIFY, 0, 0, 0, 0, Parent, NULL, | |
+ hInst, NULL); | |
gtk_set_default_font(widget->hWnd); | |
gtk_clist_update_all_widths(clist); | |
for (rows = clist->rowdata; rows; rows = g_slist_next(rows)) { | |
row = (GtkCListRow *)rows->data; | |
- if (row) | |
+ if (row) { | |
SendMessage(widget->hWnd, LB_ADDSTRING, 0, (LPARAM)row->data); | |
+ } | |
} | |
for (i = 0; i < clist->cols; i++) { | |
t@@ -203,7 +206,7 @@ void gtk_clist_realize(GtkWidget *widget) | |
hdi.cxy = clist->coldata[i].width; | |
hdi.cchTextMax = strlen(hdi.pszText); | |
hdi.fmt = HDF_LEFT | HDF_STRING; | |
- SendMessage(header, HDM_INSERTITEM, i + 1, (LPARAM)&hdi); | |
+ myHeader_InsertItem(header, i + 1, &hdi); | |
} | |
} | |
} | |
t@@ -258,8 +261,8 @@ void gtk_clist_draw_row(GtkCList *clist, LPDRAWITEMSTRUCT … | |
if (i == clist->cols - 1) | |
rcCol.right = lpdis->rcItem.right; | |
if (row->text[i]) { | |
- DrawText(lpdis->hDC, row->text[i], -1, &rcCol, | |
- DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS); | |
+ myDrawText(lpdis->hDC, row->text[i], -1, &rcCol, | |
+ DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS); | |
} | |
} | |
} | |
t@@ -357,6 +360,7 @@ gint gtk_clist_insert(GtkCList *clist, gint row, gchar *te… | |
new_row = g_new0(GtkCListRow, 1); | |
new_row->text = g_new0(gchar *, clist->cols); | |
+ new_row->data = GINT_TO_POINTER(1); | |
for (i = 0; i < clist->cols; i++) { | |
new_row->text[i] = g_strdup(text[i]); | |
t@@ -368,7 +372,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, (LPARAM)NULL); | |
+ SendMessage(hWnd, LB_INSERTSTRING, (WPARAM)row, (LPARAM)new_row->data); | |
} | |
return row; | |
t@@ -630,7 +634,7 @@ void gtk_clist_set_row_data(GtkCList *clist, gint row, gpo… | |
if (row >= 0 && row < clist->rows) { | |
list_row = (GtkCListRow *)g_slist_nth_data(clist->rowdata, row); | |
if (list_row) | |
- list_row->data = data; | |
+ list_row->data = data + 1; | |
} | |
} | |
t@@ -641,7 +645,7 @@ gpointer gtk_clist_get_row_data(GtkCList *clist, gint row) | |
if (row >= 0 && row < clist->rows) { | |
list_row = (GtkCListRow *)g_slist_nth_data(clist->rowdata, row); | |
if (list_row) | |
- return list_row->data; | |
+ return list_row->data - 1; | |
} | |
return NULL; | |
} | |
diff --git a/src/gtkport/gtkport.c b/src/gtkport/gtkport.c | |
t@@ -1142,7 +1142,7 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); | |
wc.lpszMenuName = NULL; | |
wc.lpszClassName = "mainwin"; | |
- RegisterClass(&wc); | |
+ myRegisterClass(&wc); | |
wc.style = 0; | |
wc.lpfnWndProc = MainWndProc; | |
t@@ -1154,7 +1154,7 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); | |
wc.lpszMenuName = NULL; | |
wc.lpszClassName = WC_GTKDIALOG; | |
- RegisterClass(&wc); | |
+ myRegisterClass(&wc); | |
wc.style = 0; | |
wc.lpfnWndProc = GtkPanedProc; | |
t@@ -1166,7 +1166,7 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); | |
wc.lpszMenuName = NULL; | |
wc.lpszClassName = WC_GTKHPANED; | |
- RegisterClass(&wc); | |
+ myRegisterClass(&wc); | |
wc.style = 0; | |
wc.lpfnWndProc = GtkPanedProc; | |
t@@ -1178,7 +1178,7 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); | |
wc.lpszMenuName = NULL; | |
wc.lpszClassName = WC_GTKVPANED; | |
- RegisterClass(&wc); | |
+ myRegisterClass(&wc); | |
wc.style = 0; | |
wc.lpfnWndProc = GtkSepProc; | |
t@@ -1190,7 +1190,7 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); | |
wc.lpszMenuName = NULL; | |
wc.lpszClassName = WC_GTKSEP; | |
- RegisterClass(&wc); | |
+ myRegisterClass(&wc); | |
wc.style = 0; | |
wc.lpfnWndProc = GtkUrlProc; | |
t@@ -1202,7 +1202,7 @@ void win32_init(HINSTANCE hInstance, HINSTANCE hPrevInst… | |
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); | |
wc.lpszMenuName = NULL; | |
wc.lpszClassName = WC_GTKURL; | |
- RegisterClass(&wc); | |
+ myRegisterClass(&wc); | |
} | |
InitCommonControls(); | |
t@@ -1886,16 +1886,14 @@ GSList *gtk_radio_button_group(GtkRadioButton *radio_b… | |
static void gtk_editable_sync_text(GtkEditable *editable) | |
{ | |
HWND hWnd; | |
- gint textlen; | |
gchar *buffer; | |
hWnd = GTK_WIDGET(editable)->hWnd; | |
- if (!hWnd) | |
+ if (!hWnd) { | |
return; | |
+ } | |
- textlen = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0); | |
- buffer = g_new(gchar, textlen + 1); | |
- SendMessage(hWnd, WM_GETTEXT, (WPARAM)(textlen + 1), (LPARAM)buffer); | |
+ buffer = myGetWindowText(hWnd); | |
g_string_assign(editable->text, buffer); | |
g_free(buffer); | |
} | |
t@@ -2326,7 +2324,7 @@ void gtk_window_realize(GtkWidget *widget) | |
Parent = gtk_get_parent_hwnd(widget->parent); | |
if (Parent) { | |
- widget->hWnd = CreateDialog(hInst, "gtkdialog", Parent, MainDlgProc); | |
+ widget->hWnd = myCreateDialog(hInst, "gtkdialog", Parent, MainDlgProc); | |
mySetWindowText(widget->hWnd, win->title); | |
} else { | |
widget->hWnd = myCreateWindow("mainwin", win->title, | |
t@@ -3734,7 +3732,7 @@ void gtk_check_menu_item_set_active(GtkMenuItem *menu_it… | |
mii.cbSize = sizeof(MENUITEMINFO); | |
mii.fMask = MIIM_STATE; | |
mii.fState = active ? MFS_CHECKED : MFS_UNCHECKED; | |
- SetMenuItemInfo(parent_menu, menu_item->ID, FALSE, &mii); | |
+ mySetMenuItemInfo(parent_menu, menu_item->ID, FALSE, &mii); | |
} | |
} | |
t@@ -3827,7 +3825,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); | |
- InsertMenuItem(parent_menu, pos, TRUE, &mii); | |
+ myInsertMenuItem(parent_menu, pos, TRUE, &mii); | |
} | |
void gtk_menu_realize(GtkWidget *widget) | |
t@@ -4777,7 +4775,7 @@ static void gtk_menu_item_set_text(GtkMenuItem *menuitem… | |
mii.fType = MFT_STRING; | |
mii.dwTypeData = (LPTSTR)menuitem->text; | |
mii.cch = strlen(menuitem->text); | |
- SetMenuItemInfo(parent_menu, menuitem->ID, FALSE, &mii); | |
+ mySetMenuItemInfo(parent_menu, menuitem->ID, FALSE, &mii); | |
} | |
} | |
diff --git a/src/gtkport/gtkport.h b/src/gtkport/gtkport.h | |
t@@ -751,8 +751,6 @@ struct _GtkUrl { | |
gchar *target, *bin; | |
}; | |
-gboolean HaveUnicodeSupport(void); | |
- | |
#endif /* CYGWIN */ | |
#if CYGWIN || !HAVE_GLIB2 | |
t@@ -794,5 +792,6 @@ GtkWidget *NewStockButton(const gchar *label, GtkAccelGrou… | |
gchar *GtkGetFile(const GtkWidget *parent, const gchar *oldname, | |
const gchar *title); | |
void DisplayHTML(GtkWidget *parent, const gchar *bin, const gchar *target); | |
+gboolean HaveUnicodeSupport(void); | |
#endif /* __GTKPORT_H__ */ | |
diff --git a/src/gtkport/unicodewrap.c b/src/gtkport/unicodewrap.c | |
t@@ -59,13 +59,30 @@ gboolean HaveUnicodeSupport(void) | |
* suitable for Windows Unicode-aware functions (i.e. UTF-16). This | |
* returned string must be g_free'd when no longer needed. | |
*/ | |
-static gunichar2 *strtow32(const char *instr) | |
+static gunichar2 *strtow32(const char *instr, int len) | |
{ | |
gunichar2 *outstr; | |
- outstr = g_utf8_to_utf16(instr, -1, NULL, NULL, NULL); | |
+ if (!instr) { | |
+ return NULL; | |
+ } | |
+ outstr = g_utf8_to_utf16(instr, len, NULL, NULL, NULL); | |
if (!outstr) { | |
- outstr = g_utf8_to_utf16("[?]", -1, NULL, NULL, NULL); | |
+ outstr = g_utf8_to_utf16("[?]", len, NULL, NULL, NULL); | |
} | |
+ return outstr; | |
+} | |
+ | |
+static gchar *w32tostr(const gunichar2 *instr, int len) | |
+{ | |
+ gchar *outstr; | |
+ if (!instr) { | |
+ return NULL; | |
+ } | |
+ outstr = g_utf16_to_utf8(instr, len, NULL, NULL, NULL); | |
+ if (!outstr) { | |
+ outstr = g_strdup("[?]"); | |
+ } | |
+ return outstr; | |
} | |
BOOL mySetWindowText(HWND hWnd, LPCTSTR lpString) | |
t@@ -74,7 +91,7 @@ BOOL mySetWindowText(HWND hWnd, LPCTSTR lpString) | |
if (unicode_support) { | |
gunichar2 *text; | |
- text = strtow32(lpString); | |
+ text = strtow32(lpString, -1); | |
retval = SetWindowTextW(hWnd, text); | |
g_free(text); | |
} else { | |
t@@ -84,7 +101,7 @@ BOOL mySetWindowText(HWND hWnd, LPCTSTR lpString) | |
return retval; | |
} | |
-HWND myCreateWindow(LPCTSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, | |
+HWND myCreateWindow(LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, | |
int x, int y, int nWidth, int nHeight, HWND hwndParent, | |
HMENU hMenu, HANDLE hInstance, LPVOID lpParam) | |
{ | |
t@@ -92,8 +109,8 @@ HWND myCreateWindow(LPCTSTR lpClassName, LPCSTR lpWindowNam… | |
if (unicode_support) { | |
gunichar2 *classname, *winname; | |
- classname = strtow32(lpClassName); | |
- winname = strtow32(lpWindowName); | |
+ classname = strtow32(lpClassName, -1); | |
+ winname = strtow32(lpWindowName, -1); | |
retval = CreateWindowW(classname, winname, dwStyle, x, y, nWidth, | |
nHeight, hwndParent, hMenu, hInstance, lpParam); | |
g_free(classname); | |
t@@ -106,7 +123,7 @@ HWND myCreateWindow(LPCTSTR lpClassName, LPCSTR lpWindowNa… | |
} | |
HWND myCreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, | |
- LPCSTR lpWindowName, DWORD dwStyle, int x, int y, | |
+ LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, | |
int nWidth, int nHeight, HWND hwndParent, HMENU hMenu, | |
HANDLE hInstance, LPVOID lpParam) | |
{ | |
t@@ -114,8 +131,8 @@ HWND myCreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, | |
if (unicode_support) { | |
gunichar2 *classname, *winname; | |
- classname = strtow32(lpClassName); | |
- winname = strtow32(lpWindowName); | |
+ classname = strtow32(lpClassName, -1); | |
+ winname = strtow32(lpWindowName, -1); | |
retval = CreateWindowExW(dwExStyle, classname, winname, dwStyle, x, y, | |
nWidth, nHeight, hwndParent, hMenu, hInstance, | |
lpParam); | |
t@@ -129,4 +146,187 @@ HWND myCreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassNa… | |
return retval; | |
} | |
+gchar *myGetWindowText(HWND hWnd) | |
+{ | |
+ gint textlen; | |
+ | |
+ textlen = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0); | |
+ if (unicode_support) { | |
+ gunichar2 *buffer; | |
+ gchar *retstr; | |
+ | |
+ buffer = g_new0(gunichar2, textlen + 1); | |
+ GetWindowTextW(hWnd, buffer, textlen + 1); | |
+ buffer[textlen] = '\0'; | |
+ retstr = w32tostr(buffer, textlen); | |
+ g_free(buffer); | |
+ return retstr; | |
+ } else { | |
+ gchar *buffer; | |
+ | |
+ buffer = g_new0(gchar, textlen + 1); | |
+ GetWindowTextA(hWnd, buffer, textlen + 1); | |
+ buffer[textlen] = '\0'; | |
+ return buffer; | |
+ } | |
+} | |
+ | |
+int myDrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, | |
+ UINT uFormat) | |
+{ | |
+ int retval; | |
+ | |
+ if (unicode_support) { | |
+ gunichar2 *text; | |
+ | |
+ text = strtow32(lpString, nCount); | |
+ retval = DrawTextW(hDC, text, -1, lpRect, uFormat); | |
+ g_free(text); | |
+ } else { | |
+ retval = DrawTextA(hDC, lpString, nCount, lpRect, uFormat); | |
+ } | |
+ return retval; | |
+} | |
+ | |
+static BOOL makeMenuItemInfoW(LPMENUITEMINFOW lpmiiw, LPMENUITEMINFO lpmii) | |
+{ | |
+ BOOL strdata; | |
+ strdata = (lpmii->fMask & MIIM_TYPE) | |
+ && !(lpmii->fType & (MFT_BITMAP | MFT_SEPARATOR)); | |
+ | |
+ lpmiiw->cbSize = sizeof(MENUITEMINFOW); | |
+ lpmiiw->fMask = lpmii->fMask; | |
+ lpmiiw->fType = lpmii->fType; | |
+ lpmiiw->fState = lpmii->fState; | |
+ lpmiiw->wID = lpmii->wID; | |
+ lpmiiw->hSubMenu = lpmii->hSubMenu; | |
+ lpmiiw->hbmpChecked = lpmii->hbmpChecked; | |
+ lpmiiw->hbmpUnchecked = lpmii->hbmpUnchecked; | |
+ lpmiiw->dwItemData = lpmii->dwItemData; | |
+ lpmiiw->dwTypeData = strdata ? strtow32(lpmii->dwTypeData, -1) | |
+ : (LPWSTR)lpmii->dwTypeData; | |
+ lpmiiw->cch = lpmii->cch; | |
+ return strdata; | |
+} | |
+ | |
+BOOL WINAPI mySetMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, | |
+ LPMENUITEMINFO lpmii) | |
+{ | |
+ BOOL retval; | |
+ | |
+ if (unicode_support) { | |
+ MENUITEMINFOW miiw; | |
+ BOOL strdata; | |
+ | |
+ strdata = makeMenuItemInfoW(&miiw, lpmii); | |
+ retval = SetMenuItemInfoW(hMenu, uItem, fByPosition, &miiw); | |
+ if (strdata) { | |
+ g_free(miiw.dwTypeData); | |
+ } | |
+ } else { | |
+ retval = SetMenuItemInfoA(hMenu, uItem, fByPosition, lpmii); | |
+ } | |
+ return retval; | |
+} | |
+ | |
+BOOL WINAPI myInsertMenuItem(HMENU hMenu, UINT uItem, BOOL fByPosition, | |
+ LPMENUITEMINFO lpmii) | |
+{ | |
+ BOOL retval; | |
+ | |
+ if (unicode_support) { | |
+ MENUITEMINFOW miiw; | |
+ BOOL strdata; | |
+ | |
+ strdata = makeMenuItemInfoW(&miiw, lpmii); | |
+ retval = InsertMenuItemW(hMenu, uItem, fByPosition, &miiw); | |
+ if (strdata) { | |
+ g_free(miiw.dwTypeData); | |
+ } | |
+ } else { | |
+ retval = InsertMenuItemA(hMenu, uItem, fByPosition, lpmii); | |
+ } | |
+ return retval; | |
+} | |
+ | |
+static BOOL makeHeaderItemW(HD_ITEMW *phdiw, const HD_ITEM *phdi) | |
+{ | |
+ BOOL strdata; | |
+ | |
+//strdata = phdi->mask & HDI_TEXT; | |
+ strdata = FALSE; | |
+ | |
+ phdiw->mask = phdi->mask; | |
+ phdiw->cxy = phdi->cxy; | |
+ phdiw->pszText = strdata ? strtow32(phdi->pszText, -1) | |
+ : (LPWSTR)phdi->pszText; | |
+ phdiw->hbm = phdi->hbm; | |
+ phdiw->cchTextMax = phdi->cchTextMax; | |
+ phdiw->fmt = phdi->fmt; | |
+ phdiw->lParam = phdi->lParam; | |
+ return strdata; | |
+} | |
+ | |
+int myHeader_InsertItem(HWND hWnd, int index, const HD_ITEM *phdi) | |
+{ | |
+ int retval; | |
+ if (unicode_support && IsWindowUnicode(hWnd)) { | |
+ HD_ITEMW hdiw; | |
+ BOOL strdata; | |
+ | |
+ strdata = makeHeaderItemW(&hdiw, phdi); | |
+ retval = (int)SendMessage(hWnd, HDM_INSERTITEM, (WPARAM)index, | |
+ (LPARAM)&hdiw); | |
+ if (strdata) { | |
+ g_free(hdiw.pszText); | |
+ } | |
+ } else { | |
+ retval = (int)SendMessage(hWnd, HDM_INSERTITEM, (WPARAM)index, | |
+ (LPARAM)phdi); | |
+ } | |
+ return retval; | |
+} | |
+ | |
+ATOM myRegisterClass(CONST WNDCLASS *lpWndClass) | |
+{ | |
+ ATOM retval; | |
+ | |
+ if (0 && unicode_support) { | |
+ WNDCLASSW wcw; | |
+ | |
+ wcw.style = lpWndClass->style; | |
+ wcw.lpfnWndProc = lpWndClass->lpfnWndProc; | |
+ wcw.cbClsExtra = lpWndClass->cbClsExtra; | |
+ wcw.cbWndExtra = lpWndClass->cbWndExtra; | |
+ wcw.hInstance = lpWndClass->hInstance; | |
+ wcw.hIcon = lpWndClass->hIcon; | |
+ wcw.hCursor = lpWndClass->hCursor; | |
+ wcw.hbrBackground = lpWndClass->hbrBackground; | |
+ wcw.lpszMenuName = strtow32(lpWndClass->lpszMenuName, -1); | |
+ wcw.lpszClassName = strtow32(lpWndClass->lpszClassName, -1); | |
+ retval = RegisterClassW(&wcw); | |
+ g_free((LPWSTR)wcw.lpszMenuName); | |
+ g_free((LPWSTR)wcw.lpszClassName); | |
+ } else { | |
+ retval = RegisterClassA(lpWndClass); | |
+ } | |
+ return retval; | |
+} | |
+ | |
+HWND myCreateDialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, | |
+ DLGPROC lpDialogFunc) | |
+{ | |
+ HWND retval; | |
+ | |
+ if (unicode_support) { | |
+ gunichar2 *text; | |
+ text = strtow32(lpTemplate, -1); | |
+ retval = CreateDialogW(hInstance, text, hWndParent, lpDialogFunc); | |
+ g_free(text); | |
+ } else { | |
+ retval = CreateDialogA(hInstance, lpTemplate, hWndParent, lpDialogFunc); | |
+ } | |
+ return retval; | |
+} | |
+ | |
#endif /* CYGWIN */ | |
diff --git a/src/gtkport/unicodewrap.h b/src/gtkport/unicodewrap.h | |
t@@ -29,18 +29,29 @@ | |
#ifdef CYGWIN | |
#include <windows.h> | |
+#include <commctrl.h> | |
void InitUnicodeSupport(void); | |
-void HaveUnicodeSupport(void); | |
BOOL mySetWindowText(HWND hWnd, LPCTSTR lpString); | |
-HWND myCreateWindow(LPCTSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, | |
+HWND myCreateWindow(LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, | |
int x, int y, int nWidth, int nHeight, HWND hwndParent, | |
HMENU hMenu, HANDLE hInstance, LPVOID lpParam); | |
HWND myCreateWindowEx(DWORD dwExStyle, LPCTSTR lpClassName, | |
- LPCSTR lpWindowName, DWORD dwStyle, int x, int y, | |
+ LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, | |
int nWidth, int nHeight, HWND hwndParent, HMENU hMenu, | |
HANDLE hInstance, LPVOID lpParam); | |
+gchar *myGetWindowText(HWND hWnd); | |
+int myDrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, | |
+ UINT uFormat); | |
+BOOL WINAPI mySetMenuItemInfo(HMENU hMenu, UINT uItem, BOOL fByPosition, | |
+ LPMENUITEMINFO lpmii); | |
+BOOL WINAPI myInsertMenuItem(HMENU hMenu, UINT uItem, BOOL fByPosition, | |
+ LPMENUITEMINFO lpmii); | |
+int myHeader_InsertItem(HWND hWnd, int index, const HD_ITEM *phdi); | |
+ATOM myRegisterClass(CONST WNDCLASS *lpWndClass); | |
+HWND myCreateDialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, | |
+ DLGPROC lpDialogFunc); | |
#endif /* CYGWIN */ | |