- Removed unnecessary code from radiogroup and checkgroup since LCL do all the job itself
- Removed dummy DestroyHandles. TQtWSWinControl.DestroyHandle will be used in most cases

git-svn-id: trunk@11582 -
This commit is contained in:
paul 2007-07-20 02:06:55 +00:00
parent 0daf4ff929
commit 55f077b595
10 changed files with 66 additions and 563 deletions

View File

@ -65,6 +65,8 @@ type
private
FProps: TStringList;
FPaintData: TPaintData;
FCentralWidget: QWidgetH;
function GetProps(const AnIndex: String): pointer;
function GetWidget: QWidgetH;
function LCLKeyToQtKey(AKey: Word): Integer;
@ -113,6 +115,7 @@ type
procedure Hide;
procedure Show;
function getVisible: Boolean;
function getClientOffset: TQtPoint;
function hasFocus: Boolean;
procedure setEnabled(p1: Boolean);
procedure setVisible(visible: Boolean);
@ -194,20 +197,17 @@ type
TQtMainWindow = class(TQtWidget)
private
LayoutWidget: QBoxLayoutH;
protected
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
public
LayoutWidget: QBoxLayoutH;
{$ifdef USE_QT_4_3}
MDIAreaHandle: QMDIAreaH;
{$endif}
CentralWidget: QWidgetH;
Splitter: QSplitterH;
MenuBar: TQtMenuBar;
ToolBar: TQtToolBar;
Canvas: TQtDeviceContext;
destructor Destroy; override;
function GetContainerWidget: QWidgetH; override;
procedure setTabOrders;
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
procedure SlotWindowStateChange; cdecl;
@ -267,7 +267,6 @@ type
procedure AttachEvents; override;
procedure DetachEvents; override;
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
procedure signalStateChanged(p1: Integer); cdecl;
end;
@ -284,22 +283,19 @@ type
public
procedure AttachEvents; override;
procedure DetachEvents; override;
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
end;
{ TQtGroupBox }
TQtGroupBox = class(TQtWidget)
private
LayoutWidget: QBoxLayoutH;
protected
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
private
public
destructor Destroy; override;
public
ButtonGroup: TQtButtonGroup;
BoxLayout: QGridLayoutH;
end;
{ TQtAbstractSlider , inherited by TQtScrollBar, TQtTrackBar }
TQtAbstractSlider = class(TQtWidget)
@ -434,7 +430,6 @@ type
procedure AttachEvents; override;
procedure DetachEvents; override;
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
procedure SignalCurrentChanged(Index: Integer); cdecl;
public
function insertTab(index: Integer; page: QWidgetH; p2: PWideString): Integer;
@ -872,7 +867,10 @@ end;
------------------------------------------------------------------------------}
function TQtWidget.GetContainerWidget: QWidgetH;
begin
Result := Widget;
if FCentralWidget <> nil then
Result := FCentralWidget
else
Result := Widget;
end;
{$IFDEF VerboseQt}
@ -1588,6 +1586,12 @@ begin
Result := QWidget_isVisible(Widget);
end;
function TQtWidget.getClientOffset: TQtPoint;
begin
Result.x := QWidget_width(Widget) - QWidget_width(GetContainerWidget);
Result.y := QWidget_height(Widget) - QWidget_height(GetContainerWidget);
end;
function TQtWidget.hasFocus: Boolean;
begin
Result := QWidget_hasFocus(Widget);
@ -2339,19 +2343,19 @@ begin
and not (csDesigning in LCLObject.ComponentState) then
begin
MDIAreaHandle := QMdiArea_create(Result);
CentralWidget := MDIAreaHandle;
FCentralWidget := MDIAreaHandle;
end
else
begin
CentralWidget := QWidget_create(Result);
FCentralWidget := QWidget_create(Result);
MDIAreaHandle := nil
end;
QMainWindow_setCentralWidget(QMainWindowH(Result), CentralWidget);
QMainWindow_setCentralWidget(QMainWindowH(Result), FCentralWidget);
QMainWindow_setDockOptions(QMainWindowH(Result), QMainWindowAnimatedDocks);
{$else}
CentralWidget := QWidget_create(Result);
FCentralWidget := QWidget_create(Result);
QMainWindow_setCentralWidget(QMainWindowH(Result), CentralWidget);
QMainWindow_setCentralWidget(QMainWindowH(Result), FCentralWidget);
{$endif}
end
else
@ -2369,8 +2373,7 @@ begin
// QMdiSubWindow already have an layout
LayoutWidget := QBoxLayoutH(QWidget_layout(Result));
if LayoutWidget <> nil
then
if LayoutWidget <> nil then
QBoxLayout_destroy(LayoutWidget);
end
else
@ -2381,7 +2384,7 @@ begin
// Main menu bar
MenuBar := TQtMenuBar.Create(Result);
CentralWidget := QWidget_create(Result);
FCentralWidget := QWidget_create(Result);
LayoutWidget := QBoxLayout_create(QBoxLayoutTopToBottom, Result);
@ -2394,7 +2397,7 @@ begin
{$endif}
QLayout_setMenuBar(LayoutWidget, MenuBar.Widget);
QLayout_addWidget(LayoutWidget, CentralWidget);
QLayout_addWidget(LayoutWidget, FCentralWidget);
QWidget_setLayout(Result, QLayoutH(LayoutWidget));
end;
end;
@ -2428,21 +2431,6 @@ begin
inherited Destroy;
end;
{------------------------------------------------------------------------------
Function: TQtMainWindow.GetContainerWidget
Params: None
Returns: Nothing
The main window has a special container widget to handle the size of the menu
------------------------------------------------------------------------------}
function TQtMainWindow.GetContainerWidget: QWidgetH;
begin
if (CentralWidget <> nil) then
Result := CentralWidget
else
Result := Widget;
end;
{------------------------------------------------------------------------------
Function: TQtMainWindow.setTabOrders
Params: None
@ -2726,22 +2714,8 @@ begin
WriteLn('TQtCheckBox.Create');
{$endif}
if (LCLObject.Parent is TCustomCheckGroup) then
begin
Result := QCheckBox_create;
QGridLayout_addWidget(TQtGroupBox(LCLObject.Parent.Handle).BoxLayout, Result);
if TQtGroupBox(LCLObject.Parent.Handle).ButtonGroup.GetExclusive then
TQtGroupBox(LCLObject.Parent.Handle).ButtonGroup.SetExclusive(False);
TQtGroupBox(LCLObject.Parent.Handle).ButtonGroup.AddButton(QCheckBoxH(Result));
end
else
begin
Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget;
Result := QCheckBox_create(Parent);
end;
Result := QCheckBox_create;
QWidget_setVisible(Result, False);
end;
procedure TQtCheckBox.SetGeometry;
@ -2772,18 +2746,6 @@ begin
inherited Destroy;
end;
{------------------------------------------------------------------------------
Function: TQtCheckBox.EventFilter
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
function TQtCheckBox.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
begin
Result := False;
inherited EventFilter(Sender, Event);
end;
{------------------------------------------------------------------------------
Function: TQtCheckBox.CheckState
Params: None
@ -2837,39 +2799,15 @@ end;
{ TQtRadioButton }
function TQtRadioButton.CreateWidget(const AParams: TCreateParams): QWidgetH;
var
Parent: QWidgetH;
begin
// Creates the widget
{$ifdef VerboseQt}
WriteLn('TQtRadioButton.Create');
{$endif}
if (LCLObject.Parent is TCustomRadioGroup) then
begin
Result := QRadioButton_create;
{$ifdef QT_HIDDEN_BUTTON_WORKAROUND}
if LCLObject.Name = 'HiddenRadioButton' then
QWidget_hide(Result)
else
begin
{$endif}
QGridLayout_addWidget(TQtGroupBox(LCLObject.Parent.Handle).BoxLayout, Result);
if not TQtGroupBox(LCLObject.Parent.Handle).ButtonGroup.GetExclusive then
TQtGroupBox(LCLObject.Parent.Handle).ButtonGroup.SetExclusive(True);
TQtGroupBox(LCLObject.Parent.Handle).ButtonGroup.AddButton(QRadioButtonH(Result));
{$ifdef QT_HIDDEN_BUTTON_WORKAROUND}
end;
{$endif}
end
else
begin
Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget;
Result := QRadioButton_create(Parent);
end;
Result := QRadioButton_create();
// hide widget by default
QWidget_hide(Result);
end;
procedure TQtRadioButton.SetGeometry;
@ -2917,19 +2855,6 @@ begin
inherited DetachEvents;
end;
{------------------------------------------------------------------------------
Function: TQtRadioButton.EventFilter
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
function TQtRadioButton.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
begin
Result := False;
// Inherited Callbacks
inherited EventFilter(Sender, Event);
end;
{ TQtGroupBox }
function TQtGroupBox.CreateWidget(const AParams: TCreateParams): QWidgetH;
@ -2942,8 +2867,21 @@ begin
{$endif}
Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget;
Result := QGroupBox_create(Parent);
end;
FCentralWidget := QWidget_create(Result);
LayoutWidget := QBoxLayout_create(QBoxLayoutTopToBottom, Result);
{$ifdef USE_QT_4_3}
QBoxLayout_setSpacing(LayoutWidget, 0);
QLayout_setContentsMargins(LayoutWidget, 0, 0, 0, 0);
{$else}
QLayout_setSpacing(LayoutWidget, 0);
QLayout_setMargin(LayoutWidget, 0);
{$endif}
QLayout_addWidget(LayoutWidget, FCentralWidget);
QWidget_setLayout(Result, QLayoutH(LayoutWidget));
end;
{------------------------------------------------------------------------------
Function: TQtGroupBox.Destroy
@ -3835,19 +3773,6 @@ begin
inherited DetachEvents;
end;
{------------------------------------------------------------------------------
Function: TQtTabWidget.EventFilter
Params: QObjectH, QEventH
Returns: boolean
Overrides TQtWidget EventFilter()
------------------------------------------------------------------------------}
function TQtTabWidget.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
begin
Result := False;
inherited EventFilter(Sender, Event);
end;
{------------------------------------------------------------------------------
Function: TQtTabWidget.insertTab
Params: None
@ -5659,11 +5584,8 @@ end;
function TQtHintWindow.CreateWidget(const AParams: TCreateParams): QWidgetH;
begin
Result := QWidget_create(nil, QtToolTip);
MenuBar := nil;
CentralWidget := nil;
LayoutWidget := nil;
end;
end.
@ -5671,3 +5593,5 @@ end.

View File

@ -49,7 +49,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure SetType(const AArrow: TArrow; const AArrowType: TArrowType;
const AShadowType: TShadowType); override;
end;
@ -108,18 +107,6 @@ begin
{$endif}
end;
{------------------------------------------------------------------------------
Method: TQtWSArrow.Destroy
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSArrow.DestroyHandle(const AWinControl: TWinControl);
begin
TQtArrow(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSArrow.SetType
Params: None

View File

@ -48,7 +48,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
// class procedure SetShortcut(const AButton: TCustomButton; const OldShortcut, NewShortcut: TShortcut); override;
@ -98,20 +97,6 @@ begin
Result := THandle(QtPushButton);
end;
{------------------------------------------------------------------------------
Function: TQtWSBitBtn.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSBitBtn.DestroyHandle(const AWinControl: TWinControl);
begin
TQtPushButton(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Function: TQtWSBitBtn.GetText
Params: None

View File

@ -48,7 +48,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
public
class function GetDateTime(const ACalendar: TCustomCalendar): TDateTime; override;
class procedure SetDateTime(const ACalendar: TCustomCalendar; const ADateTime: TDateTime); override;
@ -75,12 +74,6 @@ begin
Result := THandle(QtCalendar);
end;
class procedure TQtWSCustomCalendar.DestroyHandle(const AWinControl: TWinControl);
begin
TQtCalendar(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
class procedure TQtWSCustomCalendar.SetReadOnly(const ACalendar: TCustomCalendar; const AReadOnly: boolean);
var
QtCalendar: TQtCalendar;

View File

@ -80,7 +80,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
public
class procedure ColumnDelete(const ALV: TCustomListView; const AIndex: Integer); override;
class procedure ColumnInsert(const ALV: TCustomListView; const AIndex: Integer; const AColumn: TListColumn); override;
@ -171,7 +170,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure ApplyChanges(const AProgressBar: TCustomProgressBar); override;
class procedure SetPosition(const AProgressBar: TCustomProgressBar; const NewPosition: integer); override;
end;
@ -199,7 +197,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
class procedure SetColor(const AWinControl: TWinControl); override;
@ -212,7 +209,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure SetColor(const AWinControl: TWinControl); override;
end;
@ -223,7 +219,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure ApplyChanges(const ATrackBar: TCustomTrackBar); override;
class function GetPosition(const ATrackBar: TCustomTrackBar): integer; override;
class procedure SetPosition(const ATrackBar: TCustomTrackBar; const NewPosition: integer); override;
@ -261,17 +256,6 @@ begin
Result := THandle(QtToolButton);
end;
{------------------------------------------------------------------------------
Method: TQtWSToolButton.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSToolButton.DestroyHandle(const AWinControl: TWinControl);
begin
TQtToolButton(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSToolButton.GetText
@ -340,18 +324,6 @@ begin
Result := THandle(QtToolBar);
end;
{------------------------------------------------------------------------------
Method: TQtWSToolBar.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSToolBar.DestroyHandle(const AWinControl: TWinControl);
begin
TQtToolBar(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSToolBar.SetColor
Params: None
@ -389,12 +361,6 @@ begin
Result := THandle(QtTrackBar);
end;
class procedure TQtWSTrackBar.DestroyHandle(const AWinControl: TWinControl);
begin
TQtTrackBar(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
class procedure TQtWSTrackBar.ApplyChanges(const ATrackBar: TCustomTrackBar);
var
QtTrackBar: TQtTrackBar;
@ -464,13 +430,6 @@ begin
Result := THandle(QtProgressBar);
end;
class procedure TQtWSProgressBar.DestroyHandle(const AWinControl: TWinControl);
begin
TQtProgressBar(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
class procedure TQtWSProgressBar.ApplyChanges(const AProgressBar: TCustomProgressBar);
var
QtProgressBar: TQtProgressBar;
@ -764,17 +723,6 @@ begin
Result := THandle(QtTreeWidget);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListView.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomListView.DestroyHandle(const AWinControl: TWinControl);
begin
TQtTreeWidget(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListView.ColumnDelete
Params: None

View File

@ -69,6 +69,7 @@ type
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure Invalidate(const AWinControl: TWinControl); override;
public
class procedure AddControl(const AControl: TControl); override;
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
class procedure SetPos(const AWinControl: TWinControl; const ALeft, ATop: Integer); override;
@ -81,7 +82,7 @@ type
// class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
// class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
{ class procedure AddControl(const AControl: TControl); override;
{
class procedure SetChildZPosition(const AWinControl, AChild: TWinControl;
const AOldPos, ANewPos: Integer;
@ -106,8 +107,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure Invalidate(const AWinControl: TWinControl); override;
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
end;
@ -153,28 +152,6 @@ begin
{$endif}
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomControl.Destroy
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomControl.DestroyHandle(const AWinControl: TWinControl);
begin
TQtAbstractScrollArea(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomControl.Invalidate
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomControl.Invalidate(const AWinControl: TWinControl);
begin
TQtAbstractScrollArea(AWinControl.Handle).Update;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomControl.ShowHide
Params: AWinControl - the calling object
@ -298,6 +275,12 @@ begin
TQtWidget(AWinControl.Handle).Update;
end;
class procedure TQtWSWinControl.AddControl(const AControl: TControl);
begin
if (AControl is TWinControl) and (TWinControl(AControl).HandleAllocated) then
TQtWidget(TWinControl(AControl).Handle).setParent(TQtWidget(AControl.Parent.Handle).GetContainerWidget);
end;
{------------------------------------------------------------------------------
Method: TQtWSWinControl.SetBounds
Params: AWinControl - the calling object
@ -366,11 +349,8 @@ begin
if AWinControl.HandleObjectShouldBeVisible and (Widget is TQtMainWindow) then
TQtMainWindow(Widget).SetTabOrders;
if AWinControl.HandleObjectShouldBeVisible then
QWidget_setVisible(Widget.Widget, True)
else
QWidget_setVisible(Widget.Widget, False);
Widget.setVisible(AWinControl.HandleObjectShouldBeVisible);
{$ifdef VerboseQt}
Write('Trace:< [TQtWSWinControl.ShowHide] ');

View File

@ -49,7 +49,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
// class procedure UpdateProperties(const ACustomPage: TCustomPage); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
end;
@ -62,7 +61,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure AddAllNBPages(const ANotebook: TCustomNotebook);
{ class procedure AdjustSizeNotebookPages(const ANotebook: TCustomNotebook);}
class procedure AddPage(const ANotebook: TCustomNotebook;
@ -160,7 +158,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
end;
@ -180,7 +177,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure ShowHide(const AWinControl: TWinControl); override;
end;
@ -216,7 +212,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
end;
{ TQtWSPanel }
@ -268,20 +263,6 @@ begin
Result := THandle(QtFrame);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomGroupBox.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomPanel.DestroyHandle(const AWinControl: TWinControl);
begin
TQtFrame(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{ TQtWSCustomPage }
{------------------------------------------------------------------------------
@ -311,20 +292,6 @@ begin
{$endif}
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomPage.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomPage.DestroyHandle(const AWinControl: TWinControl);
begin
TQtWidget(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
class procedure TQtWSCustomPage.SetText(const AWinControl: TWinControl; const AText: string);
var
ANoteBook: TCustomNoteBook;
@ -368,20 +335,6 @@ begin
Result := THandle(QtTabWidget);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomNotebook.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomNotebook.DestroyHandle(const AWinControl: TWinControl);
begin
TQtTabWidget(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
class procedure TQtWSCustomNotebook.AddAllNBPages(const ANotebook: TCustomNotebook);
begin
@ -424,57 +377,16 @@ var
Str: WideString;
i: Integer;
begin
QtGroupBox := TQtGroupBox.Create(AWinControl, AParams);
Str := UTF8Decode(AWinControl.Caption);
QGroupBox_setTitle(QGroupBoxH(QtGroupBox.Widget), @Str);
QtGroupBox.BoxLayout := QGridLayout_create(QtGroupBox.Widget);
QWidget_setLayout(QtGroupBox.Widget, QtGroupBox.BoxLayout);
QtGroupBox.ButtonGroup := TQtButtonGroup.Create(QtGroupBox.Widget);
{QGridLayout don't know anything about TCustomRadioGroup Col count so initialize cols }
for i := 0 to TCustomRadioGroup(AWinControl).Columns - 1 do
begin
QGridLayout_setColumnMinimumWidth(QtGroupBox.BoxLayout, i, 32);
QGridLayout_setColumnStretch(QtGroupBox.BoxLayout, i, 0);
end;
{QGridLayout don't know anything about TCustomRadioGroup Row count so initialize rows }
for i := 0 to TCustomRadioGroup(AWinControl).Items.Count - 1 do
begin
QGridLayout_setRowMinimumHeight(QtGroupBox.BoxLayout, i, 22 {default height of radiobutton});
QGridLayout_setRowStretch(QtGroupBox.BoxLayout, i, 0);
end;
QtGroupBox.AttachEvents;
Result := THandle(QtGroupBox);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomRadioGroup.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomRadioGroup.DestroyHandle(const AWinControl: TWinControl);
begin
if Assigned(TQtGroupBox(AWinControl.Handle).ButtonGroup) then
TQtGroupBox(AWinControl.Handle).ButtonGroup.Free;
if TQtGroupBox(AWinControl.Handle).BoxLayout <> NiL then
QGridLayout_destroy(TQtGroupBox(AWinControl.Handle).BoxLayout);
TQtGroupBox(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
class procedure TQtWSCustomRadioGroup.ShowHide(const AWinControl: TWinControl);
var
i: Integer;
@ -526,56 +438,16 @@ var
Str: WideString;
i: Integer;
begin
QtGroupBox := TQtGroupBox.Create(AWinControl, AParams);
Str := UTF8Decode(AWinControl.Caption);
QGroupBox_setTitle(QGroupBoxH(QtGroupBox.Widget), @Str);
QtGroupBox.BoxLayout := QGridLayout_create(QtGroupBox.Widget);
QWidget_setLayout(QtGroupBox.Widget, QtGroupBox.BoxLayout);
QtGroupBox.ButtonGroup := TQtButtonGroup.Create(QtGroupBox.Widget);
{QGridLayout don't know anything about TCustomCheckGroup Col count so initialize cols }
for i := 0 to TCustomCheckGroup(AWinControl).Columns - 1 do
begin
QGridLayout_setColumnMinimumWidth(QtGroupBox.BoxLayout, i, 32);
QGridLayout_setColumnStretch(QtGroupBox.BoxLayout, i, 0);
end;
{QGridLayout don't know anything about TCustomCheckGroup Row count so initialize rows }
for i := 0 to TCustomCheckGroup(AWinControl).Items.Count - 1 do
begin
QGridLayout_setRowMinimumHeight(QtGroupBox.BoxLayout, i, 22 {default height of checkbox});
QGridLayout_setRowStretch(QtGroupBox.BoxLayout, i, 0);
end;
QtGroupBox.AttachEvents;
Result := THandle(QtGroupBox);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomCheckGroup.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomCheckGroup.DestroyHandle(const AWinControl: TWinControl);
begin
if Assigned(TQtGroupBox(AWinControl.Handle).ButtonGroup) then
TQtGroupBox(AWinControl.Handle).ButtonGroup.Free;
if TQtGroupBox(AWinControl.Handle).BoxLayout <> NiL then
QGridLayout_destroy(TQtGroupBox(AWinControl.Handle).BoxLayout);
TQtGroupBox(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
class procedure TQtWSCustomCheckGroup.ShowHide(const AWinControl: TWinControl);
var
i: Integer;

View File

@ -82,7 +82,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
@ -196,22 +195,6 @@ begin
Result := THandle(QtMainWindow);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomForm.DestroyHandle
Params: None
Returns: Nothing
Destroys a Qt Form and releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomForm.DestroyHandle(const AWinControl: TWinControl);
begin
{$ifdef VerboseQt}
WriteLn('[TQtWSCustomForm.DestroyHandle]');
{$endif}
TQtMainWindow(AWinControl.Handle).Free;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomForm.GetText
Params: AWinControl - the calling object

View File

@ -49,7 +49,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override;
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
@ -116,21 +115,6 @@ begin
end;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomFloatSpinEdit.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomFloatSpinEdit.DestroyHandle(const AWinControl: TWinControl);
begin
if TCustomFloatSpinEdit(AWinControl).DecimalPlaces > 0 then
TQtFloatSpinBox(AWinControl.Handle).Free
else
TQtSpinBox(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
class function TQtWSCustomFloatSpinEdit.GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single;
begin
if ACustomFloatSpinEdit.DecimalPlaces > 0 then

View File

@ -49,7 +49,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure SetParams(const AScrollBar: TCustomScrollBar); override;
end;
@ -61,7 +60,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
end;
{ TQtWSGroupBox }
@ -80,7 +78,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
public
{ class function GetSelStart(const ACustomComboBox: TCustomComboBox): integer; override;
class function GetSelLength(const ACustomComboBox: TCustomComboBox): integer; override;}
@ -118,7 +115,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
public
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
@ -152,7 +148,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
public
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
@ -180,7 +175,6 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
public
class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override;
class procedure SetAlignment(const ACustomMemo: TCustomMemo; const AAlignment: TAlignment); override;
@ -236,7 +230,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
// class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
// class procedure SetShortcut(const AButton: TCustomButton; const OldShortcut, NewShortcut: TShortcut); override;
@ -263,7 +256,6 @@ type
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
end;
{ TQtWSCheckBox }
@ -292,7 +284,6 @@ type
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
end;
{ TQtWSRadioButton }
@ -307,12 +298,10 @@ type
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;
{ TQtWSCustomStaticText }
@ -322,7 +311,6 @@ type
protected
public
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure DestroyHandle(const AWinControl: TWinControl); override;
class procedure SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment); override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
@ -382,18 +370,6 @@ begin
Result := THandle(QtScrollbar);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomScrollBar.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSScrollBar.DestroyHandle(const AWinControl: TWinControl);
begin
TQtScrollBar(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomScrollBar.SetParams
Params: None
@ -470,17 +446,6 @@ begin
Result := THandle(QtListWidget);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListBox.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomListBox.DestroyHandle(const AWinControl: TWinControl);
begin
TQtListWidget(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomListBox.GetSelCount
Params: None
@ -671,18 +636,6 @@ begin
Result := THandle(QtTextEdit);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomMemo.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomMemo.DestroyHandle(const AWinControl: TWinControl);
begin
TQtTextEdit(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomMemo.AppendText
Params: None
@ -800,17 +753,6 @@ begin
Result := THandle(QtLineEdit);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomEdit.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomEdit.DestroyHandle(const AWinControl: TWinControl);
begin
TQtLineEdit(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomEdit.GetText
Params: None
@ -922,18 +864,6 @@ begin
Result := THandle(QtStaticText);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomStaticText.DestroyHandle
Params: None
Returns: Nothing
------------------------------------------------------------------------------}
class procedure TQtWSCustomStaticText.DestroyHandle(const AWinControl: TWinControl);
begin
TQtStaticText(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomStaticText.SetAlignment
Params: None
@ -1004,20 +934,6 @@ begin
Result := THandle(QtPushButton);
end;
{------------------------------------------------------------------------------
Function: TQtWSButton.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSButton.DestroyHandle(const AWinControl: TWinControl);
begin
TQtPushButton(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Function: TQtWSButton.GetText
Params: None
@ -1198,20 +1114,6 @@ begin
Result := THandle(QtCheckBox);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomCheckBox.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomCheckBox.DestroyHandle(const AWinControl: TWinControl);
begin
TQtCheckBox(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{ TQtWSRadioButton }
{------------------------------------------------------------------------------
@ -1221,8 +1123,10 @@ end;
------------------------------------------------------------------------------}
class function TQtWSRadioButton.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
begin
if TQtAbstractButton(ACustomCheckBox.Handle).isChecked then Result := cbChecked
else Result := cbUnchecked;
if TQtAbstractButton(ACustomCheckBox.Handle).isChecked then
Result := cbChecked
else
Result := cbUnchecked;
end;
{------------------------------------------------------------------------------
@ -1246,8 +1150,8 @@ end;
class procedure TQtWSRadioButton.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
begin
case NewState of
cbUnchecked: TQtAbstractButton(ACustomCheckBox.Handle).setChecked(False);
cbChecked: TQtAbstractButton(ACustomCheckBox.Handle).setChecked(true);
cbUnchecked: TQtAbstractButton(ACustomCheckBox.Handle).setChecked(False);
cbChecked: TQtAbstractButton(ACustomCheckBox.Handle).setChecked(true);
end;
end;
@ -1307,15 +1211,15 @@ begin
{ we must calculate text size to get real radiobutton size in TCustomRadioGroup }
FM := QFontMetrics_create(QWidget_font(QtRadioButton.Widget));
try
Str := UTF8Encode(AWinControl.Caption);
ATextWidth := QFontMetrics_width(FM, @Str, Length(Str));
Str := UTF8Encode(AWinControl.Caption);
ATextWidth := QFontMetrics_width(FM, @Str, Length(Str));
finally
QFontMetrics_destroy(FM);
QFontMetrics_destroy(FM);
end;
{ now, textwidth + default width of radiobutton (including space), default height
qt doesn't well align control with textsize < 100 }
if ATextWidth < 100 then
ATextWidth := 100;
ATextWidth := 100;
AWinControl.SetInitialBounds(0, 0, ATextWidth + 22, 22);
end;
@ -1328,20 +1232,6 @@ begin
Result := THandle(QtRadioButton);
end;
{------------------------------------------------------------------------------
Method: TQtWSRadioButton.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSRadioButton.DestroyHandle(const AWinControl: TWinControl);
begin
TQtRadioButton(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{ TQtWSCustomGroupBox }
{------------------------------------------------------------------------------
@ -1375,20 +1265,6 @@ begin
Result := THandle(QtGroupBox);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomGroupBox.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomGroupBox.DestroyHandle(const AWinControl: TWinControl);
begin
TQtGroupBox(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{ TQtWSCustomComboBox }
{------------------------------------------------------------------------------
@ -1416,20 +1292,6 @@ begin
Result := THandle(QtComboBox);
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomComboBox.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSCustomComboBox.DestroyHandle(const AWinControl: TWinControl);
begin
TQtComboBox(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
{------------------------------------------------------------------------------
Method: TQtWSCustomComboBox.GetItemIndex
Params: None
@ -1609,21 +1471,6 @@ begin
Result := THandle(QtToggleBox);
end;
{------------------------------------------------------------------------------
Method: TQtWSToggleBox.DestroyHandle
Params: None
Returns: Nothing
Releases allocated memory and resources
------------------------------------------------------------------------------}
class procedure TQtWSToggleBox.DestroyHandle(const AWinControl: TWinControl);
begin
TQtPushButton(AWinControl.Handle).Free;
AWinControl.Handle := 0;
end;
initialization
////////////////////////////////////////////////////