View previous topic :: View next topic |
Author |
Message |
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Thu Aug 03, 2006 1:38 pm Post subject: Setting bookmark importance |
|
|
I have a situation where I get 2 bookmarks on a single line. Both have a different ImageIndex, ForeColor, and BgColor. Is there a way where I can flag a bookmark as being more important than another and if it is set on the same line as another, less important bookmark, that it will always be the one shown?
Thanks. |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Fri Aug 04, 2006 1:31 pm Post subject: |
|
|
In this case OnGetGutterImage may be used
Code: | TCustomSyntaxMemo.OnGetGutterImage: TGetGutterImageEvent;
TGetGutterImageEvent = procedure(Sender: TObject;
const Line: integer; List: TList) of object; |
List contains all gutter objects (TGutterObject, TBookmark) for the specified Line. You may add or remove gutter objects.
Example:
Code: | procedure Form1.SyntaxMemo1GetGutterImage(Sender: TObject; const Line: integer; List: TList);
var i: integer;
begin
if (List.Count > 1) and (TObject(List[List.Count - 1]) is TBookmark) then
begin
for i := 0 to List.Count - 2 do
List.Delete(i);
end;
end; |
Michael. |
|
Back to top |
|
|
mstaszew
Joined: 21 Jul 2006 Posts: 67 Location: North Carolina, USA
|
Posted: Mon Aug 07, 2006 1:57 pm Post subject: |
|
|
Thanks Michael, that worked perfectly. I do have one more question. I have a single TGutterObject that is created at design-time and many more that are created at run-time. Can I safely assume that TSyntaxMemo.Gutter.Objects[0] will always and forever be the one that I set at design-time or will the list ever get rearranged?
Thanks. |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Tue Aug 08, 2006 1:13 pm Post subject: |
|
|
Gutter objects are not rearranged, so you may safely access them via index like TSyntaxMemo.Gutter.Objects[0].
Additional info:
You may create new gutter objects and safely add them to list in OnGetGutterImage. All gutter objects without Owner (i.e. created with Collection = nil) will be automatically destroyed after processing line.
For example, see TEditorFrame.EditorMasterGetGutterImage in main demo.
Michael. |
|
Back to top |
|
|
|