mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-17 05:20:48 +01:00
LCL: Make Calculator "simple" layout work. Issue #28413, patch from Alexey Torgashin.
git-svn-id: trunk@49655 -
This commit is contained in:
parent
c4df72ddfa
commit
0e783282e9
233
lcl/extdlgs.pas
233
lcl/extdlgs.pas
@ -152,7 +152,17 @@ type
|
|||||||
FOnChange: TNotifyEvent;
|
FOnChange: TNotifyEvent;
|
||||||
FOnCalcKey: TKeyPressEvent;
|
FOnCalcKey: TKeyPressEvent;
|
||||||
FOnDisplayChange: TNotifyEvent;
|
FOnDisplayChange: TNotifyEvent;
|
||||||
|
FDialogScale: integer;
|
||||||
|
FColorBtnDigits,
|
||||||
|
FColorBtnOthers,
|
||||||
|
FColorBtnMemory,
|
||||||
|
FColorBtnOk,
|
||||||
|
FColorBtnCancel,
|
||||||
|
FColorBtnClear,
|
||||||
|
FColorDisplayText,
|
||||||
|
FColorDisplayBack: TColor;
|
||||||
function GetDisplay: Double;
|
function GetDisplay: Double;
|
||||||
|
procedure SetDialogScale(AValue: integer);
|
||||||
protected
|
protected
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
procedure Change; virtual;
|
procedure Change; virtual;
|
||||||
@ -167,13 +177,22 @@ type
|
|||||||
property Memory: Double read FMemory;
|
property Memory: Double read FMemory;
|
||||||
published
|
published
|
||||||
property BeepOnError: Boolean read FBeepOnError write FBeepOnError default True;
|
property BeepOnError: Boolean read FBeepOnError write FBeepOnError default True;
|
||||||
property CalculatorLayout : TCalculatorLayout Read FLayout Write Flayout;
|
property CalculatorLayout: TCalculatorLayout read FLayout write FLayout default clNormal;
|
||||||
property Precision: Byte read FPrecision write FPrecision default DefCalcPrecision;
|
property Precision: Byte read FPrecision write FPrecision default DefCalcPrecision;
|
||||||
property Title;
|
property Title;
|
||||||
property Value: Double read FValue write FValue;
|
property Value: Double read FValue write FValue;
|
||||||
property OnCalcKey: TKeyPressEvent read FOnCalcKey write FOnCalcKey;
|
property OnCalcKey: TKeyPressEvent read FOnCalcKey write FOnCalcKey;
|
||||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||||
property OnDisplayChange: TNotifyEvent read FOnDisplayChange write FOnDisplayChange;
|
property OnDisplayChange: TNotifyEvent read FOnDisplayChange write FOnDisplayChange;
|
||||||
|
property DialogScale: integer read FDialogScale write SetDialogScale default 100;
|
||||||
|
property ColorBtnDigits: TColor read FColorBtnDigits write FColorBtnDigits;
|
||||||
|
property ColorBtnMemory: TColor read FColorBtnMemory write FColorBtnMemory;
|
||||||
|
property ColorBtnOk: TColor read FColorBtnOk write FColorBtnOk;
|
||||||
|
property ColorBtnCancel: TColor read FColorBtnCancel write FColorBtnCancel;
|
||||||
|
property ColorBtnClear: TColor read FColorBtnClear write FColorBtnClear;
|
||||||
|
property ColorBtnOthers: TColor read FColorBtnOthers write FColorBtnOthers;
|
||||||
|
property ColorDisplayText: TColor read FColorDisplayText write FColorDisplayText;
|
||||||
|
property ColorDisplayBack: TColor read FColorDisplayBack write FColorDisplayBack;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCalculatorForm }
|
{ TCalculatorForm }
|
||||||
@ -201,9 +220,8 @@ type
|
|||||||
property DisplayPanel: TPanel read FDisplayPanel;
|
property DisplayPanel: TPanel read FDisplayPanel;
|
||||||
property DisplayLabel: TLabel read FDisplayLabel;
|
property DisplayLabel: TLabel read FDisplayLabel;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent; ALayout: TCalculatorLayout);
|
||||||
// constructor CreateLayout(AOwner: TComponent;ALayout : TCalculatorLayout);
|
property Value: Double read GetValue write SetValue;
|
||||||
property Value : Double read GetValue write SetValue;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateCalculatorForm(AOwner: TComponent; ALayout : TCalculatorLayout; AHelpContext: THelpContext): TCalculatorForm;
|
function CreateCalculatorForm(AOwner: TComponent; ALayout : TCalculatorLayout; AHelpContext: THelpContext): TCalculatorForm;
|
||||||
@ -258,10 +276,11 @@ procedure Register;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$R lcl_calc_images.res}
|
//no need as buttons don't have glyphs now
|
||||||
|
//{$R lcl_calc_images.res}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
WSExtDlgs;
|
WSExtDlgs, Math;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
@ -269,6 +288,16 @@ begin
|
|||||||
TCalendarDialog,TCalculatorDialog]);
|
TCalendarDialog,TCalculatorDialog]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
cColorBtnDigits: TColor = clblack;
|
||||||
|
cColorBtnMemory: TColor = clnavy;
|
||||||
|
cColorBtnClear: TColor = clred;
|
||||||
|
cColorBtnOk: TColor = clgreen;
|
||||||
|
cColorBtnCancel: TColor = clmaroon;
|
||||||
|
cColorBtnOthers: TColor = clblack;
|
||||||
|
cColorDisplayText: TColor = clblack;
|
||||||
|
cColorDisplayBack: TColor = clwhite;
|
||||||
|
|
||||||
{ TPreviewFileControl }
|
{ TPreviewFileControl }
|
||||||
|
|
||||||
class procedure TPreviewFileControl.WSRegisterClass;
|
class procedure TPreviewFileControl.WSRegisterClass;
|
||||||
@ -476,28 +505,53 @@ type
|
|||||||
TCalcBtnKind =
|
TCalcBtnKind =
|
||||||
(cbNone, cbNum0, cbNum1, cbNum2, cbNum3, cbNum4, cbNum5, cbNum6,
|
(cbNone, cbNum0, cbNum1, cbNum2, cbNum3, cbNum4, cbNum5, cbNum6,
|
||||||
cbNum7, cbNum8, cbNum9, cbSgn, cbDcm, cbDiv, cbMul, cbSub,
|
cbNum7, cbNum8, cbNum9, cbSgn, cbDcm, cbDiv, cbMul, cbSub,
|
||||||
cbAdd, cbSqr, cbPcnt, cbRev, cbEql, cbBck, cbClr, cbMP,
|
cbAdd, cbSqrt, cbSquare, cbPcnt, cbRev, cbEql, cbBck, cbClr, cbMP,
|
||||||
cbMS, cbMR, cbMC, cbOk, cbCancel);
|
cbMS, cbMR, cbMC, cbOk, cbCancel);
|
||||||
|
|
||||||
const
|
const
|
||||||
BtnPos: array[TCalculatorLayout, TCalcBtnKind] of TPoint =
|
CalcFormWidth: array[TCalculatorLayout] of integer = (278, 170);
|
||||||
(((X: -1; Y: -1), (X: 47; Y: 104), (X: 47; Y: 80), (X: 85; Y: 80),
|
CalcFormHeight: array[TCalculatorLayout] of integer = (160, 150);
|
||||||
|
CalcBtnEqualWidthNormal = 74;
|
||||||
|
CalcBtnClearWidthNormal = 50;
|
||||||
|
CalcBtnEqualWidthSimple = 54;
|
||||||
|
CalcResultKeys = [#13, '=', '%'];
|
||||||
|
|
||||||
|
const
|
||||||
|
CalcBtnSizes: array[TCalculatorLayout,1..2] of Integer =
|
||||||
|
((36,22), (25,21));
|
||||||
|
CalcBtnCaptions: array[cbSgn..cbCancel] of String =
|
||||||
|
('±', ',', '/', '*', '-', '+', '√', 'x²', '%', '1/x', '=', '«', 'C',
|
||||||
|
'MP','MS','MR','MC', 'ok', 'x');
|
||||||
|
CalcBtnPos: array[TCalculatorLayout, TCalcBtnKind] of TPoint =
|
||||||
|
((
|
||||||
|
//normal layout
|
||||||
|
(X: -1; Y: -1), (X: 47; Y: 104), (X: 47; Y: 80), (X: 85; Y: 80),
|
||||||
(X: 123; Y: 80), (X: 47; Y: 56), (X: 85; Y: 56), (X: 123; Y: 56),
|
(X: 123; Y: 80), (X: 47; Y: 56), (X: 85; Y: 56), (X: 123; Y: 56),
|
||||||
(X: 47; Y: 32), (X: 85; Y: 32), (X: 123; Y: 32), (X: 85; Y: 104),
|
(X: 47; Y: 32), (X: 85; Y: 32), (X: 123; Y: 32), (X: 85; Y: 104),
|
||||||
(X: 123; Y: 104), (X: 161; Y: 32), (X: 161; Y: 56), (X: 161; Y: 80),
|
(X: 123; Y: 104), (X: 161; Y: 32), (X: 161; Y: 56), (X: 161; Y: 80),
|
||||||
(X: 161; Y: 104), (X: 199; Y: 32), (X: 199; Y: 56), (X: 199; Y: 80),
|
(X: 161; Y: 104),
|
||||||
(X: 199; Y: 104), (X: 145; Y: 6), (X: 191; Y: 6), (X: 5; Y: 104),
|
(X: 199; Y: 32), //sqrt
|
||||||
(X: 5; Y: 80), (X: 5; Y: 56), (X: 5; Y: 32),
|
(X: 199+38; Y: 32), //sqr
|
||||||
(X: 47; Y: 6), (X: 85; Y: 6)),
|
(X: 199; Y: 56), //%
|
||||||
((X: -1; Y: -1), (X: 6; Y: 75), (X: 6; Y: 52), (X: 29; Y: 52),
|
(X: 199; Y: 80), //1/x
|
||||||
(X: 52; Y: 52), (X: 6; Y: 29), (X: 29; Y: 29), (X: 52; Y: 29),
|
(X: 199; Y: 104), //=
|
||||||
(X: 6; Y: 6), (X: 29; Y: 6), (X: 52; Y: 6), (X: 52; Y: 75),
|
(X: 170; Y: 6), //back
|
||||||
(X: 29; Y: 75), (X: 75; Y: 6), (X: 75; Y: 29), (X: 75; Y: 52),
|
(X: 223; Y: 6), //clear
|
||||||
(X: 75; Y: 75), (X: -1; Y: -1), (X: -1; Y: -1), (X: -1; Y: -1),
|
(X: 5; Y: 104), (X: 5; Y: 80), (X: 5; Y: 56), (X: 5; Y: 32), //mem
|
||||||
(X: 52; Y: 98), (X: 29; Y: 98), (X: 6; Y: 98), (X: -1; Y: -1),
|
(X: 47; Y: 6), //ok
|
||||||
|
(X: 100; Y: 6) //cancel
|
||||||
|
),
|
||||||
|
(
|
||||||
|
//simple layout
|
||||||
|
(X: -1; Y: -1), (X: 6; Y: 75), (X: 6; Y: 52), (X: 34; Y: 52),
|
||||||
|
(X: 62; Y: 52), (X: 6; Y: 29), (X: 34; Y: 29), (X: 62; Y: 29),
|
||||||
|
(X: 6; Y: 6), (X: 34; Y: 6), (X: 62; Y: 6), (X: 62; Y: 75),
|
||||||
|
(X: 34; Y: 75), (X: 90; Y: 6), (X: 90; Y: 29), (X: 90; Y: 52),
|
||||||
|
(X: 90; Y: 75), (X: -1; Y: -1), (X: -1; Y: -1), (X: -1; Y: -1), (X: -1; Y: -1),
|
||||||
|
(X: 62; Y: 98), (X: 34; Y: 98), (X: 6; Y: 98), (X: -1; Y: -1),
|
||||||
(X: -1; Y: -1), (X: -1; Y: -1), (X: -1; Y: -1),
|
(X: -1; Y: -1), (X: -1; Y: -1), (X: -1; Y: -1),
|
||||||
(X: -1; Y: -1), (X: -1; Y: -1)));
|
(X: 140; Y: 6), (X: 140; Y: 29)
|
||||||
ResultKeys = [#13, '=', '%'];
|
));
|
||||||
|
|
||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
Auxiliary
|
Auxiliary
|
||||||
@ -515,17 +569,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateCalculatorForm(AOwner: TComponent; ALayout : TCalculatorLayout; AHelpContext: THelpContext): TCalculatorForm;
|
function CreateCalculatorForm(AOwner: TComponent; ALayout: TCalculatorLayout; AHelpContext: THelpContext): TCalculatorForm;
|
||||||
begin
|
begin
|
||||||
Result:=TCalculatorForm.Create(AOwner);
|
Result:=TCalculatorForm.Create(AOwner, ALayout);
|
||||||
with Result do
|
with Result do
|
||||||
try
|
try
|
||||||
HelpContext:=AHelpContext;
|
HelpContext:=AHelpContext;
|
||||||
if Screen.PixelsPerInch <> 96 then
|
if Screen.PixelsPerInch <> 96 then
|
||||||
begin { scale to screen res }
|
begin { scale to screen res }
|
||||||
SetDefaultFont(Font, ALayout);
|
SetDefaultFont(Font, ALayout);
|
||||||
Left:=(Screen.Width div 2) - (Width div 2);
|
Left:=(Screen.Width - Width) div 2;
|
||||||
Top:=(Screen.Height div 2) - (Height div 2);
|
Top:=(Screen.Height - Height) div 2;
|
||||||
end;
|
end;
|
||||||
except
|
except
|
||||||
Free;
|
Free;
|
||||||
@ -616,12 +670,6 @@ end;
|
|||||||
|
|
||||||
function CreateCalcBtn(AParent: TWinControl; AKind: TCalcBtnKind;
|
function CreateCalcBtn(AParent: TWinControl; AKind: TCalcBtnKind;
|
||||||
AOnClick: TNotifyEvent; ALayout: TCalculatorLayout): TCalcButton;
|
AOnClick: TNotifyEvent; ALayout: TCalculatorLayout): TCalcButton;
|
||||||
const
|
|
||||||
BtnSizes: array[TCalculatorLayout,1..2] of Integer =
|
|
||||||
((36,22),(21,21));
|
|
||||||
BtnCaptions: array[cbSgn..cbMC] of String =
|
|
||||||
('±', ',', '/', '*', '-', '+', 'sqrt', '%', '1/x', '=', '<-', 'C',
|
|
||||||
'MP','MS','MR','MC');
|
|
||||||
begin
|
begin
|
||||||
Result:=TCalcButton.CreateKind(AParent, AKind);
|
Result:=TCalcButton.CreateKind(AParent, AKind);
|
||||||
with Result do
|
with Result do
|
||||||
@ -630,15 +678,25 @@ begin
|
|||||||
Caption:=IntToStr(Tag)
|
Caption:=IntToStr(Tag)
|
||||||
else if Kind = cbDcm then
|
else if Kind = cbDcm then
|
||||||
Caption:=DefaultFormatSettings.DecimalSeparator
|
Caption:=DefaultFormatSettings.DecimalSeparator
|
||||||
else if Kind in [cbSgn..cbMC] then
|
else if Kind in [cbSgn..cbCancel] then
|
||||||
Caption:=BtnCaptions[Kind];
|
Caption:=CalcBtnCaptions[Kind];
|
||||||
Left:=BtnPos[ALayout, Kind].X;
|
|
||||||
Top:=BtnPos[ALayout, Kind].Y;
|
Left:=CalcBtnPos[ALayout, Kind].X;
|
||||||
Width:=BtnSizes[ALayout,1];
|
Top:=CalcBtnPos[ALayout, Kind].Y;
|
||||||
Height:=BtnSizes[ALayout,2];
|
Width:=CalcBtnSizes[ALayout,1];
|
||||||
|
Height:=CalcBtnSizes[ALayout,2];
|
||||||
OnClick:=AOnClick;
|
OnClick:=AOnClick;
|
||||||
ParentFont:=True;
|
ParentFont:=True;
|
||||||
Parent:=AParent;
|
Parent:=AParent;
|
||||||
|
|
||||||
|
case Result.Kind of
|
||||||
|
cbMC, cbMR, cbMS, cbMP: Result.Font.Color:= cColorBtnMemory;
|
||||||
|
cbOk: Result.Font.Color:= cColorBtnOk;
|
||||||
|
cbCancel: Result.Font.Color:= cColorBtnCancel;
|
||||||
|
cbClr: Result.Font.Color:= cColorBtnClear;
|
||||||
|
cbNum0..cbNum9: Result.Font.Color:= cColorBtnDigits;
|
||||||
|
else Result.Font.Color:= cColorBtnOthers;
|
||||||
|
end;
|
||||||
except
|
except
|
||||||
Free;
|
Free;
|
||||||
raise;
|
raise;
|
||||||
@ -703,12 +761,6 @@ constructor TCalculatorPanel.CreateLayout(AOwner: TComponent; ALayout: TCalculat
|
|||||||
const
|
const
|
||||||
PanelSizes: array[TCalculatorLayout,1..2] of Integer =
|
PanelSizes: array[TCalculatorLayout,1..2] of Integer =
|
||||||
((129,140),(124,98));
|
((129,140),(124,98));
|
||||||
BtnGlyphs: array[TCalculatorLayout,cbSgn..cbCancel] of String =
|
|
||||||
(('btncalcpmin','','','btncalcmul','btncalcmin','btncalcplus', '',
|
|
||||||
'','','','','','','','','', 'btncalcok', 'btncalccancel'),
|
|
||||||
('btncalcpmin','','','btncalcmul','btncalcmin','btncalcplus', '',
|
|
||||||
'','','','','','','','','', 'btncalcok', 'btncalccancel')
|
|
||||||
);
|
|
||||||
var
|
var
|
||||||
I: TCalcBtnKind;
|
I: TCalcBtnKind;
|
||||||
Bitmap: TCustomBitmap;
|
Bitmap: TCustomBitmap;
|
||||||
@ -725,29 +777,19 @@ begin
|
|||||||
ParentColor:=True;
|
ParentColor:=True;
|
||||||
for I:=cbNum0 to cbCancel do
|
for I:=cbNum0 to cbCancel do
|
||||||
begin
|
begin
|
||||||
if BtnPos[ALayout, I].X > 0 then
|
if CalcBtnPos[ALayout, I].X > 0 then
|
||||||
with CreateCalcBtn(Self, I, @BtnClick, ALayout) do
|
with CreateCalcBtn(Self, I, @BtnClick, ALayout) do
|
||||||
begin
|
begin
|
||||||
if ALayout = clNormal then
|
if ALayout = clNormal then
|
||||||
begin
|
begin
|
||||||
if (Kind in [cbBck, cbClr]) then
|
if (Kind in [cbBck, cbClr, cbOk, cbCancel]) then
|
||||||
Width:=44;
|
Width:=CalcBtnClearWidthNormal;
|
||||||
if (Kind in [cbSgn..cbCancel]) then
|
if (Kind in [cbPcnt, cbRev, cbEql]) then
|
||||||
if (BtnGlyphs[ALayout,Kind]<>'') then
|
Width:=CalcBtnEqualWidthNormal;
|
||||||
begin
|
|
||||||
Caption:='';
|
|
||||||
Bitmap := TPixmap.Create;
|
|
||||||
try
|
|
||||||
Bitmap.LoadFromResourceName(hInstance, BtnGlyphs[ALayout,Kind]);
|
|
||||||
Glyph.Assign(Bitmap);
|
|
||||||
finally
|
|
||||||
Bitmap.Free;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if Kind in [cbEql] then Width:=44;
|
if Kind in [cbEql] then Width:=CalcBtnEqualWidthSimple;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -903,6 +945,12 @@ begin
|
|||||||
else
|
else
|
||||||
SetDisplay(Sqrt(GetDisplay));
|
SetDisplay(Sqrt(GetDisplay));
|
||||||
end;
|
end;
|
||||||
|
'S':
|
||||||
|
if FStatus in [csValid, csFirst] then
|
||||||
|
begin
|
||||||
|
FStatus:=csFirst;
|
||||||
|
SetDisplay(Sqr(GetDisplay));
|
||||||
|
end;
|
||||||
'0'..'9':
|
'0'..'9':
|
||||||
begin
|
begin
|
||||||
CheckFirst;
|
CheckFirst;
|
||||||
@ -949,7 +997,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
FOperator:=Key;
|
FOperator:=Key;
|
||||||
FOperand:=GetDisplay;
|
FOperand:=GetDisplay;
|
||||||
if (Key in ResultKeys) and Assigned(FOnResult) then
|
if (Key in CalcResultKeys) and Assigned(FOnResult) then
|
||||||
FOnResult(Self);
|
FOnResult(Self);
|
||||||
end;
|
end;
|
||||||
#27, 'C':
|
#27, 'C':
|
||||||
@ -1019,7 +1067,8 @@ begin
|
|||||||
cbMul: CalcKey('*');
|
cbMul: CalcKey('*');
|
||||||
cbSub: CalcKey('-');
|
cbSub: CalcKey('-');
|
||||||
cbAdd: CalcKey('+');
|
cbAdd: CalcKey('+');
|
||||||
cbSqr: CalcKey('Q');
|
cbSqrt: CalcKey('Q');
|
||||||
|
cbSquare: CalcKey('S');
|
||||||
cbPcnt: CalcKey('%');
|
cbPcnt: CalcKey('%');
|
||||||
cbRev: CalcKey('R');
|
cbRev: CalcKey('R');
|
||||||
cbEql: CalcKey('=');
|
cbEql: CalcKey('=');
|
||||||
@ -1092,6 +1141,17 @@ begin
|
|||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FPrecision:=DefCalcPrecision;
|
FPrecision:=DefCalcPrecision;
|
||||||
FBeepOnError:=True;
|
FBeepOnError:=True;
|
||||||
|
FDialogScale:=100;
|
||||||
|
FLayout:=clNormal;
|
||||||
|
|
||||||
|
FColorBtnDigits:=cColorBtnDigits;
|
||||||
|
FColorBtnOthers:=cColorBtnOthers;
|
||||||
|
FColorBtnMemory:=cColorBtnMemory;
|
||||||
|
FColorBtnOk:=cColorBtnOk;
|
||||||
|
FColorBtnCancel:=cColorBtnCancel;
|
||||||
|
FColorBtnClear:=cColorBtnClear;
|
||||||
|
FColorDisplayText:=cColorDisplayText;
|
||||||
|
FColorDisplayBack:=cColorDisplayBack;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCalculatorDialog.Destroy;
|
destructor TCalculatorDialog.Destroy;
|
||||||
@ -1114,6 +1174,15 @@ begin
|
|||||||
else Result:=FValue;
|
else Result:=FValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCalculatorDialog.SetDialogScale(AValue: integer);
|
||||||
|
const
|
||||||
|
cMinSize = 80;
|
||||||
|
cMaxSize = 400;
|
||||||
|
begin
|
||||||
|
if FDialogScale=AValue then Exit;
|
||||||
|
FDialogScale:=Max(cMinSize, Min(cMaxSize, AValue));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCalculatorDialog.CalcKey(var Key: char);
|
procedure TCalculatorDialog.CalcKey(var Key: char);
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnCalcKey) then FOnCalcKey(Self, Key);
|
if Assigned(FOnCalcKey) then FOnCalcKey(Self, Key);
|
||||||
@ -1139,8 +1208,19 @@ function TCalculatorDialog.Execute: Boolean;
|
|||||||
var
|
var
|
||||||
CPanel: TCalculatorPanel;
|
CPanel: TCalculatorPanel;
|
||||||
begin
|
begin
|
||||||
|
cColorBtnDigits:=FColorBtnDigits;
|
||||||
|
cColorBtnOthers:=FColorBtnOthers;
|
||||||
|
cColorBtnMemory:=FColorBtnMemory;
|
||||||
|
cColorBtnOk:=FColorBtnOk;
|
||||||
|
cColorBtnCancel:=FColorBtnCancel;
|
||||||
|
cColorBtnClear:=FColorBtnClear;
|
||||||
|
cColorDisplayText:=FColorDisplayText;
|
||||||
|
cColorDisplayBack:=FColorDisplayBack;
|
||||||
|
|
||||||
DlgForm:=CreateCalculatorForm(Application, FLayout, HelpContext);
|
DlgForm:=CreateCalculatorForm(Application, FLayout, HelpContext);
|
||||||
try
|
try
|
||||||
|
if FDialogScale<>100 then
|
||||||
|
DlgForm.ScaleBy(FDialogScale,100);
|
||||||
if (csDesigning in ComponentState) then
|
if (csDesigning in ComponentState) then
|
||||||
DlgForm.Position:=poScreenCenter
|
DlgForm.Position:=poScreenCenter
|
||||||
else
|
else
|
||||||
@ -1153,6 +1233,7 @@ begin
|
|||||||
FTop:=DlgForm.Top;
|
FTop:=DlgForm.Top;
|
||||||
end;
|
end;
|
||||||
CPanel:=TCalculatorPanel(TCalculatorForm(DlgForm).FCalcPanel);
|
CPanel:=TCalculatorPanel(TCalculatorForm(DlgForm).FCalcPanel);
|
||||||
|
|
||||||
DlgForm.Caption:=Title;
|
DlgForm.Caption:=Title;
|
||||||
CPanel.FMemory:=FMemory;
|
CPanel.FMemory:=FMemory;
|
||||||
CPanel.UpdateMemoryLabel;
|
CPanel.UpdateMemoryLabel;
|
||||||
@ -1187,29 +1268,20 @@ end;
|
|||||||
|
|
||||||
{ TCalculatorForm }
|
{ TCalculatorForm }
|
||||||
|
|
||||||
constructor TCalculatorForm.Create(AOwner: TComponent);
|
constructor TCalculatorForm.Create(AOwner: TComponent; ALayout: TCalculatorLayout);
|
||||||
begin
|
|
||||||
BeginFormUpdate;
|
|
||||||
inherited CreateNew(AOwner, 0);
|
|
||||||
InitForm(clNormal);
|
|
||||||
EndFormUpdate;
|
|
||||||
end;
|
|
||||||
{
|
|
||||||
constructor TCalculatorForm.CreateLayout(AOwner: TComponent;ALayout : TCalculatorLayout);
|
|
||||||
begin
|
begin
|
||||||
BeginFormUpdate;
|
BeginFormUpdate;
|
||||||
inherited CreateNew(AOwner, 0);
|
inherited CreateNew(AOwner, 0);
|
||||||
InitForm(ALayout);
|
InitForm(ALayout);
|
||||||
EndFormUpdate;
|
EndFormUpdate;
|
||||||
end;
|
end;
|
||||||
}
|
|
||||||
|
|
||||||
procedure TCalculatorForm.InitForm(ALayout : TCalculatorLayout);
|
procedure TCalculatorForm.InitForm(ALayout: TCalculatorLayout);
|
||||||
begin
|
begin
|
||||||
BorderStyle:=bsDialog;
|
BorderStyle:=bsDialog;
|
||||||
Caption:=rsCalculator;
|
Caption:=rsCalculator;
|
||||||
ClientHeight:=159;
|
ClientHeight:=CalcFormHeight[ALayout];
|
||||||
ClientWidth:=242;
|
ClientWidth:=CalcFormWidth[ALayout];
|
||||||
SetDefaultFont(Font, ALayout);
|
SetDefaultFont(Font, ALayout);
|
||||||
KeyPreview:=True;
|
KeyPreview:=True;
|
||||||
PixelsPerInch:=96;
|
PixelsPerInch:=96;
|
||||||
@ -1228,10 +1300,12 @@ begin
|
|||||||
FDisplayPanel:=TPanel.Create(Self);
|
FDisplayPanel:=TPanel.Create(Self);
|
||||||
with FDisplayPanel do
|
with FDisplayPanel do
|
||||||
begin
|
begin
|
||||||
SetBounds(6, 6, 230, 23);
|
Height:=23;
|
||||||
|
Align:=alTop;
|
||||||
|
BorderSpacing.Around:=7;
|
||||||
Parent:=FMainPanel;
|
Parent:=FMainPanel;
|
||||||
BevelOuter:=bvLowered;
|
BevelOuter:=bvLowered;
|
||||||
Color:=clWhite;
|
Color:=cColorDisplayBack;
|
||||||
Font:=Self.Font;
|
Font:=Self.Font;
|
||||||
end;
|
end;
|
||||||
FDisplayLabel:=TLabel.Create(Self);
|
FDisplayLabel:=TLabel.Create(Self);
|
||||||
@ -1239,10 +1313,11 @@ begin
|
|||||||
begin
|
begin
|
||||||
AutoSize:=False;
|
AutoSize:=False;
|
||||||
Alignment:=taRightJustify;
|
Alignment:=taRightJustify;
|
||||||
SetBounds(5, 2, 217, 15);
|
Align:=alClient;
|
||||||
|
BorderSpacing.Around:=2;
|
||||||
Parent:=FDisplayPanel;
|
Parent:=FDisplayPanel;
|
||||||
Caption:='0';
|
Caption:='0';
|
||||||
Font.Color:=clBlack;
|
Font.Color:=cColorDisplayText;
|
||||||
end;
|
end;
|
||||||
{ CalcPanel }
|
{ CalcPanel }
|
||||||
FCalcPanel:=TCalculatorPanel.CreateLayout(Self, ALayout);
|
FCalcPanel:=TCalculatorPanel.CreateLayout(Self, ALayout);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user