summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2012-11-20 00:26:57 +0000
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2012-11-20 00:26:57 +0000
commitea094f1006d0af479e6e0d78aabef66277491202 (patch)
tree189e0ef2504a17c00e803629171a3a028539933a /src
parentbe7db03ecbeecc2d78f499a32a12449e3d5d8e36 (diff)
downloadfpGUI-ea094f1006d0af479e6e0d78aabef66277491202.tar.xz
Implements a ReadOnly property for TfpgCheckBox.
Diffstat (limited to 'src')
-rw-r--r--src/gui/fpg_checkbox.pas25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/gui/fpg_checkbox.pas b/src/gui/fpg_checkbox.pas
index a68ecfa0..886f69ca 100644
--- a/src/gui/fpg_checkbox.pas
+++ b/src/gui/fpg_checkbox.pas
@@ -34,6 +34,7 @@ type
private
FChecked: boolean;
FOnChange: TNotifyEvent;
+ FReadOnly: Boolean;
FText: string;
FFont: TfpgFont;
FBoxLayout: TBoxLayout;
@@ -45,6 +46,7 @@ type
procedure SetBoxLayout(const AValue: TBoxLayout);
procedure SetChecked(const AValue: boolean);
procedure SetFontDesc(const AValue: string);
+ procedure SetReadOnly(const AValue: Boolean);
procedure SetText(const AValue: string);
procedure DoOnChange;
protected
@@ -55,6 +57,7 @@ type
property Checked: boolean read FChecked write SetChecked default False;
property FontDesc: string read GetFontDesc write SetFontDesc;
property BoxLayout: TBoxLayout read GetBoxLayout write SetBoxLayout default tbLeftBox;
+ property ReadOnly: Boolean read FReadOnly write SetReadOnly default False;
property Text: string read FText write SetText;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
public
@@ -80,6 +83,7 @@ type
property MinHeight;
property MinWidth;
property ParentShowHint;
+ property ReadOnly;
property ShowHint;
property TabOrder;
property Text;
@@ -112,6 +116,8 @@ end;
procedure TfpgBaseCheckBox.SetChecked(const AValue: boolean);
begin
+ if ReadOnly then
+ Exit; //==>
if FChecked = AValue then
Exit; //==>
FChecked := AValue;
@@ -146,6 +152,13 @@ begin
RePaint;
end;
+procedure TfpgBaseCheckBox.SetReadOnly(const AValue: Boolean);
+begin
+ if FReadOnly=AValue then exit;
+ FReadOnly:=AValue;
+ RePaint;
+end;
+
procedure TfpgBaseCheckBox.SetText(const AValue: string);
begin
if FText = AValue then
@@ -184,9 +197,14 @@ begin
// calculate which image to paint.
if Enabled then
begin
- ix := Ord(FChecked);
- if FIsPressed then
- Inc(ix, 2);
+ if ReadOnly then
+ ix := (2 + (Ord(FChecked) * 2)) - Ord(FChecked)
+ else
+ begin
+ ix := Ord(FChecked);
+ if FIsPressed then
+ Inc(ix, 2);
+ end;
end
else
ix := (2 + (Ord(FChecked) * 2)) - Ord(FChecked);
@@ -279,6 +297,7 @@ begin
FIsPressed := False;
FOnChange := nil;
FBoxLayout := tbLeftBox;
+ FReadOnly := False;
end;
destructor TfpgBaseCheckBox.Destroy;