You've already forked lazarus-ccr
richmemo: introducing zoomfactor property with win32 implementation.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3827 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -88,6 +88,7 @@ type
|
||||
private
|
||||
fHideSelection : Boolean;
|
||||
fOnSelectionChange: TNotifyEvent;
|
||||
fZoomFactor : Double;
|
||||
protected
|
||||
procedure DoSelectionChange;
|
||||
class procedure WSRegisterClass; override;
|
||||
@ -97,7 +98,10 @@ type
|
||||
function GetContStyleLength(TextStart: Integer): Integer;
|
||||
|
||||
procedure SetSelText(const SelTextUTF8: string); override;
|
||||
function GetZoomFactor: Double; virtual;
|
||||
procedure SetZoomFactor(AValue: Double); virtual;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure CopyToClipboard; override;
|
||||
procedure CutToClipboard; override;
|
||||
procedure PasteFromClipboard; override;
|
||||
@ -136,6 +140,7 @@ type
|
||||
|
||||
property HideSelection : Boolean read fHideSelection write SetHideSelection;
|
||||
property OnSelectionChange: TNotifyEvent read fOnSelectionChange write fOnSelectionChange;
|
||||
property ZoomFactor: Double read GetZoomFactor write SetZoomFactor;
|
||||
end;
|
||||
|
||||
{ TRichMemo }
|
||||
@ -203,6 +208,7 @@ type
|
||||
property WantReturns;
|
||||
property WantTabs;
|
||||
property WordWrap;
|
||||
property ZoomFactor;
|
||||
end;
|
||||
|
||||
procedure InitFontParams(var p: TFontParams);
|
||||
@ -325,6 +331,19 @@ begin
|
||||
fHideSelection := AValue;
|
||||
end;
|
||||
|
||||
function TCustomRichMemo.GetZoomFactor: Double;
|
||||
begin
|
||||
Result:=fZoomFactor;
|
||||
end;
|
||||
|
||||
procedure TCustomRichMemo.SetZoomFactor(AValue: Double);
|
||||
begin
|
||||
if AValue=0 then AValue:=1.0;
|
||||
fZoomFactor:=AValue;
|
||||
if HandleAllocated then
|
||||
TWSCustomRichMemoClass(WidgetSetClass).SetZoomFactor(Self, AValue);
|
||||
end;
|
||||
|
||||
procedure TCustomRichMemo.DoSelectionChange;
|
||||
begin
|
||||
if Assigned(fOnSelectionChange) then fOnSelectionChange(Self);
|
||||
@ -346,6 +365,7 @@ procedure TCustomRichMemo.UpdateRichMemo;
|
||||
begin
|
||||
if not HandleAllocated then Exit;
|
||||
TWSCustomRichMemoClass(WidgetSetClass).SetHideSelection(Self, fHideSelection);
|
||||
TWSCustomRichMemoClass(WidgetSetClass).SetZoomFactor(Self, fZoomFactor);
|
||||
end;
|
||||
|
||||
procedure TCustomRichMemo.SetTextAttributes(TextStart, TextLen: Integer;
|
||||
@ -486,6 +506,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCustomRichMemo.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fZoomFactor:=1;
|
||||
end;
|
||||
|
||||
|
||||
procedure TCustomRichMemo.CopyToClipboard;
|
||||
begin
|
||||
|
@ -103,6 +103,8 @@ type
|
||||
|
||||
class function Search(const AWinControl: TWinControl; const ANiddle: string;
|
||||
const SearchOpts: TIntSearchOpt): Integer; override;
|
||||
|
||||
class procedure SetZoomFactor(const AWinControl: TWinControl; AZoomFactor: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -681,6 +683,16 @@ begin
|
||||
if not Assigned(RichEditManager) or not Assigned(AWinControl) then Exit;
|
||||
Result:=RichEditManager.Find(AWinControl.Handle, UTF8Decode(ANiddle), SearchOpts);
|
||||
end;
|
||||
|
||||
class procedure TWin32WSCustomRichMemo.SetZoomFactor(
|
||||
const AWinControl: TWinControl; AZoomFactor: Double);
|
||||
var
|
||||
DN : WParam;
|
||||
begin
|
||||
if not Assigned(RichEditManager) or not Assigned(AWinControl) then Exit;
|
||||
DN := 1000;
|
||||
SendMessage( AWinControl.Handle, EM_SETZOOM, round(AZoomFactor * DN), DN);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -89,6 +89,8 @@ type
|
||||
class function SaveRichText(const AWinControl: TWinControl; Dest: TStream): Boolean; virtual;
|
||||
|
||||
class function Search(const AWinControl: TWinControl; const ANiddle: string; const SearchOpts: TIntSearchOpt): Integer; virtual;
|
||||
|
||||
class procedure SetZoomFactor(const AWinControl: TWinControl; AZoomFactor: Double); virtual;
|
||||
end;
|
||||
TWSCustomRichMemoClass = class of TWSCustomRichMemo;
|
||||
|
||||
@ -207,5 +209,11 @@ begin
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
class procedure TWSCustomRichMemo.SetZoomFactor(const AWinControl: TWinControl;
|
||||
AZoomFactor: Double);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Reference in New Issue
Block a user