You've already forked lazarus-ccr
richmemo: started qt interface
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3764 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
109
components/richmemo/qt/qtrichmemo.pas
Normal file
109
components/richmemo/qt/qtrichmemo.pas
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
unit QtRichMemo;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
LCLType, Controls, StdCtrls,
|
||||||
|
qt4, qtwidgets, qtprivate,
|
||||||
|
WSProc,
|
||||||
|
RichMemo, WSRichMemo;
|
||||||
|
|
||||||
|
type
|
||||||
|
{ TQtWSCustomRichMemo }
|
||||||
|
|
||||||
|
TQtWSCustomRichMemo = class(TWSCustomRichMemo)
|
||||||
|
published
|
||||||
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
|
const AParams: TCreateParams): HWND; override;
|
||||||
|
class function GetParaAlignment(const AWinControl: TWinControl; TextStart: Integer;
|
||||||
|
var AAlign: TIntParaAlignment): Boolean; override;
|
||||||
|
class procedure SetParaAlignment(const AWinControl: TWinControl; TextStart, TextLen: Integer;
|
||||||
|
const AAlign: TIntParaAlignment); override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
const
|
||||||
|
WordWrapMap: array[Boolean] of QTextEditLineWrapMode =
|
||||||
|
(
|
||||||
|
QTextEditNoWrap,
|
||||||
|
QTextEditWidgetWidth
|
||||||
|
);
|
||||||
|
|
||||||
|
AlignmentMap: array[TIntParaAlignment] of QtAlignment =
|
||||||
|
(
|
||||||
|
QtAlignLeft,
|
||||||
|
QtAlignRight,
|
||||||
|
QtAlignHCenter,
|
||||||
|
QtAlignJustify
|
||||||
|
);
|
||||||
|
|
||||||
|
{ TQtWSCustomRichMemo }
|
||||||
|
|
||||||
|
class function TQtWSCustomRichMemo.CreateHandle(const AWinControl: TWinControl;
|
||||||
|
const AParams: TCreateParams): HWND;
|
||||||
|
var
|
||||||
|
QtTextEdit: TQtTextEdit;
|
||||||
|
begin
|
||||||
|
QtTextEdit := TQtTextEdit.Create(AWinControl, AParams);
|
||||||
|
QtTextEdit.AcceptRichText := True;
|
||||||
|
QtTextEdit.ClearText;
|
||||||
|
QtTextEdit.setBorder(TCustomMemo(AWinControl).BorderStyle = bsSingle);
|
||||||
|
QtTextEdit.setReadOnly(TCustomMemo(AWinControl).ReadOnly);
|
||||||
|
QtTextEdit.setLineWrapMode(WordWrapMap[TCustomMemo(AWinControl).WordWrap]);
|
||||||
|
// create our FList helper
|
||||||
|
QtTextEdit.FList := TQtMemoStrings.Create(TCustomMemo(AWinControl));
|
||||||
|
QtTextEdit.setScrollStyle(TCustomMemo(AWinControl).ScrollBars);
|
||||||
|
QtTextEdit.setTabChangesFocus(not TCustomMemo(AWinControl).WantTabs);
|
||||||
|
|
||||||
|
QtTextEdit.AttachEvents;
|
||||||
|
|
||||||
|
Result := TLCLIntfHandle(QtTextEdit);
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TQtWSCustomRichMemo.SetParaAlignment(
|
||||||
|
const AWinControl: TWinControl; TextStart, TextLen: Integer;
|
||||||
|
const AAlign: TIntParaAlignment);
|
||||||
|
var
|
||||||
|
w : QTextEditH;
|
||||||
|
te : TQtTextEdit;
|
||||||
|
ss, sl : Integer;
|
||||||
|
begin
|
||||||
|
if not WSCheckHandleAllocated(AWinControl, 'SetParaAlignment') then
|
||||||
|
Exit;
|
||||||
|
te:=TQtTextEdit(AWinControl.Handle);
|
||||||
|
w:=QTextEditH(te.Widget);
|
||||||
|
|
||||||
|
ss:=te.getSelectionStart;
|
||||||
|
sl:=te.getSelectionLength;
|
||||||
|
|
||||||
|
te.setSelection(TextStart, TextLen);
|
||||||
|
|
||||||
|
// alignment
|
||||||
|
QTextEdit_setAlignment(w, AlignmentMap[AAlign]);
|
||||||
|
|
||||||
|
te.setSelection(ss, sl);
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TQtWSCustomRichMemo.GetParaAlignment(
|
||||||
|
const AWinControl: TWinControl; TextStart: Integer;
|
||||||
|
var AAlign: TIntParaAlignment): Boolean;
|
||||||
|
var
|
||||||
|
te : TQtTextEdit;
|
||||||
|
al : QtAlignment;
|
||||||
|
begin
|
||||||
|
if not WSCheckHandleAllocated(AWinControl, 'GetParaAlignment') then begin
|
||||||
|
Result:=false;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
te:=TQtTextEdit(AWinControl.Handle);
|
||||||
|
al:=QTextEdit_alignment(QTextEditH(te.Widget));
|
||||||
|
if QtAlignLeading and al > 0 then AAlign:=paLeft
|
||||||
|
else if QtAlignTrailing and al > 0 then AAlign:=paRight
|
||||||
|
else if QtAlignCenter and al > 0 then AAlign:=paCenter
|
||||||
|
else if QtAlignJustify and al > 0 then AAlign:=paJustify
|
||||||
|
else AAlign:=paLeft;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
@ -9,6 +9,7 @@ interface
|
|||||||
{$ifdef LCLCarbon}{$undef NoRichMemo}{$endif}
|
{$ifdef LCLCarbon}{$undef NoRichMemo}{$endif}
|
||||||
{$ifdef LCLGtk2}{$undef NoRichMemo}{$endif}
|
{$ifdef LCLGtk2}{$undef NoRichMemo}{$endif}
|
||||||
{$ifdef LCLCocoa}{$undef NoRichMemo}{$endif}
|
{$ifdef LCLCocoa}{$undef NoRichMemo}{$endif}
|
||||||
|
{$ifdef LCLQt}{$undef NoRichMemo}{$endif}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
WSLCLClasses,
|
WSLCLClasses,
|
||||||
@ -26,6 +27,7 @@ uses
|
|||||||
,RichMemoRTF, Gtk2RichMemo
|
,RichMemoRTF, Gtk2RichMemo
|
||||||
{$endif}
|
{$endif}
|
||||||
{$ifdef LCLCocoa},CocoaRichMemo{$endif}
|
{$ifdef LCLCocoa},CocoaRichMemo{$endif}
|
||||||
|
{$ifdef LCLQt},QtRichMemo{$endif}
|
||||||
;
|
;
|
||||||
|
|
||||||
function RegisterCustomRichMemo: Boolean;
|
function RegisterCustomRichMemo: Boolean;
|
||||||
@ -44,6 +46,7 @@ begin
|
|||||||
{$endif}
|
{$endif}
|
||||||
{$endif}
|
{$endif}
|
||||||
{$ifdef LCLCocoa}RegisterWSComponent(TCustomRichMemo, TCocoaWSCustomRichMemo);{$endif}
|
{$ifdef LCLCocoa}RegisterWSComponent(TCustomRichMemo, TCocoaWSCustomRichMemo);{$endif}
|
||||||
|
{$ifdef LCLQt}RegisterWSComponent(TCustomRichMemo, TQtWSCustomRichMemo);{$endif}
|
||||||
{$ifdef NoRichMemo}RegisterWSComponent(TCustomRichMemo, TWSCustomRichMemo);{$endif}
|
{$ifdef NoRichMemo}RegisterWSComponent(TCustomRichMemo, TWSCustomRichMemo);{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
<Version Value="11"/>
|
<Version Value="11"/>
|
||||||
<PathDelim Value="\"/>
|
<PathDelim Value="\"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="cocoa"/>
|
<IncludeFiles Value="cocoa;qt"/>
|
||||||
<OtherUnitFiles Value="win32;carbon;gtk2;cocoa"/>
|
<OtherUnitFiles Value="win32;carbon;gtk2;cocoa;qt"/>
|
||||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Parsing>
|
<Parsing>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
"/>
|
"/>
|
||||||
<License Value="LGPL"/>
|
<License Value="LGPL"/>
|
||||||
<Version Major="1"/>
|
<Version Major="1"/>
|
||||||
<Files Count="15">
|
<Files Count="16">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="wsrichmemo.pas"/>
|
<Filename Value="wsrichmemo.pas"/>
|
||||||
<AddToUsesPkgSection Value="False"/>
|
<AddToUsesPkgSection Value="False"/>
|
||||||
@ -98,6 +98,10 @@
|
|||||||
<Filename Value="richmemohelpers.pas"/>
|
<Filename Value="richmemohelpers.pas"/>
|
||||||
<UnitName Value="RichMemoHelpers"/>
|
<UnitName Value="RichMemoHelpers"/>
|
||||||
</Item15>
|
</Item15>
|
||||||
|
<Item16>
|
||||||
|
<Filename Value="qt\qtrichmemo.pas"/>
|
||||||
|
<AddToUsesPkgSection Value="False"/>
|
||||||
|
</Item16>
|
||||||
</Files>
|
</Files>
|
||||||
<Type Value="RunAndDesignTime"/>
|
<Type Value="RunAndDesignTime"/>
|
||||||
<RequiredPkgs Count="2">
|
<RequiredPkgs Count="2">
|
||||||
|
Reference in New Issue
Block a user