diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/fpg_checkbox.pas | 29 | ||||
-rw-r--r-- | src/gui/fpg_radiobutton.pas | 28 |
2 files changed, 53 insertions, 4 deletions
diff --git a/src/gui/fpg_checkbox.pas b/src/gui/fpg_checkbox.pas index 95d591d1..f1e4ecac 100644 --- a/src/gui/fpg_checkbox.pas +++ b/src/gui/fpg_checkbox.pas @@ -36,9 +36,12 @@ type FOnChange: TNotifyEvent; FText: string; FFont: TfpgFont; + FBoxLayout: TBoxLayout; FBoxSize: integer; FIsPressed: boolean; + function GetBoxLayout: TBoxLayout; function GetFontDesc: string; + procedure SetBoxLayout(const AValue: TBoxLayout); procedure SetChecked(const AValue: boolean); procedure SetFontDesc(const AValue: string); procedure SetText(const AValue: string); @@ -50,6 +53,7 @@ type procedure HandleKeyRelease(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override; 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 Text: string read FText write SetText; property OnChange: TNotifyEvent read FOnChange write FOnChange; public @@ -62,6 +66,7 @@ type TfpgCheckBox = class(TfpgBaseCheckBox) published property BackgroundColor; + property BoxLayout; property Checked; property FontDesc; property ParentShowHint; @@ -100,11 +105,24 @@ begin RePaint; end; +function TfpgBaseCheckBox.GetBoxLayout: TBoxLayout; +begin + Result := FBoxLayout; +end; + function TfpgBaseCheckBox.GetFontDesc: string; begin Result := FFont.FontDesc; end; +procedure TfpgBaseCheckBox.SetBoxLayout(const AValue: TBoxLayout); +begin + if FBoxLayout = AValue then + Exit; //==> + FBoxLayout := AValue; + RePaint; +end; + procedure TfpgBaseCheckBox.SetFontDesc(const AValue: string); begin FFont.Free; @@ -148,7 +166,10 @@ begin end; Canvas.SetLineStyle(1, lsSolid); - r.SetRect(2, (Height div 2) - (FBoxSize div 2), FBoxSize, FBoxSize); + if FBoxLayout = tbLeftBox then + r.SetRect(2, (Height div 2) - (FBoxSize div 2), FBoxSize, FBoxSize) + else + r.SetRect(Width - FBoxSize - 2, (Height div 2) - (FBoxSize div 2), FBoxSize, FBoxSize); if r.top < 0 then r.top := 0; @@ -163,7 +184,10 @@ begin ix := (2 + (Ord(FChecked) * 2)) - Ord(FChecked); // paint the check (in this case a X) - tx := r.right + 8; + if FBoxLayout = tbLeftBox then + tx := r.right + 8 + else + tx := 0; inc(r.left, 2); inc(r.top, 1); img := fpgImages.GetImage('sys.checkboxes'); // Do NOT localize @@ -221,6 +245,7 @@ begin FChecked := False; FIsPressed := False; FOnChange := nil; + FBoxLayout := tbLeftBox; end; destructor TfpgBaseCheckBox.Destroy; diff --git a/src/gui/fpg_radiobutton.pas b/src/gui/fpg_radiobutton.pas index 1d58e0ea..540e19bf 100644 --- a/src/gui/fpg_radiobutton.pas +++ b/src/gui/fpg_radiobutton.pas @@ -40,9 +40,12 @@ type FGroupIndex: integer; FOnChange: TNotifyEvent; FText: string; + FBoxLayout: TBoxLayout; FBoxSize: integer; FIsPressed: boolean; + function GetBoxLayout: TBoxLayout; function GetFontDesc: string; + procedure SetBoxLayout(const AValue: TBoxLayout); procedure SetAutoSize(const AValue: boolean); procedure SetChecked(const AValue: boolean); procedure SetFontDesc(const AValue: string); @@ -64,6 +67,7 @@ type property BackgroundColor; 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 GroupIndex: integer read FGroupIndex write FGroupIndex; property ParentShowHint; property ShowHint; @@ -91,11 +95,24 @@ end; { TfpgRadioButton } +function TfpgRadioButton.GetBoxLayout: TBoxLayout; +begin + Result := FBoxLayout; +end; + function TfpgRadioButton.GetFontDesc: string; begin Result := FFont.FontDesc; end; +procedure TfpgRadioButton.SetBoxLayout(const AValue: TBoxLayout); +begin + if FBoxLayout = AValue then + Exit; //==> + FBoxLayout := AValue; + RePaint; +end; + procedure TfpgRadioButton.SetAutoSize(const AValue: boolean); begin if FAutoSize = AValue then @@ -184,7 +201,10 @@ begin end; Canvas.SetLineStyle(1, lsSolid); - r.SetRect(2, (Height div 2) - (FBoxSize div 2), FBoxSize, FBoxSize); + if FBoxLayout = tbLeftBox then + r.SetRect(2, (Height div 2) - (FBoxSize div 2), FBoxSize, FBoxSize) + else + r.SetRect(Width - FBoxSize - 2, (Height div 2) - (FBoxSize div 2), FBoxSize, FBoxSize); if r.top < 0 then r.top := 0; @@ -199,7 +219,10 @@ begin ix := (2 + (Ord(FChecked) * 2)) - Ord(FChecked); // paint the radio button - tx := r.right + 8; + if FBoxLayout = tbLeftBox then + tx := r.right + 8 + else + tx := 0; inc(r.left, 2); inc(r.top, 1); img := fpgImages.GetImage('sys.radiobuttons'); // Do NOT localize @@ -365,6 +388,7 @@ begin FIsPressed := False; FAutoSize := False; FOnChange := nil; + FBoxLayout := tbLeftBox; end; destructor TfpgRadioButton.Destroy; |