ReactOS  0.4.15-dev-5142-g967f5b9
layout.h File Reference
#include <assert.h>
Include dependency graph for layout.h:

Go to the source code of this file.

Classes

struct  LAYOUT_INFO
 
struct  LAYOUT_DATA
 

Typedefs

typedef struct LAYOUT_INFO LAYOUT_INFO
 
typedef struct LAYOUT_DATA LAYOUT_DATA
 

Functions

static __inline void _layout_ModifySystemMenu (LAYOUT_DATA *pData, BOOL bEnableResize)
 
static __inline HDWP _layout_MoveGrip (LAYOUT_DATA *pData, HDWP hDwp OPTIONAL)
 
static __inline void LayoutShowGrip (LAYOUT_DATA *pData, BOOL bShow)
 
static __inline void _layout_GetPercents (LPRECT prcPercents, UINT uEdges)
 
static __inline HDWP _layout_DoMoveItem (LAYOUT_DATA *pData, HDWP hDwp, const LAYOUT_INFO *pLayout, const RECT *rcClient)
 
static __inline void _layout_ArrangeLayout (LAYOUT_DATA *pData)
 
static __inline void _layout_InitLayouts (LAYOUT_DATA *pData)
 
static __inline void LayoutUpdate (HWND ignored1, LAYOUT_DATA *pData, LPCVOID ignored2, UINT ignored3)
 
static __inline void LayoutEnableResize (LAYOUT_DATA *pData, BOOL bEnable)
 
static __inline LAYOUT_DATALayoutInit (HWND hwndParent, const LAYOUT_INFO *pLayouts, INT cLayouts)
 
static __inline void LayoutDestroy (LAYOUT_DATA *pData)
 

Typedef Documentation

◆ LAYOUT_DATA

◆ LAYOUT_INFO

Function Documentation

◆ _layout_ArrangeLayout()

static __inline void _layout_ArrangeLayout ( LAYOUT_DATA pData)
static

Definition at line 136 of file layout.h.

137 {
138  RECT rcClient;
139  UINT iItem;
140  HDWP hDwp = BeginDeferWindowPos(pData->m_cLayouts + 1);
141  if (hDwp == NULL)
142  return;
143 
144  GetClientRect(pData->m_hwndParent, &rcClient);
145 
146  for (iItem = 0; iItem < pData->m_cLayouts; ++iItem)
147  hDwp = _layout_DoMoveItem(pData, hDwp, &pData->m_pLayouts[iItem], &rcClient);
148 
149  hDwp = _layout_MoveGrip(pData, hDwp);
150  EndDeferWindowPos(hDwp);
151 }
static __inline HDWP _layout_DoMoveItem(LAYOUT_DATA *pData, HDWP hDwp, const LAYOUT_INFO *pLayout, const RECT *rcClient)
Definition: layout.h:107
HDWP WINAPI BeginDeferWindowPos(_In_ int)
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static __inline HDWP _layout_MoveGrip(LAYOUT_DATA *pData, HDWP hDwp OPTIONAL)
Definition: layout.h:42
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by LayoutUpdate().

◆ _layout_DoMoveItem()

static __inline HDWP _layout_DoMoveItem ( LAYOUT_DATA pData,
HDWP  hDwp,
const LAYOUT_INFO pLayout,
const RECT rcClient 
)
static

Definition at line 107 of file layout.h.

109 {
110  RECT rcChild, NewRect, rcPercents;
111  LONG nWidth, nHeight;
112 
113  if (!GetWindowRect(pLayout->m_hwndCtrl, &rcChild))
114  return hDwp;
115  MapWindowPoints(NULL, pData->m_hwndParent, (LPPOINT)&rcChild, 2);
116 
117  nWidth = rcClient->right - rcClient->left;
118  nHeight = rcClient->bottom - rcClient->top;
119 
120  _layout_GetPercents(&rcPercents, pLayout->m_uEdges);
121  NewRect.left = pLayout->m_margin1.cx + nWidth * rcPercents.left / 100;
122  NewRect.top = pLayout->m_margin1.cy + nHeight * rcPercents.top / 100;
123  NewRect.right = pLayout->m_margin2.cx + nWidth * rcPercents.right / 100;
124  NewRect.bottom = pLayout->m_margin2.cy + nHeight * rcPercents.bottom / 100;
125 
126  if (!EqualRect(&NewRect, &rcChild))
127  {
128  hDwp = DeferWindowPos(hDwp, pLayout->m_hwndCtrl, NULL, NewRect.left, NewRect.top,
129  NewRect.right - NewRect.left, NewRect.bottom - NewRect.top,
131  }
132  return hDwp;
133 }
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1237
LONG right
Definition: windef.h:308
SIZE m_margin1
Definition: layout.h:14
#define SWP_NOCOPYBITS
Definition: winuser.h:1233
long LONG
Definition: pedump.c:60
LONG cx
Definition: windef.h:334
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
UINT m_uEdges
Definition: layout.h:12
#define SWP_NOACTIVATE
Definition: winuser.h:1232
HWND m_hwndCtrl
Definition: layout.h:13
SIZE m_margin2
Definition: layout.h:15
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define NULL
Definition: types.h:112
#define SWP_NOREPOSITION
Definition: winuser.h:1240
LONG bottom
Definition: windef.h:309
static __inline void _layout_GetPercents(LPRECT prcPercents, UINT uEdges)
Definition: layout.h:98
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
LONG cy
Definition: windef.h:335

Referenced by _layout_ArrangeLayout().

◆ _layout_GetPercents()

static __inline void _layout_GetPercents ( LPRECT  prcPercents,
UINT  uEdges 
)
static

Definition at line 98 of file layout.h.

99 {
100  prcPercents->left = (uEdges & BF_LEFT) ? 0 : 100;
101  prcPercents->right = (uEdges & BF_RIGHT) ? 100 : 0;
102  prcPercents->top = (uEdges & BF_TOP) ? 0 : 100;
103  prcPercents->bottom = (uEdges & BF_BOTTOM) ? 100 : 0;
104 }
#define BF_BOTTOM
Definition: winuser.h:457
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define BF_RIGHT
Definition: winuser.h:456
#define BF_TOP
Definition: winuser.h:455
LONG bottom
Definition: windef.h:309
#define BF_LEFT
Definition: winuser.h:454

Referenced by _layout_DoMoveItem(), and _layout_InitLayouts().

◆ _layout_InitLayouts()

static __inline void _layout_InitLayouts ( LAYOUT_DATA pData)
static

Definition at line 154 of file layout.h.

155 {
156  RECT rcClient, rcChild, rcPercents;
157  LONG nWidth, nHeight;
158  UINT iItem;
159 
160  GetClientRect(pData->m_hwndParent, &rcClient);
161  nWidth = rcClient.right - rcClient.left;
162  nHeight = rcClient.bottom - rcClient.top;
163 
164  for (iItem = 0; iItem < pData->m_cLayouts; ++iItem)
165  {
166  LAYOUT_INFO *pInfo = &pData->m_pLayouts[iItem];
167  if (pInfo->m_hwndCtrl == NULL)
168  {
169  pInfo->m_hwndCtrl = GetDlgItem(pData->m_hwndParent, pInfo->m_nCtrlID);
170  if (pInfo->m_hwndCtrl == NULL)
171  continue;
172  }
173 
174  GetWindowRect(pInfo->m_hwndCtrl, &rcChild);
175  MapWindowPoints(NULL, pData->m_hwndParent, (LPPOINT)&rcChild, 2);
176 
177  _layout_GetPercents(&rcPercents, pInfo->m_uEdges);
178  pInfo->m_margin1.cx = rcChild.left - nWidth * rcPercents.left / 100;
179  pInfo->m_margin1.cy = rcChild.top - nHeight * rcPercents.top / 100;
180  pInfo->m_margin2.cx = rcChild.right - nWidth * rcPercents.right / 100;
181  pInfo->m_margin2.cy = rcChild.bottom - nHeight * rcPercents.bottom / 100;
182  }
183 }
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
SIZE m_margin1
Definition: layout.h:14
long LONG
Definition: pedump.c:60
UINT m_nCtrlID
Definition: layout.h:11
LONG cx
Definition: windef.h:334
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT m_uEdges
Definition: layout.h:12
HWND m_hwndCtrl
Definition: layout.h:13
SIZE m_margin2
Definition: layout.h:15
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
LONG bottom
Definition: windef.h:309
static __inline void _layout_GetPercents(LPRECT prcPercents, UINT uEdges)
Definition: layout.h:98
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
LONG cy
Definition: windef.h:335

Referenced by LayoutInit().

◆ _layout_ModifySystemMenu()

static __inline void _layout_ModifySystemMenu ( LAYOUT_DATA pData,
BOOL  bEnableResize 
)
static

Definition at line 26 of file layout.h.

27 {
28  if (bEnableResize)
29  {
30  GetSystemMenu(pData->m_hwndParent, TRUE); /* revert */
31  }
32  else
33  {
34  HMENU hSysMenu = GetSystemMenu(pData->m_hwndParent, FALSE);
36  RemoveMenu(hSysMenu, SC_SIZE, MF_BYCOMMAND);
38  }
39 }
#define MF_BYCOMMAND
Definition: winuser.h:202
#define SC_RESTORE
Definition: winuser.h:2588
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SC_MAXIMIZE
Definition: winuser.h:2578
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define SC_SIZE
Definition: winuser.h:2574
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60

Referenced by LayoutEnableResize().

◆ _layout_MoveGrip()

static __inline HDWP _layout_MoveGrip ( LAYOUT_DATA pData,
HDWP hDwp  OPTIONAL 
)
static

Definition at line 42 of file layout.h.

43 {
44  if (!IsWindowVisible(pData->m_hwndGrip))
45  return hDwp;
46 
49  RECT rcClient;
50  GetClientRect(pData->m_hwndParent, &rcClient);
51 
52  if (hDwp)
53  {
54  hDwp = DeferWindowPos(hDwp, pData->m_hwndGrip, NULL,
55  rcClient.right - size.cx, rcClient.bottom - size.cy,
56  size.cx, size.cy, uFlags);
57  }
58  else
59  {
60  SetWindowPos(pData->m_hwndGrip, NULL,
61  rcClient.right - size.cx, rcClient.bottom - size.cy,
62  size.cx, size.cy, uFlags);
63  }
64  return hDwp;
65 }
#define SM_CYHSCROLL
Definition: winuser.h:956
#define SWP_NOZORDER
Definition: winuser.h:1237
UINT uFlags
Definition: api.c:59
LONG right
Definition: windef.h:308
#define SWP_NOCOPYBITS
Definition: winuser.h:1233
GLsizeiptr size
Definition: glext.h:5919
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOACTIVATE
Definition: winuser.h:1232
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define SM_CXVSCROLL
Definition: winuser.h:955
BOOL WINAPI IsWindowVisible(_In_ HWND)
LONG bottom
Definition: windef.h:309
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define SWP_NOOWNERZORDER
Definition: winuser.h:1239

Referenced by _layout_ArrangeLayout(), and LayoutShowGrip().

◆ LayoutDestroy()

static __inline void LayoutDestroy ( LAYOUT_DATA pData)
static

Definition at line 251 of file layout.h.

252 {
253  if (!pData)
254  return;
255  HeapFree(GetProcessHeap(), 0, pData->m_pLayouts);
257 }
#define GetProcessHeap()
Definition: compat.h:595
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by BrsFolder_OnDestroy().

◆ LayoutEnableResize()

static __inline void LayoutEnableResize ( LAYOUT_DATA pData,
BOOL  bEnable 
)
static

Definition at line 199 of file layout.h.

200 {
203 }
static __inline void _layout_ModifySystemMenu(LAYOUT_DATA *pData, BOOL bEnableResize)
Definition: layout.h:26
static __inline void LayoutShowGrip(LAYOUT_DATA *pData, BOOL bShow)
Definition: layout.h:68
_In_ BOOL bEnable
Definition: winddi.h:3426
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

◆ LayoutInit()

static __inline LAYOUT_DATA* LayoutInit ( HWND  hwndParent,
const LAYOUT_INFO pLayouts,
INT  cLayouts 
)
static

Definition at line 206 of file layout.h.

207 {
208  BOOL bShowGrip;
209  SIZE_T cb;
211  if (pData == NULL)
212  {
213  assert(0);
214  return NULL;
215  }
216 
217  if (cLayouts < 0) /* NOTE: If cLayouts was negative, then don't show size grip */
218  {
219  cLayouts = -cLayouts;
220  bShowGrip = FALSE;
221  }
222  else
223  {
224  bShowGrip = TRUE;
225  }
226 
227  cb = cLayouts * sizeof(LAYOUT_INFO);
228  pData->m_cLayouts = cLayouts;
229  pData->m_pLayouts = (LAYOUT_INFO *)HeapAlloc(GetProcessHeap(), 0, cb);
230  if (pData->m_pLayouts == NULL)
231  {
232  assert(0);
234  return NULL;
235  }
236  memcpy(pData->m_pLayouts, pLayouts, cb);
237 
239 
240  pData->m_hwndParent = hwndParent;
241 
242  pData->m_hwndGrip = NULL;
243  if (bShowGrip)
244  LayoutShowGrip(pData, bShowGrip);
245 
247  return pData;
248 }
BOOL WINAPI IsWindow(_In_opt_ HWND)
struct LAYOUT_INFO LAYOUT_INFO
#define TRUE
Definition: types.h:120
static __inline void _layout_InitLayouts(LAYOUT_DATA *pData)
Definition: layout.h:154
#define assert(x)
Definition: debug.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static HWND hwndParent
Definition: cryptui.c:300
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static __inline void LayoutShowGrip(LAYOUT_DATA *pData, BOOL bShow)
Definition: layout.h:68
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define NULL
Definition: types.h:112
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
struct LAYOUT_DATA LAYOUT_DATA
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ LayoutShowGrip()

static __inline void LayoutShowGrip ( LAYOUT_DATA pData,
BOOL  bShow 
)
static

Definition at line 68 of file layout.h.

69 {
72  DWORD style = GetWindowLongPtrW(pData->m_hwndParent, GWL_STYLE);
73  DWORD new_style = (bShow ? (style | WS_SIZEBOX) : (style & ~WS_SIZEBOX));
74  if (style != new_style)
75  {
76  SetWindowLongPtrW(pData->m_hwndParent, GWL_STYLE, new_style); /* change style */
77  SetWindowPos(pData->m_hwndParent, NULL, 0, 0, 0, 0, uSWP); /* frame changed */
78  }
79 
80  if (!bShow)
81  {
82  ShowWindow(pData->m_hwndGrip, SW_HIDE);
83  return;
84  }
85 
86  if (pData->m_hwndGrip == NULL)
87  {
89  pData->m_hwndGrip = CreateWindowExW(0, L"SCROLLBAR", NULL, style,
90  0, 0, 0, 0, pData->m_hwndParent,
92  }
94  ShowWindow(pData->m_hwndGrip, SW_SHOWNOACTIVATE);
95 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
#define SW_HIDE
Definition: winuser.h:762
#define WS_SIZEBOX
Definition: pedump.c:642
#define WS_CHILD
Definition: pedump.c:617
#define GetWindowLongPtrW
Definition: winuser.h:4819
#define SWP_NOZORDER
Definition: winuser.h:1237
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define L(x)
Definition: ntvdm.h:50
#define SBS_SIZEGRIP
Definition: winuser.h:332
#define SWP_NOACTIVATE
Definition: winuser.h:1232
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define SWP_FRAMECHANGED
Definition: winuser.h:1230
#define SWP_NOSIZE
Definition: winuser.h:1235
#define GWL_STYLE
Definition: winuser.h:846
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static __inline HDWP _layout_MoveGrip(LAYOUT_DATA *pData, HDWP hDwp OPTIONAL)
Definition: layout.h:42
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define SWP_NOMOVE
Definition: winuser.h:1234
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SetWindowLongPtrW
Definition: winuser.h:5336
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
Arabic default style
Definition: afstyles.h:93
#define SWP_NOOWNERZORDER
Definition: winuser.h:1239

Referenced by LayoutEnableResize(), and LayoutInit().

◆ LayoutUpdate()

static __inline void LayoutUpdate ( HWND  ignored1,
LAYOUT_DATA pData,
LPCVOID  ignored2,
UINT  ignored3 
)
static

Definition at line 187 of file layout.h.

188 {
189  UNREFERENCED_PARAMETER(ignored1);
190  UNREFERENCED_PARAMETER(ignored2);
191  UNREFERENCED_PARAMETER(ignored3);
192  if (pData == NULL || !pData->m_hwndParent)
193  return;
194  assert(IsWindow(pData->m_hwndParent));
196 }
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define assert(x)
Definition: debug.h:53
#define NULL
Definition: types.h:112
static __inline void _layout_ArrangeLayout(LAYOUT_DATA *pData)
Definition: layout.h:136
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827