OSDN Git Service

enable command notify on x64
[yamy/yamy.git] / layoutmanager.h
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
2 // layoutmanager.h\r
3 \r
4 \r
5 #ifndef _LAYOUTMANAGER_H\r
6 #  define _LAYOUTMANAGER_H\r
7 \r
8 #  include "misc.h"\r
9 #  include <list>\r
10 \r
11 \r
12 ///\r
13 class LayoutManager\r
14 {\r
15 public:\r
16         ///\r
17         enum Origin {\r
18                 ORIGIN_LEFT_EDGE,                               ///\r
19                 ORIGIN_TOP_EDGE = ORIGIN_LEFT_EDGE,             ///\r
20                 ORIGIN_CENTER,                          ///\r
21                 ORIGIN_RIGHT_EDGE,                              ///\r
22                 ORIGIN_BOTTOM_EDGE = ORIGIN_RIGHT_EDGE, ///\r
23         };\r
24 \r
25         ///\r
26         enum Restrict {\r
27                 RESTRICT_NONE = 0,                              ///\r
28                 RESTRICT_HORIZONTALLY = 1,                      ///\r
29                 RESTRICT_VERTICALLY = 2,                        ///\r
30                 RESTRICT_BOTH = RESTRICT_HORIZONTALLY | RESTRICT_VERTICALLY, ///\r
31         };\r
32 \r
33 private:\r
34         ///\r
35         class Item\r
36         {\r
37         public:\r
38                 HWND m_hwnd;                            ///\r
39                 HWND m_hwndParent;                              ///\r
40                 RECT m_rc;                                      ///\r
41                 RECT m_rcParent;                                ///\r
42                 Origin m_origin[4];                             ///\r
43         };\r
44 \r
45         ///\r
46         class SmallestSize\r
47         {\r
48         public:\r
49                 HWND m_hwnd;                            ///\r
50                 SIZE m_size;                            ///\r
51 \r
52         public:\r
53                 ///\r
54                 SmallestSize() : m_hwnd(NULL) { }\r
55         };\r
56 \r
57         typedef std::list<Item> Items;          ///\r
58 \r
59 protected:\r
60         HWND m_hwnd;                                    ///\r
61 \r
62 private:\r
63         Items m_items;                          ///\r
64         Restrict m_smallestRestriction;         ///\r
65         SIZE m_smallestSize;                            ///\r
66         Restrict m_largestRestriction;          ///\r
67         SIZE m_largestSize;                             ///\r
68 \r
69 public:\r
70         ///\r
71         LayoutManager(HWND i_hwnd);\r
72 \r
73         /** restrict the smallest size of the window to the current size of it or\r
74             specified by i_size */\r
75         void restrictSmallestSize(Restrict i_restrict = RESTRICT_BOTH,\r
76                                                           SIZE *i_size = NULL);\r
77 \r
78         /** restrict the largest size of the window to the current size of it or\r
79             specified by i_size */\r
80         void restrictLargestSize(Restrict i_restrict = RESTRICT_BOTH,\r
81                                                          SIZE *i_size = NULL);\r
82 \r
83         ///\r
84         bool addItem(HWND i_hwnd,\r
85                                  Origin i_originLeft = ORIGIN_LEFT_EDGE,\r
86                                  Origin i_originTop = ORIGIN_TOP_EDGE,\r
87                                  Origin i_originRight = ORIGIN_LEFT_EDGE,\r
88                                  Origin i_originBottom = ORIGIN_TOP_EDGE);\r
89         ///\r
90         void adjust() const;\r
91 \r
92         /// draw size box\r
93         virtual BOOL wmPaint();\r
94 \r
95         /// size restriction\r
96         virtual BOOL wmSizing(int i_edge, RECT *io_rc);\r
97 \r
98         /// hittest for size box\r
99         virtual BOOL wmNcHitTest(int i_x, int i_y);\r
100 \r
101         /// WM_SIZE\r
102         virtual BOOL wmSize(DWORD /* i_fwSizeType */, short /* i_nWidth */,\r
103                                                 short /* i_nHeight */);\r
104 \r
105         /// forward message\r
106         virtual BOOL defaultWMHandler(UINT i_message, WPARAM i_wParam,\r
107                                                                   LPARAM i_lParam);\r
108 };\r
109 \r
110 \r
111 #endif // !_LAYOUTMANAGER_H\r