source: trunk/Packages/bgracontrols/testbgracontrols/uwin7toolbar.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 5.4 KB
Line 
1unit uwin7toolbar;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Forms, SysUtils, StdCtrls, Spin, BGRAButton, BGRASamples, BGRAWin7ToolBar,
9 Classes, types, Controls, BGRABitmap, BGRABitmapTypes, Graphics, LCLType;
10
11type
12
13 { TfrmWin7ToolBar }
14
15 TfrmWin7ToolBar = class(TForm)
16 BGRAButton1: TBGRAButton;
17 BGRAButton2: TBGRAButton;
18 BGRAButton3: TBGRAButton;
19 BGRAButton5: TBGRAButton;
20 BGRAButton6: TBGRAButton;
21 BGRAButton7: TBGRAButton;
22 BGRAButton8: TBGRAButton;
23 BGRAWin7ToolBar1: TBGRAWin7ToolBar;
24 ComboBox1: TComboBox;
25 ListBox1: TListBox;
26 SpinEdit1: TSpinEdit;
27 procedure BGRAButton1Click(Sender: TObject);
28 procedure BGRAButton2Click(Sender: TObject);
29 procedure BGRAButton3Click(Sender: TObject);
30 procedure BGRAButton5Click(Sender: TObject);
31 procedure BGRAButton6Click(Sender: TObject);
32 procedure BGRAButton7Click(Sender: TObject);
33 procedure BGRAButton8Click(Sender: TObject);
34 procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
35 ARect: TRect; State: TOwnerDrawState);
36 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
37 procedure FormCreate(Sender: TObject);
38 procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
39 ARect: TRect; State: TOwnerDrawState);
40 procedure ListBox1SelectionChange(Sender: TObject; User: boolean);
41 procedure SpinEdit1Change(Sender: TObject);
42 private
43 { private declarations }
44 public
45 { public declarations }
46 end;
47
48var
49 frmWin7ToolBar: TfrmWin7ToolBar;
50
51implementation
52
53{$R *.lfm}
54
55{ TfrmWin7ToolBar }
56
57procedure TfrmWin7ToolBar.BGRAButton2Click(Sender: TObject);
58begin
59 // Switch align clockwise
60 BGRAWin7ToolBar1.SwitchAlign;
61end;
62
63procedure TfrmWin7ToolBar.BGRAButton1Click(Sender: TObject);
64begin
65 if BGRAButton1.Caption = 'glyph' then
66 BGRAButton1.Caption := ''
67 else
68 BGRAButton1.Caption := 'glyph';
69end;
70
71procedure TfrmWin7ToolBar.BGRAButton3Click(Sender: TObject);
72begin
73 BGRAButton3.Down := not BGRAButton3.Down;
74end;
75
76procedure TfrmWin7ToolBar.BGRAButton5Click(Sender: TObject);
77begin
78 BGRAButton5.Enabled := False;
79 BGRAButton5.Caption := 'not enabled';
80end;
81
82procedure TfrmWin7ToolBar.BGRAButton6Click(Sender: TObject);
83begin
84 BGRAButton6.StaticButton := not BGRAButton6.StaticButton;
85end;
86
87procedure TfrmWin7ToolBar.BGRAButton7Click(Sender: TObject);
88begin
89 if BGRAButton7.Style = bbtDropDown then
90 BGRAButton7.Style := bbtButton
91 else
92 BGRAButton7.Style := bbtDropDown;
93end;
94
95procedure TfrmWin7ToolBar.BGRAButton8Click(Sender: TObject);
96begin
97 BGRAButton3.Down := True;
98 //BGRAButton4.Caption := '';
99 BGRAButton5.Enabled := True;
100 BGRAButton5.Caption := 'enabled';
101 BGRAButton6.StaticButton := True;
102 BGRAButton7.Style := bbtDropDown;
103end;
104
105procedure TfrmWin7ToolBar.ComboBox1DrawItem(Control: TWinControl;
106 Index: Integer; ARect: TRect; State: TOwnerDrawState);
107var
108 temp: TBGRABitmap;
109 str: string;
110begin
111 str := TComboBox(Control).Items[Index];
112
113 temp := TBGRABitmap.Create(ARect.Right, TComboBox(Control).ItemHeight,
114 BGRAPixelTransparent);
115
116 if odSelected in State then
117 DrawWin7ToolBar(temp, alNone)
118 else
119 DrawIOSBackground(temp);
120
121 temp.FontHeight := Trunc(TComboBox(Control).ItemHeight div 2);
122 temp.FontQuality := fqFineClearTypeRGB;
123
124 if str <> '' then
125 temp.TextOut(10, Trunc((TComboBox(Control).ItemHeight - temp.FontFullHeight) div 2),
126 str, BGRABlack);
127 temp.Draw(TComboBox(Control).Canvas, ARect, False);
128 temp.Free;
129end;
130
131procedure TfrmWin7ToolBar.FormClose(Sender: TObject;
132 var CloseAction: TCloseAction);
133begin
134 SpinEdit1.Value := 8;
135end;
136
137procedure TfrmWin7ToolBar.FormCreate(Sender: TObject);
138var
139 ss: TBGRASampleStyle;
140begin
141 for ss := low(TBGRASampleStyle) to high(TBGRASampleStyle) do
142 ListBox1.Items.Add(TBGRASampleStyleStr[ss]);
143
144 SpinEdit1.Value := BGRAButton2.ArrowSize;
145end;
146
147procedure TfrmWin7ToolBar.ListBox1DrawItem(Control: TWinControl;
148 Index: Integer; ARect: TRect; State: TOwnerDrawState);
149var
150 temp: TBGRABitmap;
151 str: string;
152begin
153 str := TListBox(Control).Items[Index];
154
155 temp := TBGRABitmap.Create(ARect.Right, TListBox(Control).ItemHeight,
156 BGRAPixelTransparent);
157
158 if odSelected in State then
159 DrawWin7ToolBar(temp, alNone)
160 else
161 DrawIOSBackground(temp);
162
163 temp.FontHeight := Trunc(TListBox(Control).ItemHeight div 2);
164 temp.FontQuality := fqFineClearTypeRGB;
165
166 if str <> '' then
167 temp.TextOut(10, Trunc((TListBox(Control).ItemHeight - temp.FontFullHeight) div 2),
168 str, BGRABlack);
169 temp.Draw(TListBox(Control).Canvas, ARect, False);
170 temp.Free;
171end;
172
173procedure TfrmWin7ToolBar.ListBox1SelectionChange(Sender: TObject; User: boolean
174 );
175begin
176 BGRAWin7ToolBar1.Style := StrToTBGRASampleStyle(ListBox1.GetSelectedText);
177end;
178
179procedure TfrmWin7ToolBar.SpinEdit1Change(Sender: TObject);
180var
181 i: integer;
182begin
183 with BGRAWin7ToolBar1 do
184 begin
185 ChildSizing.LeftRightSpacing := Trunc(SpinEdit1.Value / 2);
186 ChildSizing.TopBottomSpacing := Trunc(SpinEdit1.Value / 2);
187 end;
188
189 // This Changes the Size Variables (ArrowSize, ArrowSpace, AutoSizeExtraVertical, AutoSizeExtraHorizontal).
190 // In Windows by default those variables are affected by the DPI (Screen.PixelsPerInch)
191 for i:=0 to BGRAWin7ToolBar1.ControlCount - 1 do
192 begin
193 if BGRAWin7ToolBar1.Controls[i] is TBGRAButton then
194 with BGRAWin7ToolBar1.Controls[i] as TBGRAButton do
195 SetSizeVariables(SpinEdit1.Value, SpinEdit1.Value*2, SpinEdit1.Value, SpinEdit1.Value*3);
196 end;
197end;
198
199end.
Note: See TracBrowser for help on using the repository browser.