foobar2000 SDK  2015-01-14
Data Structures | Public Types | Public Member Functions | Private Member Functions | Private Attributes
CDialogResizeHelper

#include <CDialogResizeHelper.h>

+ Inheritance diagram for CDialogResizeHelper:

Data Structures

struct  Param
 

Public Types

typedef dialog_resize_helper::param ParamOld
 

Public Member Functions

t_size paramCount CDialogResizeHelper (const TParam(&src)[paramCount], CRect const &minMaxRange=CRect(0, 0, 0, 0))
 
 BEGIN_MSG_MAP_EX (CDialogResizeHelper) if(uMsg
 
bool EvalRect (UINT id, CRect &out) const
 
void InitMinMax (const CRect &range)
 
void InitTable (const Param *table, t_size tableSize)
 
void InitTable (const ParamOld *table, t_size tableSize)
 
 MSG_WM_SIZE (OnSize) MSG_WM_DESTROY(OnDestroy) MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo) END_MSG_MAP() template< typename TParam
 
void set_max_size (unsigned x, unsigned y)
 
void set_min_size (unsigned x, unsigned y)
 

Private Member Functions

bool _EvalRect (t_size index, CSize wndSize, CRect &out) const
 
void AddSizeGrip ()
 
void OnDestroy ()
 
void OnGetMinMaxInfo (LPMINMAXINFO lpMMI) const
 
void OnInitDialog (CWindow thisWnd)
 
void OnSize (UINT nType, CSize size)
 

Private Attributes

pfc::map_t< UINT, CRect > m_origRects
 
CRect m_rcOrigClient
 
CWindow m_sizeGrip
 
pfc::array_t< Paramm_table
 
CWindow m_thisWnd
 
unsigned max_x
 
unsigned max_y
 
unsigned min_x
 
unsigned min_y
 

Detailed Description

Definition at line 1 of file CDialogResizeHelper.h.


Data Structure Documentation

struct CDialogResizeHelper::Param

Definition at line 5 of file CDialogResizeHelper.h.

Data Fields
t_uint32 id
float snapBottom
float snapLeft
float snapRight
float snapTop

Member Typedef Documentation

Definition at line 3 of file CDialogResizeHelper.h.

Constructor & Destructor Documentation

t_size paramCount CDialogResizeHelper::CDialogResizeHelper ( const TParam(&)  src[paramCount],
CRect const &  minMaxRange = CRect(0,0,0,0) 
)
inline

Definition at line 23 of file CDialogResizeHelper.h.

23  {
24  InitTable(src, paramCount);
25  InitMinMax(minMaxRange);
26  }
void InitMinMax(const CRect &range)
void InitTable(const Param *table, t_size tableSize)

Member Function Documentation

bool CDialogResizeHelper::_EvalRect ( t_size  index,
CSize  wndSize,
CRect &  out 
) const
private

Definition at line 13 of file CDialogResizeHelper.cpp.

13  {
14  CRect rc;
15  const Param & e = m_table[index];
16  if (m_origRects.query(e.id, rc)) {
17  int delta_x = wndSize.cx - m_rcOrigClient.right,
18  delta_y = wndSize.cy - m_rcOrigClient.bottom;
19 
20  rc.left += pfc::rint32( e.snapLeft * delta_x );
21  rc.right += pfc::rint32( e.snapRight * delta_x );
22  rc.top += pfc::rint32(e.snapTop * delta_y );
23  rc.bottom += pfc::rint32(e.snapBottom * delta_y );
24 
25  out = rc;
26  return true;
27  }
28  return false;
29 }
pfc::map_t< UINT, CRect > m_origRects
pfc::array_t< Param > m_table
t_int32 rint32(double p_val)
Definition: primitives.h:712
bool query(const _t_key &p_key, _t_value &p_value) const
Definition: map.h:44
void CDialogResizeHelper::AddSizeGrip ( )
private

Definition at line 100 of file CDialogResizeHelper.cpp.

101 {
102  if (m_thisWnd != NULL && m_sizeGrip == NULL)
103  {
104  if (m_thisWnd.GetWindowLong(GWL_STYLE) & WS_POPUP) {
105  m_sizeGrip = CreateWindowEx(0, WC_SCROLLBAR, _T(""), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN,
106  0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
107  m_thisWnd, (HMENU)0, NULL, NULL);
108  if (m_sizeGrip != NULL)
109  {
110  RECT rc, rc_grip;
111  if (m_thisWnd.GetClientRect(&rc) && m_sizeGrip.GetWindowRect(&rc_grip)) {
112  m_sizeGrip.SetWindowPos(NULL, rc.right - (rc_grip.right - rc_grip.left), rc.bottom - (rc_grip.bottom - rc_grip.top), 0, 0, SWP_NOZORDER | SWP_NOSIZE);
113  }
114  }
115  }
116  }
117 }
CDialogResizeHelper::BEGIN_MSG_MAP_EX ( CDialogResizeHelper  )
bool CDialogResizeHelper::EvalRect ( UINT  id,
CRect &  out 
) const

Definition at line 3 of file CDialogResizeHelper.cpp.

3  {
4  for(t_size walk = 0; walk < m_table.get_size(); ++walk) {
5  if (m_table[walk].id == id) {
6  CRect client; WIN32_OP_D( m_thisWnd.GetClientRect(client) );
7  return _EvalRect(walk, client.Size(), out);
8  }
9  }
10  return false;
11 }
bool _EvalRect(t_size index, CSize wndSize, CRect &out) const
pfc::array_t< Param > m_table
size_t t_size
Definition: int_types.h:48
void CDialogResizeHelper::InitMinMax ( const CRect &  range)

Definition at line 136 of file CDialogResizeHelper.cpp.

136  {
137  min_x = range.left; min_y = range.top; max_x = range.right; max_y = range.bottom;
138 }
void CDialogResizeHelper::InitTable ( const Param table,
t_size  tableSize 
)

Definition at line 120 of file CDialogResizeHelper.cpp.

120  {
121  m_table.set_data_fromptr(table, tableSize);
122 }
pfc::array_t< Param > m_table
void CDialogResizeHelper::InitTable ( const ParamOld table,
t_size  tableSize 
)

Definition at line 123 of file CDialogResizeHelper.cpp.

123  {
124  m_table.set_size(tableSize);
125  for(t_size walk = 0; walk < tableSize; ++walk) {
126  const ParamOld in = table[walk];
127  Param entry = {};
128  entry.id = table[walk].id;
129  if (in.flags & dialog_resize_helper::X_MOVE) entry.snapLeft = entry.snapRight = 1;
130  else if (in.flags & dialog_resize_helper::X_SIZE) entry.snapRight = 1;
131  if (in.flags & dialog_resize_helper::Y_MOVE) entry.snapTop = entry.snapBottom = 1;
132  else if (in.flags & dialog_resize_helper::Y_SIZE) entry.snapBottom = 1;
133  m_table[walk] = entry;
134  }
135 }
pfc::array_t< Param > m_table
size_t t_size
Definition: int_types.h:48
dialog_resize_helper::param ParamOld
CDialogResizeHelper::MSG_WM_SIZE ( OnSize  )
void CDialogResizeHelper::OnDestroy ( )
private

Definition at line 95 of file CDialogResizeHelper.cpp.

95  {
96  m_sizeGrip = NULL; m_thisWnd = NULL;
97  SetMsgHandled(FALSE);
98 }
void CDialogResizeHelper::OnGetMinMaxInfo ( LPMINMAXINFO  lpMMI) const
private

Definition at line 57 of file CDialogResizeHelper.cpp.

57  {
58  CRect r;
59  const DWORD dwStyle = m_thisWnd.GetWindowLong(GWL_STYLE);
60  const DWORD dwExStyle = m_thisWnd.GetWindowLong(GWL_EXSTYLE);
61  if (max_x && max_y)
62  {
63  r.left = 0; r.right = max_x;
64  r.top = 0; r.bottom = max_y;
65  MapDialogRect(m_thisWnd,&r);
66  AdjustWindowRectEx(&r, dwStyle, FALSE, dwExStyle);
67  info->ptMaxTrackSize.x = r.right - r.left;
68  info->ptMaxTrackSize.y = r.bottom - r.top;
69  }
70  if (min_x && min_y)
71  {
72  r.left = 0; r.right = min_x;
73  r.top = 0; r.bottom = min_y;
74  MapDialogRect(m_thisWnd,&r);
75  AdjustWindowRectEx(&r, dwStyle, FALSE, dwExStyle);
76  info->ptMinTrackSize.x = r.right - r.left;
77  info->ptMinTrackSize.y = r.bottom - r.top;
78  }
79 }
void info(const char *p_message)
Definition: console.cpp:4
void CDialogResizeHelper::OnInitDialog ( CWindow  thisWnd)
private

Definition at line 81 of file CDialogResizeHelper.cpp.

81  {
83  m_thisWnd = thisWnd;
84  m_thisWnd.GetClientRect(&m_rcOrigClient);
85  for(t_size n = 0; n < m_table.get_size(); n++) {
86  CRect rc;
87  const UINT id = m_table[n].id;
88  if (GetChildWindowRect(m_thisWnd,id,&rc)) {
89  m_origRects.set(id, rc);
90  }
91  }
92  AddSizeGrip();
93  SetMsgHandled(FALSE);
94 }
BOOL GetChildWindowRect(HWND wnd, UINT id, RECT *child)
void remove_all()
Definition: map.h:139
pfc::map_t< UINT, CRect > m_origRects
pfc::array_t< Param > m_table
size_t t_size
Definition: int_types.h:48
void set(const _t_key &p_key, const _t_value &p_value)
Definition: map.h:22
void CDialogResizeHelper::OnSize ( UINT  nType,
CSize  size 
)
private

Definition at line 31 of file CDialogResizeHelper.cpp.

32 {
33  if (m_thisWnd != NULL) {
34  HDWP hWinPosInfo = BeginDeferWindowPos( m_table.get_size() + (m_sizeGrip != NULL ? 1 : 0) );
35  for(t_size n = 0; n < m_table.get_size(); ++n) {
36  CRect rc;
37  if (_EvalRect(n, newSize, rc)) {
38  hWinPosInfo = DeferWindowPos(hWinPosInfo, m_thisWnd.GetDlgItem(m_table[n].id), 0, rc.left,rc.top,rc.Width(),rc.Height(),SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
39  }
40  }
41  if (m_sizeGrip != NULL)
42  {
43  RECT rc, rc_grip;
44  if (m_thisWnd.GetClientRect(&rc) && m_sizeGrip.GetWindowRect(&rc_grip)) {
45  DWORD flags = SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS;
46  if (IsZoomed(m_thisWnd)) flags |= SWP_HIDEWINDOW;
47  else flags |= SWP_SHOWWINDOW;
48  hWinPosInfo = DeferWindowPos(hWinPosInfo, m_sizeGrip, NULL, rc.right - (rc_grip.right - rc_grip.left), rc.bottom - (rc_grip.bottom - rc_grip.top), 0, 0, flags );
49  }
50  }
51  EndDeferWindowPos(hWinPosInfo);
52  //RedrawWindow(m_thisWnd, NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN);
53  }
54  SetMsgHandled(FALSE);
55 }
bool _EvalRect(t_size index, CSize wndSize, CRect &out) const
pfc::array_t< Param > m_table
size_t t_size
Definition: int_types.h:48
void CDialogResizeHelper::set_max_size ( unsigned  x,
unsigned  y 
)
inline

Definition at line 13 of file CDialogResizeHelper.h.

void CDialogResizeHelper::set_min_size ( unsigned  x,
unsigned  y 
)
inline

Definition at line 12 of file CDialogResizeHelper.h.

Field Documentation

pfc::map_t<UINT, CRect> CDialogResizeHelper::m_origRects
private

Definition at line 42 of file CDialogResizeHelper.h.

CRect CDialogResizeHelper::m_rcOrigClient
private

Definition at line 43 of file CDialogResizeHelper.h.

CWindow CDialogResizeHelper::m_sizeGrip
private

Definition at line 44 of file CDialogResizeHelper.h.

pfc::array_t<Param> CDialogResizeHelper::m_table
private

Definition at line 41 of file CDialogResizeHelper.h.

CWindow CDialogResizeHelper::m_thisWnd
private

Definition at line 44 of file CDialogResizeHelper.h.

unsigned CDialogResizeHelper::max_x
private

Definition at line 45 of file CDialogResizeHelper.h.

unsigned CDialogResizeHelper::max_y
private

Definition at line 45 of file CDialogResizeHelper.h.

unsigned CDialogResizeHelper::min_x
private

Definition at line 45 of file CDialogResizeHelper.h.

unsigned CDialogResizeHelper::min_y
private

Definition at line 45 of file CDialogResizeHelper.h.


The documentation for this class was generated from the following files: