libui/windows/container.cpp

74 lines
1.7 KiB
C++
Raw Normal View History

2015-05-14 12:42:28 -05:00
// 26 april 2015
#include "uipriv_windows.hpp"
2015-05-14 12:42:28 -05:00
2015-08-30 18:32:05 -05:00
// Code for the HWND of the following uiControls:
// - uiBox
// - uiRadioButtons
2015-05-14 12:42:28 -05:00
static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RECT r;
HDC dc;
PAINTSTRUCT ps;
2015-05-18 08:52:37 -05:00
LRESULT lResult;
2015-05-14 12:42:28 -05:00
2015-05-18 08:52:37 -05:00
if (handleParentMessages(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
return lResult;
2015-05-14 12:42:28 -05:00
switch (uMsg) {
case WM_PAINT:
dc = BeginPaint(hwnd, &ps);
if (dc == NULL) {
logLastError(L"error beginning container paint");
// bail out; hope DefWindowProc() catches us
break;
}
2015-05-14 12:42:28 -05:00
r = ps.rcPaint;
paintContainerBackground(hwnd, dc, &r);
EndPaint(hwnd, &ps);
return 0;
// tab controls use this to draw the background of the tab area
case WM_PRINTCLIENT:
if (GetClientRect(hwnd, &r) == 0) {
logLastError(L"error getting client rect");
// likewise
break;
}
2015-05-14 12:42:28 -05:00
paintContainerBackground(hwnd, (HDC) wParam, &r);
return 0;
case WM_ERASEBKGND:
// avoid some flicker
// we draw the whole update area anyway
return 1;
}
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
ATOM initContainer(HICON hDefaultIcon, HCURSOR hDefaultCursor)
{
WNDCLASSW wc;
ZeroMemory(&wc, sizeof (WNDCLASSW));
wc.lpszClassName = containerClass;
wc.lpfnWndProc = containerWndProc;
wc.hInstance = hInstance;
wc.hIcon = hDefaultIcon;
wc.hCursor = hDefaultCursor;
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
return RegisterClassW(&wc);
}
void uninitContainer(void)
{
if (UnregisterClassW(containerClass, hInstance) == 0)
logLastError(L"error unregistering container window class");
2015-05-14 12:42:28 -05:00
}
HWND newContainer(void)
2015-05-14 12:42:28 -05:00
{
2015-08-31 11:33:44 -05:00
return uiWindowsEnsureCreateControlHWND(WS_EX_CONTROLPARENT,
containerClass, L"",
0,
hInstance, NULL,
FALSE);
2015-05-14 12:42:28 -05:00
}