mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 16:19:36 +02:00
Qt:
- complete TQtWsCustomStaticText - some code moving for TQtWsCustomMemo git-svn-id: trunk@11996 -
This commit is contained in:
parent
a513e16d9b
commit
9b01dc0727
@ -337,8 +337,9 @@ type
|
||||
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
||||
public
|
||||
destructor Destroy; override;
|
||||
procedure SetText(text: PWideString);
|
||||
procedure Text(retval: PWideString);
|
||||
procedure getText(retval: PWideString);
|
||||
procedure setText(text: PWideString);
|
||||
procedure setAlignment(const AAlignment: QtAlignment);
|
||||
end;
|
||||
|
||||
{ TQtCheckBox }
|
||||
@ -455,7 +456,7 @@ type
|
||||
function getPlainText: WideString;
|
||||
function getSelectionStart: Integer;
|
||||
function getSelectionEnd: Integer;
|
||||
procedure setAlignment(const AAlignment: TAlignment);
|
||||
procedure setAlignment(const AAlignment: QtAlignment);
|
||||
procedure setColor(const Value: PQColor); override;
|
||||
procedure setLineWrapMode(const AMode: QTextEditLineWrapMode);
|
||||
procedure setPlainText(const AText: WideString);
|
||||
@ -749,7 +750,7 @@ type
|
||||
public
|
||||
procedure setRange(minimum: Integer; maximum: Integer);
|
||||
procedure setTextVisible(visible: Boolean);
|
||||
procedure setAlignment(alignment: QtAlignment);
|
||||
procedure setAlignment(const AAlignment: QtAlignment);
|
||||
procedure setTextDirection(textDirection: QProgressBarDirection);
|
||||
procedure setValue(value: Integer);
|
||||
procedure setOrientation(p1: QtOrientation);
|
||||
@ -819,14 +820,6 @@ type
|
||||
procedure setShape(AShape: QRubberBandShape);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
|
||||
LCLMessageGlue,
|
||||
qtCaret;
|
||||
|
||||
|
||||
const
|
||||
AlignmentMap: array[TAlignment] of QtAlignment =
|
||||
(
|
||||
@ -835,6 +828,13 @@ const
|
||||
{taCenter } QtAlignHCenter
|
||||
);
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
LCLMessageGlue,
|
||||
qtCaret;
|
||||
|
||||
const
|
||||
DblClickThreshold = 3;// max Movement between two clicks of a DblClick
|
||||
|
||||
type
|
||||
@ -3022,8 +3022,7 @@ begin
|
||||
WriteLn('TQtStaticText.Create');
|
||||
{$endif}
|
||||
|
||||
Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget;
|
||||
Result := QLabel_create(Parent);
|
||||
Result := QLabel_create();
|
||||
QWidget_setAutoFillBackground(Result, True);
|
||||
end;
|
||||
|
||||
@ -3058,12 +3057,17 @@ begin
|
||||
QLabel_setText(QLabelH(Widget), text);
|
||||
end;
|
||||
|
||||
procedure TQtStaticText.setAlignment(const AAlignment: QtAlignment);
|
||||
begin
|
||||
QLabel_setAlignment(QLabelH(Widget), AAlignment);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtStaticText.Text
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtStaticText.Text(retval: PWideString);
|
||||
procedure TQtStaticText.getText(retval: PWideString);
|
||||
begin
|
||||
QLabel_text(QLabelH(Widget), retval);
|
||||
end;
|
||||
@ -3945,16 +3949,7 @@ begin
|
||||
WriteLn('TQtTextEdit.Create');
|
||||
{$endif}
|
||||
|
||||
Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget;
|
||||
Result := QTextEdit_create(Parent);
|
||||
QTextEdit_setAlignment(QTextEditH(Result), AlignmentMap[(LCLObject as TCustomMemo).Alignment]);
|
||||
|
||||
QTextEdit_setReadOnly(QTextEditH(Result), (LCLObject as TCustomMemo).ReadOnly);
|
||||
|
||||
if (LCLObject as TCustomMemo).WordWrap then
|
||||
QTextEdit_setLineWrapMode(QTextEditH(Result),QTextEditWidgetWidth)
|
||||
else
|
||||
QTextEdit_setLineWrapMode(QTextEditH(Result),QTextEditNoWrap);
|
||||
Result := QTextEdit_create();
|
||||
end;
|
||||
|
||||
procedure TQtTextEdit.append(AStr: WideString);
|
||||
@ -4043,7 +4038,7 @@ begin
|
||||
QTextEdit_setTabChangesFocus(QTextEditH(Widget), AValue);
|
||||
end;
|
||||
|
||||
procedure TQtTextEdit.SetAlignment(const AAlignment: TAlignment);
|
||||
procedure TQtTextEdit.SetAlignment(const AAlignment: QtAlignment);
|
||||
var
|
||||
TextCursor: QTextCursorH;
|
||||
begin
|
||||
@ -4054,7 +4049,7 @@ begin
|
||||
QTextEdit_selectAll(QTextEditH(Widget));
|
||||
|
||||
// 2. Set format
|
||||
QTextEdit_setAlignment(QTextEditH(Widget), AlignmentMap[(LCLObject as TCustomMemo).Alignment]);
|
||||
QTextEdit_setAlignment(QTextEditH(Widget), AAlignment);
|
||||
|
||||
// 3. Clear selection. To unselect all document we must create new text cursor,
|
||||
// get format from Text Edit, clear selection in cursor and set it back to Text Edit
|
||||
@ -5539,9 +5534,9 @@ begin
|
||||
QProgressBar_setTextVisible(QProgressBarH(Widget), visible);
|
||||
end;
|
||||
|
||||
procedure TQtProgressBar.setAlignment(alignment: QtAlignment);
|
||||
procedure TQtProgressBar.setAlignment(const AAlignment: QtAlignment);
|
||||
begin
|
||||
QProgressBar_setAlignment(QProgressBarH(Widget), alignment);
|
||||
QProgressBar_setAlignment(QProgressBarH(Widget), AAlignment);
|
||||
end;
|
||||
|
||||
procedure TQtProgressBar.setTextDirection(textDirection: QProgressBarDirection);
|
||||
|
@ -109,7 +109,7 @@ type
|
||||
private
|
||||
protected
|
||||
public
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND; override;
|
||||
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
|
||||
end;
|
||||
@ -136,7 +136,7 @@ const
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
class function TQtWSCustomControl.CreateHandle(const AWinControl: TWinControl;
|
||||
class function TQtWSCustomControl.CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): HWND;
|
||||
var
|
||||
QtAbstractScrollArea: TQtAbstractScrollArea;
|
||||
|
@ -234,9 +234,10 @@ 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 SetColor(const AWinControl: TWinControl); override;
|
||||
|
||||
{class procedure GetPreferredSize(const AWinControl: TWinControl;
|
||||
var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); override;}
|
||||
class procedure SetColor(const AWinControl: TWinControl); override;
|
||||
end;
|
||||
|
||||
{ TQtWSCustomCheckBox }
|
||||
@ -310,11 +311,10 @@ type
|
||||
private
|
||||
protected
|
||||
public
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; 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 SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment); override;
|
||||
|
||||
class function GetText(const AWinControl: TWinControl; var AText: String): Boolean; override;
|
||||
|
||||
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||
end;
|
||||
|
||||
@ -334,6 +334,11 @@ uses
|
||||
|
||||
const
|
||||
QtMaxEditLength = 32767;
|
||||
WordWrapMap: array[Boolean] of QTextEditLineWrapMode =
|
||||
(
|
||||
QTextEditNoWrap,
|
||||
QTextEditWidgetWidth
|
||||
);
|
||||
|
||||
|
||||
{ TQtWSScrollBar }
|
||||
@ -674,6 +679,11 @@ begin
|
||||
QtTextEdit := TQtTextEdit.Create(AWinControl, AParams);
|
||||
QtTextEdit.AttachEvents;
|
||||
|
||||
QtTextEdit.setAlignment(AlignmentMap[TCustomMemo(AWinControl).Alignment]);
|
||||
QtTextEdit.setReadOnly(TCustomMemo(AWinControl).ReadOnly);
|
||||
|
||||
QtTextEdit.setLineWrapMode(WordWrapMap[TCustomMemo(AWinControl).WordWrap]);
|
||||
|
||||
// create our FList helper
|
||||
QtTextEdit.FList := TQtMemoStrings.Create(QTextEditH(QtTextEdit.Widget), TCustomMemo(AWinControl));
|
||||
QtTextEdit.setScrollStyle(TCustomMemo(AWinControl).ScrollBars);
|
||||
@ -700,7 +710,7 @@ end;
|
||||
class procedure TQtWSCustomMemo.SetAlignment(const ACustomMemo: TCustomMemo;
|
||||
const AAlignment: TAlignment);
|
||||
begin
|
||||
TQtTextEdit(ACustomMemo.Handle).setAlignment(ACustomMemo.Alignment);
|
||||
TQtTextEdit(ACustomMemo.Handle).setAlignment(AlignmentMap[AAlignment]);
|
||||
end;
|
||||
|
||||
|
||||
@ -753,12 +763,6 @@ end;
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
class procedure TQtWSCustomMemo.SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean);
|
||||
const
|
||||
WordWrapMap: array[Boolean] of QTextEditLineWrapMode =
|
||||
(
|
||||
QTextEditNoWrap,
|
||||
QTextEditWidgetWidth
|
||||
);
|
||||
begin
|
||||
TQtTextEdit(ACustomMemo.Handle).setLineWrapMode(WordWrapMap[NewWordWrap]);
|
||||
end;
|
||||
@ -948,12 +952,11 @@ var
|
||||
QtStaticText: TQtStaticText;
|
||||
begin
|
||||
QtStaticText := TQtStaticText.Create(AWinControl, AParams);
|
||||
|
||||
QtStaticText.AttachEvents;
|
||||
// SetSlots(QtStaticText);
|
||||
|
||||
QtStaticText.setAlignment(AlignmentMap[TCustomStaticText(AWinControl).Alignment]);
|
||||
|
||||
// Returns the Handle
|
||||
|
||||
Result := THandle(QtStaticText);
|
||||
end;
|
||||
|
||||
@ -965,6 +968,7 @@ end;
|
||||
class procedure TQtWSCustomStaticText.SetAlignment(
|
||||
const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment);
|
||||
begin
|
||||
TQtStaticText(ACustomStaticText.Handle).setAlignment(AlignmentMap[NewAlignment]);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -976,13 +980,10 @@ class function TQtWSCustomStaticText.GetText(const AWinControl: TWinControl; var
|
||||
var
|
||||
Str: WideString;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AWinControl, 'GetText') then
|
||||
Exit;
|
||||
|
||||
if (csDestroying in AWinControl.ComponentState)
|
||||
or (csFreeNotification in AWinControl.ComponentState)
|
||||
then
|
||||
exit;
|
||||
|
||||
TQtStaticText(AWinControl.Handle).Text(@Str);
|
||||
TQtStaticText(AWinControl.Handle).getText(@Str);
|
||||
|
||||
AText := UTF8Encode(Str);
|
||||
|
||||
@ -998,7 +999,7 @@ class procedure TQtWSCustomStaticText.SetText(const AWinControl: TWinControl; co
|
||||
var
|
||||
Str: WideString;
|
||||
begin
|
||||
Str := UTF8Decode(AText);
|
||||
Str := GetUtf8String(AText);
|
||||
|
||||
TQtStaticText(AWinControl.Handle).SetText(@Str);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user