Qt: introduced TQtToolBox class, fixed problem with messages delivery to LCL. issue #18757

git-svn-id: trunk@29569 -
This commit is contained in:
zeljko 2011-02-15 21:54:45 +00:00
parent 0394cf0a93
commit f73311c159
2 changed files with 53 additions and 6 deletions

View File

@ -490,6 +490,7 @@ type
TQtPushButton = class(TQtAbstractButton)
private
FClickedHook: QAbstractButton_hookH;
FToggledHook: QAbstractButton_hookH;
protected
function CreateWidget(const AParams: TCreateParams): QWidgetH; override;
public
@ -499,7 +500,16 @@ type
procedure AttachEvents; override;
procedure DetachEvents; override;
procedure SlotClicked; cdecl;
procedure SlotClicked; cdecl; virtual;
procedure SlotToggled(AChecked: Boolean); cdecl; virtual;
end;
{ TQtToggleBox }
TQtToggleBox = class(TQtPushButton)
public
procedure SlotClicked; cdecl; override;
procedure SlotToggled(AChecked: Boolean); cdecl; override;
end;
{ TQtMainWindow }
@ -4672,11 +4682,15 @@ begin
FClickedHook := QAbstractButton_hook_create(Widget);
QAbstractButton_hook_hook_clicked2(FClickedHook, @SlotClicked);
FToggledHook := QAbstractButton_hook_create(Widget);
QAbstractButton_hook_hook_toggled(FToggledHook, @SlotToggled);
end;
procedure TQtPushButton.DetachEvents;
begin
QAbstractButton_hook_destroy(FClickedHook);
QAbstractButton_hook_destroy(FToggledHook);
inherited DetachEvents;
end;
@ -4694,6 +4708,31 @@ begin
DeliverMessage(Msg);
end;
procedure TQtPushButton.SlotToggled(AChecked: Boolean); cdecl;
begin
// override later (eg. TQtToggleBox)
end;
{ TQtToggleBox }
procedure TQtToggleBox.SlotClicked; cdecl;
begin
// do nothing with ToggleBox
end;
procedure TQtToggleBox.SlotToggled(AChecked: Boolean); cdecl;
var
Msg: TLMessage;
begin
if InUpdate then
exit;
FillChar(Msg, SizeOf(Msg), #0);
Msg.Msg := LM_CHANGED;
DeliverMessage(Msg);
end;
{ TQtMainWindow }
function TQtMainWindow.CreateWidget(const AParams: TCreateParams): QWidgetH;

View File

@ -1490,7 +1490,9 @@ end;
------------------------------------------------------------------------------}
class function TQtWSToggleBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
begin
if TQtPushButton(ACustomCheckBox.Handle).isDown then
if not WSCheckHandleAllocated(ACustomCheckBox, 'RetrieveState') then
Exit;
if TQtToggleBox(ACustomCheckBox.Handle).isChecked then
Result := cbChecked
else
Result := cbUnChecked;
@ -1504,7 +1506,9 @@ end;
class procedure TQtWSToggleBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut);
begin
TQtPushButton(ACustomCheckBox.Handle).setShortcut(NewShortCut);
if not WSCheckHandleAllocated(ACustomCheckBox, 'SetShortCut') then
Exit;
TQtToggleBox(ACustomCheckBox.Handle).setShortcut(NewShortCut);
end;
{------------------------------------------------------------------------------
@ -1514,7 +1518,11 @@ end;
------------------------------------------------------------------------------}
class procedure TQtWSToggleBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
begin
TQtPushButton(ACustomCheckBox.Handle).setDown(NewState = cbChecked)
if not WSCheckHandleAllocated(ACustomCheckBox, 'SetState') then
Exit;
TQtToggleBox(ACustomCheckBox.Handle).BeginUpdate;
TQtToggleBox(ACustomCheckBox.Handle).setChecked(NewState = cbChecked);
TQtToggleBox(ACustomCheckBox.Handle).EndUpdate;
end;
{------------------------------------------------------------------------------
@ -1526,9 +1534,9 @@ end;
------------------------------------------------------------------------------}
class function TQtWSToggleBox.CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle;
var
QtToggleBox: TQtPushButton;
QtToggleBox: TQtToggleBox;
begin
QtToggleBox := TQtPushButton.Create(AWinControl, AParams);
QtToggleBox := TQtToggleBox.Create(AWinControl, AParams);
QtToggleBox.setCheckable(True);
QtToggleBox.AttachEvents;