15#define classCLayoutDialog classCDialog
48 ms_GetSize(m_hWnd, m_size);
79 return ms_GetSize(m_hWnd, _size);
104 ::SetWindowPos(m_hWnd, NULL, 0, 0, size.cx, size.cy, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREDRAW);
116 virtual void Decide(
int x,
int y, WPARAM wParam, LPARAM lParam)
118 if ( y >= 0 && wParam ==
'HWND' )
121 HWND* pPrevHwnd =
reinterpret_cast<HWND*
>(lParam);
122 ASSERT( ! ::IsBadWritePtr(pPrevHwnd,
sizeof(HWND)) );
123 ::SetWindowPos(m_hWnd, *pPrevHwnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW);
126 ms_MoveControlPos(m_hWnd, x, y);
148 static bool ms_GetControlPos(POINT& _pos, HWND hWnd)
150 HWND hParent = ::GetParent(hWnd);
152 if ( hParent != NULL && ::GetWindowRect(hWnd, &rc) )
154 POINT po = { rc.left, rc.top };
155 if ( ::ScreenToClient(hParent, &po) )
170 static bool ms_MoveControlPos(HWND hWnd,
int x,
int y)
173 if ( ms_GetControlPos(po, hWnd) )
175 int xx = (x < 0) ? po.x : x;
176 int yy = (y < 0) ? po.y : y;
177 ::SetWindowPos(hWnd, NULL, xx, yy, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOREDRAW);
183 static bool ms_GetSize(HWND hWnd, SIZE& _size)
186 if ( ::GetWindowRect(hWnd, &rc) )
188 _size.cx = rc.right - rc.left;
189 _size.cy = rc.bottom - rc.top;
205 ASSERT( pWnd != NULL );
212 return Li(pParent->GetDlgItem(ctrlId));
303 : _super(lpszTemplateName, pParentWnd)
315 : _super(nIDTemplate, pParentWnd)
325 void SetResizeMode(
bool canHorizontalResize =
true,
bool canVerticalResize =
true)
327 m_param.canHorizontalResize = canHorizontalResize;
328 m_param.canVerticalResize = canVerticalResize;
343 m_pLayout = lay.
Clone();
344 if ( ! m_pLayout.
IsNull() &&
Decide(
this, *m_pLayout, zorderTop) )
347 _super::GetWindowRect(winRc);
348 return !! _super::SetWindowPos(NULL, 0, 0, winRc.Width(), winRc.Height(), SWP_NOMOVE | SWP_NOZORDER);
363 _super::GetWindowRect(winRc);
364 _super::GetClientRect(cliRc);
365 CSize s = winRc.Size() - cliRc.Size();
366 return !! _super::SetWindowPos(NULL, 0, 0, sz.cx + s.cx, sz.cy + s.cy, SWP_NOMOVE | SWP_NOZORDER);
377 if ( ! m_pLayout.
IsNull() )
396 void Decide(
int x,
int y, WPARAM wParam, LPARAM lParam)
398 if ( ! m_pLayout.
IsNull() )
400 m_pLayout->
Decide(x, y, wParam, lParam);
413 static bool Decide(
const RECT& rect,
ILayout& lay, HWND zorderTop = HWND_TOP)
417 if ( zorderTop != HWND_NOTOPMOST && zorderTop != HWND_BOTTOM && zorderTop != HWND_TOPMOST)
420 lParam =
reinterpret_cast<LPARAM
>(&zorderTop);
422 SIZE sz = { rect.right - rect.left, rect.bottom - rect.top };
424 lay.
Decide(rect.left, rect.top, wParam, lParam);
443 pWnd->GetClientRect(&rc);
444 r =
Decide(rc, lay, zorderTop);
445 pWnd->Invalidate(FALSE);
461 virtual LRESULT
WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
463 if ( ! m_pLayout.
IsNull() )
465 if ( message == WM_SIZE )
467 int h = HIWORD(lParam);
468 int w = LOWORD(lParam);
469 m_pLayout->
Resize(CSize(w, h));
470 m_pLayout->
Decide(0, 0, 0, 0);
471 _super::RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);
475 if ( message == WM_GETMINMAXINFO )
477 MINMAXINFO* P =
reinterpret_cast<MINMAXINFO*
>(lParam);
480 _super::GetWindowRect(winRc);
481 _super::GetClientRect(cliRc);
485 CSize s = winRc.Size() - cliRc.Size();
486 P->ptMinTrackSize.x = sz.cx + s.cx;
487 P->ptMinTrackSize.y = sz.cy + s.cy;
488 if ( ! m_param.canHorizontalResize )
490 P->ptMaxTrackSize.x = P->ptMinTrackSize.x;
492 if ( ! m_param.canVerticalResize )
494 P->ptMaxTrackSize.y = P->ptMinTrackSize.y;
501 return _super::WindowProc(message, wParam, lParam);
509 bool canHorizontalResize;
510 bool canVerticalResize;
512 TParam(
void) : canHorizontalResize(true), canVerticalResize(true)
HWND GetSafeHwnd(void) const
[取得] ウィンドウハンドル取得.
bool IsNull(void) const
[確認] NULLチェック
friend CControlLayoutItem Li(CWnd *pWnd)
[作成] レイアウトアイテム作成.
virtual bool GetMinimumSize(SIZE &_size) const
[取得] 最小サイズ取得.
virtual ILayout * Clone(void) const
[作成] クローン作成.
CControlLayoutItem(HWND hWnd)
コンストラクタ.
virtual void Decide(int x, int y, WPARAM wParam, LPARAM lParam)
[処理] 決定.
CControlLayoutItem(HWND hWnd, const SIZE &sz)
コンストラクタ.
virtual bool Resize(const SIZE &size)
[設定] サイズ設定.
virtual bool GetSize(SIZE &_size) const
[取得] サイズ取得.
static bool Decide(const RECT &rect, ILayout &lay, HWND zorderTop=HWND_TOP)
[設定] レイアウト指定.
bool ChangeMinimumSize(void)
[設定] 最小サイズ化.
bool ChangeClientSize(const SIZE &sz)
[設定] サイズ変更.
bool SetLayout(ILayout &lay, HWND zorderTop=HWND_TOP)
[設定] レイアウト設定.
void Decide(int x, int y, WPARAM wParam, LPARAM lParam)
[処理] 決定.
CLayoutDialog(UINT nIDTemplate, CWnd *pParentWnd=NULL)
コンストラクタ
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
[通知] for processing Windows messages.
CLayoutDialog(void)
コンストラクタ
static bool Decide(CWnd *pWnd, ILayout &lay, HWND zorderTop=HWND_TOP)
[設定] レイアウト指定.
CLayoutDialog(LPCTSTR lpszTemplateName, CWnd *pParentWnd=NULL)
コンストラクタ
void SetResizeMode(bool canHorizontalResize=true, bool canVerticalResize=true)
[設定] リサイズモード設定.
CControlLayoutItem Li(CWnd *pWnd)
virtual bool Resize(const SIZE &size)=0
[設定] サイズ設定.
virtual bool GetMinimumSize(SIZE &_size) const =0
[取得] 最小サイズ取得.
virtual void Decide(int x, int y, WPARAM wParam, LPARAM lParam)=0
[処理] 決定.
virtual ILayout * Clone(void) const =0
[作成] クローン作成.