From 9f7f8da2458e329f71429e5062910718e5f78634 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 10 Sep 2007 15:44:43 +0000 Subject: [PATCH] Qt: - complete TQtWSCustomCheckBox, TQtWSToggleBox, TQtWSRadioButton - fixed typos in TQtWSCustomFloatSpinEdit declaration - temporary removed TQtWsButton.GetPrefferedSize due to non adequate return values git-svn-id: trunk@11988 - --- lcl/interfaces/qt/qtwidgets.pas | 40 ++++++++++---- lcl/interfaces/qt/qtwsspin.pp | 16 +++--- lcl/interfaces/qt/qtwsstdctrls.pp | 90 ++++++++++++++----------------- 3 files changed, 78 insertions(+), 68 deletions(-) diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index 829e7fd088..94532e53f2 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -267,8 +267,11 @@ type procedure setShortcut(AShortcut: TShortcut); procedure setText(text: PWideString); procedure Text(retval: PWideString); - function isChecked: Boolean; + procedure Toggle; + function isChecked: Boolean; + function isDown: Boolean; procedure setChecked(p1: Boolean); + procedure setDown(p1: Boolean); procedure SignalPressed; cdecl; procedure SignalReleased; cdecl; procedure SignalClicked(Checked: Boolean = False); cdecl; @@ -2551,6 +2554,11 @@ begin QAbstractButton_text(QAbstractButtonH(Widget), retval); end; +procedure TQtAbstractButton.Toggle; +begin + QAbstractButton_toggle(QAbstractButtonH(Widget)); +end; + {------------------------------------------------------------------------------ Function: TQtAbstractButton.isChecked Params: None @@ -2561,6 +2569,11 @@ begin Result := QAbstractButton_isChecked(QAbstractButtonH(Widget)); end; +function TQtAbstractButton.isDown: Boolean; +begin + Result := QAbstractButton_isDown(QAbstractButtonH(Widget)); +end; + {------------------------------------------------------------------------------ Function: TQtAbstractButton.setChecked Params: None @@ -2571,6 +2584,11 @@ begin QAbstractButton_setChecked(QAbstractButtonH(Widget), p1); end; +procedure TQtAbstractButton.setDown(p1: Boolean); +begin + QAbstractButton_setDown(QAbstractButtonH(Widget), p1); +end; + {------------------------------------------------------------------------------ Function: TQtAbstractButton.SignalPressed Params: None @@ -3891,7 +3909,8 @@ end; procedure TQtLineEdit.setSelection(const AStart, ALength: Integer); begin - QLineEdit_setSelection(QLineEditH(Widget), AStart, ALength); + if AStart >= 0 then + QLineEdit_setSelection(QLineEditH(Widget), AStart, ALength); end; procedure TQtLineEdit.setText(const AText: WideString); @@ -4007,13 +4026,16 @@ procedure TQtTextEdit.setSelection(const AStart, ALength: Integer); var TextCursor: QTextCursorH; begin - TextCursor := QTextCursor_create(); - QTextEdit_textCursor(QTextEditH(Widget), TextCursor); - QTextCursor_clearSelection(TextCursor); - QTextCursor_setPosition(TextCursor, AStart); - QTextCursor_setPosition(TextCursor, AStart + ALength, QTextCursorKeepAnchor); - QTextEdit_setTextCursor(QTextEditH(Widget), TextCursor); - QTextCursor_destroy(TextCursor); + if AStart >= 0 then + begin + TextCursor := QTextCursor_create(); + QTextEdit_textCursor(QTextEditH(Widget), TextCursor); + QTextCursor_clearSelection(TextCursor); + QTextCursor_setPosition(TextCursor, AStart); + QTextCursor_setPosition(TextCursor, AStart + ALength, QTextCursorKeepAnchor); + QTextEdit_setTextCursor(QTextEditH(Widget), TextCursor); + QTextCursor_destroy(TextCursor); + end; end; procedure TQtTextEdit.setTabChangesFocus(const AValue: Boolean); diff --git a/lcl/interfaces/qt/qtwsspin.pp b/lcl/interfaces/qt/qtwsspin.pp index 7c6161941a..ae2d9036ad 100644 --- a/lcl/interfaces/qt/qtwsspin.pp +++ b/lcl/interfaces/qt/qtwsspin.pp @@ -51,15 +51,15 @@ type const AParams: TCreateParams): HWND; override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; - class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; virtual; - class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; virtual; + class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override; + class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override; class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override; class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override; class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override; - class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); virtual; - class procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); virtual; + class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override; + class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override; class procedure SetText(const AWinControl: TWinControl; const AText: string); override; (*TODO: seperation into properties instead of bulk update @@ -154,14 +154,14 @@ begin end; class function TQtWSCustomFloatSpinEdit.GetSelStart( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; + const ACustomEdit: TCustomEdit): integer; begin {$note implement} Result := 0; end; class function TQtWSCustomFloatSpinEdit.GetSelLength( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; + const ACustomEdit: TCustomEdit): integer; begin {$note implement} Result := 0; @@ -185,13 +185,13 @@ begin end; class procedure TQtWSCustomFloatSpinEdit.SetSelLength( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); + const ACustomEdit: TCustomEdit; NewLength: integer); begin {$note implement} end; class procedure TQtWSCustomFloatSpinEdit.SetSelStart( - const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); + const ACustomEdit: TCustomEdit; NewStart: integer); begin {$note implement} end; diff --git a/lcl/interfaces/qt/qtwsstdctrls.pp b/lcl/interfaces/qt/qtwsstdctrls.pp index 6ed2c4463f..d7aaaed815 100644 --- a/lcl/interfaces/qt/qtwsstdctrls.pp +++ b/lcl/interfaces/qt/qtwsstdctrls.pp @@ -234,8 +234,8 @@ type class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override; class procedure SetShortcut(const AButton: TCustomButton; const OldShortcut, NewShortcut: TShortcut); override; class procedure SetText(const AWinControl: TWinControl; const AText: String); override; - class procedure GetPreferredSize(const AWinControl: TWinControl; - var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override; + {class procedure GetPreferredSize(const AWinControl: TWinControl; + var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;} class procedure SetColor(const AWinControl: TWinControl); override; end; @@ -245,17 +245,17 @@ type private protected public - class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; + class function CreateHandle(const AWinControl: TWinControl; + const AParams: TCreateParams): TLCLIntfHandle; override; + + class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; 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 function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; end; { TQtWSCheckBox } @@ -272,18 +272,17 @@ type private protected public - public - class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; + class function CreateHandle(const AWinControl: TWinControl; + const AParams: TCreateParams): TLCLIntfHandle; override; + + class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; 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 function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; end; { TQtWSRadioButton } @@ -292,16 +291,17 @@ type private protected public - class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; + class function CreateHandle(const AWinControl: TWinControl; + const AParams: TCreateParams): TLCLIntfHandle; override; + + class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; 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 function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; end; { TQtWSCustomStaticText } @@ -1080,12 +1080,12 @@ begin TQtAbstractButton(AWinControl.Handle).SetText(@Str); end; -class procedure TQtWSButton.GetPreferredSize(const AWinControl: TWinControl; +{class procedure TQtWSButton.GetPreferredSize(const AWinControl: TWinControl; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); begin PreferredWidth := QStyle_pixelMetric(QApplication_style(), QStylePM_DialogButtonsButtonWidth); PreferredHeight := QStyle_pixelMetric(QApplication_style(), QStylePM_DialogButtonsButtonHeight); -end; +end;} {------------------------------------------------------------------------------ Method: TQtWSButton.SetColor @@ -1124,8 +1124,8 @@ end; class function TQtWSCustomCheckBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; begin case TQtCheckBox(ACustomCheckBox.Handle).CheckState of - QtPartiallyChecked: Result := cbGrayed; - QtChecked: Result := cbChecked; + QtPartiallyChecked: Result := cbGrayed; + QtChecked: Result := cbChecked; else Result := cbUnchecked; end; @@ -1139,7 +1139,9 @@ end; class procedure TQtWSCustomCheckBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox; const OldShortCut, NewShortCut: TShortCut); begin - inherited SetShortCut(ACustomCheckBox, OldShortCut, NewShortCut); + if not WSCheckHandleAllocated(ACustomCheckBox, 'SetShortcut') then Exit; + + TQtCheckBox(ACustomCheckBox.Handle).setShortcut(NewShortcut); end; {------------------------------------------------------------------------------ @@ -1150,8 +1152,8 @@ end; class procedure TQtWSCustomCheckBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); begin case NewState of - cbGrayed: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtPartiallyChecked); - cbChecked: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtChecked); + cbGrayed: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtPartiallyChecked); + cbChecked: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtChecked); else TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtUnchecked); end; @@ -1182,7 +1184,7 @@ class procedure TQtWSCustomCheckBox.SetText(const AWinControl: TWinControl; cons var Str: WideString; begin - Str := UTF8Decode(AText); + Str := GetUtf8String(AText); TQtAbstractButton(AWinControl.Handle).SetText(@Str); end; @@ -1216,7 +1218,7 @@ end; ------------------------------------------------------------------------------} class function TQtWSRadioButton.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; begin - if TQtAbstractButton(ACustomCheckBox.Handle).isChecked then + if TQtRadioButton(ACustomCheckBox.Handle).isChecked then Result := cbChecked else Result := cbUnchecked; @@ -1230,7 +1232,7 @@ end; class procedure TQtWSRadioButton.SetShortCut(const ACustomCheckBox: TCustomCheckBox; const OldShortCut, NewShortCut: TShortCut); begin - inherited SetShortCut(ACustomCheckBox, OldShortCut, NewShortCut); + TQtRadioButton(ACustomCheckBox.Handle).setShortcut(NewShortCut); end; {------------------------------------------------------------------------------ @@ -1242,10 +1244,7 @@ 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); - end; + TQtRadioButton(ACustomCheckBox.Handle).setChecked(NewState = cbChecked); end; {------------------------------------------------------------------------------ @@ -1275,7 +1274,7 @@ class procedure TQtWSRadioButton.SetText(const AWinControl: TWinControl; const A var Str: WideString; begin - Str := UTF8Decode(AText); + Str := GetUtf8String(AText); TQtAbstractButton(AWinControl.Handle).SetText(@Str); end; @@ -1597,11 +1596,10 @@ end; ------------------------------------------------------------------------------} class function TQtWSToggleBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; begin - if QAbstractButton_isDown(QAbstractButtonH(TQtPushButton(ACustomCheckBox.Handle).Widget)) - then - Result := cbChecked + if TQtPushButton(ACustomCheckBox.Handle).isDown then + Result := cbChecked else - Result := cbUnChecked; + Result := cbUnChecked; end; {------------------------------------------------------------------------------ @@ -1612,7 +1610,7 @@ end; class procedure TQtWSToggleBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox; const OldShortCut, NewShortCut: TShortCut); begin - inherited SetShortCut(ACustomCheckBox, OldShortCut, NewShortCut); + TQtPushButton(ACustomCheckBox.Handle).setShortcut(NewShortCut); end; {------------------------------------------------------------------------------ @@ -1621,17 +1619,8 @@ end; Returns: Nothing ------------------------------------------------------------------------------} class procedure TQtWSToggleBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); -var - AState: TCheckBoxState; begin - if QAbstractButton_isDown(QAbstractButtonH(TQtPushButton(ACustomCheckBox.Handle).Widget)) - then - AState := cbChecked - else - AState := cbUnChecked; - - if AState <> NewState then - QAbstractButton_toggle(QAbstractButtonH(TQtPushButton(ACustomCheckBox.Handle).Widget)); + TQtPushButton(ACustomCheckBox.Handle).setDown(NewState = cbChecked) end; {------------------------------------------------------------------------------ @@ -1675,7 +1664,6 @@ class function TQtWSToggleBox.CreateHandle(const AWinControl: TWinControl; const var QtToggleBox: TQtPushButton; begin - QtToggleBox := TQtPushButton.Create(AWinControl, AParams); QAbstractButton_setCheckable(QAbstractButtonH(QtToggleBox.Widget), True);