TNB Library
TnbRatioLayout.h
[詳解]
1#pragma once
11#include "TnbLayout.h"
12
13
14
15//TNB Library
16namespace TNB
17{
18
19
20
55{
56 DEFSUPER(CAbstractLayout);
57public:
58
64 CRatioLayout(bool isHorizental = true, DWORD parsent = 50) : m_isWideMode(isHorizental), m_center(parsent)
65 {
66 }
67
73 void SetParameter(bool isHorizental = true, DWORD parsent = 50)
74 {
75 m_isWideMode = isHorizental;
76 m_center = parsent;
77 }
78
88 CRatioLayout& Add(bool isFirst, const ILayout& layout, ELocation hloc = DEFAULT, ELocation vloc = DEFAULT)
89 {
90 m_param[isFirst ? 0 : 1] = TParam(hloc, vloc, layout);
91 return *this;
92 }
93
99 virtual ILayout* Clone(void) const
100 {
101 CRatioLayout* P = new CRatioLayout();
102 *P = *this;
103 return P;
104 }
105
113 virtual bool GetMinimumSize(SIZE& _size) const
114 {
115 if ( ! m_IsValid() )
116 {
117 return false;
118 }
119 _size.cx =0;
120 _size.cy =0;
121 SIZE sz;
122 loop ( i, 2 )
123 {
124 if ( m_param[i].pLayout->GetMinimumSize(sz) )
125 {
126 if ( m_isWideMode )
127 {
128 //== 横画面
129 _size.cy = max(_size.cy, sz.cy);
130 if ( _size.cx != 0 )
131 {
132 _size.cx += m_gapSize.cx;
133 }
134 _size.cx += sz.cx;
135 }
136 else
137 {
138 //== 縦画面
139 _size.cx = max(_size.cx, sz.cx);
140 if ( _size.cy != 0 )
141 {
142 _size.cy += m_gapSize.cy;
143 }
144 _size.cy += sz.cy;
145 }
146 }
147 }
148 AddMargnSize(_size);
149 return true;
150 }
151
160 virtual void Decide(int x, int y, WPARAM wParam, LPARAM lParam)
161 {
162 SIZE areaSize = m_layoutSize;
163 {
164 SIZE sz = { 0, 0 };
165 if ( m_isWideMode )
166 {
167 AddChinkSize(sz, 2, 1);
168 }
169 else
170 {
171 AddChinkSize(sz, 1, 2);
172 }
173 areaSize.cx -= sz.cx;
174 areaSize.cy -= sz.cy;
175 }
176 POINT pos[2] = { 0 };
177 SIZE size[2];
178 size[0] = areaSize;
179 size[1] = areaSize;
180 if ( m_isWideMode )
181 {
182 //== 横画面
183 size[0].cx *= m_center;
184 size[0].cx /= 100;
185 size[1].cx -= size[0].cx;
186 pos[1].x = size[0].cx + m_gapSize.cx;
187 }
188 else
189 {
190 //== 縦画面
191 size[0].cy *= m_center;
192 size[0].cy /= 100;
193 size[1].cy -= size[0].cy;
194 pos[1].y = size[0].cy + m_gapSize.cy;
195 }
196 //レイアウト
197 loop ( i, 2 )
198 {
199 TParam& pa = m_param[i];
200 HorizontalItemDecide(pa.pLayout, x, pos[i].x + m_margn.left, size[i].cx, pa.horizontalLocate, wParam, lParam);
201 VerticalItemDecide(pa.pLayout, y, pos[i].y + m_margn.top, size[i].cy, pa.verticalLocate, wParam, lParam);
202 }
203 }
204
205private:
206 // 有効?
207 bool m_IsValid(void) const
208 {
209 return m_param[0].pLayout != NULL && m_param[1].pLayout != NULL;
210 }
211 TParam m_param[2];
212 size_t m_center;
213 bool m_isWideMode;
214};
215
216
217
218}; // TNB
#define loop(VAR, CNT)
loop構文.
Definition: TnbDef.h:343
レイアウト関係のヘッダ
レイアウトアイテム抽象クラス.
Definition: TnbLayout.h:194
ELocation
レイアウトアイテム配置方法.
Definition: TnbLayout.h:204
@ DEFAULT
横方向は左寄せ、縦方向は中央
Definition: TnbLayout.h:205
void AddMargnSize(SIZE &_size) const
[加算] マージンサイズ加算.
Definition: TnbLayout.h:425
void HorizontalItemDecide(ILayout *pLayout, INT_PTR x, INT_PTR xx, INT_PTR width, ELocation loc, WPARAM wParam, LPARAM lParam)
[設定] 水平方向アイテム決定.
Definition: TnbLayout.h:338
SIZE m_gapSize
各アイテム間のギャップ(縦、横)
Definition: TnbLayout.h:326
SIZE m_layoutSize
レイアウト全体サイズ(縦、横)
Definition: TnbLayout.h:324
void VerticalItemDecide(ILayout *pLayout, INT_PTR y, INT_PTR yy, INT_PTR height, ELocation loc, WPARAM wParam, LPARAM lParam)
[設定] 垂直方向アイテム決定.
Definition: TnbLayout.h:379
void AddChinkSize(SIZE &_size, size_t cx, size_t cy) const
[加算] 隙間サイズ加算.
Definition: TnbLayout.h:438
RECT m_margn
外周のマージン
Definition: TnbLayout.h:325
比率レイアウトアイテムクラス.
virtual bool GetMinimumSize(SIZE &_size) const
[取得] 最小サイズ取得.
virtual ILayout * Clone(void) const
[作成] クローン作成.
virtual void Decide(int x, int y, WPARAM wParam, LPARAM lParam)
[処理] 決定.
CRatioLayout(bool isHorizental=true, DWORD parsent=50)
コンストラクタ
CRatioLayout & Add(bool isFirst, const ILayout &layout, ELocation hloc=DEFAULT, ELocation vloc=DEFAULT)
[設定] アイテム追加.
void SetParameter(bool isHorizental=true, DWORD parsent=50)
[設定] パラメータ設定.
TNB Library
Definition: TnbDoxyTitle.txt:2
管理パラメータ型
Definition: TnbLayout.h:307
ELocation horizontalLocate
アイテムの水平配置種
Definition: TnbLayout.h:308
ELocation verticalLocate
アイテムの垂直配置種
Definition: TnbLayout.h:309
ILayout::Ptr pLayout
レイアウトアイテム
Definition: TnbLayout.h:310
レイアウトインターフェース.
Definition: TnbLayout.h:34