source: trunk/Packages/DpiControls/Dpi.Grids.pas

Last change on this file was 468, checked in by chronos, 6 months ago
  • Added: High DPI support integrated into trunk branch. It can be enabled by adding DPI define to compiler parameters for main project and packages.
File size: 6.6 KB
Line 
1unit Dpi.Grids;
2
3interface
4
5uses
6 Classes, SysUtils, Grids, Controls, StdCtrls, Dpi.Controls;
7
8type
9 { TDpiCustomDrawGrid }
10
11 TDpiCustomDrawGrid = class(TWinControl)
12 private
13 NativeCustomDrawGrid: TCustomDrawGrid;
14 function GetEditor: TWinControl;
15 procedure SetEditor(AValue: TWinControl);
16 public
17 function GetNativeCustomDrawGrid: TCustomDrawGrid;
18 constructor Create(TheOwner: TComponent); override;
19 destructor Destroy; override;
20 property Editor: TWinControl read GetEditor write SetEditor;
21 end;
22
23 { TDpiStringGrid }
24
25 TDpiStringGrid = class(TWinControl)
26 private
27 NativeStringGrid: TStringGrid;
28 function DefaultRowHeightIsStored: Boolean;
29 function GetCells(ACol, ARow: Integer): string;
30 function GetColCount: Integer;
31 function GetColumns: TGridColumns;
32 function GetDefRowHeight: Integer;
33 function GetEditor: Controls.TWinControl;
34 function GetFixedCols: Integer;
35 function GetFixedRows: Integer;
36 function GetOptions: TGridOptions;
37 function GetRowCount: Integer;
38 function GetScrollBars: TScrollStyle;
39 function GetSelection: TGridRect;
40 function IsColumnsStored: Boolean;
41 procedure SetCells(ACol, ARow: Integer; AValue: string);
42 procedure SetColCount(AValue: Integer);
43 procedure SetColumns(AValue: TGridColumns);
44 procedure SetDefRowHeight(AValue: Integer);
45 procedure SetEditor(AValue: Controls.TWinControl);
46 procedure SetFixedCols(AValue: Integer);
47 procedure SetFixedRows(AValue: Integer);
48 procedure SetOptions(AValue: TGridOptions);
49 procedure SetRowCount(AValue: Integer);
50 procedure SetScrollBars(AValue: TScrollStyle);
51 procedure SetSelection(AValue: TGridRect);
52 public
53 function GetNativeStringGrid: TStringGrid;
54 function CellRect(ACol, ARow: Integer): TRect;
55 constructor Create(TheOwner: TComponent); override;
56 destructor Destroy; override;
57 property Selection: TGridRect read GetSelection write SetSelection;
58 property Cells[ACol, ARow: Integer]: string read GetCells write SetCells;
59 published
60 property DefaultRowHeight: Integer read GetDefRowHeight write SetDefRowHeight stored DefaultRowHeightIsStored;
61 property ScrollBars: TScrollStyle read GetScrollBars write SetScrollBars default ssAutoBoth;
62 property FixedCols: Integer read GetFixedCols write SetFixedCols default 1;
63 property FixedRows: Integer read GetFixedRows write SetFixedRows default 1;
64 property RowCount: Integer read GetRowCount write SetRowCount default 5;
65 property ColCount: Integer read GetColCount write SetColCount default 5;
66 property Options: TGridOptions read GetOptions write SetOptions default DefaultGridOptions;
67 property Columns: TGridColumns read GetColumns write SetColumns stored IsColumnsStored;
68 property Editor: Controls.TWinControl read GetEditor write SetEditor;
69 end;
70
71
72implementation
73
74{ TDpiStringGrid }
75
76function TDpiStringGrid.DefaultRowHeightIsStored: Boolean;
77begin
78 Result := GetDefRowHeight >= 0;
79end;
80
81function TDpiStringGrid.GetCells(ACol, ARow: Integer): string;
82begin
83 Result := GetNativeStringGrid.Cells[ACol, ARow];
84end;
85
86function TDpiStringGrid.GetColCount: Integer;
87begin
88 Result := GetNativeStringGrid.ColCount;
89end;
90
91function TDpiStringGrid.GetColumns: TGridColumns;
92begin
93 Result := GetNativeStringGrid.Columns;
94end;
95
96function TDpiStringGrid.GetDefRowHeight: Integer;
97begin
98 Result := GetNativeStringGrid.DefaultRowHeight;
99end;
100
101function TDpiStringGrid.GetEditor: Controls.TWinControl;
102begin
103 Result := GetNativeStringGrid.Editor;
104end;
105
106function TDpiStringGrid.GetFixedCols: Integer;
107begin
108 Result := GetNativeStringGrid.FixedCols;
109end;
110
111function TDpiStringGrid.GetFixedRows: Integer;
112begin
113 Result := GetNativeStringGrid.FixedRows;
114end;
115
116function TDpiStringGrid.GetOptions: TGridOptions;
117begin
118 Result := GetNativeStringGrid.Options;
119end;
120
121function TDpiStringGrid.GetRowCount: Integer;
122begin
123 Result := GetNativeStringGrid.RowCount;
124end;
125
126function TDpiStringGrid.GetScrollBars: TScrollStyle;
127begin
128 Result := GetNativeStringGrid.ScrollBars;
129end;
130
131function TDpiStringGrid.GetSelection: TGridRect;
132begin
133 Result := GetNativeStringGrid.Selection;
134end;
135
136function TDpiStringGrid.IsColumnsStored: Boolean;
137begin
138 Result := GetNativeStringGrid.Columns.Enabled;
139end;
140
141procedure TDpiStringGrid.SetCells(ACol, ARow: Integer; AValue: string);
142begin
143 GetNativeStringGrid.Cells[ACol, ARow] := AValue;
144end;
145
146procedure TDpiStringGrid.SetColCount(AValue: Integer);
147begin
148 GetNativeStringGrid.ColCount := AValue;
149end;
150
151procedure TDpiStringGrid.SetColumns(AValue: TGridColumns);
152begin
153 GetNativeStringGrid.Columns := AValue;
154end;
155
156procedure TDpiStringGrid.SetDefRowHeight(AValue: Integer);
157begin
158 GetNativeStringGrid.DefaultRowHeight := AValue;
159end;
160
161procedure TDpiStringGrid.SetEditor(AValue: Controls.TWinControl);
162begin
163 GetNativeStringGrid.Editor := AValue;
164end;
165
166procedure TDpiStringGrid.SetFixedCols(AValue: Integer);
167begin
168 GetNativeStringGrid.FixedCols := AValue;
169end;
170
171procedure TDpiStringGrid.SetFixedRows(AValue: Integer);
172begin
173 GetNativeStringGrid.FixedRows := AValue;
174end;
175
176procedure TDpiStringGrid.SetOptions(AValue: TGridOptions);
177begin
178 GetNativeStringGrid.Options := AValue;
179end;
180
181procedure TDpiStringGrid.SetRowCount(AValue: Integer);
182begin
183 GetNativeStringGrid.RowCount := AValue;
184end;
185
186procedure TDpiStringGrid.SetScrollBars(AValue: TScrollStyle);
187begin
188 GetNativeStringGrid.ScrollBars := AValue;
189end;
190
191procedure TDpiStringGrid.SetSelection(AValue: TGridRect);
192begin
193 GetNativeStringGrid.Selection := AValue;
194end;
195
196function TDpiStringGrid.GetNativeStringGrid: TStringGrid;
197begin
198 if not Assigned(NativeStringGrid) then NativeStringGrid := TStringGrid.Create(nil);
199 Result := NativeStringGrid;
200end;
201
202function TDpiStringGrid.CellRect(ACol, ARow: Integer): TRect;
203begin
204 Result := GetNativeStringGrid.CellRect(ACol, ARow);
205end;
206
207constructor TDpiStringGrid.Create(TheOwner: TComponent);
208begin
209 inherited Create(TheOwner);
210end;
211
212destructor TDpiStringGrid.Destroy;
213begin
214 FreeAndNil(NativeStringGrid);
215 inherited;
216end;
217
218{ TDpiCustomDrawGrid }
219
220function TDpiCustomDrawGrid.GetEditor: TWinControl;
221begin
222 //Result := GetNativeCustomDrawGrid.Editor;
223end;
224
225procedure TDpiCustomDrawGrid.SetEditor(AValue: TWinControl);
226begin
227 //GetNativeCustomDrawGrid.Editor := AValue
228end;
229
230function TDpiCustomDrawGrid.GetNativeCustomDrawGrid: TCustomDrawGrid;
231begin
232 if not Assigned(NativeCustomDrawGrid) then NativeCustomDrawGrid := TCustomDrawGrid.Create(nil);
233 Result := NativeCustomDrawGrid;
234end;
235
236constructor TDpiCustomDrawGrid.Create(TheOwner: TComponent);
237begin
238 inherited Create(TheOwner);
239end;
240
241destructor TDpiCustomDrawGrid.Destroy;
242begin
243 FreeAndNil(NativeCustomDrawGrid);
244 inherited;
245end;
246
247
248
249end.
250
Note: See TracBrowser for help on using the repository browser.