summaryrefslogtreecommitdiff
path: root/alf/alflayout.h
blob: 183c336604642d6c73573a40274b5f32a11db15f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once

#include "alf.h"
#include "alflist.h"

typedef struct {
    ALFListHeader list;
    HWND hwnd;
    int x;
    int y;
    int width;
    int height;
    DWORD flags;
} ALFWidgetPriv;

typedef struct {
    HWND hwnd;
    int x;
    int y;
    int width;
    int height;
    DWORD flags;
} ALFAddWidgetParams;

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         widgets;
    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                (*handleContainerWidgetSize)(struct tagALFLayout *layout, HWND hwnd, HWND hwndContainerWidget, SIZE *s);
    void                (*endCalcSizes)(struct tagALFLayout *layout, HWND hwnd, SIZE *minSize);
    RECT                  allocatedWidgetRect;
    void                (*preApplyLayoutToContainerWidget)(struct tagALFLayout *layout, HWND hwnd, HWND hwndContainerWidget, 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_AddWidget(ALFLayout *layout, HWND window, const ALFAddWidgetParams *params);

BOOL
ALF_Layout_RemoveWidget(ALFLayout *layout, HWND window, HWND widget, BOOL destroy);

BOOL
ALF_Layout_HandleMessage(ALFLayout *layout, HWND window, UINT msg, WPARAM wparam, LPARAM lparam, LRESULT *ret);

HWND
ALF_Layout_WidgetAtPos(ALFLayout *layout, int x, int y);

void
ALF_Layout_Invalidate(ALFLayout *layout, HWND window);

BOOL
ALF_Layout_Validate(ALFLayout *layout, HWND window);