#pragma once #include "alf.h" #include "alflist.h" typedef struct { ALFListHeader list; HWND hwnd; int x; int y; int width; int height; int xspan; int yspan; DWORD flags; SIZE calculatedSize; } ALFControlPriv; typedef struct { HWND hwnd; int x; int y; int width; int height; DWORD flags; } ALFAddControlParams; typedef struct { // properties set by user int requestedMinWidth; int requestedExpandNumerator; DWORD requestedFlags; // calculated properties int calculatedMinWidth; int calculatedExpandNumerator; // allocated size for layout application int allocatedWidth; int allocatedPosition; } ALFLayoutRowOrColumn; #define ALF_LAYOUT_NEED_RECALC ((DWORD)1) #define ALF_LAYOUT_NEED_REAPPLY ((DWORD)2) #define ALF_LAYOUT_NEED_RECALC_CONTAINER ((DWORD)4) typedef struct tagALFLayout { ALFListHeader controls; ALFLayoutRowOrColumn *columns; ALFLayoutRowOrColumn *rows; int nColumns; int nRows; int totalMinWidth; int totalMinHeight; int columnExpandDenominator; int rowExpandDenominator; int biggestColumnNo; int biggestRowNo; DWORD layoutValididityFlags; int dpi; HFONT font; ALFColor bgcolor; RECT containerMargins; // may be written to by the following functions void (*beginCalcSizes)(struct tagALFLayout *layout, HWND hwnd); void (*handleContainerControlSize)(struct tagALFLayout *layout, HWND hwnd, HWND hwndContainerControl, SIZE *s); void (*endCalcSizes)(struct tagALFLayout *layout, HWND hwnd, SIZE *minSize); RECT allocatedControlRect; void (*preApplyLayoutToContainerControl)(struct tagALFLayout *layout, HWND hwnd, HWND hwndContainerControl, RECT *pos); // should modify pos } ALFLayout; void ALF_Layout_Init(ALFLayout *layout); void ALF_Layout_Clear(ALFLayout *layout); void ALF_Layout_GetMinSize(ALFLayout *layout, HWND window, SIZE *size); void ALF_Layout_Apply(ALFLayout *layout, HWND window); void ALF_Layout_AddControl(ALFLayout *layout, HWND window, const ALFAddControlParams *params); BOOL ALF_Layout_RemoveControl(ALFLayout *layout, HWND window, HWND control, BOOL destroy); BOOL ALF_Layout_HandleMessage(ALFLayout *layout, HWND window, UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *ret); HWND ALF_Layout_ControlAtPosPriv(ALFLayout *layout, int x, int y); void ALF_Layout_Invalidate(ALFLayout *layout, HWND window); BOOL ALF_Layout_Validate(ALFLayout *layout, HWND window);