OSDN Git Service

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