foobar2000 SDK  2015-08-03
Data Structures | Public Types | Public Member Functions | Private Member Functions | Private Attributes
dialog_resize_helper

#include <dialog_resize_helper.h>

Data Structures

struct  param
 

Public Types

enum  {
  X_MOVE = 1, X_SIZE = 2, Y_MOVE = 4, Y_SIZE = 8,
  XY_MOVE = X_MOVE|Y_MOVE, XY_SIZE = X_SIZE|Y_SIZE, X_MOVE_Y_SIZE = X_MOVE|Y_SIZE, X_SIZE_Y_MOVE = X_SIZE|Y_MOVE
}
 

Public Member Functions

 dialog_resize_helper (const param *src, unsigned count, unsigned p_min_x, unsigned p_min_y, unsigned p_max_x, unsigned p_max_y)
 
 ~dialog_resize_helper ()
 
void add_sizegrip ()
 
 PFC_CLASS_NOT_COPYABLE_EX (dialog_resize_helper)
 
bool process_message (HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
 
BOOL ProcessWindowMessage (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
 
void set_max_size (unsigned x, unsigned y)
 
void set_min_size (unsigned x, unsigned y)
 

Private Member Functions

void on_wm_size ()
 
void reset ()
 
void set_parent (HWND wnd)
 

Private Attributes

pfc::array_t< paramm_table
 
unsigned max_x
 
unsigned max_y
 
unsigned min_x
 
unsigned min_y
 
RECT orig_client
 
HWND parent
 
pfc::array_t< RECT > rects
 
HWND sizegrip
 

Detailed Description

Definition at line 8 of file dialog_resize_helper.h.


Data Structure Documentation

struct dialog_resize_helper::param

Definition at line 17 of file dialog_resize_helper.h.

Data Fields
unsigned short flags
unsigned short id

Member Enumeration Documentation

anonymous enum

Constructor & Destructor Documentation

dialog_resize_helper::dialog_resize_helper ( const param src,
unsigned  count,
unsigned  p_min_x,
unsigned  p_min_y,
unsigned  p_max_x,
unsigned  p_max_y 
)

Definition at line 150 of file dialog_resize_helper.cpp.

151  : min_x(p_min_x), min_y(p_min_y), max_x(p_max_x), max_y(p_max_y), parent(0), sizegrip(0)
152 {
153  m_table.set_size(count);
154  unsigned n;
155  for(n=0;n<count;n++)
156  m_table[n] = src[n];
157  rects.set_size(count);
158 }
pfc::array_t< param > m_table
void set_size(t_size p_size)
Definition: array.h:104
pfc::array_t< RECT > rects
dialog_resize_helper::~dialog_resize_helper ( )

Definition at line 160 of file dialog_resize_helper.cpp.

161 {
162 }

Member Function Documentation

void dialog_resize_helper::add_sizegrip ( )

Definition at line 132 of file dialog_resize_helper.cpp.

133 {
134  if (parent != 0 && sizegrip == 0)
135  {
136  sizegrip = CreateWindowEx(0, WC_SCROLLBAR, _T(""), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBS_SIZEGRIP | SBS_SIZEBOXBOTTOMRIGHTALIGN,
137  0, 0, CW_USEDEFAULT, CW_USEDEFAULT,
138  parent, (HMENU)0, NULL, NULL);
139  if (sizegrip != 0)
140  {
141  RECT rc, rc_grip;
142  GetClientRect(parent, &rc);
143  GetWindowRect(sizegrip, &rc_grip);
144  SetWindowPos(sizegrip, NULL, rc.right - (rc_grip.right - rc_grip.left), rc.bottom - (rc_grip.bottom - rc_grip.top), 0, 0, SWP_NOZORDER | SWP_NOSIZE);
145  }
146  }
147 }
void dialog_resize_helper::on_wm_size ( )
private

Definition at line 30 of file dialog_resize_helper.cpp.

31 {
32  if (parent)
33  {
34  unsigned count = m_table.get_size();
35  if (sizegrip != 0) count++;
36  HDWP hWinPosInfo = BeginDeferWindowPos(count);
37  for(unsigned n=0;n<m_table.get_size();n++)
38  {
39  param & e = m_table[n];
40  const RECT & orig_rect = rects[n];
41  RECT cur_client;
42  GetClientRect(parent,&cur_client);
43  HWND wnd = GetDlgItem(parent,e.id);
44  if (wnd != NULL) {
45  unsigned dest_x = orig_rect.left, dest_y = orig_rect.top,
46  dest_cx = orig_rect.right - orig_rect.left, dest_cy = orig_rect.bottom - orig_rect.top;
47 
48  int delta_x = cur_client.right - orig_client.right,
49  delta_y = cur_client.bottom - orig_client.bottom;
50 
51  if (e.flags & X_MOVE)
52  dest_x += delta_x;
53  else if (e.flags & X_SIZE)
54  dest_cx += delta_x;
55 
56  if (e.flags & Y_MOVE)
57  dest_y += delta_y;
58  else if (e.flags & Y_SIZE)
59  dest_cy += delta_y;
60 
61  hWinPosInfo = DeferWindowPos(hWinPosInfo, wnd,0,dest_x,dest_y,dest_cx,dest_cy,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE);
62  }
63  }
64  if (sizegrip != 0)
65  {
66  RECT rc, rc_grip;
67  GetClientRect(parent, &rc);
68  GetWindowRect(sizegrip, &rc_grip);
69  hWinPosInfo = DeferWindowPos(hWinPosInfo, sizegrip, NULL, rc.right - (rc_grip.right - rc_grip.left), rc.bottom - (rc_grip.bottom - rc_grip.top), 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
70  }
71  EndDeferWindowPos(hWinPosInfo);
72  //RedrawWindow(parent,0,0,RDW_INVALIDATE);
73  }
74 }
pfc::array_t< param > m_table
pfc::array_t< RECT > rects
dialog_resize_helper::PFC_CLASS_NOT_COPYABLE_EX ( dialog_resize_helper  )
bool dialog_resize_helper::process_message ( HWND  wnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)

Definition at line 76 of file dialog_resize_helper.cpp.

76  {
77  LRESULT result = 0;
78  if (!ProcessWindowMessage(wnd,msg,wp,lp,result)) return false;
79  SetWindowLongPtr(wnd,DWLP_MSGRESULT,result);
80  return true;
81 }
BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
BOOL dialog_resize_helper::ProcessWindowMessage ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
LRESULT &  lResult 
)

Definition at line 83 of file dialog_resize_helper.cpp.

83  {
84  switch(uMsg) {
85  case WM_SIZE:
86  on_wm_size();
87  return FALSE;
88  case WM_GETMINMAXINFO:
89  {
90  RECT r;
91  LPMINMAXINFO info = (LPMINMAXINFO) lParam;
92  DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE);
93  DWORD dwExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
94  if (max_x && max_y)
95  {
96  r.left = 0; r.right = max_x;
97  r.top = 0; r.bottom = max_y;
98  MapDialogRect(hWnd,&r);
99  AdjustWindowRectEx(&r, dwStyle, FALSE, dwExStyle);
100  info->ptMaxTrackSize.x = r.right - r.left;
101  info->ptMaxTrackSize.y = r.bottom - r.top;
102  }
103  if (min_x && min_y)
104  {
105  r.left = 0; r.right = min_x;
106  r.top = 0; r.bottom = min_y;
107  MapDialogRect(hWnd,&r);
108  AdjustWindowRectEx(&r, dwStyle, FALSE, dwExStyle);
109  info->ptMinTrackSize.x = r.right - r.left;
110  info->ptMinTrackSize.y = r.bottom - r.top;
111  }
112  }
113  lResult = 0;
114  return TRUE;
115  case WM_INITDIALOG:
116  set_parent(hWnd);
117  {
118  t_size n;
119  for(n=0;n<m_table.get_size();n++) {
121  }
122  }
123  return FALSE;
124  case WM_DESTROY:
125  reset();
126  return FALSE;
127  default:
128  return FALSE;
129  }
130 }
BOOL GetChildWindowRect(HWND wnd, UINT id, RECT *child)
void info(const char *p_message)
Definition: console.cpp:4
pfc::array_t< param > m_table
size_t t_size
Definition: int_types.h:48
pfc::array_t< RECT > rects
void dialog_resize_helper::reset ( )
private

Definition at line 24 of file dialog_resize_helper.cpp.

25 {
26  parent = 0;
27  sizegrip = 0;
28 }
void dialog_resize_helper::set_max_size ( unsigned  x,
unsigned  y 
)
inline

Definition at line 29 of file dialog_resize_helper.h.

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

Definition at line 28 of file dialog_resize_helper.h.

void dialog_resize_helper::set_parent ( HWND  wnd)
private

Definition at line 17 of file dialog_resize_helper.cpp.

18 {
19  reset();
20  parent = wnd;
21  GetClientRect(parent,&orig_client);
22 }

Field Documentation

pfc::array_t<param> dialog_resize_helper::m_table
private

Definition at line 22 of file dialog_resize_helper.h.

unsigned dialog_resize_helper::max_x
private

Definition at line 14 of file dialog_resize_helper.h.

unsigned dialog_resize_helper::max_y
private

Definition at line 14 of file dialog_resize_helper.h.

unsigned dialog_resize_helper::min_x
private

Definition at line 14 of file dialog_resize_helper.h.

unsigned dialog_resize_helper::min_y
private

Definition at line 14 of file dialog_resize_helper.h.

RECT dialog_resize_helper::orig_client
private

Definition at line 11 of file dialog_resize_helper.h.

HWND dialog_resize_helper::parent
private

Definition at line 12 of file dialog_resize_helper.h.

pfc::array_t<RECT> dialog_resize_helper::rects
private

Definition at line 10 of file dialog_resize_helper.h.

HWND dialog_resize_helper::sizegrip
private

Definition at line 13 of file dialog_resize_helper.h.


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