1 unit umain;
2 
3 {$mode objfpc}{$H+}
4 
5 interface
6 
7 uses
8   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9   Spin, BCNumericKeyboard, BCButton, BCTypes, BCPanel, BGRABitmapTypes;
10 
11 type
12 
13   { TForm1 }
14 
15   TForm1 = class(TForm)
16     BCPanel1: TBCPanel;
17     BCRealNumericKeyboard1: TBCRealNumericKeyboard;
18     Edit1: TEdit;
19     FloatSpinEdit1: TFloatSpinEdit;
20     procedure Button1Click(Sender: TObject);
21     procedure FormClick(Sender: TObject);
22     procedure FormCreate(Sender: TObject);
23   private
24     NumericSender: TControl;
25   public
26 
27   end;
28 
29 var
30   Form1: TForm1;
31 
32 implementation
33 
34 {$R *.lfm}
35 
36 { TForm1 }
37 
38 { Button style }
39 procedure BCButtonWindows8(AButton: TBCButton; cl1, cl2: TColor);
40 begin
41   AButton.Rounding.RoundX := 1;
42   AButton.Rounding.RoundY := 1;
43   AButton.RoundingDropDown.Assign(AButton.Rounding);
44 
45   with AButton.StateNormal do
46   begin
47     Background.Style := bbsColor;
48     Background.Color := cl1;
49     Border.Style := bboSolid;
50     Border.Width := 1;
51     Border.Color := cl1;
52     Border.LightWidth := 0;
53     Border.LightOpacity := 255;
54     Border.Style := bboSolid;
55     FontEx.Color := clWhite;
56     FontEx.Shadow := False;
57     FontEx.Style := [];
58   end;
59 
60   AButton.StateHover.Assign(AButton.StateNormal);
61   AButton.StateClicked.Assign(AButton.StateNormal);
62 
63   with AButton.StateHover do
64   begin
65     Background.Color := cl2;
66     Border.Color := cl2;
67   end;
68 
69   with AButton.StateClicked do
70   begin
71     Background.Color := cl2;
72     Border.Color := cl2;
73   end;
74 end;
75 
76 procedure TForm1.Button1Click(Sender: TObject);
77 begin
78   if (NumericSender <> nil) and (NumericSender.Name = TControl(Sender).Name) and
79     (BCRealNumericKeyboard1.Visible) then
80   begin
81     BCRealNumericKeyboard1.Hide();
82   end
83   else
84   begin
85     NumericSender := Sender as TControl;
86     BCRealNumericKeyboard1.Panel.Left := NumericSender.Left;
87     BCRealNumericKeyboard1.Panel.Top := NumericSender.Top + NumericSender.Height;
88     BCRealNumericKeyboard1.Show();
89   end;
90 end;
91 
92 procedure TForm1.FormClick(Sender: TObject);
93 begin
94   if NumericSender <> nil then
95     Button1Click(NumericSender);
96 end;
97 
98 procedure TForm1.FormCreate(Sender: TObject);
99 begin
100   // Assign custom format settings
101   DefaultFormatSettings.CurrencyString := '$';
102   // DefaultFormatSettings.DecimalSeparator := '.';
103 
104   // Assign a style
105   BCButtonWindows8(BCRealNumericKeyboard1.ButtonStyle, clGray, clSkyBlue);
106   // Custom extra size inside the button
107   BCRealNumericKeyboard1.ButtonStyle.SetSizeVariables(0, 0, 15, 25);
108   // Apply the style
109   BCRealNumericKeyboard1.UpdateButtonStyle;
110 
111   with BCRealNumericKeyboard1.Panel do
112   begin
113     BevelInner := bvNone;
114     BevelOuter := bvNone;
115     Background.Gradient1.StartColor := clNavy;
116     Background.Gradient1.EndColor := clPurple;
117     Background.Gradient1.Point1XPercent := 0;
118     Background.Gradient1.Point1YPercent := 0;
119     Background.Gradient1.Point2XPercent := 0;
120     Background.Gradient1.Point2YPercent := 100;
121     Background.Gradient1EndPercent := 100;
122     Background.Style := bbsGradient;
123     // Spacing around
124     ChildSizing.TopBottomSpacing := 5;
125     ChildSizing.LeftRightSpacing := 5;
126     // Spacing between buttons
127     ChildSizing.VerticalSpacing := 10;
128     ChildSizing.HorizontalSpacing := 10;
129   end;
130 end;
131 
132 end.
133