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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef XFA_FWL_CORE_FWL_GRIDIMP_H_
#define XFA_FWL_CORE_FWL_GRIDIMP_H_
#include "xfa/fwl/core/fwl_contentimp.h"
#include "xfa/include/fwl/core/fwl_app.h"
#include "xfa/include/fwl/core/fwl_content.h"
#include "xfa/include/fwl/core/fwl_grid.h"
class CFWL_GridLength {
public:
CFWL_GridLength() : fLength(0), eUnit(FWL_GRIDUNIT_Fixed) {}
CFWL_GridLength(FX_FLOAT fValue, FWL_GRIDUNIT e)
: fLength(fValue), eUnit(e) {}
FX_FLOAT fLength;
FWL_GRIDUNIT eUnit;
};
class CFWL_GridColRow {
public:
CFWL_GridColRow()
: m_Size(1, FWL_GRIDUNIT_Scaled),
m_MinSize(0, FWL_GRIDUNIT_Fixed),
m_MaxSize(0, FWL_GRIDUNIT_Infinity),
m_fActualSize(0),
m_fActualPos(0) {}
CFWL_GridLength m_Size;
CFWL_GridLength m_MinSize;
CFWL_GridLength m_MaxSize;
FX_FLOAT m_fActualSize;
FX_FLOAT m_fActualPos;
};
class CFWL_GridWidgetInfo {
public:
CFWL_GridWidgetInfo()
: m_iColumn(0),
m_iColumnSpan(1),
m_iRow(0),
m_iRowSpan(1),
m_dwMarginFlag(0),
m_fActualWidth(0),
m_fActualHeight(0) {
m_Size[FWL_GRIDSIZE_Width].eUnit = FWL_GRIDUNIT_Auto;
m_Size[FWL_GRIDSIZE_Width].fLength = 0;
m_Size[FWL_GRIDSIZE_Height].eUnit = FWL_GRIDUNIT_Auto;
m_Size[FWL_GRIDSIZE_Height].fLength = 0;
m_Size[FWL_GRIDSIZE_MinWidth].eUnit = FWL_GRIDUNIT_Fixed;
m_Size[FWL_GRIDSIZE_MinWidth].fLength = 0;
m_Size[FWL_GRIDSIZE_MaxWidth].eUnit = FWL_GRIDUNIT_Infinity;
m_Size[FWL_GRIDSIZE_MaxWidth].fLength = 0;
m_Size[FWL_GRIDSIZE_MinHeight].eUnit = FWL_GRIDUNIT_Fixed;
m_Size[FWL_GRIDSIZE_MinHeight].fLength = 0;
m_Size[FWL_GRIDSIZE_MaxHeight].eUnit = FWL_GRIDUNIT_Infinity;
m_Size[FWL_GRIDSIZE_MaxHeight].fLength = 0;
m_Margin[0] = m_Margin[1] = m_Margin[2] = m_Margin[3] = 0;
}
int32_t m_iColumn;
int32_t m_iColumnSpan;
int32_t m_iRow;
int32_t m_iRowSpan;
CFWL_GridLength m_Size[6];
FX_DWORD m_dwMarginFlag;
FX_FLOAT m_Margin[4];
FX_FLOAT m_fActualWidth;
FX_FLOAT m_fActualHeight;
};
class CFWL_GridImp : public CFWL_ContentImp {
public:
CFWL_GridImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
virtual ~CFWL_GridImp();
virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
virtual FX_DWORD GetClassID() const;
virtual FWL_ERR Initialize();
virtual FWL_ERR Finalize();
virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
virtual FWL_ERR SetWidgetRect(const CFX_RectF& rect);
virtual FWL_ERR Update();
virtual FWL_ERR DrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = NULL);
virtual FWL_ERR InsertWidget(IFWL_Widget* pChild, int32_t nIndex = -1);
virtual FWL_ERR RemoveWidget(IFWL_Widget* pWidget);
virtual FWL_HGRIDCOLROW InsertColRow(FX_BOOL bColumn, int32_t nIndex = -1);
virtual int32_t CountColRows(FX_BOOL bColumn);
virtual FWL_HGRIDCOLROW GetColRow(FX_BOOL bColumn, int32_t nIndex);
virtual int32_t GetIndex(FWL_HGRIDCOLROW hColRow);
virtual FX_FLOAT GetSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
virtual FWL_ERR SetSize(FWL_HGRIDCOLROW hColRow,
FX_FLOAT fSize,
FWL_GRIDUNIT eUnit);
FX_FLOAT GetMinSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
FWL_ERR SetMinSize(FWL_HGRIDCOLROW hColRow,
FX_FLOAT fSize,
FWL_GRIDUNIT eUnit);
FX_FLOAT GetMaxSize(FWL_HGRIDCOLROW hColRow, FWL_GRIDUNIT& eUnit);
FWL_ERR SetMaxSize(FWL_HGRIDCOLROW hColRow,
FX_FLOAT fSize,
FWL_GRIDUNIT eUnit);
virtual FX_BOOL DeleteColRow(FWL_HGRIDCOLROW hColRow);
virtual FX_BOOL IsColumn(FWL_HGRIDCOLROW hColRow);
virtual int32_t GetWidgetPos(IFWL_Widget* pWidget, FX_BOOL bColumn);
virtual FWL_ERR SetWidgetPos(IFWL_Widget* pWidget,
int32_t iPos,
FX_BOOL bColumn);
virtual int32_t GetWidgetSpan(IFWL_Widget* pWidget, FX_BOOL bColumn);
virtual FWL_ERR SetWidgetSpan(IFWL_Widget* pWidget,
int32_t iSpan,
FX_BOOL bColumn);
virtual FX_FLOAT GetWidgetSize(IFWL_Widget* pWidget,
FWL_GRIDSIZE eSize,
FWL_GRIDUNIT& eUnit);
virtual FWL_ERR SetWidgetSize(IFWL_Widget* pWidget,
FWL_GRIDSIZE eSize,
FX_FLOAT fSize,
FWL_GRIDUNIT eUit);
virtual FX_BOOL GetWidgetMargin(IFWL_Widget* pWidget,
FWL_GRIDMARGIN eMargin,
FX_FLOAT& fMargin);
virtual FWL_ERR SetWidgetMargin(IFWL_Widget* pWidget,
FWL_GRIDMARGIN eMargin,
FX_FLOAT fMargin);
virtual FWL_ERR RemoveWidgetMargin(IFWL_Widget* pWidget,
FWL_GRIDMARGIN eMargin);
virtual FX_FLOAT GetGridSize(FWL_GRIDSIZE eSize, FWL_GRIDUNIT& eUnit);
virtual FWL_ERR SetGridSize(FWL_GRIDSIZE eSize,
FX_FLOAT fSize,
FWL_GRIDUNIT eUit);
protected:
CFWL_GridWidgetInfo* GetWidgetInfo(IFWL_Widget* pWidget);
void ProcFixedColRow(CFWL_GridColRow* pColRow,
int32_t nIndex,
FX_FLOAT fColRowSize,
FX_BOOL bColumn);
void ProcAutoColRow(CFWL_GridColRow* pColRow,
int32_t nIndex,
FX_BOOL bColumn);
void ProcScaledColRow(CFWL_GridColRow* pColRow,
int32_t nIndex,
FX_FLOAT fColRowSize,
FX_BOOL bColumn);
void CalcWidgetWidth(IFWL_Widget* pWidget,
CFWL_GridWidgetInfo* pInfo,
FX_FLOAT fColunmWidth);
void CalcWidgetHeigt(IFWL_Widget* pWidget,
CFWL_GridWidgetInfo* pInfo,
FX_FLOAT fRowHeigt);
FX_FLOAT CalcAutoColumnWidgetWidth(IFWL_Widget* pWidget,
CFWL_GridWidgetInfo* pInfo);
FX_FLOAT CalcAutoColumnWidgetHeight(IFWL_Widget* pWidget,
CFWL_GridWidgetInfo* pInfo);
FX_FLOAT ProcessColumns(FX_FLOAT fWidth);
FX_FLOAT ProcessRows(FX_FLOAT fHeight);
FX_FLOAT ProcessUnCertainColumns();
FX_FLOAT ProcessUnCertainRows();
FX_BOOL SetColRowActualSize(CFWL_GridColRow* pColRow,
FX_FLOAT fSize,
FX_BOOL bSetBeyond = FALSE);
FX_FLOAT SetWidgetActualWidth(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fWidth);
FX_FLOAT SetWidgetActualHeight(CFWL_GridWidgetInfo* pInfo, FX_FLOAT fHeight);
void SetAllWidgetsRect();
FX_BOOL IsGrid(IFWL_Widget* pWidget);
void SetSpanAutoColRowSize(const CFX_PtrArray& spanAutos,
FX_FLOAT fTotalSize);
void SetSpanScaledColRowSize(const CFX_PtrArray& spanScaleds,
FX_FLOAT fTotalSize,
FX_FLOAT fTotalScaledNum);
void SetScaledColRowsSize(const CFX_PtrArray& spanScaleds,
FX_FLOAT fTotalSize,
FX_FLOAT fTotalScaledNum);
CFX_PtrArray m_Rows;
CFX_PtrArray m_Columns;
CFX_PtrArray m_Widgets;
CFX_MapPtrToPtr m_mapWidgetInfo;
CFWL_GridLength m_Size[6];
friend class CFWL_GridImpDelegate;
};
class CFWL_GridImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_GridImpDelegate(CFWL_GridImp* pOwner);
int32_t OnProcessMessage(CFWL_Message* pMessage) override;
FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
const CFX_Matrix* pMatrix = NULL) override;
protected:
CFWL_GridImp* m_pOwner;
};
#endif // XFA_FWL_CORE_FWL_GRIDIMP_H_
|