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