started get style range implementaion for Win32/64
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@847 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
5ce2730604
commit
fc539c83ce
@ -178,8 +178,20 @@ end;
|
|||||||
class function TWin32WSCustomRichMemo.GetStyleRange(
|
class function TWin32WSCustomRichMemo.GetStyleRange(
|
||||||
const AWinControl: TWinControl; TextStart: Integer; var RangeStart,
|
const AWinControl: TWinControl; TextStart: Integer; var RangeStart,
|
||||||
RangeLen: Integer): Boolean;
|
RangeLen: Integer): Boolean;
|
||||||
|
var
|
||||||
|
OrigStart : Integer;
|
||||||
|
OrigLen : Integer;
|
||||||
begin
|
begin
|
||||||
Result:=inherited GetStyleRange(AWinControl, TextStart, RangeStart, RangeLen);
|
if not Assigned(RichEditManager) or not Assigned(AWinControl) then begin
|
||||||
|
Result := false;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
RichEditManager.GetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
||||||
|
LockRedraw(AWinControl.Handle);
|
||||||
|
RichEditManager.SetSelection(AWinControl.Handle, TextStart, 1);
|
||||||
|
Result := RichEditManager.GetStyleRange(AWinControl.Handle, TextStart, RangeStart, RangeLen);
|
||||||
|
RichEditManager.SetSelection(AWinControl.Handle, OrigStart, OrigLen);
|
||||||
|
UnlockRedraw(AWinControl.Handle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TWin32WSCustomRichMemo.LoadRichText(
|
class function TWin32WSCustomRichMemo.LoadRichText(
|
||||||
|
@ -21,9 +21,9 @@ type
|
|||||||
|
|
||||||
TRichEditManager = class(TObject)
|
TRichEditManager = class(TObject)
|
||||||
public
|
public
|
||||||
class function SetSelectedTextStyle(RichEditWnd: Handle;
|
class function SetSelectedTextStyle(RichEditWnd: Handle; Params: TIntFontParams): Boolean; virtual;
|
||||||
Params: TIntFontParams): Boolean; virtual;
|
|
||||||
class function GetSelectedTextStyle(RichEditWnd: Handle; var Params: TIntFontParams): Boolean; virtual;
|
class function GetSelectedTextStyle(RichEditWnd: Handle; var Params: TIntFontParams): Boolean; virtual;
|
||||||
|
class function GetStyleRange(RichEditWnd: Handle; TextStart: Integer; var RangeStart, RangeLen: Integer): Boolean; virtual;
|
||||||
class procedure GetSelection(RichEditWnd: Handle; var TextStart, TextLen: Integer); virtual;
|
class procedure GetSelection(RichEditWnd: Handle; var TextStart, TextLen: Integer); virtual;
|
||||||
class procedure SetSelection(RichEditWnd: Handle; TextStart, TextLen: Integer); virtual;
|
class procedure SetSelection(RichEditWnd: Handle; TextStart, TextLen: Integer); virtual;
|
||||||
class procedure SetHideSelection(RichEditWnd: Handle; AValue: Boolean); virtual;
|
class procedure SetHideSelection(RichEditWnd: Handle; AValue: Boolean); virtual;
|
||||||
@ -163,6 +163,58 @@ begin
|
|||||||
Result := true;
|
Result := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TRichEditManager.GetStyleRange(RichEditWnd: Handle; TextStart: Integer;
|
||||||
|
var RangeStart, RangeLen: Integer): Boolean;
|
||||||
|
var
|
||||||
|
w : WPARAM;
|
||||||
|
len : integer;
|
||||||
|
fmt : TCHARFORMAT;
|
||||||
|
mask : LongWord;
|
||||||
|
textlen : TGETTEXTEX;
|
||||||
|
sel : TCHARRANGE;
|
||||||
|
rngend : Integer;
|
||||||
|
d : Integer;
|
||||||
|
const
|
||||||
|
CP_UNICODE = 1200;
|
||||||
|
ALL_MASK = CFM_BOLD or CFM_ITALIC or CFM_STRIKEOUT or CFM_UNDERLINE or
|
||||||
|
CFM_SIZE or CFM_COLOR or CFM_FACE;
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
if RichEditWnd = 0 then Exit;
|
||||||
|
|
||||||
|
textlen.flags := GTL_DEFAULT or GTL_NUMCHARS;
|
||||||
|
textlen.codepage := CP_UNICODE;
|
||||||
|
len := SendMessage(RichEditWnd, EM_GETTEXTLENGTHEX, WPARAM(@textlen), 0);
|
||||||
|
|
||||||
|
sel.cpMin := TextStart;
|
||||||
|
sel.cpMax := len;
|
||||||
|
SendMessage(RichEditWnd, EM_EXSETSEL, 0, LPARAM(@sel));
|
||||||
|
|
||||||
|
FillChar(fmt, sizeof(fmt), 0);
|
||||||
|
fmt.cbSize := sizeof(fmt);
|
||||||
|
SendMessage(RichEditWnd, EM_GETCHARFORMAT, SCF_SELECTION, PtrInt(@fmt));
|
||||||
|
|
||||||
|
|
||||||
|
if fmt.dwMask and ALL_MASK <> ALL_MASK then begin
|
||||||
|
rngend := len;
|
||||||
|
d := rngend - sel.cpMin;
|
||||||
|
sel.cpMax := sel.cpMin + d div 2;
|
||||||
|
while d > 1 do begin
|
||||||
|
SendMessage(RichEditWnd, EM_EXSETSEL, 0, LPARAM(@sel));
|
||||||
|
SendMessage(RichEditWnd, EM_GETCHARFORMAT, SCF_SELECTION, PtrInt(@fmt));
|
||||||
|
d := d div 2;
|
||||||
|
if fmt.dwMask and ALL_MASK = ALL_MASK then
|
||||||
|
sel.cpMax := sel.cpMax + d
|
||||||
|
else
|
||||||
|
sel.cpMax := sel.cpMax - d;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
RangeStart := sel.cpMin;
|
||||||
|
RangeLen := sel.cpMax - sel.cpMin;
|
||||||
|
Result := true;
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TRichEditManager.GetSelection(RichEditWnd: Handle; var TextStart, TextLen: Integer);
|
class procedure TRichEditManager.GetSelection(RichEditWnd: Handle; var TextStart, TextLen: Integer);
|
||||||
var
|
var
|
||||||
Range : TCHARRANGE;
|
Range : TCHARRANGE;
|
||||||
|
Loading…
Reference in New Issue
Block a user