| 1 | unit uwin7toolbar;
|
|---|
| 2 |
|
|---|
| 3 | {$mode objfpc}{$H+}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Forms, SysUtils, StdCtrls, Spin, BGRAButton, BGRASamples, BGRAWin7ToolBar,
|
|---|
| 9 | Classes, types, Controls, BGRABitmap, BGRABitmapTypes, Graphics, LCLType;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 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 |
|
|---|
| 48 | var
|
|---|
| 49 | frmWin7ToolBar: TfrmWin7ToolBar;
|
|---|
| 50 |
|
|---|
| 51 | implementation
|
|---|
| 52 |
|
|---|
| 53 | {$R *.lfm}
|
|---|
| 54 |
|
|---|
| 55 | { TfrmWin7ToolBar }
|
|---|
| 56 |
|
|---|
| 57 | procedure TfrmWin7ToolBar.BGRAButton2Click(Sender: TObject);
|
|---|
| 58 | begin
|
|---|
| 59 | // Switch align clockwise
|
|---|
| 60 | BGRAWin7ToolBar1.SwitchAlign;
|
|---|
| 61 | end;
|
|---|
| 62 |
|
|---|
| 63 | procedure TfrmWin7ToolBar.BGRAButton1Click(Sender: TObject);
|
|---|
| 64 | begin
|
|---|
| 65 | if BGRAButton1.Caption = 'glyph' then
|
|---|
| 66 | BGRAButton1.Caption := ''
|
|---|
| 67 | else
|
|---|
| 68 | BGRAButton1.Caption := 'glyph';
|
|---|
| 69 | end;
|
|---|
| 70 |
|
|---|
| 71 | procedure TfrmWin7ToolBar.BGRAButton3Click(Sender: TObject);
|
|---|
| 72 | begin
|
|---|
| 73 | BGRAButton3.Down := not BGRAButton3.Down;
|
|---|
| 74 | end;
|
|---|
| 75 |
|
|---|
| 76 | procedure TfrmWin7ToolBar.BGRAButton5Click(Sender: TObject);
|
|---|
| 77 | begin
|
|---|
| 78 | BGRAButton5.Enabled := False;
|
|---|
| 79 | BGRAButton5.Caption := 'not enabled';
|
|---|
| 80 | end;
|
|---|
| 81 |
|
|---|
| 82 | procedure TfrmWin7ToolBar.BGRAButton6Click(Sender: TObject);
|
|---|
| 83 | begin
|
|---|
| 84 | BGRAButton6.StaticButton := not BGRAButton6.StaticButton;
|
|---|
| 85 | end;
|
|---|
| 86 |
|
|---|
| 87 | procedure TfrmWin7ToolBar.BGRAButton7Click(Sender: TObject);
|
|---|
| 88 | begin
|
|---|
| 89 | if BGRAButton7.Style = bbtDropDown then
|
|---|
| 90 | BGRAButton7.Style := bbtButton
|
|---|
| 91 | else
|
|---|
| 92 | BGRAButton7.Style := bbtDropDown;
|
|---|
| 93 | end;
|
|---|
| 94 |
|
|---|
| 95 | procedure TfrmWin7ToolBar.BGRAButton8Click(Sender: TObject);
|
|---|
| 96 | begin
|
|---|
| 97 | BGRAButton3.Down := True;
|
|---|
| 98 | //BGRAButton4.Caption := '';
|
|---|
| 99 | BGRAButton5.Enabled := True;
|
|---|
| 100 | BGRAButton5.Caption := 'enabled';
|
|---|
| 101 | BGRAButton6.StaticButton := True;
|
|---|
| 102 | BGRAButton7.Style := bbtDropDown;
|
|---|
| 103 | end;
|
|---|
| 104 |
|
|---|
| 105 | procedure TfrmWin7ToolBar.ComboBox1DrawItem(Control: TWinControl;
|
|---|
| 106 | Index: Integer; ARect: TRect; State: TOwnerDrawState);
|
|---|
| 107 | var
|
|---|
| 108 | temp: TBGRABitmap;
|
|---|
| 109 | str: string;
|
|---|
| 110 | begin
|
|---|
| 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;
|
|---|
| 129 | end;
|
|---|
| 130 |
|
|---|
| 131 | procedure TfrmWin7ToolBar.FormClose(Sender: TObject;
|
|---|
| 132 | var CloseAction: TCloseAction);
|
|---|
| 133 | begin
|
|---|
| 134 | SpinEdit1.Value := 8;
|
|---|
| 135 | end;
|
|---|
| 136 |
|
|---|
| 137 | procedure TfrmWin7ToolBar.FormCreate(Sender: TObject);
|
|---|
| 138 | var
|
|---|
| 139 | ss: TBGRASampleStyle;
|
|---|
| 140 | begin
|
|---|
| 141 | for ss := low(TBGRASampleStyle) to high(TBGRASampleStyle) do
|
|---|
| 142 | ListBox1.Items.Add(TBGRASampleStyleStr[ss]);
|
|---|
| 143 |
|
|---|
| 144 | SpinEdit1.Value := BGRAButton2.ArrowSize;
|
|---|
| 145 | end;
|
|---|
| 146 |
|
|---|
| 147 | procedure TfrmWin7ToolBar.ListBox1DrawItem(Control: TWinControl;
|
|---|
| 148 | Index: Integer; ARect: TRect; State: TOwnerDrawState);
|
|---|
| 149 | var
|
|---|
| 150 | temp: TBGRABitmap;
|
|---|
| 151 | str: string;
|
|---|
| 152 | begin
|
|---|
| 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;
|
|---|
| 171 | end;
|
|---|
| 172 |
|
|---|
| 173 | procedure TfrmWin7ToolBar.ListBox1SelectionChange(Sender: TObject; User: boolean
|
|---|
| 174 | );
|
|---|
| 175 | begin
|
|---|
| 176 | BGRAWin7ToolBar1.Style := StrToTBGRASampleStyle(ListBox1.GetSelectedText);
|
|---|
| 177 | end;
|
|---|
| 178 |
|
|---|
| 179 | procedure TfrmWin7ToolBar.SpinEdit1Change(Sender: TObject);
|
|---|
| 180 | var
|
|---|
| 181 | i: integer;
|
|---|
| 182 | begin
|
|---|
| 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;
|
|---|
| 197 | end;
|
|---|
| 198 |
|
|---|
| 199 | end.
|
|---|