mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 20:41:37 +02:00
Basic implementation for RadioButton and CheckBox for fpgui
git-svn-id: trunk@11138 -
This commit is contained in:
parent
fc50c1c19f
commit
a8d0d39571
@ -182,6 +182,34 @@ type
|
|||||||
function GetText: String;
|
function GetText: String;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TFPGUIPrivateCheckBox }
|
||||||
|
|
||||||
|
TFPGUIPrivateCheckBox = class(TFPGUIPrivateWidget, ISimpleText)
|
||||||
|
private
|
||||||
|
protected
|
||||||
|
public
|
||||||
|
function CheckBox: TFCheckBox;
|
||||||
|
constructor Create(ALCLObject: TWinControl; const AParams: TCreateParams); override;
|
||||||
|
procedure CreateWidget(const AParams: TCreateParams); override;
|
||||||
|
// ISimpleText
|
||||||
|
procedure SetText(const AText: String);
|
||||||
|
function GetText: String;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TFPGUIPrivateRadioButton }
|
||||||
|
|
||||||
|
TFPGUIPrivateRadioButton = class(TFPGUIPrivateWidget, ISimpleText)
|
||||||
|
private
|
||||||
|
protected
|
||||||
|
public
|
||||||
|
function RadioButton: TFRadioButton;
|
||||||
|
constructor Create(ALCLObject: TWinControl; const AParams: TCreateParams); override;
|
||||||
|
procedure CreateWidget(const AParams: TCreateParams); override;
|
||||||
|
// ISimpleText
|
||||||
|
procedure SetText(const AText: String);
|
||||||
|
function GetText: String;
|
||||||
|
end;
|
||||||
|
|
||||||
{TFPGUIPrivateNotebook = class(TPrivateNotebook)
|
{TFPGUIPrivateNotebook = class(TPrivateNotebook)
|
||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
@ -513,5 +541,77 @@ begin
|
|||||||
Result := Edit.Text;
|
Result := Edit.Text;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TFPGUIPrivateCheckBox }
|
||||||
|
|
||||||
|
function TFPGUIPrivateCheckBox.CheckBox: TFCheckBox;
|
||||||
|
begin
|
||||||
|
Result := TFCheckBox(Widget);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TFPGUIPrivateCheckBox.Create(ALCLObject: TWinControl;
|
||||||
|
const AParams: TCreateParams);
|
||||||
|
begin
|
||||||
|
inherited Create(ALCLObject, AParams);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPGUIPrivateCheckBox.CreateWidget(const AParams: TCreateParams);
|
||||||
|
var
|
||||||
|
ParentContainer: TFPGUIPrivateContainer;
|
||||||
|
begin
|
||||||
|
ParentContainer := TFPGUIPrivateContainer(LCLObject.Parent.Handle);
|
||||||
|
|
||||||
|
Widget := TFCheckBox.Create(ParentContainer.Widget);
|
||||||
|
|
||||||
|
ParentContainer.AddChild(Widget);
|
||||||
|
|
||||||
|
Widget.SetBounds(LCLObject.Left, LCLObject.Top, LCLObject.Width, LCLObject.Height);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPGUIPrivateCheckBox.SetText(const AText: String);
|
||||||
|
begin
|
||||||
|
CheckBox.Text := AText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFPGUIPrivateCheckBox.GetText: String;
|
||||||
|
begin
|
||||||
|
Result := CheckBox.Text;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TFPGUIPrivateRadioButton }
|
||||||
|
|
||||||
|
function TFPGUIPrivateRadioButton.RadioButton: TFRadioButton;
|
||||||
|
begin
|
||||||
|
Result := TFRadioButton(Widget);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TFPGUIPrivateRadioButton.Create(ALCLObject: TWinControl;
|
||||||
|
const AParams: TCreateParams);
|
||||||
|
begin
|
||||||
|
inherited Create(ALCLObject, AParams);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPGUIPrivateRadioButton.CreateWidget(const AParams: TCreateParams);
|
||||||
|
var
|
||||||
|
ParentContainer: TFPGUIPrivateContainer;
|
||||||
|
begin
|
||||||
|
ParentContainer := TFPGUIPrivateContainer(LCLObject.Parent.Handle);
|
||||||
|
|
||||||
|
Widget := TFRadioButton.Create(ParentContainer.Widget);
|
||||||
|
|
||||||
|
ParentContainer.AddChild(Widget);
|
||||||
|
|
||||||
|
Widget.SetBounds(LCLObject.Left, LCLObject.Top, LCLObject.Width, LCLObject.Height);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPGUIPrivateRadioButton.SetText(const AText: String);
|
||||||
|
begin
|
||||||
|
RadioButton.Text := AText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFPGUIPrivateRadioButton.GetText: String;
|
||||||
|
begin
|
||||||
|
Result := RadioButton.Text;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -178,6 +178,18 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
|
class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override;
|
||||||
|
class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
|
||||||
|
const OldShortCut, NewShortCut: TShortCut); override;
|
||||||
|
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override;
|
||||||
|
public
|
||||||
|
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||||
|
|
||||||
|
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||||
|
|
||||||
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
|
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
|
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFpGuiWSCheckBox }
|
{ TFpGuiWSCheckBox }
|
||||||
@ -202,6 +214,18 @@ type
|
|||||||
private
|
private
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
|
class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override;
|
||||||
|
class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
|
||||||
|
const OldShortCut, NewShortCut: TShortCut); override;
|
||||||
|
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override;
|
||||||
|
public
|
||||||
|
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||||
|
|
||||||
|
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||||
|
|
||||||
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
|
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
|
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFpGuiWSCustomStaticText }
|
{ TFpGuiWSCustomStaticText }
|
||||||
@ -352,6 +376,140 @@ begin
|
|||||||
vEdit.Text := AText;
|
vEdit.Text := AText;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TFpGuiWSCustomCheckBox }
|
||||||
|
|
||||||
|
class function TFpGuiWSCustomCheckBox.RetrieveState(
|
||||||
|
const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
|
||||||
|
var
|
||||||
|
vCheckBox: TFCheckBox;
|
||||||
|
begin
|
||||||
|
vCheckBox := TFPGUIPrivateCheckBox(ACustomCheckBox.Handle).CheckBox;
|
||||||
|
|
||||||
|
if vCheckBox.Checked then Result := cbChecked
|
||||||
|
else Result := cbUnchecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TFpGuiWSCustomCheckBox.SetShortCut(
|
||||||
|
const ACustomCheckBox: TCustomCheckBox; const OldShortCut,
|
||||||
|
NewShortCut: TShortCut);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TFpGuiWSCustomCheckBox.SetState(
|
||||||
|
const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
|
||||||
|
var
|
||||||
|
vCheckBox: TFCheckBox;
|
||||||
|
begin
|
||||||
|
vCheckBox := TFPGUIPrivateCheckBox(ACustomCheckBox.Handle).CheckBox;
|
||||||
|
|
||||||
|
if NewState = cbChecked then vCheckBox.Checked := True
|
||||||
|
else vCheckBox.Checked := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TFpGuiWSCustomCheckBox.GetText(const AWinControl: TWinControl;
|
||||||
|
var AText: String): Boolean;
|
||||||
|
var
|
||||||
|
vCheckBox: TFCheckBox;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
vCheckBox := TFPGUIPrivateCheckBox(AWinControl.Handle).CheckBox;
|
||||||
|
|
||||||
|
AText := vCheckBox.Text;
|
||||||
|
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TFpGuiWSCustomCheckBox.SetText(const AWinControl: TWinControl;
|
||||||
|
const AText: String);
|
||||||
|
var
|
||||||
|
vCheckBox: TFCheckBox;
|
||||||
|
begin
|
||||||
|
vCheckBox := TFPGUIPrivateCheckBox(AWinControl.Handle).CheckBox;
|
||||||
|
|
||||||
|
vCheckBox.Text := AText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TFpGuiWSCustomCheckBox.CreateHandle(
|
||||||
|
const AWinControl: TWinControl; const AParams: TCreateParams
|
||||||
|
): TLCLIntfHandle;
|
||||||
|
begin
|
||||||
|
Result := TLCLIntfHandle(TFPGUIPrivateCheckBox.Create(AWinControl, AParams));
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TFpGuiWSCustomCheckBox.DestroyHandle(
|
||||||
|
const AWinControl: TWinControl);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TFpGuiWSRadioButton }
|
||||||
|
|
||||||
|
class function TFpGuiWSRadioButton.RetrieveState(
|
||||||
|
const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
|
||||||
|
var
|
||||||
|
vRadioButton: TFRadioButton;
|
||||||
|
begin
|
||||||
|
vRadioButton := TFPGUIPrivateRadioButton(ACustomCheckBox.Handle).RadioButton;
|
||||||
|
|
||||||
|
if vRadioButton.Checked then Result := cbChecked
|
||||||
|
else Result := cbUnchecked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TFpGuiWSRadioButton.SetShortCut(
|
||||||
|
const ACustomCheckBox: TCustomCheckBox; const OldShortCut,
|
||||||
|
NewShortCut: TShortCut);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TFpGuiWSRadioButton.SetState(
|
||||||
|
const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
|
||||||
|
var
|
||||||
|
vRadioButton: TFRadioButton;
|
||||||
|
begin
|
||||||
|
vRadioButton := TFPGUIPrivateRadioButton(ACustomCheckBox.Handle).RadioButton;
|
||||||
|
|
||||||
|
if NewState = cbChecked then vRadioButton.Checked := True
|
||||||
|
else vRadioButton.Checked := False;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TFpGuiWSRadioButton.GetText(const AWinControl: TWinControl;
|
||||||
|
var AText: String): Boolean;
|
||||||
|
var
|
||||||
|
vRadioButton: TFRadioButton;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
|
||||||
|
vRadioButton := TFPGUIPrivateRadioButton(AWinControl.Handle).RadioButton;
|
||||||
|
|
||||||
|
AText := vRadioButton.Text;
|
||||||
|
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TFpGuiWSRadioButton.SetText(const AWinControl: TWinControl;
|
||||||
|
const AText: String);
|
||||||
|
var
|
||||||
|
vRadioButton: TFRadioButton;
|
||||||
|
begin
|
||||||
|
vRadioButton := TFPGUIPrivateRadioButton(AWinControl.Handle).RadioButton;
|
||||||
|
|
||||||
|
vRadioButton.Text := AText;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TFpGuiWSRadioButton.CreateHandle(const AWinControl: TWinControl;
|
||||||
|
const AParams: TCreateParams): TLCLIntfHandle;
|
||||||
|
begin
|
||||||
|
Result := TLCLIntfHandle(TFPGUIPrivateRadioButton.Create(AWinControl, AParams));
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TFpGuiWSRadioButton.DestroyHandle(const AWinControl: TWinControl);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
@ -374,11 +532,10 @@ initialization
|
|||||||
// RegisterWSComponent(TCustomLabel, TFpGuiWSCustomLabel);
|
// RegisterWSComponent(TCustomLabel, TFpGuiWSCustomLabel);
|
||||||
// RegisterWSComponent(TLabel, TFpGuiWSLabel);
|
// RegisterWSComponent(TLabel, TFpGuiWSLabel);
|
||||||
// RegisterWSComponent(TButtonControl, TFpGuiWSButtonControl);
|
// RegisterWSComponent(TButtonControl, TFpGuiWSButtonControl);
|
||||||
// RegisterWSComponent(TCustomCheckBox, TFpGuiWSCustomCheckBox);
|
RegisterWSComponent(TCustomCheckBox, TFpGuiWSCustomCheckBox);
|
||||||
// RegisterWSComponent(TCheckBox, TFpGuiWSCheckBox);
|
|
||||||
// RegisterWSComponent(TCheckBox, TFpGuiWSCheckBox);
|
// RegisterWSComponent(TCheckBox, TFpGuiWSCheckBox);
|
||||||
// RegisterWSComponent(TToggleBox, TFpGuiWSToggleBox);
|
// RegisterWSComponent(TToggleBox, TFpGuiWSToggleBox);
|
||||||
// RegisterWSComponent(TRadioButton, TFpGuiWSRadioButton);
|
RegisterWSComponent(TRadioButton, TFpGuiWSRadioButton);
|
||||||
// RegisterWSComponent(TCustomStaticText, TFpGuiWSCustomStaticText);
|
// RegisterWSComponent(TCustomStaticText, TFpGuiWSCustomStaticText);
|
||||||
// RegisterWSComponent(TStaticText, TFpGuiWSStaticText);
|
// RegisterWSComponent(TStaticText, TFpGuiWSStaticText);
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user