You've already forked lazarus-ccr
richmemo: added modified paragraph modified mask.
update the paragraph demo to adjust paragraph metrics git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3786 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -59,6 +59,7 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
TTextModifyMask = set of (tmm_Color, tmm_Name, tmm_Size, tmm_Styles);
|
TTextModifyMask = set of (tmm_Color, tmm_Name, tmm_Size, tmm_Styles);
|
||||||
|
TParaModifyMask = set of (pmm_FirstLine, pmm_HeadIndent, pmm_TailIndent, pmm_SpaceBefore, pmm_SpaceAfter, pmm_LineSpacing);
|
||||||
|
|
||||||
TSearchOption = (soMatchCase, soWholeWord, soBackward);
|
TSearchOption = (soMatchCase, soWholeWord, soBackward);
|
||||||
TSearchOptions = set of TSearchOption;
|
TSearchOptions = set of TSearchOption;
|
||||||
@ -112,6 +113,8 @@ type
|
|||||||
procedure SetRangeColor(TextStart, TextLength: Integer; FontColor: TColor);
|
procedure SetRangeColor(TextStart, TextLength: Integer; FontColor: TColor);
|
||||||
procedure SetRangeParams(TextStart, TextLength: Integer; ModifyMask: TTextModifyMask;
|
procedure SetRangeParams(TextStart, TextLength: Integer; ModifyMask: TTextModifyMask;
|
||||||
const FontName: String; FontSize: Integer; FontColor: TColor; AddFontStyle, RemoveFontStyle: TFontStyles);
|
const FontName: String; FontSize: Integer; FontColor: TColor; AddFontStyle, RemoveFontStyle: TFontStyles);
|
||||||
|
procedure SetRangeParaParams(TextStart, TextLength: INteger; ModifyMask: TParaModifyMask;
|
||||||
|
const ParaMetric: TParaMetric);
|
||||||
|
|
||||||
function LoadRichText(Source: TStream): Boolean; virtual;
|
function LoadRichText(Source: TStream): Boolean; virtual;
|
||||||
function SaveRichText(Dest: TStream): Boolean; virtual;
|
function SaveRichText(Dest: TStream): Boolean; virtual;
|
||||||
@ -458,6 +461,31 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomRichMemo.SetRangeParaParams(TextStart, TextLength: INteger;
|
||||||
|
ModifyMask: TParaModifyMask; const ParaMetric: TParaMetric);
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
st, ln: Integer;
|
||||||
|
m : TParaMetric;
|
||||||
|
begin
|
||||||
|
repeat
|
||||||
|
GetParaRange(TextStart, TextStart, ln);
|
||||||
|
GetParaMetric(TextStart, m);
|
||||||
|
|
||||||
|
if pmm_FirstLine in ModifyMask then m.FirstLine:=ParaMetric.FirstLine;
|
||||||
|
if pmm_HeadIndent in ModifyMask then m.HeadIndent:=ParaMetric.HeadIndent;
|
||||||
|
if pmm_TailIndent in ModifyMask then m.TailIndent:=ParaMetric.TailIndent;
|
||||||
|
if pmm_SpaceBefore in ModifyMask then m.SpaceBefore:=ParaMetric.SpaceBefore;
|
||||||
|
if pmm_SpaceAfter in ModifyMask then m.SpaceAfter:=ParaMetric.SpaceAfter;
|
||||||
|
if pmm_LineSpacing in ModifyMask then m.LineSpacing:=ParaMetric.LineSpacing;
|
||||||
|
SetParaMetric(TextStart, 1, m);
|
||||||
|
|
||||||
|
inc(TextStart, ln);
|
||||||
|
dec(TextLength, ln);
|
||||||
|
|
||||||
|
until TextLength<=0;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomRichMemo.LoadRichText(Source: TStream): Boolean;
|
function TCustomRichMemo.LoadRichText(Source: TStream): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
@ -20,8 +20,8 @@ object Form1: TForm1
|
|||||||
end
|
end
|
||||||
object RichMemo1: TRichMemo
|
object RichMemo1: TRichMemo
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 280
|
Height = 224
|
||||||
Top = 48
|
Top = 104
|
||||||
Width = 599
|
Width = 599
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
HideSelection = False
|
HideSelection = False
|
||||||
@ -187,6 +187,57 @@ object Form1: TForm1
|
|||||||
GroupIndex = 1
|
GroupIndex = 1
|
||||||
OnClick = btnJAClick
|
OnClick = btnJAClick
|
||||||
end
|
end
|
||||||
|
object edtFL: TSpinEdit
|
||||||
|
Left = 72
|
||||||
|
Height = 21
|
||||||
|
Top = 48
|
||||||
|
Width = 88
|
||||||
|
MaxValue = 1000
|
||||||
|
OnChange = edtFLChange
|
||||||
|
TabOrder = 3
|
||||||
|
end
|
||||||
|
object edtHI: TSpinEdit
|
||||||
|
Left = 72
|
||||||
|
Height = 21
|
||||||
|
Top = 72
|
||||||
|
Width = 88
|
||||||
|
MaxValue = 1000
|
||||||
|
OnChange = edtHIChange
|
||||||
|
TabOrder = 4
|
||||||
|
end
|
||||||
|
object edtTI: TSpinEdit
|
||||||
|
Left = 240
|
||||||
|
Height = 21
|
||||||
|
Top = 48
|
||||||
|
Width = 88
|
||||||
|
MaxValue = 1000
|
||||||
|
OnChange = edtTIChange
|
||||||
|
TabOrder = 5
|
||||||
|
end
|
||||||
|
object Label1: TLabel
|
||||||
|
Left = 8
|
||||||
|
Height = 13
|
||||||
|
Top = 48
|
||||||
|
Width = 43
|
||||||
|
Caption = 'First Line'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object Label2: TLabel
|
||||||
|
Left = 8
|
||||||
|
Height = 13
|
||||||
|
Top = 72
|
||||||
|
Width = 32
|
||||||
|
Caption = 'Indent'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object Label3: TLabel
|
||||||
|
Left = 176
|
||||||
|
Height = 13
|
||||||
|
Top = 48
|
||||||
|
Width = 51
|
||||||
|
Caption = 'Tail Indent'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
object OpenDialog1: TOpenDialog
|
object OpenDialog1: TOpenDialog
|
||||||
left = 488
|
left = 488
|
||||||
top = 16
|
top = 16
|
||||||
|
@ -6,7 +6,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||||
Buttons, ComCtrls, RichMemo, RichMemoUtils, Win32RichMemo;
|
Buttons, ComCtrls, Spin, RichMemo, RichMemoUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -16,12 +16,18 @@ type
|
|||||||
Button1: TButton;
|
Button1: TButton;
|
||||||
Button2: TButton;
|
Button2: TButton;
|
||||||
ImageList1: TImageList;
|
ImageList1: TImageList;
|
||||||
|
Label1: TLabel;
|
||||||
|
Label2: TLabel;
|
||||||
|
Label3: TLabel;
|
||||||
OpenDialog1: TOpenDialog;
|
OpenDialog1: TOpenDialog;
|
||||||
RichMemo1: TRichMemo;
|
RichMemo1: TRichMemo;
|
||||||
btnLA: TSpeedButton;
|
btnLA: TSpeedButton;
|
||||||
btnCA: TSpeedButton;
|
btnCA: TSpeedButton;
|
||||||
btnRA: TSpeedButton;
|
btnRA: TSpeedButton;
|
||||||
btnJA: TSpeedButton;
|
btnJA: TSpeedButton;
|
||||||
|
edtFL: TSpinEdit;
|
||||||
|
edtHI: TSpinEdit;
|
||||||
|
edtTI: TSpinEdit;
|
||||||
procedure btnCAClick(Sender: TObject);
|
procedure btnCAClick(Sender: TObject);
|
||||||
procedure btnJAClick(Sender: TObject);
|
procedure btnJAClick(Sender: TObject);
|
||||||
procedure btnLAClick(Sender: TObject);
|
procedure btnLAClick(Sender: TObject);
|
||||||
@ -29,6 +35,9 @@ type
|
|||||||
procedure Button1Click(Sender: TObject);
|
procedure Button1Click(Sender: TObject);
|
||||||
procedure Button2Click(Sender: TObject);
|
procedure Button2Click(Sender: TObject);
|
||||||
procedure Button3Click(Sender: TObject);
|
procedure Button3Click(Sender: TObject);
|
||||||
|
procedure edtFLChange(Sender: TObject);
|
||||||
|
procedure edtHIChange(Sender: TObject);
|
||||||
|
procedure edtTIChange(Sender: TObject);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
procedure RichMemo1Click(Sender: TObject);
|
procedure RichMemo1Click(Sender: TObject);
|
||||||
procedure RichMemo1KeyDown(Sender: TObject; var Key: Word;
|
procedure RichMemo1KeyDown(Sender: TObject; var Key: Word;
|
||||||
@ -92,6 +101,36 @@ procedure TForm1.Button3Click(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.edtFLChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
m : TParaMetric;
|
||||||
|
begin
|
||||||
|
InitParaMetric(m);
|
||||||
|
m.FirstLine:=edtFL.Value;
|
||||||
|
RichMemo1.SetRangeParaParams(RichMemo1.SelStart, RichMemo1.SelLength,
|
||||||
|
[pmm_FirstLine], m);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.edtHIChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
m :TParaMetric;
|
||||||
|
begin
|
||||||
|
InitParaMetric(m);
|
||||||
|
m.HeadIndent:=edtHI.Value;
|
||||||
|
RichMemo1.SetRangeParaParams(RichMemo1.SelStart, RichMemo1.SelLength,
|
||||||
|
[pmm_HeadIndent], m);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.edtTIChange(Sender: TObject);
|
||||||
|
var
|
||||||
|
m :TParaMetric;
|
||||||
|
begin
|
||||||
|
InitParaMetric(m);
|
||||||
|
m.TailIndent:=edtTI.Value;
|
||||||
|
RichMemo1.SetRangeParaParams(RichMemo1.SelStart, RichMemo1.SelLength,
|
||||||
|
[pmm_TailIndent], m);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormShow(Sender: TObject);
|
procedure TForm1.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
SelectionChanged;
|
SelectionChanged;
|
||||||
@ -111,6 +150,7 @@ end;
|
|||||||
procedure TForm1.SelectionChanged;
|
procedure TForm1.SelectionChanged;
|
||||||
var
|
var
|
||||||
pa : TParaAlignment;
|
pa : TParaAlignment;
|
||||||
|
m : TParaMetric;
|
||||||
begin
|
begin
|
||||||
pa:=RichMemo1.GetParaAlignment(RichMemo1.SelStart);
|
pa:=RichMemo1.GetParaAlignment(RichMemo1.SelStart);
|
||||||
case pa of
|
case pa of
|
||||||
@ -119,6 +159,16 @@ begin
|
|||||||
paCenter: btnCA.Down:=true;
|
paCenter: btnCA.Down:=true;
|
||||||
paJustify: btnJA.Down:=true;
|
paJustify: btnJA.Down:=true;
|
||||||
end;
|
end;
|
||||||
|
edtFL.OnChange:=nil;
|
||||||
|
edtHI.OnChange:=nil;
|
||||||
|
edtTI.OnChange:=nil;
|
||||||
|
RichMemo1.GetParaMetric(RichMemo1.SelStart, m);
|
||||||
|
edtFL.Value:=round(m.FirstLine);
|
||||||
|
edtHI.Value:=round(m.HeadIndent);
|
||||||
|
edtTI.Value:=round(m.TailIndent);
|
||||||
|
edtFL.OnChange:=@edtFLChange;
|
||||||
|
edtHI.OnChange:=@edtHIChange;
|
||||||
|
edtTI.OnChange:=@edtTIChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.SetRichAlign(a: TParaAlignment);
|
procedure TForm1.SetRichAlign(a: TParaAlignment);
|
||||||
|
Reference in New Issue
Block a user