richmemo: * added tabstops support for the RichMemo and Win32Implementation

* added initialization to factory unit to prevent a warning on package compilation 
* clean up uses for richedit helpers
* code cleanup (removing empty lines)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4040 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2015-03-16 17:41:08 +00:00
parent d1a80fc98f
commit 3f1fc5e502
6 changed files with 171 additions and 31 deletions

View File

@ -90,6 +90,18 @@ type
// thus length = lengthNoBr
end;
type
TTabAlignment = (taHead, taCenter, taTail, taDecimal, taWordBar);
TTabStop = record
Offset : Double;
Align : TTabAlignment; // not used
end;
TTabStopList = record
Count : Integer;
Tabs : array of TTabStop;
end;
type
TRichMemoObject = class(TObject);
@ -150,6 +162,9 @@ type
function GetParaRange(CharOfs: Integer; var ParaRange: TParaRange): Boolean; virtual;
function GetParaRange(CharOfs: Integer; var TextStart, TextLength: Integer): Boolean;
procedure SetParaTabs(TextStart, TextLen: Integer; const AStopList: TTabStopList); virtual;
function GetParaTabs(CharOfs: Integer; var AStopList: TTabStopList): Boolean; virtual;
procedure SetTextAttributes(TextStart, TextLen: Integer; AFont: TFont);
procedure SetRangeColor(TextStart, TextLength: Integer; FontColor: TColor);
procedure SetRangeParams(TextStart, TextLength: Integer; ModifyMask: TTextModifyMask;
@ -253,6 +268,9 @@ procedure InitParaMetric(var m: TParaMetric);
procedure InitParaNumbering(var n: TParaNumbering);
procedure InitParaNumber(var n: TParaNumbering; ASepChar: WideChar = SepPar; StartNum: Integer = 1);
procedure InitParaBullet(var n: TParaNumbering);
procedure InitTabStopList(var tabs: TTabStopList); overload;
procedure InitTabStopList(var tabs: TTabStopList; const TabStopsPt: array of double); overload;
var
RTFLoadStream : function (AMemo: TCustomRichMemo; Source: TStream): Boolean = nil;
@ -379,6 +397,23 @@ begin
n.Style:=pnBullet;
end;
procedure InitTabStopList(var tabs: TTabStopList);
begin
FillChar(tabs, sizeof(tabs), 0);
end;
procedure InitTabStopList(var tabs: TTabStopList; const TabStopsPt: array of double);
var
i : Integer;
begin
InitTabStopList(tabs);
tabs.count:=length(TabStopsPt);
SetLength(tabs.tabs, tabs.Count);
for i:=0 to tabs.Count-1 do begin
tabs.tabs[i].Offset:=TabStopsPt[i];
end;
end;
{ TRichMemoInline }
procedure TRichMemoInline.Draw(Canvas: TCanvas; const ASize: TSize);
@ -611,6 +646,21 @@ begin
TextLength:=p.length;
end;
procedure TCustomRichMemo.SetParaTabs(TextStart, TextLen: Integer;
const AStopList: TTabStopList);
begin
if HandleAllocated then
TWSCustomRichMemoClass(WidgetSetClass).SetParaTabs(Self, TextStart, TextLen, AStopList);
end;
function TCustomRichMemo.GetParaTabs(CharOfs: Integer; var AStopList: TTabStopList): Boolean;
begin
Result:=false;
if not HandleAllocated then HandleNeeded;
if HandleAllocated then
Result:=TWSCustomRichMemoClass(WidgetSetClass).GetParaTabs(Self, CharOfs, AStopList);
end;
function TCustomRichMemo.GetContStyleLength(TextStart: Integer): Integer;
var
ofs, len : Integer;