source: trunk/Packages/bgracontrols/customdrawn_win7/utest.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 6.7 KB
Line 
1unit utest;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Forms, SysUtils,
9 { Custom Drawn }
10 customdrawncontrols, customdrawndrawers, StdCtrls,
11 { BGRABitmap }
12 BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes, BGRASamples,
13 { Custom Drawn + BGRABitmap }
14 customdrawn_windows7;
15
16type
17
18 { TfrmTest }
19
20 TfrmTest = class(TForm)
21 BGRAVirtualScreen1: TBGRAVirtualScreen;
22 cbd_a_c: TCDCheckBox;
23 cbd_a_g: TCDCheckBox;
24 cbd_a_u: TCDCheckBox;
25 cbd_c: TCDCheckBox;
26 cbd_g: TCDCheckBox;
27 cbd_u: TCDCheckBox;
28 cb_a_c: TCDCheckBox;
29 cb_a_g: TCDCheckBox;
30 cb_a_u: TCDCheckBox;
31 cb_c: TCDCheckBox;
32 cb_g: TCDCheckBox;
33 cb_u: TCDCheckBox;
34 CDButton1: TCDButton;
35 CDButton10: TCDButton;
36 CDButton2: TCDButton;
37 CDButton3: TCDButton;
38 CDButton4: TCDButton;
39 CDButton5: TCDButton;
40 CDButton6: TCDButton;
41 CDButton7: TCDButton;
42 CDButton8: TCDButton;
43 CDButton9: TCDButton;
44 CDComboBox1: TCDComboBox;
45 CDEdit1: TCDEdit;
46 CDGroupBox1: TCDGroupBox;
47 CDGroupBox2: TCDGroupBox;
48 CDGroupBox3: TCDGroupBox;
49 CDGroupBox4: TCDGroupBox;
50 CDListView1: TCDListView;
51 CDPageControl1: TCDPageControl;
52 CDPageControl2: TCDPageControl;
53 CDProgressBar1: TCDProgressBar;
54 CDProgressBar2: TCDProgressBar;
55 CDProgressBar3: TCDProgressBar;
56 CDProgressBar4: TCDProgressBar;
57 CDRadioButton1: TCDRadioButton;
58 CDRadioButton2: TCDRadioButton;
59 CDRadioButton3: TCDRadioButton;
60 CDRadioButton4: TCDRadioButton;
61 CDScrollBar1: TCDScrollBar;
62 CDScrollBar2: TCDScrollBar;
63 CDSpinEdit1: TCDSpinEdit;
64 CDStaticText1: TCDStaticText;
65 CDTabSheet1: TCDTabSheet;
66 CDTabSheet2: TCDTabSheet;
67 CDTrackBar1: TCDTrackBar;
68 CDTrackBar2: TCDTrackBar;
69 CDTrackBar3: TCDTrackBar;
70 CDTrackBar4: TCDTrackBar;
71 procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
72 procedure CDButton10Click(Sender: TObject);
73 procedure CDButton1Click(Sender: TObject);
74 procedure CDButton2Click(Sender: TObject);
75 procedure CDButton4Click(Sender: TObject);
76 procedure CDButton9Click(Sender: TObject);
77 procedure CDScrollBar1Change(Sender: TObject);
78 procedure CDTrackBar1Change(Sender: TObject);
79 procedure FormCreate(Sender: TObject);
80 private
81 { private declarations }
82 public
83 { public declarations }
84 end;
85
86var
87 frmTest: TfrmTest;
88
89implementation
90
91{$R *.lfm}
92
93{ TfrmTest }
94
95procedure TfrmTest.FormCreate(Sender: TObject);
96begin
97 { This code set the dsWindows7 style
98 that is registered in the unit customdrawn_windows7 }
99 DefaultStyle := dsWindows7;
100
101 { Set the form color }
102 Color := WIN7_FORM_COLOR;
103 BGRAVirtualScreen1.Color := WIN7_FORM_COLOR;
104
105end;
106
107{ The code below is how to configure this drawer }
108
109procedure TfrmTest.CDButton1Click(Sender: TObject);
110begin
111 { This code is for changing DPI }
112 if win7.dpi = 96 then
113 win7.dpi := 120
114 else if win7.dpi = 120 then
115 win7.dpi := 144
116 else if win7.dpi = 144 then
117 win7.dpi := 96
118 else
119 win7.dpi := 96;
120
121 { This code is for scaling extra1 buttons }
122 // extra1 'arrowleft' in caption
123 CDButton5.Width := win7.ArrowLeft.SliceScalingArray[0].BitmapWidth;
124 CDButton5.Height := win7.ArrowLeft.SliceScalingArray[0].BitmapHeight;
125 // extra1 'arrowright' in caption
126 CDButton6.Width := win7.ArrowRight.SliceScalingArray[0].BitmapWidth;
127 CDButton6.Height := win7.ArrowRight.SliceScalingArray[0].BitmapHeight;
128 // extra1 'arrow' in caption
129 CDButton7.Width := win7.Arrow.SliceScalingArray[0].BitmapWidth;
130 CDButton7.Height := win7.Arrow.SliceScalingArray[0].BitmapHeight;
131 // extra1 'closebutton' in caption
132 CDButton8.Width := win7.CloseButton.SliceScalingArray[0].BitmapWidth;
133 CDButton8.Height := win7.CloseButton.SliceScalingArray[0].BitmapHeight;
134
135 { Do changes visible }
136 Invalidate;
137end;
138
139procedure TfrmTest.CDButton2Click(Sender: TObject);
140begin
141 { This code is for using the extra tickmark }
142 win7.tickmark := not win7.tickmark;
143
144 { Do changes visible }
145 Invalidate;
146end;
147
148procedure TfrmTest.CDButton4Click(Sender: TObject);
149begin
150 { This code is for changing the folder }
151 if win7.folder = 'aero' + pathdelim then
152 win7.folder := 'aerolite' + pathdelim
153 else if win7.folder = 'aerolite' + pathdelim then
154 win7.folder := 'luna' + pathdelim
155 else if win7.folder = 'luna' + pathdelim then
156 win7.folder := 'extra' + pathdelim
157 else if win7.folder = 'extra' + pathdelim then
158 win7.folder := 'aero' + pathdelim
159 else
160 win7.folder := 'aero' + pathdelim;
161
162 { Do changes visible }
163 Invalidate;
164end;
165
166procedure TfrmTest.CDButton9Click(Sender: TObject);
167begin
168 { This show / hide debug lines }
169 win7.debug := not win7.debug;
170
171 { Do changes visible }
172 Invalidate;
173end;
174
175{ The code below is just for testing purposes }
176
177procedure TfrmTest.CDButton10Click(Sender: TObject);
178begin
179 CDButton5.Enabled := not CDButton5.Enabled;
180 CDButton6.Enabled := not CDButton6.Enabled;
181 CDButton7.Enabled := not CDButton7.Enabled;
182 CDButton8.Enabled := not CDButton8.Enabled;
183 CDScrollBar1.Enabled := not CDScrollBar1.Enabled;
184 CDScrollBar2.Enabled := not CDScrollBar2.Enabled;
185 CDComboBox1.Enabled := not CDComboBox1.Enabled;
186 CDStaticText1.Enabled := not CDStaticText1.Enabled;
187 CDSpinEdit1.Enabled := not CDSpinEdit1.Enabled;
188 CDListView1.Enabled := not CDListView1.Enabled;
189 CDButton3.Enabled := not CDButton3.Enabled;
190 CDEdit1.Enabled := not CDEdit1.Enabled;
191 CDPageControl1.Enabled := not CDPageControl1.Enabled;
192 CDPageControl2.Enabled := not CDPageControl2.Enabled;
193end;
194
195procedure TfrmTest.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
196
197 procedure DrawTileBackground(ABitmap: TBGRABitmap; Multiply: integer);
198 var
199 temp: TBGRABitmap;
200 begin
201 temp := TBGRABitmap.Create(2, 2, BGRAWhite);
202 temp.SetPixel(0, 1, BGRA(220, 220, 220));
203 temp.SetPixel(1, 0, BGRA(220, 220, 220));
204 BGRAReplace(temp, temp.Resample(2 * Multiply, 2 * Multiply, rmSimpleStretch));
205 ABitmap.Fill(temp, dmSet);
206 temp.Free;
207 end;
208
209begin
210 //DrawTileBackground(Bitmap, 8);
211 //DrawIOSBackground(Bitmap);
212end;
213
214procedure TfrmTest.CDScrollBar1Change(Sender: TObject);
215begin
216 CDProgressBar1.Position := TCDScrollBar(Sender).Position;
217 CDProgressBar2.Position := TCDScrollBar(Sender).Position;
218 CDProgressBar3.Position := TCDScrollBar(Sender).Position;
219 CDProgressBar4.Position := TCDScrollBar(Sender).Position;
220end;
221
222procedure TfrmTest.CDTrackBar1Change(Sender: TObject);
223begin
224 CDProgressBar1.Position := TCDTrackBar(Sender).Position;
225 CDProgressBar2.Position := TCDTrackBar(Sender).Position;
226 CDProgressBar3.Position := TCDTrackBar(Sender).Position;
227 CDProgressBar4.Position := TCDTrackBar(Sender).Position;
228 CDTrackBar1.Position := CDProgressBar1.Position;
229 CDTrackBar2.Position := CDProgressBar1.Position;
230 CDTrackBar3.Position := CDProgressBar1.Position;
231 CDTrackBar4.Position := CDProgressBar1.Position;
232end;
233
234end.
235
236
Note: See TracBrowser for help on using the repository browser.