summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-10-14 17:27:11 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-10-14 17:27:11 +0000
commit230b9ed0ad5e53734a6e754c2d5146dc8719ef44 (patch)
tree3110d53b3006051b3a78296ec3efe022e24ba4be
parentc6b377bb5efbb8141450ffdaf40f7808044924aa (diff)
downloadfpGUI-230b9ed0ad5e53734a6e754c2d5146dc8719ef44.tar.xz
* Applied SpinEdit, Edit, Button and Panel patch from Jean-Marc.
-rw-r--r--src/gui/fpg_button.pas1
-rw-r--r--src/gui/fpg_edit.pas12
-rw-r--r--src/gui/fpg_panel.pas5
-rw-r--r--src/gui/fpg_spinedit.pas243
-rw-r--r--uidesigner/uidesigner.lpi1
5 files changed, 242 insertions, 20 deletions
diff --git a/src/gui/fpg_button.pas b/src/gui/fpg_button.pas
index e3e2a62e..4600d894 100644
--- a/src/gui/fpg_button.pas
+++ b/src/gui/fpg_button.pas
@@ -152,6 +152,7 @@ type
property OnMouseDown;
property OnMouseExit;
property OnMouseEnter;
+ property OnMouseMove;
property OnMouseUp;
property OnClick;
end;
diff --git a/src/gui/fpg_edit.pas b/src/gui/fpg_edit.pas
index dbf79361..2e9da481 100644
--- a/src/gui/fpg_edit.pas
+++ b/src/gui/fpg_edit.pas
@@ -213,6 +213,7 @@ type
property OnKeyPress;
property OnMouseEnter;
property OnMouseExit;
+ property OnMouseMove;
end;
@@ -244,6 +245,7 @@ type
property OnKeyPress;
property OnMouseEnter;
property OnMouseExit;
+ property OnMouseMove;
property ShowThousand;
property TabOrder;
property TextColor;
@@ -290,7 +292,7 @@ function CreateEditInteger(AOwner: TComponent; x, y, w, h: TfpgCoord;
AShowThousand: boolean= True): TfpgEditInteger;
function CreateEditFloat(AOwner: TComponent; x, y, w, h: TfpgCoord;
- AShowThousand: boolean= True; ADecimals: Integer= -1): TfpgEditFloat;
+ AShowThousand: boolean= True; ADecimals: Integer= -1; AFixedDecimals: boolean= False): TfpgEditFloat;
function CreateEditCurrency(AOwner: TComponent; x, y, w, h: TfpgCoord;
AShowThousand: boolean= True; ADecimals: Integer= 2): TfpgEditCurrency;
@@ -338,7 +340,7 @@ begin
end;
function CreateEditFloat(AOwner: TComponent; x, y, w, h: TfpgCoord; AShowThousand: boolean= True;
- ADecimals: Integer= -1): TfpgEditFloat;
+ ADecimals: Integer= -1; AFixedDecimals: boolean= False): TfpgEditFloat;
begin
Result := TfpgEditFloat.Create(AOwner);
Result.Left := x;
@@ -346,6 +348,7 @@ begin
Result.Width := w;
Result.ShowThousand:= AShowThousand;
Result.Decimals := ADecimals;
+ Result.FFixedDecimals:= AFixedDecimals;
if h < TfpgEditFloat(Result).FFont.Height + 6 then
Result.Height:= TfpgEditFloat(Result).FFont.Height + 6
else
@@ -1494,7 +1497,10 @@ end;
procedure TfpgEditFloat.SetValue(const AValue: extended);
begin
try
- Text := FloatToStr(AValue);
+ if FFixedDecimals then
+ Text := FloatToStrF(AValue, ffFixed, 18, FDecimals)
+ else
+ Text := FloatToStr(AValue);
except
on E: EConvertError do
Text := '';
diff --git a/src/gui/fpg_panel.pas b/src/gui/fpg_panel.pas
index 6e75dda0..4d064ff9 100644
--- a/src/gui/fpg_panel.pas
+++ b/src/gui/fpg_panel.pas
@@ -63,13 +63,12 @@ type
published
property BackgroundColor;
property BorderStyle;
- property ParentShowHint;
property Shape: TPanelShape read FPanelShape write SetPanelShape default bsBox;
- property ShowHint;
property Style;
property OnClick;
property OnDoubleClick;
property OnMouseDown;
+ property OnMouseMove;
property OnMouseUp;
property OnPaint;
end;
@@ -110,8 +109,6 @@ type
property BorderStyle;
property FontDesc: string read GetFontDesc write SetFontDesc;
property Layout: TLayout read GetLayout write SetLayout default tlCenter;
- property ParentShowHint;
- property ShowHint;
property Style;
property Text: string read GetText write SetText;
property TextColor;
diff --git a/src/gui/fpg_spinedit.pas b/src/gui/fpg_spinedit.pas
index ec0be607..0000148b 100644
--- a/src/gui/fpg_spinedit.pas
+++ b/src/gui/fpg_spinedit.pas
@@ -112,9 +112,11 @@ type
procedure SetMaxValue(const AValue: extended);
procedure SetMinValue(const AValue: extended);
procedure SetIncrement(const AValue: extended);
+ procedure SetLargeIncrement(const AValue: extended);
procedure SetValue(const AValue: extended);
procedure SetDecimals(const AValue: integer);
procedure SetFixedDecimals(const AValue: Boolean);
+ procedure SetHint(const AValue: string);
procedure ButtonUpClick(Sender: TObject);
procedure ButtonDownClick(Sender: TObject);
procedure ButtonUpMouseDown(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
@@ -123,6 +125,9 @@ type
procedure ButtonDownMouseUp(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
procedure EditKeyPress(Sender: TObject; var keycode: word; var shiftstate: TShiftState; var consumed: Boolean);
procedure EditExit(Sender: TObject);
+ procedure MouseEnter(Sender: TObject);
+ procedure MouseMove(Sender: TObject; AShift: TShiftState; const AMousePos: TPoint);
+ procedure MouseExit(Sender: TObject);
procedure TimerStep(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
@@ -137,10 +142,11 @@ type
property MaxValue: extended read FMaxValue write SetMaxValue;
property MinValue: extended read FMinValue write SetMinValue;
property Increment: extended read FIncrement write SetIncrement;
- property LargeIncrement: extended read FLargeIncrement write FLargeIncrement;
+ property LargeIncrement: extended read FLargeIncrement write SetLargeIncrement;
property Value: extended read FValue write SetValue;
property Decimals: integer read GetDecimals write SetDecimals;
property FixedDecimals: Boolean read GetFixedDecimals write SetFixedDecimals;
+ property Hint: string read FHint write SetHint;
end;
@@ -169,7 +175,9 @@ type
procedure SetMaxValue(const AValue: integer);
procedure SetMinValue(const AValue: integer);
procedure SetIncrement(const AValue: integer);
+ procedure SetLargeIncrement(const AValue: integer);
procedure SetValue(const AValue: integer);
+ procedure SetHint(const AValue: string);
procedure ButtonUpClick(Sender: TObject);
procedure ButtonDownClick(Sender: TObject);
procedure ButtonUpMouseDown(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
@@ -178,6 +186,9 @@ type
procedure ButtonDownMouseUp(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
procedure EditKeyPress(Sender: TObject; var keycode: word; var shiftstate: TShiftState; var consumed: Boolean);
procedure EditExit(Sender: TObject);
+ procedure MouseEnter(Sender: TObject);
+ procedure MouseMove(Sender: TObject; AShift: TShiftState; const AMousePos: TPoint);
+ procedure MouseExit(Sender: TObject);
procedure TimerStep(Sender: TObject);
public
constructor Create(AOwner: TComponent); override;
@@ -193,16 +204,18 @@ type
property MaxValue: integer read FMaxValue write SetMaxValue default 100;
property MinValue: integer read FMinValue write SetMinValue default 0;
property Increment: integer read FIncrement write SetIncrement default 1;
- property LargeIncrement: integer read FLargeIncrement write FLargeIncrement default 10;
+ property LargeIncrement: integer read FLargeIncrement write SetLargeIncrement default 10;
property Value: integer read FValue write SetValue default 0;
+ property Hint: string read FHint write SetHint;
end;
function CreateSpinEditFloat(AOwner: TComponent; x, y, w, h: TfpgCoord;
- AMinValue: extended = 0; AMaxValue: extended = 100; AIncrement: extended = 1; ADecimals: integer = 1;
- AValue: extended = 0): TfpgSpinEditFloat;
+ AMinValue: extended = 0; AMaxValue: extended = 100; AIncrement: extended = 1; ALargeIncrement: extended = 10.0;
+ ADecimals: integer = 1; AValue: extended = 0; AFixedDecimals: boolean= False): TfpgSpinEditFloat;
function CreateSpinEdit(AOwner: TComponent; x, y, w, h: TfpgCoord; AMinValue: integer = 0;
- AMaxValue: integer = 100; AIncrement: integer = 1; AValue: integer = 0): TfpgSpinEdit;
+ AMaxValue: integer = 100; AIncrement: integer = 1; ALargeIncrement: integer = 10;
+ AValue: integer = 0): TfpgSpinEdit;
implementation
@@ -212,8 +225,8 @@ uses
function CreateSpinEditFloat(AOwner: TComponent; x, y, w, h: TfpgCoord;
- AMinValue: extended = 0; AMaxValue: extended = 100; AIncrement: extended = 1; ADecimals: integer = 1;
- AValue: extended = 0): TfpgSpinEditFloat;
+ AMinValue: extended = 0; AMaxValue: extended = 100; AIncrement: extended = 1; ALargeIncrement: extended = 10.0;
+ ADecimals: integer = 1; AValue: extended = 0; AFixedDecimals: boolean= False): TfpgSpinEditFloat;
var
newh: TfpgCoord;
begin
@@ -230,13 +243,16 @@ begin
Result.MaxValue := AMaxValue;
end;
Result.Increment := AIncrement;
+ Result.LargeIncrement := ALargeIncrement;
Result.FEdit.Decimals := ADecimals;
+ Result.FEdit.FixedDecimals := AFixedDecimals;
if (AValue <= Result.MaxValue) and (AValue >= Result.MinValue) then
Result.Value := AValue;
end;
function CreateSpinEdit(AOwner: TComponent; x, y, w, h: TfpgCoord; AMinValue: integer = 0;
- AMaxValue: integer = 100; AIncrement: integer = 1; AValue: integer = 0): TfpgSpinEdit;
+ AMaxValue: integer = 100; AIncrement: integer = 1; ALargeIncrement: integer = 10;
+ AValue: integer = 0): TfpgSpinEdit;
var
newh: TfpgCoord;
begin
@@ -253,6 +269,7 @@ begin
Result.MaxValue := AMaxValue;
end;
Result.Increment := AIncrement;
+ Result.LargeIncrement := ALargeIncrement;
if (AValue <= Result.MaxValue) and (AValue >= Result.MinValue) then
Result.Value := AValue;
end;
@@ -538,7 +555,18 @@ end;
procedure TfpgSpinEditFloat.SetIncrement(const AValue: extended);
begin
if FIncrement <> AValue then
+ begin
FIncrement := AValue;
+ if FLargeIncrement < AValue then
+ FLargeIncrement := AValue;
+ end;
+end;
+
+procedure TfpgSpinEditFloat.SetLargeIncrement(const AValue: extended);
+begin
+ if FLargeIncrement <> AValue then
+ if FIncrement <= AValue then
+ FLargeIncrement := AValue;
end;
procedure TfpgSpinEditFloat.SetValue(const AValue: extended);
@@ -562,7 +590,20 @@ end;
procedure TfpgSpinEditFloat.SetFixedDecimals(const AValue: Boolean);
begin
if FEdit.FixedDecimals <> AValue then
+ begin
FEdit.FixedDecimals := AValue;
+ FEdit.Text:= FloatToStrF(FEdit.Value, ffFixed, 18, FEdit.Decimals);
+ end;
+end;
+
+procedure TfpgSpinEditFloat.SetHint(const AValue: string);
+begin
+ if Hint <> AValue then
+ begin
+ FEdit.Hint := AValue;
+ FButtonUp.Hint := AValue;
+ FButtonDown.Hint := AValue;
+ end;
end;
procedure TfpgSpinEditFloat.ButtonUpClick(Sender: TObject);
@@ -663,6 +704,73 @@ begin
EnableButtons;
end;
+procedure TfpgSpinEditFloat.MouseEnter(Sender: TObject);
+var
+ msgp: TfpgMessageParams;
+ b: boolean;
+begin
+ fillchar(msgp, sizeof(msgp), 0);
+ if Sender is TfpgEditFloat then
+ with Sender as TfpgEditFloat do
+ if Assigned(Parent) then
+ b := Enabled and fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.Parent.ShowHint)) and (FHint <> '')
+ else
+ b := Enabled and fpgApplication.ShowHint and FShowHint and (FHint <> '');
+ if Sender is TfpgButton then
+ with Sender as TfpgButton do
+ if Assigned(Parent) then
+ b := Enabled and fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.Parent.ShowHint)) and (FHint <> '')
+ else
+ b := Enabled and fpgApplication.ShowHint and FShowHint and (FHint <> '');
+
+ msgp.user.Param1 := Ord(b);
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+end;
+
+procedure TfpgSpinEditFloat.MouseMove(Sender: TObject; AShift: TShiftState; const AMousePos: TPoint);
+var
+ msgp: TfpgMessageParams;
+begin
+ fillchar(msgp, sizeof(msgp), 0);
+ msgp.user.Param1 := 2;
+ msgp.user.Param2 := AMousePos.x+10;
+ msgp.user.Param3 := AMousePos.y+2;
+
+ { Only send message if really needed. }
+ if Sender is TfpgEditFloat then
+ with Sender as TfpgEditFloat do
+ if Assigned(Parent) then
+ begin
+ if fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.Parent.ShowHint)) and (FHint <> '') then
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+ end
+ else
+ if fpgApplication.ShowHint and FShowHint and (FHint <> '') then
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+ if Sender is TfpgButton then
+ with Sender as TfpgButton do
+ if Assigned(Parent) then
+ begin
+ if fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.Parent.ShowHint)) and (FHint <> '') then
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+ end
+ else
+ if fpgApplication.ShowHint and FShowHint and (FHint <> '') then
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+end;
+
+procedure TfpgSpinEditFloat.MouseExit(Sender: TObject);
+begin
+ if Sender is TfpgEditFloat then
+ with Sender as TfpgEditFloat do
+ if FShowHint then
+ fpgApplication.HideHint;
+ if Sender is TfpgButton then
+ with Sender as TfpgButton do
+ if FShowHint then
+ fpgApplication.HideHint;
+end;
+
procedure TfpgSpinEditFloat.TimerStep(Sender: TObject);
begin
if FUp then
@@ -708,6 +816,7 @@ begin
FEdit.Decimals := 1;
FEdit.Value := FValue;
+ FEdit.FixedDecimals := False;
FButtonUp.OnClick := @ButtonUpClick;
FButtonDown.OnClick := @ButtonDownClick;
@@ -715,8 +824,18 @@ begin
FButtonUp.OnMouseUp := @ButtonUpMouseUp;
FButtonDown.OnMouseDown := @ButtonDownMouseDown;
FButtonDown.OnMouseUp := @ButtonDownMouseUp;
- FEdit.OnKeyPress := @EditKeyPress;
- FEdit.OnExit := @EditExit;
+ FEdit.OnKeyPress := @EditKeyPress;
+ FEdit.OnExit := @EditExit;
+ FEdit.OnMouseEnter:= @MouseEnter;
+ FButtonUp.OnMouseEnter:= @MouseEnter;
+ FButtonDown.OnMouseEnter:= @MouseEnter;
+ FEdit.OnMouseMove:= @MouseMove;
+ FButtonUp.OnMouseMove:= @MouseMove;
+ FButtonDown.OnMouseMove:= @MouseMove;
+ FEdit.OnMouseExit:= @MouseExit;
+ FButtonUp.OnMouseExit:= @MouseExit;
+ FButtonDown.OnMouseExit:= @MouseExit;
+
FTimer.OnTimer := @TimerStep;
EnableButtons;
end;
@@ -846,7 +965,18 @@ end;
procedure TfpgSpinEdit.SetIncrement(const AValue: integer);
begin
if FIncrement <> AValue then
+ begin
FIncrement := AValue;
+ if FLargeIncrement < AValue then
+ FLargeIncrement := AValue;
+ end;
+end;
+
+procedure TfpgSpinEdit.SetLargeIncrement(const AValue: integer);
+begin
+ if FLargeIncrement <> AValue then
+ if FIncrement <= AValue then
+ FLargeIncrement := AValue;
end;
procedure TfpgSpinEdit.SetValue(const AValue: integer);
@@ -859,6 +989,16 @@ begin
end;
end;
+procedure TfpgSpinEdit.SetHint(const AValue: string);
+begin
+ if FHint <> AValue then
+ begin
+ FEdit.Hint := AValue;
+ FButtonUp.Hint := AValue;
+ FButtonDown.Hint := AValue;
+ end;
+end;
+
procedure TfpgSpinEdit.ButtonUpClick(Sender: TObject);
begin
if FValue + FIncrement <= FMaxValue then
@@ -876,6 +1016,7 @@ begin
FUp := True;
FTimer.Enabled := True;
FSteps := 0;
+ FTempIncrement := Increment;
end;
procedure TfpgSpinEdit.ButtonUpMouseUp(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
@@ -891,6 +1032,7 @@ begin
FDown := True;
FTimer.Enabled := True;
FSteps := 0;
+ FTempIncrement := Increment;
end;
procedure TfpgSpinEdit.ButtonDownMouseUp(Sender: TObject; AButton: TMouseButton; AShift: TShiftState; const AMousePos: TPoint);
@@ -957,6 +1099,73 @@ begin
EnableButtons;
end;
+procedure TfpgSpinEdit.MouseEnter(Sender: TObject);
+var
+ msgp: TfpgMessageParams;
+ b: boolean;
+begin
+ fillchar(msgp, sizeof(msgp), 0);
+ if Sender is TfpgEditInteger then
+ with Sender as TfpgEditInteger do
+ if Assigned(Parent) then
+ b := Enabled and fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.Parent.ShowHint)) and (FHint <> '')
+ else
+ b := Enabled and fpgApplication.ShowHint and FShowHint and (FHint <> '');
+ if Sender is TfpgButton then
+ with Sender as TfpgButton do
+ if Assigned(Parent) then
+ b := Enabled and fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.Parent.ShowHint)) and (FHint <> '')
+ else
+ b := Enabled and fpgApplication.ShowHint and FShowHint and (FHint <> '');
+
+ msgp.user.Param1 := Ord(b);
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+end;
+
+procedure TfpgSpinEdit.MouseMove(Sender: TObject; AShift: TShiftState; const AMousePos: TPoint);
+var
+ msgp: TfpgMessageParams;
+begin
+ fillchar(msgp, sizeof(msgp), 0);
+ msgp.user.Param1 := 2;
+ msgp.user.Param2 := AMousePos.x+10;
+ msgp.user.Param3 := AMousePos.y+2;
+
+ { Only send message if really needed. }
+ if Sender is TfpgEditInteger then
+ with Sender as TfpgEditInteger do
+ if Assigned(Parent) then
+ begin
+ if fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.Parent.ShowHint)) and (FHint <> '') then
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+ end
+ else
+ if fpgApplication.ShowHint and FShowHint and (FHint <> '') then
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+ if Sender is TfpgButton then
+ with Sender as TfpgButton do
+ if Assigned(Parent) then
+ begin
+ if fpgApplication.ShowHint and (FShowHint or (FParentShowHint and Parent.Parent.ShowHint)) and (FHint <> '') then
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+ end
+ else
+ if fpgApplication.ShowHint and FShowHint and (FHint <> '') then
+ fpgPostMessage(Sender, fpgApplication, FPGM_HINTTIMER, msgp);
+end;
+
+procedure TfpgSpinEdit.MouseExit(Sender: TObject);
+begin
+ if Sender is TfpgEditInteger then
+ with Sender as TfpgEditInteger do
+ if FShowHint then
+ fpgApplication.HideHint;
+ if Sender is TfpgButton then
+ with Sender as TfpgButton do
+ if FShowHint then
+ fpgApplication.HideHint;
+end;
+
procedure TfpgSpinEdit.TimerStep(Sender: TObject);
begin
if FUp then
@@ -1008,8 +1217,18 @@ begin
FButtonUp.OnMouseUp := @ButtonUpMouseUp;
FButtonDown.OnMouseDown := @ButtonDownMouseDown;
FButtonDown.OnMouseUp := @ButtonDownMouseUp;
- FEdit.OnKeyPress := @EditKeyPress;
- FEdit.OnExit := @EditExit;
+ FEdit.OnKeyPress := @EditKeyPress;
+ FEdit.OnExit := @EditExit;
+ FEdit.OnMouseEnter:= @MouseEnter;
+ FButtonUp.OnMouseEnter:= @MouseEnter;
+ FButtonDown.OnMouseEnter:= @MouseEnter;
+ FEdit.OnMouseMove:= @MouseMove;
+ FButtonUp.OnMouseMove:= @MouseMove;
+ FButtonDown.OnMouseMove:= @MouseMove;
+ FEdit.OnMouseExit:= @MouseExit;
+ FButtonUp.OnMouseExit:= @MouseExit;
+ FButtonDown.OnMouseExit:= @MouseExit;
+
FTimer.OnTimer := @TimerStep;
EnableButtons;
end;
diff --git a/uidesigner/uidesigner.lpi b/uidesigner/uidesigner.lpi
index 50fde60d..a509ea53 100644
--- a/uidesigner/uidesigner.lpi
+++ b/uidesigner/uidesigner.lpi
@@ -9,7 +9,6 @@
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
- <IconPath Value="./"/>
<TargetFileExt Value=""/>
<Title Value="uiDesigner"/>
</General>