From 277fa5d6bd824b4cdbf5ef4701c4ac1cc2000fd5 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 22 Apr 2016 12:44:18 -0400 Subject: [PATCH] Migrated control.c, I think. Changing the current way uiControl works will wait for another branch. --- windows/{control.c => control.cpp} | 28 +++++----------------------- windows/text.cpp | 20 ++++++++++++++++++++ windows/ui_windows_new.h | 15 +++++++++++++++ 3 files changed, 40 insertions(+), 23 deletions(-) rename windows/{control.c => control.cpp} (78%) diff --git a/windows/control.c b/windows/control.cpp similarity index 78% rename from windows/control.c rename to windows/control.cpp index cfa14c49..5ed9a036 100644 --- a/windows/control.c +++ b/windows/control.cpp @@ -15,13 +15,16 @@ HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCW // use a nonzero initial size just in case some control breaks with a zero initial size 100, 100, utilWindow, NULL, hInstance, lpParam); - if (hwnd == NULL) - logLastError("error creating window in uiWindowsUtilCreateControlHWND()"); + if (hwnd == NULL) { + logLastError("error creating window"); + // TODO return a decoy window + } if (useStandardControlFont) SendMessageW(hwnd, WM_SETFONT, (WPARAM) hMessageFont, (LPARAM) TRUE); return hwnd; } +// TODO make this unnecessary static uintmax_t type_uiWindowsControl = 0; uintmax_t uiWindowsControlType(void) @@ -57,27 +60,6 @@ void uiWindowsFinishControl(uiControl *c) c->CommitHide = defaultCommitHide; } -char *uiWindowsUtilText(HWND hwnd) -{ - WCHAR *wtext; - char *text; - - wtext = windowText(hwnd); - text = toUTF8(wtext); - uiFree(wtext); - return text; -} - -void uiWindowsUtilSetText(HWND hwnd, const char *text) -{ - WCHAR *wtext; - - wtext = toUTF16(text); - if (SetWindowTextW(hwnd, wtext) == 0) - logLastError("error setting control text in uiWindowsControlSetText()"); - uiFree(wtext); -} - void uiWindowsRearrangeControlIDsZOrder(uiControl *c) { uiWindowsControl *wc; diff --git a/windows/text.cpp b/windows/text.cpp index d354a45f..7228e585 100644 --- a/windows/text.cpp +++ b/windows/text.cpp @@ -85,3 +85,23 @@ noTextOrError: uiFree(text); return 0; } + +char *uiWindowsWindowText(HWND hwnd) +{ + WCHAR *wtext; + char *text; + + wtext = windowText(hwnd); + text = toUTF8(wtext); + uiFree(wtext); + return text; +} + +void uiWindowsSetWindowText(HWND hwnd, const char *text) +{ + WCHAR *wtext; + + wtext = toUTF16(text); + setWindowText(hwnd, wtext); + uiFree(wtext); +} diff --git a/windows/ui_windows_new.h b/windows/ui_windows_new.h index 1645e45e..183ec924 100644 --- a/windows/ui_windows_new.h +++ b/windows/ui_windows_new.h @@ -1,5 +1,8 @@ // 21 april 2016 +// TODO document +_UI_EXTERN HWND uiWindowsEnsureCreateControlHWND(DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, HINSTANCE hInstance, LPVOID lpParam, BOOL useStandardControlFont); + // TODO document _UI_EXTERN void uiWindowsEnsureDestroyWindow(HWND hwnd); @@ -9,6 +12,10 @@ _UI_EXTERN void uiWindowsEnsureSetParent(HWND hwnd, HWND parent); // TODO document _UI_EXTERN void uiWindowsEnsureAssignControlIDZOrder(HWND hwnd, LONG_PTR controlID, HWND insertAfter); +// TODO document +_UI_EXTERN char *uiWindowsWindowText(HWND hwnd); +_UI_EXTERN void uiWindowsSetWindowText(HWND hwnd, const char *text); + // TODO document _UI_EXTERN intmax_t uiWindowsWindowTextWidth(HWND hwnd); @@ -27,3 +34,11 @@ _UI_EXTERN void uiWindowsUnregisterWM_HSCROLLHandler(HWND hwnd); // TODO document _UI_EXTERN void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd); _UI_EXTERN void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd); + + + + +// everything below here is TODO + +_UI_EXTERN void uiWindowsFinishControl(uiControl *c); +_UI_EXTERN void uiWindowsRearrangeControlIDsZOrder(uiControl *c);