\r
//\r
LayoutManager::LayoutManager(HWND i_hwnd)\r
- : m_hwnd(i_hwnd),\r
- m_smallestRestriction(RESTRICT_NONE),\r
- m_largestRestriction(RESTRICT_NONE)\r
+ : m_hwnd(i_hwnd),\r
+ m_smallestRestriction(RESTRICT_NONE),\r
+ m_largestRestriction(RESTRICT_NONE)\r
{\r
}\r
\r
// specified by i_size\r
void LayoutManager::restrictSmallestSize(Restrict i_restrict, SIZE *i_size)\r
{\r
- m_smallestRestriction = i_restrict;\r
- if (i_size)\r
- m_smallestSize = *i_size;\r
- else\r
- {\r
- RECT rc;\r
- GetWindowRect(m_hwnd, &rc);\r
- m_smallestSize.cx = rc.right - rc.left;\r
- m_smallestSize.cy = rc.bottom - rc.top;\r
- }\r
+ m_smallestRestriction = i_restrict;\r
+ if (i_size)\r
+ m_smallestSize = *i_size;\r
+ else {\r
+ RECT rc;\r
+ GetWindowRect(m_hwnd, &rc);\r
+ m_smallestSize.cx = rc.right - rc.left;\r
+ m_smallestSize.cy = rc.bottom - rc.top;\r
+ }\r
}\r
\r
\r
// specified by i_size\r
void LayoutManager::restrictLargestSize(Restrict i_restrict, SIZE *i_size)\r
{\r
- m_largestRestriction = i_restrict;\r
- if (i_size)\r
- m_largestSize = *i_size;\r
- else\r
- {\r
- RECT rc;\r
- GetWindowRect(m_hwnd, &rc);\r
- m_largestSize.cx = rc.right - rc.left;\r
- m_largestSize.cy = rc.bottom - rc.top;\r
- }\r
+ m_largestRestriction = i_restrict;\r
+ if (i_size)\r
+ m_largestSize = *i_size;\r
+ else {\r
+ RECT rc;\r
+ GetWindowRect(m_hwnd, &rc);\r
+ m_largestSize.cx = rc.right - rc.left;\r
+ m_largestSize.cy = rc.bottom - rc.top;\r
+ }\r
}\r
\r
//\r
bool LayoutManager::addItem(HWND i_hwnd, Origin i_originLeft,\r
- Origin i_originTop,\r
- Origin i_originRight, Origin i_originBottom)\r
+ Origin i_originTop,\r
+ Origin i_originRight, Origin i_originBottom)\r
{\r
- Item item;\r
- if (!i_hwnd)\r
- return false;\r
- item.m_hwnd = i_hwnd;\r
- if (!(GetWindowLong(i_hwnd, GWL_STYLE) & WS_CHILD))\r
- return false;\r
- item.m_hwndParent = GetParent(i_hwnd);\r
- if (!item.m_hwndParent)\r
- return false;\r
- getChildWindowRect(item.m_hwnd, &item.m_rc);\r
- GetWindowRect(item.m_hwndParent, &item.m_rcParent);\r
- item.m_origin[0] = i_originLeft;\r
- item.m_origin[1] = i_originTop;\r
- item.m_origin[2] = i_originRight;\r
- item.m_origin[3] = i_originBottom;\r
- \r
- m_items.push_back(item);\r
- return true;\r
+ Item item;\r
+ if (!i_hwnd)\r
+ return false;\r
+ item.m_hwnd = i_hwnd;\r
+#ifdef MAYU64\r
+ if (!(GetWindowLongPtr(i_hwnd, GWL_STYLE) & WS_CHILD))\r
+#else\r
+ if (!(GetWindowLong(i_hwnd, GWL_STYLE) & WS_CHILD))\r
+#endif\r
+ return false;\r
+ item.m_hwndParent = GetParent(i_hwnd);\r
+ if (!item.m_hwndParent)\r
+ return false;\r
+ getChildWindowRect(item.m_hwnd, &item.m_rc);\r
+ GetWindowRect(item.m_hwndParent, &item.m_rcParent);\r
+ item.m_origin[0] = i_originLeft;\r
+ item.m_origin[1] = i_originTop;\r
+ item.m_origin[2] = i_originRight;\r
+ item.m_origin[3] = i_originBottom;\r
+\r
+ m_items.push_back(item);\r
+ return true;\r
}\r
\r
//\r
void LayoutManager::adjust() const\r
{\r
- for (Items::const_iterator i = m_items.begin(); i != m_items.end(); ++ i)\r
- {\r
- RECT rc;\r
- GetWindowRect(i->m_hwndParent, &rc);\r
-\r
- struct { int m_width, m_pos; int m_curWidth; LONG *m_out; }\r
- pos[4] =\r
- {\r
- { rcWidth(&i->m_rcParent), i->m_rc.left, rcWidth(&rc), &rc.left },\r
- { rcHeight(&i->m_rcParent), i->m_rc.top, rcHeight(&rc), &rc.top },\r
- { rcWidth(&i->m_rcParent), i->m_rc.right, rcWidth(&rc), &rc.right },\r
- { rcHeight(&i->m_rcParent), i->m_rc.bottom, rcHeight(&rc), &rc.bottom }\r
- };\r
- for (int j = 0; j < 4; ++ j)\r
- {\r
- switch (i->m_origin[j])\r
- {\r
- case ORIGIN_LEFT_EDGE:\r
- *pos[j].m_out = pos[j].m_pos;\r
- break;\r
- case ORIGIN_CENTER:\r
- *pos[j].m_out = pos[j].m_curWidth / 2\r
- - (pos[j].m_width / 2 - pos[j].m_pos);\r
- break;\r
- case ORIGIN_RIGHT_EDGE:\r
- *pos[j].m_out = pos[j].m_curWidth\r
- - (pos[j].m_width - pos[j].m_pos);\r
- break;\r
- }\r
- }\r
- MoveWindow(i->m_hwnd, rc.left, rc.top,\r
- rcWidth(&rc), rcHeight(&rc), FALSE);\r
- }\r
+ for (Items::const_iterator i = m_items.begin(); i != m_items.end(); ++ i) {\r
+ RECT rc;\r
+ GetWindowRect(i->m_hwndParent, &rc);\r
+\r
+ struct {\r
+ int m_width, m_pos;\r
+ int m_curWidth;\r
+ LONG *m_out;\r
+ }\r
+ pos[4] = {\r
+ { rcWidth(&i->m_rcParent), i->m_rc.left, rcWidth(&rc), &rc.left },\r
+ { rcHeight(&i->m_rcParent), i->m_rc.top, rcHeight(&rc), &rc.top },\r
+ { rcWidth(&i->m_rcParent), i->m_rc.right, rcWidth(&rc), &rc.right },\r
+ { rcHeight(&i->m_rcParent), i->m_rc.bottom, rcHeight(&rc), &rc.bottom }\r
+ };\r
+ for (int j = 0; j < 4; ++ j) {\r
+ switch (i->m_origin[j]) {\r
+ case ORIGIN_LEFT_EDGE:\r
+ *pos[j].m_out = pos[j].m_pos;\r
+ break;\r
+ case ORIGIN_CENTER:\r
+ *pos[j].m_out = pos[j].m_curWidth / 2\r
+ - (pos[j].m_width / 2 - pos[j].m_pos);\r
+ break;\r
+ case ORIGIN_RIGHT_EDGE:\r
+ *pos[j].m_out = pos[j].m_curWidth\r
+ - (pos[j].m_width - pos[j].m_pos);\r
+ break;\r
+ }\r
+ }\r
+ MoveWindow(i->m_hwnd, rc.left, rc.top,\r
+ rcWidth(&rc), rcHeight(&rc), FALSE);\r
+ }\r
}\r
\r
\r
// draw size box\r
BOOL LayoutManager::wmPaint()\r
{\r
- PAINTSTRUCT ps;\r
- HDC hdc = BeginPaint(m_hwnd, &ps);\r
- RECT rc;\r
- GetClientRect(m_hwnd, &rc);\r
- rc.left = rc.right - GetSystemMetrics(SM_CXHTHUMB);\r
- rc.top = rc.bottom - GetSystemMetrics(SM_CYVTHUMB);\r
- DrawFrameControl(hdc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);\r
- EndPaint(m_hwnd, &ps);\r
- return TRUE;\r
+ PAINTSTRUCT ps;\r
+ HDC hdc = BeginPaint(m_hwnd, &ps);\r
+ RECT rc;\r
+ GetClientRect(m_hwnd, &rc);\r
+ rc.left = rc.right - GetSystemMetrics(SM_CXHTHUMB);\r
+ rc.top = rc.bottom - GetSystemMetrics(SM_CYVTHUMB);\r
+ DrawFrameControl(hdc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);\r
+ EndPaint(m_hwnd, &ps);\r
+ return TRUE;\r
}\r
\r
\r
// size restriction\r
BOOL LayoutManager::wmSizing(int i_edge, RECT *io_rc)\r
{\r
- switch (i_edge)\r
- {\r
- case WMSZ_TOPLEFT:\r
- case WMSZ_LEFT:\r
- case WMSZ_BOTTOMLEFT:\r
- if (m_smallestRestriction & RESTRICT_HORIZONTALLY)\r
- if (io_rc->right - io_rc->left < m_smallestSize.cx)\r
- io_rc->left = io_rc->right - m_smallestSize.cx;\r
- if (m_largestRestriction & RESTRICT_HORIZONTALLY)\r
- if (m_largestSize.cx < io_rc->right - io_rc->left)\r
- io_rc->left = io_rc->right - m_largestSize.cx;\r
- break;\r
- }\r
- switch (i_edge)\r
- {\r
- case WMSZ_TOPRIGHT:\r
- case WMSZ_RIGHT:\r
- case WMSZ_BOTTOMRIGHT:\r
- if (m_smallestRestriction & RESTRICT_HORIZONTALLY)\r
- if (io_rc->right - io_rc->left < m_smallestSize.cx)\r
- io_rc->right = io_rc->left + m_smallestSize.cx;\r
- if (m_largestRestriction & RESTRICT_HORIZONTALLY)\r
- if (m_largestSize.cx < io_rc->right - io_rc->left)\r
- io_rc->right = io_rc->left + m_largestSize.cx;\r
- break;\r
- }\r
- switch (i_edge)\r
- {\r
- case WMSZ_TOP:\r
- case WMSZ_TOPLEFT:\r
- case WMSZ_TOPRIGHT:\r
- if (m_smallestRestriction & RESTRICT_VERTICALLY)\r
- if (io_rc->bottom - io_rc->top < m_smallestSize.cy)\r
- io_rc->top = io_rc->bottom - m_smallestSize.cy;\r
- if (m_largestRestriction & RESTRICT_VERTICALLY)\r
- if (m_largestSize.cy < io_rc->bottom - io_rc->top)\r
- io_rc->top = io_rc->bottom - m_largestSize.cy;\r
- break;\r
- }\r
- switch (i_edge)\r
- {\r
- case WMSZ_BOTTOM:\r
- case WMSZ_BOTTOMLEFT:\r
- case WMSZ_BOTTOMRIGHT:\r
- if (m_smallestRestriction & RESTRICT_VERTICALLY)\r
- if (io_rc->bottom - io_rc->top < m_smallestSize.cy)\r
- io_rc->bottom = io_rc->top + m_smallestSize.cy;\r
- if (m_largestRestriction & RESTRICT_VERTICALLY)\r
- if (m_largestSize.cy < io_rc->bottom - io_rc->top)\r
- io_rc->bottom = io_rc->top + m_largestSize.cy;\r
- break;\r
- }\r
- return TRUE;\r
+ switch (i_edge) {\r
+ case WMSZ_TOPLEFT:\r
+ case WMSZ_LEFT:\r
+ case WMSZ_BOTTOMLEFT:\r
+ if (m_smallestRestriction & RESTRICT_HORIZONTALLY)\r
+ if (io_rc->right - io_rc->left < m_smallestSize.cx)\r
+ io_rc->left = io_rc->right - m_smallestSize.cx;\r
+ if (m_largestRestriction & RESTRICT_HORIZONTALLY)\r
+ if (m_largestSize.cx < io_rc->right - io_rc->left)\r
+ io_rc->left = io_rc->right - m_largestSize.cx;\r
+ break;\r
+ }\r
+ switch (i_edge) {\r
+ case WMSZ_TOPRIGHT:\r
+ case WMSZ_RIGHT:\r
+ case WMSZ_BOTTOMRIGHT:\r
+ if (m_smallestRestriction & RESTRICT_HORIZONTALLY)\r
+ if (io_rc->right - io_rc->left < m_smallestSize.cx)\r
+ io_rc->right = io_rc->left + m_smallestSize.cx;\r
+ if (m_largestRestriction & RESTRICT_HORIZONTALLY)\r
+ if (m_largestSize.cx < io_rc->right - io_rc->left)\r
+ io_rc->right = io_rc->left + m_largestSize.cx;\r
+ break;\r
+ }\r
+ switch (i_edge) {\r
+ case WMSZ_TOP:\r
+ case WMSZ_TOPLEFT:\r
+ case WMSZ_TOPRIGHT:\r
+ if (m_smallestRestriction & RESTRICT_VERTICALLY)\r
+ if (io_rc->bottom - io_rc->top < m_smallestSize.cy)\r
+ io_rc->top = io_rc->bottom - m_smallestSize.cy;\r
+ if (m_largestRestriction & RESTRICT_VERTICALLY)\r
+ if (m_largestSize.cy < io_rc->bottom - io_rc->top)\r
+ io_rc->top = io_rc->bottom - m_largestSize.cy;\r
+ break;\r
+ }\r
+ switch (i_edge) {\r
+ case WMSZ_BOTTOM:\r
+ case WMSZ_BOTTOMLEFT:\r
+ case WMSZ_BOTTOMRIGHT:\r
+ if (m_smallestRestriction & RESTRICT_VERTICALLY)\r
+ if (io_rc->bottom - io_rc->top < m_smallestSize.cy)\r
+ io_rc->bottom = io_rc->top + m_smallestSize.cy;\r
+ if (m_largestRestriction & RESTRICT_VERTICALLY)\r
+ if (m_largestSize.cy < io_rc->bottom - io_rc->top)\r
+ io_rc->bottom = io_rc->top + m_largestSize.cy;\r
+ break;\r
+ }\r
+ return TRUE;\r
}\r
\r
\r
// hittest for size box\r
BOOL LayoutManager::wmNcHitTest(int i_x, int i_y)\r
{\r
- POINT p = { i_x, i_y };\r
- ScreenToClient(m_hwnd, &p);\r
- RECT rc;\r
- GetClientRect(m_hwnd, &rc);\r
- if (rc.right - GetSystemMetrics(SM_CXHTHUMB) <= p.x &&\r
- rc.bottom - GetSystemMetrics(SM_CYVTHUMB) <= p.y)\r
- {\r
- SetWindowLong(m_hwnd, DWL_MSGRESULT, HTBOTTOMRIGHT);\r
- return TRUE;\r
- }\r
- return FALSE;\r
+ POINT p = { i_x, i_y };\r
+ ScreenToClient(m_hwnd, &p);\r
+ RECT rc;\r
+ GetClientRect(m_hwnd, &rc);\r
+ if (rc.right - GetSystemMetrics(SM_CXHTHUMB) <= p.x &&\r
+ rc.bottom - GetSystemMetrics(SM_CYVTHUMB) <= p.y) {\r
+#ifdef MAYU64\r
+ SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, HTBOTTOMRIGHT);\r
+#else\r
+ SetWindowLong(m_hwnd, DWL_MSGRESULT, HTBOTTOMRIGHT);\r
+#endif\r
+ return TRUE;\r
+ }\r
+ return FALSE;\r
}\r
\r
\r
// WM_SIZE\r
BOOL LayoutManager::wmSize(DWORD /* i_fwSizeType */, short /* i_nWidth */,\r
- short /* i_nHeight */)\r
+ short /* i_nHeight */)\r
{\r
- adjust();\r
- RedrawWindow(m_hwnd, NULL, NULL,\r
- RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);\r
- return TRUE;\r
+ adjust();\r
+ RedrawWindow(m_hwnd, NULL, NULL,\r
+ RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);\r
+ return TRUE;\r
}\r
\r
\r
// forward message\r
BOOL LayoutManager::defaultWMHandler(UINT i_message,\r
- WPARAM i_wParam, LPARAM i_lParam)\r
+ WPARAM i_wParam, LPARAM i_lParam)\r
{\r
- switch (i_message)\r
- {\r
- case WM_SIZE:\r
- return wmSize(i_wParam, LOWORD(i_lParam), HIWORD(i_lParam));\r
- case WM_PAINT:\r
- return wmPaint();\r
- case WM_SIZING:\r
- return wmSizing(i_wParam, reinterpret_cast<RECT *>(i_lParam));\r
- case WM_NCHITTEST:\r
- return wmNcHitTest(GET_X_LPARAM(i_lParam), GET_Y_LPARAM(i_lParam));\r
- }\r
- return FALSE;\r
+ switch (i_message) {\r
+ case WM_SIZE:\r
+ return wmSize(i_wParam, LOWORD(i_lParam), HIWORD(i_lParam));\r
+ case WM_PAINT:\r
+ return wmPaint();\r
+ case WM_SIZING:\r
+ return wmSizing(i_wParam, reinterpret_cast<RECT *>(i_lParam));\r
+ case WM_NCHITTEST:\r
+ return wmNcHitTest(GET_X_LPARAM(i_lParam), GET_Y_LPARAM(i_lParam));\r
+ }\r
+ return FALSE;\r
}\r