| 1 | unit BGRAWin7ToolBar;
|
|---|
| 2 |
|
|---|
| 3 | {$mode objfpc}{$H+}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Controls, Graphics,
|
|---|
| 9 | BGRAVirtualScreen, BGRASamples, LResources, Dialogs, Forms;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TCustomBGRAWin7ToolBar }
|
|---|
| 14 |
|
|---|
| 15 | TCustomBGRAWin7ToolBar = class(TCustomBGRAVirtualScreen)
|
|---|
| 16 | private
|
|---|
| 17 | procedure SetFStyle(AValue: TBGRASampleStyle);
|
|---|
| 18 | protected
|
|---|
| 19 | FSmooth: boolean;
|
|---|
| 20 | FStyle: TBGRASampleStyle;
|
|---|
| 21 | procedure RedrawBitmapContent; override;
|
|---|
| 22 | public
|
|---|
| 23 | procedure StyleButtons;
|
|---|
| 24 | procedure SwitchAlign;
|
|---|
| 25 | constructor Create(TheOwner: TComponent); override;
|
|---|
| 26 | public
|
|---|
| 27 | property Style: TBGRASampleStyle Read FStyle Write SetFStyle;
|
|---|
| 28 | end;
|
|---|
| 29 |
|
|---|
| 30 | TBGRAWin7ToolBar = class(TCustomBGRAWin7ToolBar)
|
|---|
| 31 | published
|
|---|
| 32 | property Style;
|
|---|
| 33 | // TBGRAVirtualScreen
|
|---|
| 34 | property OnRedraw;
|
|---|
| 35 | property Bitmap;
|
|---|
| 36 | // TPanel
|
|---|
| 37 | property Align;
|
|---|
| 38 | //property Alignment;
|
|---|
| 39 | property Anchors;
|
|---|
| 40 | property AutoSize;
|
|---|
| 41 | property BorderSpacing;
|
|---|
| 42 | //property BevelInner;
|
|---|
| 43 | //property BevelOuter;
|
|---|
| 44 | //property BevelWidth;
|
|---|
| 45 | property BidiMode;
|
|---|
| 46 | property BorderWidth;
|
|---|
| 47 | property BorderStyle;
|
|---|
| 48 | property Caption;
|
|---|
| 49 | //property ChildSizing;
|
|---|
| 50 | property ClientHeight;
|
|---|
| 51 | property ClientWidth;
|
|---|
| 52 | //property Color;
|
|---|
| 53 | property Constraints;
|
|---|
| 54 | property DockSite;
|
|---|
| 55 | property DragCursor;
|
|---|
| 56 | property DragKind;
|
|---|
| 57 | property DragMode;
|
|---|
| 58 | property Enabled;
|
|---|
| 59 | //property Font;
|
|---|
| 60 | property FullRepaint;
|
|---|
| 61 | property ParentBidiMode;
|
|---|
| 62 | //property ParentColor;
|
|---|
| 63 | //property ParentFont;
|
|---|
| 64 | property ParentShowHint;
|
|---|
| 65 | property PopupMenu;
|
|---|
| 66 | property ShowHint;
|
|---|
| 67 | property TabOrder;
|
|---|
| 68 | property TabStop;
|
|---|
| 69 | property UseDockManager default True;
|
|---|
| 70 | property Visible;
|
|---|
| 71 | property OnClick;
|
|---|
| 72 | property OnContextPopup;
|
|---|
| 73 | property OnDockDrop;
|
|---|
| 74 | property OnDockOver;
|
|---|
| 75 | property OnDblClick;
|
|---|
| 76 | property OnDragDrop;
|
|---|
| 77 | property OnDragOver;
|
|---|
| 78 | property OnEndDock;
|
|---|
| 79 | property OnEndDrag;
|
|---|
| 80 | property OnEnter;
|
|---|
| 81 | property OnExit;
|
|---|
| 82 | property OnGetSiteInfo;
|
|---|
| 83 | property OnGetDockCaption;
|
|---|
| 84 | property OnMouseDown;
|
|---|
| 85 | property OnMouseEnter;
|
|---|
| 86 | property OnMouseLeave;
|
|---|
| 87 | property OnMouseMove;
|
|---|
| 88 | property OnMouseUp;
|
|---|
| 89 | property OnResize;
|
|---|
| 90 | property OnStartDock;
|
|---|
| 91 | property OnStartDrag;
|
|---|
| 92 | property OnUnDock;
|
|---|
| 93 | end;
|
|---|
| 94 |
|
|---|
| 95 | procedure Register;
|
|---|
| 96 |
|
|---|
| 97 | implementation
|
|---|
| 98 |
|
|---|
| 99 | procedure Register;
|
|---|
| 100 | begin
|
|---|
| 101 | {$I bgrawin7toolbar_icon.lrs}
|
|---|
| 102 | RegisterComponents('BGRA Controls', [TBGRAWin7ToolBar]);
|
|---|
| 103 | end;
|
|---|
| 104 |
|
|---|
| 105 | { TBGRAWin7ToolBar }
|
|---|
| 106 |
|
|---|
| 107 | procedure TCustomBGRAWin7ToolBar.SetFStyle(AValue: TBGRASampleStyle);
|
|---|
| 108 | begin
|
|---|
| 109 | if FStyle = AValue then
|
|---|
| 110 | Exit;
|
|---|
| 111 | FStyle := AValue;
|
|---|
| 112 |
|
|---|
| 113 | StyleButtons;
|
|---|
| 114 |
|
|---|
| 115 | RedrawBitmap;
|
|---|
| 116 | end;
|
|---|
| 117 |
|
|---|
| 118 | procedure TCustomBGRAWin7ToolBar.RedrawBitmapContent;
|
|---|
| 119 | begin
|
|---|
| 120 | if (Bitmap <> nil) and (Bitmap.NbPixels <> 0) then
|
|---|
| 121 | begin
|
|---|
| 122 |
|
|---|
| 123 | case Style of
|
|---|
| 124 | ssWin7ToolBar: DrawWin7ToolBar(Bitmap, Align);
|
|---|
| 125 | ssWin7ToolBarSmooth: DrawWin7ToolBar(Bitmap, Align, True);
|
|---|
| 126 | ssFlashPlayer: DrawFlashPlayerButtonPanel(Bitmap);
|
|---|
| 127 | ssiOSBar: DrawiOSBar(Bitmap);
|
|---|
| 128 | ssiOSToolBar: DrawiOSToolBar(Bitmap, False);
|
|---|
| 129 | ssiOSBackground: DrawiOSBackground(Bitmap);
|
|---|
| 130 | //ssFacebookBlue: DrawFacebookButton(Bitmap, ColorToBGRA(fbBlue), ColorToBGRA(ColorToRGB(Parent.Color), 255), False);
|
|---|
| 131 | //ssFacebookGreen: DrawFacebookButton(Bitmap, ColorToBGRA(fbGreen), ColorToBGRA(ColorToRGB(Parent.Color), 255), False);
|
|---|
| 132 | //ssFacebookGray: DrawFacebookButton(Bitmap, ColorToBGRA(fbGray), ColorToBGRA(ColorToRGB(Parent.Color), 255), False);
|
|---|
| 133 | ssBlack: Bitmap.Fill(BGRA(23, 23, 23, 255));
|
|---|
| 134 | ssSilverSquared: Bitmap.Fill(BGRA(223, 226, 230, 255));
|
|---|
| 135 | ssSilver, ssGreen, ssBlue: DrawSilverToolBar(Bitmap);
|
|---|
| 136 | else
|
|---|
| 137 | DrawWin7ToolBar(Bitmap, Align); // ToDO: add a toolbar for each style
|
|---|
| 138 | end;
|
|---|
| 139 |
|
|---|
| 140 | if Assigned(OnRedraw) then
|
|---|
| 141 | OnRedraw(self, Bitmap);
|
|---|
| 142 | end;
|
|---|
| 143 | end;
|
|---|
| 144 |
|
|---|
| 145 | procedure TCustomBGRAWin7ToolBar.StyleButtons;
|
|---|
| 146 | begin
|
|---|
| 147 | StyleButtonsSample(Self, Style);
|
|---|
| 148 | end;
|
|---|
| 149 |
|
|---|
| 150 | procedure TCustomBGRAWin7ToolBar.SwitchAlign;
|
|---|
| 151 | begin
|
|---|
| 152 | case Align of
|
|---|
| 153 | alCustom, alNone, alClient, alLeft: Align := alTop;
|
|---|
| 154 | alTop: Align := alRight;
|
|---|
| 155 | alRight: Align := alBottom;
|
|---|
| 156 | alBottom: Align := alLeft;
|
|---|
| 157 | end;
|
|---|
| 158 |
|
|---|
| 159 | case Align of
|
|---|
| 160 | // if horizontal
|
|---|
| 161 | alCustom, alNone, alClient, alTop, alBottom: ChildSizing.Layout :=
|
|---|
| 162 | cclTopToBottomThenLeftToRight;
|
|---|
| 163 | // if vertical
|
|---|
| 164 | alLeft, alRight: ChildSizing.Layout := cclLeftToRightThenTopToBottom;
|
|---|
| 165 | end;
|
|---|
| 166 | end;
|
|---|
| 167 |
|
|---|
| 168 | constructor TCustomBGRAWin7ToolBar.Create(TheOwner: TComponent);
|
|---|
| 169 | begin
|
|---|
| 170 | inherited Create(TheOwner);
|
|---|
| 171 | // align top default sizing
|
|---|
| 172 | Align := alTop;
|
|---|
| 173 | ChildSizing.Layout := cclTopToBottomThenLeftToRight;
|
|---|
| 174 | //{$IFDEF WINDOWS}
|
|---|
| 175 | // default spacing under different dpi settings
|
|---|
| 176 | //ChildSizing.LeftRightSpacing := ScaleX(4,96);
|
|---|
| 177 | //ChildSizing.TopBottomSpacing := ScaleY(4,96);
|
|---|
| 178 | //{$ELSE}
|
|---|
| 179 | // default spacing
|
|---|
| 180 | ChildSizing.LeftRightSpacing := 4;
|
|---|
| 181 | ChildSizing.TopBottomSpacing := 4;
|
|---|
| 182 | //{$ENDIF}
|
|---|
| 183 | end;
|
|---|
| 184 |
|
|---|
| 185 | end.
|
|---|