EControl Ltd. Forum Index EControl Ltd.
VCL libraries and software support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Customizing Problem

 
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor
View previous topic :: View next topic  
Author Message
Schnorrenberg



Joined: 10 Aug 2006
Posts: 8

PostPosted: Tue Aug 15, 2006 8:58 am    Post subject: Customizing Problem Reply with quote

Hello Michael,

I wanted to customize TSyntaxMemo (introducing Linenumbers as ec_Edit as an option), and recognized, that this is impossible without modifying the original source SyntaxMemo.pas.

Therefore, what are you thinking about introducing class function, so that customizing is possible without modifying the source?

for exapmle:

type
TLineNumbersClass = class of TLineNumber;

introducing protected, virtual function in TSyntaxMemo:

function TSyntaxMemo.GetLineNumbersClass: TLineNumbersClass;
begin
Result := TLineNumbers;
end;

modifying the constructor:

constructor TSyntaxMemo.Create(AOwner: TComponent);
begin
.....
FLineNumbers := GetLineNumbersClass.Create(Self);
......
end;


Then, it would be possible to customize TLineNumers by simple overriding GetLineNumberClass:

Result := TMyLineNumbersClass;


Hans-Jürgen
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Tue Aug 15, 2006 12:27 pm    Post subject: Reply with quote

Hello Hans,

TLineNumbers is only storage for properties, there is only one method that forms line number string and this process may be controled by via event handler OnGetLineNumberStr.
All functionality of line numbers rendering is implemented in TCustomSyntaxMemo.

What is the task that requires such replacement?

Michael.
Back to top
View user's profile Send private message Send e-mail
Schnorrenberg



Joined: 10 Aug 2006
Posts: 8

PostPosted: Tue Aug 15, 2006 6:29 pm    Post subject: Reply with quote

Hello Michael,

in this task I wanted to replace the event handler by a method, because we plan to replace (and will replace) many controls by your control in our applications, and I do not want to implement every time an event handler. Therefore, I override the GetNumberString method in a descendant of TLinenumbers (in order to get linenumbers like in ec_edit.exe).

However, I think it is a question of more principal nature (at the moment I'm still testing your control, please consider the "linenumber wish" only as an example). We use many third-party components in our applications, and for a component user there exists often the problems of customizing nested components and missing virtualty. (Borland components, too: if you want to sort a Collection, you have to hack into the VMT, because they forget to give access to FList).

Hans-Jürgen
Back to top
View user's profile Send private message
econtrol
Site Admin


Joined: 09 Jun 2006
Posts: 202

PostPosted: Wed Aug 16, 2006 3:52 am    Post subject: Reply with quote

I offer next solution (ecSyntMemo.pas):

new protected method:

Code:
  TCustomSyntaxMemo
  ...
    function GetLineNumberStr(Line: integer): ecString; dynamic;
  ...

function TCustomSyntaxMemo.GetLineNumberStr(Line: integer): ecString;
begin
  Result := FLineNumbers.GetNumberString(Line);
  if Assigned(FOnGetLineNumberStr) then FOnGetLineNumberStr(Self, Line, Result);
end;

procedure TCustomSyntaxMemo.DrawGutterLine(y1, y2, Line, LineColState: integer);   // Draw Gutter
...
   s := GetLineNumberStr(Line); // <==
   if s = '' then Exit;
   ts := cvs.TextExtent(S);
...


In this case you may reimplement this method in derived class.

P.S. The advantage of Win32 in comparison with .NET is the ability of accessing to protected and private memebers. I often used these techniques.

Michael.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    EControl Ltd. Forum Index -> EControl Syntax Editor All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group