- complete TQtWSCustomCheckBox, TQtWSToggleBox, TQtWSRadioButton
- fixed typos in TQtWSCustomFloatSpinEdit declaration
- temporary removed TQtWsButton.GetPrefferedSize due to non adequate return values

git-svn-id: trunk@11988 -
This commit is contained in:
paul 2007-09-10 15:44:43 +00:00
parent a41d43cb80
commit 9f7f8da245
3 changed files with 78 additions and 68 deletions

View File

@ -267,8 +267,11 @@ type
procedure setShortcut(AShortcut: TShortcut); procedure setShortcut(AShortcut: TShortcut);
procedure setText(text: PWideString); procedure setText(text: PWideString);
procedure Text(retval: PWideString); procedure Text(retval: PWideString);
function isChecked: Boolean; procedure Toggle;
function isChecked: Boolean;
function isDown: Boolean;
procedure setChecked(p1: Boolean); procedure setChecked(p1: Boolean);
procedure setDown(p1: Boolean);
procedure SignalPressed; cdecl; procedure SignalPressed; cdecl;
procedure SignalReleased; cdecl; procedure SignalReleased; cdecl;
procedure SignalClicked(Checked: Boolean = False); cdecl; procedure SignalClicked(Checked: Boolean = False); cdecl;
@ -2551,6 +2554,11 @@ begin
QAbstractButton_text(QAbstractButtonH(Widget), retval); QAbstractButton_text(QAbstractButtonH(Widget), retval);
end; end;
procedure TQtAbstractButton.Toggle;
begin
QAbstractButton_toggle(QAbstractButtonH(Widget));
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: TQtAbstractButton.isChecked Function: TQtAbstractButton.isChecked
Params: None Params: None
@ -2561,6 +2569,11 @@ begin
Result := QAbstractButton_isChecked(QAbstractButtonH(Widget)); Result := QAbstractButton_isChecked(QAbstractButtonH(Widget));
end; end;
function TQtAbstractButton.isDown: Boolean;
begin
Result := QAbstractButton_isDown(QAbstractButtonH(Widget));
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: TQtAbstractButton.setChecked Function: TQtAbstractButton.setChecked
Params: None Params: None
@ -2571,6 +2584,11 @@ begin
QAbstractButton_setChecked(QAbstractButtonH(Widget), p1); QAbstractButton_setChecked(QAbstractButtonH(Widget), p1);
end; end;
procedure TQtAbstractButton.setDown(p1: Boolean);
begin
QAbstractButton_setDown(QAbstractButtonH(Widget), p1);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: TQtAbstractButton.SignalPressed Function: TQtAbstractButton.SignalPressed
Params: None Params: None
@ -3891,7 +3909,8 @@ end;
procedure TQtLineEdit.setSelection(const AStart, ALength: Integer); procedure TQtLineEdit.setSelection(const AStart, ALength: Integer);
begin begin
QLineEdit_setSelection(QLineEditH(Widget), AStart, ALength); if AStart >= 0 then
QLineEdit_setSelection(QLineEditH(Widget), AStart, ALength);
end; end;
procedure TQtLineEdit.setText(const AText: WideString); procedure TQtLineEdit.setText(const AText: WideString);
@ -4007,13 +4026,16 @@ procedure TQtTextEdit.setSelection(const AStart, ALength: Integer);
var var
TextCursor: QTextCursorH; TextCursor: QTextCursorH;
begin begin
TextCursor := QTextCursor_create(); if AStart >= 0 then
QTextEdit_textCursor(QTextEditH(Widget), TextCursor); begin
QTextCursor_clearSelection(TextCursor); TextCursor := QTextCursor_create();
QTextCursor_setPosition(TextCursor, AStart); QTextEdit_textCursor(QTextEditH(Widget), TextCursor);
QTextCursor_setPosition(TextCursor, AStart + ALength, QTextCursorKeepAnchor); QTextCursor_clearSelection(TextCursor);
QTextEdit_setTextCursor(QTextEditH(Widget), TextCursor); QTextCursor_setPosition(TextCursor, AStart);
QTextCursor_destroy(TextCursor); QTextCursor_setPosition(TextCursor, AStart + ALength, QTextCursorKeepAnchor);
QTextEdit_setTextCursor(QTextEditH(Widget), TextCursor);
QTextCursor_destroy(TextCursor);
end;
end; end;
procedure TQtTextEdit.setTabChangesFocus(const AValue: Boolean); procedure TQtTextEdit.setTabChangesFocus(const AValue: Boolean);

View File

@ -51,15 +51,15 @@ type
const AParams: TCreateParams): HWND; override; const AParams: TCreateParams): HWND; override;
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override; class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
class function GetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; virtual; class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
class function GetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; virtual; class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override; class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override; class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): single; override;
class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override; class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override;
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override; class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
class procedure SetSelLength(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); virtual; class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
class procedure SetSelStart(const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); virtual; class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override; class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
(*TODO: seperation into properties instead of bulk update (*TODO: seperation into properties instead of bulk update
@ -154,14 +154,14 @@ begin
end; end;
class function TQtWSCustomFloatSpinEdit.GetSelStart( class function TQtWSCustomFloatSpinEdit.GetSelStart(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; const ACustomEdit: TCustomEdit): integer;
begin begin
{$note implement} {$note implement}
Result := 0; Result := 0;
end; end;
class function TQtWSCustomFloatSpinEdit.GetSelLength( class function TQtWSCustomFloatSpinEdit.GetSelLength(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit): integer; const ACustomEdit: TCustomEdit): integer;
begin begin
{$note implement} {$note implement}
Result := 0; Result := 0;
@ -185,13 +185,13 @@ begin
end; end;
class procedure TQtWSCustomFloatSpinEdit.SetSelLength( class procedure TQtWSCustomFloatSpinEdit.SetSelLength(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewLength: integer); const ACustomEdit: TCustomEdit; NewLength: integer);
begin begin
{$note implement} {$note implement}
end; end;
class procedure TQtWSCustomFloatSpinEdit.SetSelStart( class procedure TQtWSCustomFloatSpinEdit.SetSelStart(
const ACustomFloatSpinEdit: TCustomFloatSpinEdit; NewStart: integer); const ACustomEdit: TCustomEdit; NewStart: integer);
begin begin
{$note implement} {$note implement}
end; end;

View File

@ -234,8 +234,8 @@ type
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override; class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
class procedure SetShortcut(const AButton: TCustomButton; const OldShortcut, NewShortcut: TShortcut); override; class procedure SetShortcut(const AButton: TCustomButton; const OldShortcut, NewShortcut: TShortcut); override;
class procedure SetText(const AWinControl: TWinControl; const AText: String); override; class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
class procedure GetPreferredSize(const AWinControl: TWinControl; {class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override; var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;}
class procedure SetColor(const AWinControl: TWinControl); override; class procedure SetColor(const AWinControl: TWinControl); override;
end; end;
@ -245,17 +245,17 @@ type
private private
protected 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; class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); override; const OldShortCut, NewShortCut: TShortCut); override;
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); 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 procedure SetText(const AWinControl: TWinControl; const AText: String); override;
class function CreateHandle(const AWinControl: TWinControl; class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override;
const AParams: TCreateParams): TLCLIntfHandle; override;
end; end;
{ TQtWSCheckBox } { TQtWSCheckBox }
@ -272,18 +272,17 @@ type
private private
protected protected
public public
public class function CreateHandle(const AWinControl: TWinControl;
class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override; const AParams: TCreateParams): TLCLIntfHandle; override;
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox; class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); override; const OldShortCut, NewShortCut: TShortCut); override;
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); 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 procedure SetText(const AWinControl: TWinControl; const AText: String); override;
class function CreateHandle(const AWinControl: TWinControl; class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override;
const AParams: TCreateParams): TLCLIntfHandle; override;
end; end;
{ TQtWSRadioButton } { TQtWSRadioButton }
@ -292,16 +291,17 @@ type
private private
protected 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; class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); override; const OldShortCut, NewShortCut: TShortCut); override;
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); 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 procedure SetText(const AWinControl: TWinControl; const AText: String); override;
class function CreateHandle(const AWinControl: TWinControl; class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override;
const AParams: TCreateParams): TLCLIntfHandle; override;
end; end;
{ TQtWSCustomStaticText } { TQtWSCustomStaticText }
@ -1080,12 +1080,12 @@ begin
TQtAbstractButton(AWinControl.Handle).SetText(@Str); TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end; end;
class procedure TQtWSButton.GetPreferredSize(const AWinControl: TWinControl; {class procedure TQtWSButton.GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean);
begin begin
PreferredWidth := QStyle_pixelMetric(QApplication_style(), QStylePM_DialogButtonsButtonWidth); PreferredWidth := QStyle_pixelMetric(QApplication_style(), QStylePM_DialogButtonsButtonWidth);
PreferredHeight := QStyle_pixelMetric(QApplication_style(), QStylePM_DialogButtonsButtonHeight); PreferredHeight := QStyle_pixelMetric(QApplication_style(), QStylePM_DialogButtonsButtonHeight);
end; end;}
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TQtWSButton.SetColor Method: TQtWSButton.SetColor
@ -1124,8 +1124,8 @@ end;
class function TQtWSCustomCheckBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; class function TQtWSCustomCheckBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
begin begin
case TQtCheckBox(ACustomCheckBox.Handle).CheckState of case TQtCheckBox(ACustomCheckBox.Handle).CheckState of
QtPartiallyChecked: Result := cbGrayed; QtPartiallyChecked: Result := cbGrayed;
QtChecked: Result := cbChecked; QtChecked: Result := cbChecked;
else else
Result := cbUnchecked; Result := cbUnchecked;
end; end;
@ -1139,7 +1139,9 @@ end;
class procedure TQtWSCustomCheckBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox; class procedure TQtWSCustomCheckBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); const OldShortCut, NewShortCut: TShortCut);
begin begin
inherited SetShortCut(ACustomCheckBox, OldShortCut, NewShortCut); if not WSCheckHandleAllocated(ACustomCheckBox, 'SetShortcut') then Exit;
TQtCheckBox(ACustomCheckBox.Handle).setShortcut(NewShortcut);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1150,8 +1152,8 @@ end;
class procedure TQtWSCustomCheckBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); class procedure TQtWSCustomCheckBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
begin begin
case NewState of case NewState of
cbGrayed: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtPartiallyChecked); cbGrayed: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtPartiallyChecked);
cbChecked: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtChecked); cbChecked: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtChecked);
else else
TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtUnchecked); TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtUnchecked);
end; end;
@ -1182,7 +1184,7 @@ class procedure TQtWSCustomCheckBox.SetText(const AWinControl: TWinControl; cons
var var
Str: WideString; Str: WideString;
begin begin
Str := UTF8Decode(AText); Str := GetUtf8String(AText);
TQtAbstractButton(AWinControl.Handle).SetText(@Str); TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end; end;
@ -1216,7 +1218,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
class function TQtWSRadioButton.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; class function TQtWSRadioButton.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
begin begin
if TQtAbstractButton(ACustomCheckBox.Handle).isChecked then if TQtRadioButton(ACustomCheckBox.Handle).isChecked then
Result := cbChecked Result := cbChecked
else else
Result := cbUnchecked; Result := cbUnchecked;
@ -1230,7 +1232,7 @@ end;
class procedure TQtWSRadioButton.SetShortCut(const ACustomCheckBox: TCustomCheckBox; class procedure TQtWSRadioButton.SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); const OldShortCut, NewShortCut: TShortCut);
begin begin
inherited SetShortCut(ACustomCheckBox, OldShortCut, NewShortCut); TQtRadioButton(ACustomCheckBox.Handle).setShortcut(NewShortCut);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1242,10 +1244,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
class procedure TQtWSRadioButton.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); class procedure TQtWSRadioButton.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
begin begin
case NewState of TQtRadioButton(ACustomCheckBox.Handle).setChecked(NewState = cbChecked);
cbUnchecked: TQtAbstractButton(ACustomCheckBox.Handle).setChecked(False);
cbChecked: TQtAbstractButton(ACustomCheckBox.Handle).setChecked(true);
end;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1275,7 +1274,7 @@ class procedure TQtWSRadioButton.SetText(const AWinControl: TWinControl; const A
var var
Str: WideString; Str: WideString;
begin begin
Str := UTF8Decode(AText); Str := GetUtf8String(AText);
TQtAbstractButton(AWinControl.Handle).SetText(@Str); TQtAbstractButton(AWinControl.Handle).SetText(@Str);
end; end;
@ -1597,11 +1596,10 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
class function TQtWSToggleBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; class function TQtWSToggleBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
begin begin
if QAbstractButton_isDown(QAbstractButtonH(TQtPushButton(ACustomCheckBox.Handle).Widget)) if TQtPushButton(ACustomCheckBox.Handle).isDown then
then Result := cbChecked
Result := cbChecked
else else
Result := cbUnChecked; Result := cbUnChecked;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1612,7 +1610,7 @@ end;
class procedure TQtWSToggleBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox; class procedure TQtWSToggleBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); const OldShortCut, NewShortCut: TShortCut);
begin begin
inherited SetShortCut(ACustomCheckBox, OldShortCut, NewShortCut); TQtPushButton(ACustomCheckBox.Handle).setShortcut(NewShortCut);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1621,17 +1619,8 @@ end;
Returns: Nothing Returns: Nothing
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
class procedure TQtWSToggleBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); class procedure TQtWSToggleBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
var
AState: TCheckBoxState;
begin begin
if QAbstractButton_isDown(QAbstractButtonH(TQtPushButton(ACustomCheckBox.Handle).Widget)) TQtPushButton(ACustomCheckBox.Handle).setDown(NewState = cbChecked)
then
AState := cbChecked
else
AState := cbUnChecked;
if AState <> NewState then
QAbstractButton_toggle(QAbstractButtonH(TQtPushButton(ACustomCheckBox.Handle).Widget));
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1675,7 +1664,6 @@ class function TQtWSToggleBox.CreateHandle(const AWinControl: TWinControl; const
var var
QtToggleBox: TQtPushButton; QtToggleBox: TQtPushButton;
begin begin
QtToggleBox := TQtPushButton.Create(AWinControl, AParams); QtToggleBox := TQtPushButton.Create(AWinControl, AParams);
QAbstractButton_setCheckable(QAbstractButtonH(QtToggleBox.Widget), True); QAbstractButton_setCheckable(QAbstractButtonH(QtToggleBox.Widget), True);