mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-06 09:59:36 +01:00
qt intf: fixes spin edit from Felipe
git-svn-id: trunk@9268 -
This commit is contained in:
parent
19d2543a28
commit
fef1681254
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2189,8 +2189,8 @@ lcl/interfaces/qt/qtcallback.inc svneol=native#text/pascal
|
|||||||
lcl/interfaces/qt/qtint.pp svneol=native#text/pascal
|
lcl/interfaces/qt/qtint.pp svneol=native#text/pascal
|
||||||
lcl/interfaces/qt/qtlclintf.inc svneol=native#text/pascal
|
lcl/interfaces/qt/qtlclintf.inc svneol=native#text/pascal
|
||||||
lcl/interfaces/qt/qtlclintfh.inc svneol=native#text/pascal
|
lcl/interfaces/qt/qtlclintfh.inc svneol=native#text/pascal
|
||||||
lcl/interfaces/qt/qtmemostrings.inc svneol=native#text/plain
|
|
||||||
lcl/interfaces/qt/qtobject.inc svneol=native#text/pascal
|
lcl/interfaces/qt/qtobject.inc svneol=native#text/pascal
|
||||||
|
lcl/interfaces/qt/qtobjects.pas svneol=native#text/plain
|
||||||
lcl/interfaces/qt/qtprivate.pp svneol=native#text/plain
|
lcl/interfaces/qt/qtprivate.pp svneol=native#text/plain
|
||||||
lcl/interfaces/qt/qtwinapi.inc svneol=native#text/pascal
|
lcl/interfaces/qt/qtwinapi.inc svneol=native#text/pascal
|
||||||
lcl/interfaces/qt/qtwinapih.inc svneol=native#text/pascal
|
lcl/interfaces/qt/qtwinapih.inc svneol=native#text/pascal
|
||||||
|
|||||||
@ -1,4 +1,10 @@
|
|||||||
{$IFDEF MEMOHEADER}
|
unit qtobjects;
|
||||||
|
|
||||||
|
{$mode delphi}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses Classes, StdCtrls, Controls, Graphics, SysUtils, qt4;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -32,12 +38,11 @@ type
|
|||||||
property Owner: TWinControl read FOwner;
|
property Owner: TWinControl read FOwner;
|
||||||
function TextChangedHandler(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function TextChangedHandler(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
|
||||||
{
|
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
|
||||||
}
|
uses qtprivate, LMessages;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
DelphiOnChange sets Delphi compatibility for OnChange event:
|
DelphiOnChange sets Delphi compatibility for OnChange event:
|
||||||
If defined, OnChange is generated whenever there's a change
|
If defined, OnChange is generated whenever there's a change
|
||||||
@ -186,8 +191,13 @@ end;
|
|||||||
function TQtMemoStrings.TextChangedHandler(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function TQtMemoStrings.TextChangedHandler(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
var
|
var
|
||||||
Mess: TLMessage;
|
Mess: TLMessage;
|
||||||
|
// just for debugging
|
||||||
|
SenderView: QObjectH;
|
||||||
|
EventView: QEventH;
|
||||||
begin
|
begin
|
||||||
if not FUpdating then begin
|
if not FUpdating then begin
|
||||||
|
SenderView := Sender;
|
||||||
|
EventView := Event;
|
||||||
FTextChanged := True;
|
FTextChanged := True;
|
||||||
FillChar(Mess, SizeOf(Mess), #0);
|
FillChar(Mess, SizeOf(Mess), #0);
|
||||||
Mess.Msg := CM_TEXTCHANGED;
|
Mess.Msg := CM_TEXTCHANGED;
|
||||||
@ -313,4 +323,5 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{$ENDIF}
|
end.
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ type
|
|||||||
class procedure SetSize(const AWinControl: TWinControl; const AWidth, AHeight: Integer); override;
|
class procedure SetSize(const AWinControl: TWinControl; const AWidth, AHeight: Integer); override;
|
||||||
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
|
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
|
||||||
|
|
||||||
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
// 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 procedure AddControl(const AControl: TControl); override;
|
{ class procedure AddControl(const AControl: TControl); override;
|
||||||
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
|
||||||
@ -242,42 +242,6 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TQtWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
|
|
||||||
var
|
|
||||||
AString: WideString;
|
|
||||||
begin
|
|
||||||
Result := True;
|
|
||||||
if AWinControl = nil then exit;
|
|
||||||
|
|
||||||
if not AWinControl.HandleAllocated then exit;
|
|
||||||
case AWinControl.fCompStyle of
|
|
||||||
//csComboBox:
|
|
||||||
csEdit,csSpinedit:
|
|
||||||
QLineEdit_text(QLineEditH(TQtWidget(AWinControl.Handle).Widget),@AString);
|
|
||||||
csMemo:
|
|
||||||
QTextEdit_toPlainText(QTextEditH(TQtWidget(AWinControl.Handle).Widget),@AString);
|
|
||||||
else
|
|
||||||
Result := false;
|
|
||||||
end;
|
|
||||||
if Result then AText := AString;
|
|
||||||
end;
|
|
||||||
|
|
||||||
class procedure TQtWSWinControl.SetText(const AWinControl: TWinControl; const AText: string);
|
|
||||||
var
|
|
||||||
AString: WideString;
|
|
||||||
begin
|
|
||||||
if AWinControl = nil then exit;
|
|
||||||
if not AWinControl.HandleAllocated then exit;
|
|
||||||
AString := AText;
|
|
||||||
case AWinControl.fCompStyle of
|
|
||||||
csEdit,csSpinedit:
|
|
||||||
QLineEdit_setText(QLineEditH(TQtWidget(AWinControl.Handle).Widget),@AString);
|
|
||||||
//csStaticText:
|
|
||||||
csMemo:
|
|
||||||
QTextEdit_append(QTextEditH(TQtWidget(AWinControl.Handle).Widget),@AString);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
@ -293,4 +257,4 @@ initialization
|
|||||||
// RegisterWSComponent(TCustomControl, TQtWSCustomControl);
|
// RegisterWSComponent(TCustomControl, TQtWSCustomControl);
|
||||||
// RegisterWSComponent(TImageList, TQtWSImageList);
|
// RegisterWSComponent(TImageList, TQtWSImageList);
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
end.
|
end.
|
||||||
|
|||||||
@ -34,7 +34,7 @@ uses
|
|||||||
// uncomment only when needed for registration
|
// uncomment only when needed for registration
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
Classes, StdCtrls, Controls, Graphics, Forms, SysUtils,
|
Classes, StdCtrls, Controls, Graphics, Forms, SysUtils,
|
||||||
InterfaceBase, qt4, qtprivate,
|
InterfaceBase, qt4, qtprivate, qtobjects,
|
||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
WSStdCtrls, WSLCLClasses, LCLType;
|
WSStdCtrls, WSLCLClasses, LCLType;
|
||||||
|
|
||||||
@ -129,6 +129,8 @@ type
|
|||||||
const AParams: TCreateParams): HWND; override;
|
const AParams: TCreateParams): HWND; override;
|
||||||
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
||||||
public
|
public
|
||||||
|
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||||
|
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
|
||||||
{ class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
{ class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
|
|
||||||
@ -159,6 +161,8 @@ type
|
|||||||
// class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); virtual;
|
// class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); virtual;
|
||||||
class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;
|
class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;
|
||||||
public
|
public
|
||||||
|
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||||
|
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
|
||||||
{ class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
{ class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
|
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
|
||||||
|
|
||||||
@ -278,16 +282,11 @@ type
|
|||||||
public
|
public
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$DEFINE MEMOHEADER}
|
|
||||||
{$I qtmemostrings.inc}
|
|
||||||
{$UNDEF MEMOHEADER}
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses LMessages;
|
uses LMessages;
|
||||||
|
|
||||||
{$I qtmemostrings.inc}
|
|
||||||
|
|
||||||
{ TQtWSCustomMemo }
|
{ TQtWSCustomMemo }
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -363,6 +362,36 @@ begin
|
|||||||
QTextEdit_setLineWrapMode(TextEditH,QTextEditNoWrap);
|
QTextEdit_setLineWrapMode(TextEditH,QTextEditNoWrap);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TQtWSCustomMemo.GetText
|
||||||
|
Params:
|
||||||
|
Returns: Nothing
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
class function TQtWSCustomMemo.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
|
||||||
|
var
|
||||||
|
Str: WideString;
|
||||||
|
begin
|
||||||
|
QTextEdit_toPlainText(QTextEditH(TQtWidget(AWinControl.Handle).Widget), @Str);
|
||||||
|
|
||||||
|
AText := String(Str);
|
||||||
|
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TQtWSCustomMemo.SetText
|
||||||
|
Params:
|
||||||
|
Returns: Nothing
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
class procedure TQtWSCustomMemo.SetText(const AWinControl: TWinControl; const AText: string);
|
||||||
|
var
|
||||||
|
AString: WideString;
|
||||||
|
begin
|
||||||
|
AString := WideString(AText);
|
||||||
|
|
||||||
|
QTextEdit_append(QTextEditH(TQtWidget(AWinControl.Handle).Widget), @AString);
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TQtWSCustomMemo.SetReadOnly
|
Method: TQtWSCustomMemo.SetReadOnly
|
||||||
Params: NewReadOnly boolean
|
Params: NewReadOnly boolean
|
||||||
@ -376,7 +405,7 @@ begin
|
|||||||
QTextEdit_setReadOnly(TextEditH,NewReadOnly);
|
QTextEdit_setReadOnly(TextEditH,NewReadOnly);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{{ TQtWSCustomEdit }
|
{ TQtWSCustomEdit }
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TQtWSCustomEdit.CreateHandle
|
Method: TQtWSCustomEdit.CreateHandle
|
||||||
@ -403,6 +432,36 @@ begin
|
|||||||
TQtLineEdit(AWinControl.Handle).Free;
|
TQtLineEdit(AWinControl.Handle).Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TQtWSCustomEdit.GetText
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
class function TQtWSCustomEdit.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
|
||||||
|
var
|
||||||
|
Str: WideString;
|
||||||
|
begin
|
||||||
|
QLineEdit_text(QLineEditH(TQtWidget(AWinControl.Handle).Widget), @Str);
|
||||||
|
|
||||||
|
AText := String(Str);
|
||||||
|
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{------------------------------------------------------------------------------
|
||||||
|
Method: TQtWSCustomEdit.SetText
|
||||||
|
Params: None
|
||||||
|
Returns: Nothing
|
||||||
|
------------------------------------------------------------------------------}
|
||||||
|
class procedure TQtWSCustomEdit.SetText(const AWinControl: TWinControl; const AText: string);
|
||||||
|
var
|
||||||
|
AString: WideString;
|
||||||
|
begin
|
||||||
|
AString := WideString(AText);
|
||||||
|
|
||||||
|
QLineEdit_setText(QLineEditH(TQtWidget(AWinControl.Handle).Widget), @AString);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TQtWSStaticText }
|
{ TQtWSStaticText }
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user