From 1d53d4db1dab28efb2aa9c4bc8eee00a68e72766 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 27 Oct 2014 10:19:39 -0400 Subject: [PATCH] Removed the gouicontainer window class from the Windows backend; it is no longer needed. --- common_windows.c | 7 +++--- container_windows.c | 54 -------------------------------------------- container_windows.go | 45 ------------------------------------ uitask_windows.go | 3 --- winapi_windows.h | 3 --- 5 files changed, 3 insertions(+), 109 deletions(-) diff --git a/common_windows.c b/common_windows.c index d4db842..a8a2444 100644 --- a/common_windows.c +++ b/common_windows.c @@ -112,10 +112,9 @@ void paintControlBackground(HWND hwnd, HDC dc) return; if (GetClassNameW(parent, classname, 128) == 0) xpanic("error getting name of focused window class in paintControlBackground()", GetLastError()); - // skip container and groupboxes - if (_wcsicmp(classname, containerclass) != 0) // container - if (_wcsicmp(classname, L"button") != 0) // groupbox - break; + // skip groupboxes; they're (supposed to be) transparent + if (_wcsicmp(classname, L"button") != 0) + break; } if (GetWindowRect(hwnd, &r) == 0) xpanic("error getting control's window rect in paintControlBackground()", GetLastError()); diff --git a/container_windows.c b/container_windows.c index 7910b92..bbad9ec 100644 --- a/container_windows.c +++ b/container_windows.c @@ -3,60 +3,6 @@ #include "winapi_windows.h" #include "_cgo_export.h" -/* -This could all just be part of Window, but doing so just makes things complex. -In this case, I chose to waste a window handle rather than keep things super complex. -If this is seriously an issue in the future, I can roll it back. -*/ - -static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - LRESULT lResult; - - if (sharedWndProc(hwnd, uMsg, wParam, lParam, &lResult)) - return lResult; - switch (uMsg) { - default: - return DefWindowProcW(hwnd, uMsg, wParam, lParam); - } - xmissedmsg("container", "containerWndProc()", uMsg); - return 0; // unreached -} - -DWORD makeContainerWindowClass(char **errmsg) -{ - WNDCLASSW wc; - - ZeroMemory(&wc, sizeof (WNDCLASSW)); - wc.lpfnWndProc = containerWndProc; - wc.hInstance = hInstance; - wc.hIcon = hDefaultIcon; - wc.hCursor = hArrowCursor; - wc.hbrBackground = NULL;//(HBRUSH) (COLOR_BTNFACE + 1); - wc.lpszClassName = containerclass; - if (RegisterClassW(&wc) == 0) { - *errmsg = "error registering container window class"; - return GetLastError(); - } - return 0; -} - -HWND newContainer(void) -{ - HWND hwnd; - - hwnd = CreateWindowExW( - WS_EX_CONTROLPARENT | WS_EX_TRANSPARENT, - containerclass, L"", - WS_CHILD | WS_VISIBLE, - CW_USEDEFAULT, CW_USEDEFAULT, - 100, 100, - msgwin, NULL, hInstance, NULL); - if (hwnd == NULL) - xpanic("container creation failed", GetLastError()); - return hwnd; -} - RECT containerBounds(HWND hwnd) { RECT r; diff --git a/container_windows.go b/container_windows.go index 02da760..953d108 100644 --- a/container_windows.go +++ b/container_windows.go @@ -2,18 +2,9 @@ package ui -import ( - "fmt" - "syscall" -) - // #include "winapi_windows.h" import "C" -type container struct { - *controlSingleHWND -} - type sizing struct { sizingbase @@ -26,42 +17,6 @@ type sizing struct { // possibly the HDWP } -func makeContainerWindowClass() error { - var errmsg *C.char - - err := C.makeContainerWindowClass(&errmsg) - if err != 0 || errmsg != nil { - return fmt.Errorf("%s: %v", C.GoString(errmsg), syscall.Errno(err)) - } - return nil -} - -func newContainer() *container { - // don't set preferredSize(); it should never be called - return &container{ - controlSingleHWND: newControlSingleHWND(C.newContainer()), - } -} - -// TODO merge with controlSingleHWND -func (c *container) show() { - C.ShowWindow(c.hwnd, C.SW_SHOW) -} - -// TODO merge with controlSingleHWND -func (c *container) hide() { - C.ShowWindow(c.hwnd, C.SW_HIDE) -} - -func (c *container) parent() *controlParent { - return &controlParent{c.hwnd} -} - -func (c *container) bounds(d *sizing) (int, int, int, int) { - r := C.containerBounds(c.hwnd) - return int(r.left), int(r.top), int(r.right - r.left), int(r.bottom - r.top) -} - // For Windows, Microsoft just hands you a list of preferred control sizes as part of the MSDN documentation and tells you to roll with it. // These sizes are given in "dialog units", which are independent of the font in use. // We need to convert these into standard pixels, which requires we get the device context of the OS window. diff --git a/uitask_windows.go b/uitask_windows.go index c3c1884..045933a 100644 --- a/uitask_windows.go +++ b/uitask_windows.go @@ -33,9 +33,6 @@ func uiinit() error { if err := makeWindowWindowClass(); err != nil { return fmt.Errorf("error creating Window window class: %v", err) } - if err := makeContainerWindowClass(); err != nil { - return fmt.Errorf("error creating container window class: %v", err) - } if err := makeAreaWindowClass(); err != nil { return fmt.Errorf("error creating Area window class: %v", err) } diff --git a/winapi_windows.h b/winapi_windows.h index e6858e5..a7ee19e 100644 --- a/winapi_windows.h +++ b/winapi_windows.h @@ -122,9 +122,6 @@ extern intptr_t tableSelectedItem(HWND); extern void tableSelectItem(HWND, intptr_t); // container_windows.c -#define containerclass L"gouicontainer" -extern DWORD makeContainerWindowClass(char **); -extern HWND newContainer(); extern RECT containerBounds(HWND); extern void calculateBaseUnits(HWND, int *, int *, LONG *);