icon

Questions on using RSyntaxTextArea should go here.

Moderator: robert

icon

Postby sara » Sun Jan 17, 2010 4:58 pm

Hi!

Is there a way to add icons on the side of the RSyntaxTextArea?
I want to mark some of the lines - by adding an icon near it, in the matching line.
(like eclipse does for breakpoints, compilations problems).

thanks.
sara
 

Re: icon

Postby robert » Sun Jan 17, 2010 8:46 pm

Sure there is. To do this you use the Gutter component of the RTextScrollPane:
Code: Select all
scrollPane.setIconAreaEnabled(true);
Gutter gutter = scrollPane.getGutter();
GutterIconInfo info = gutter.addLineTrackingIcon(line, icon);


You can also use addOffsetTrackingIcon() if the icon should track a particular offset in the line.

Call removeTrackingIcon(GutterIconInfo) to remove an icon you've added.
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: icon

Postby sara » Sun Jan 17, 2010 9:50 pm

hi!

I cant find the setIconAreaEnabled -
do you mean: setIconRowHeaderEnabled?
sara
 

Re: icon

Postby robert » Mon Jan 18, 2010 4:46 am

Yes, sorry, I was recalling the methods from memory. Call setIconRowHeaderEnabled(true), otherwise any icons you add simply won't be rendered, since the row header won't be visible to see them.

Post back if you have any more questions!
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: icon

Postby sara » Mon Jan 18, 2010 9:25 pm

Hi!

I have another question....
I need to know how many rows the icon "moved".
lets say, if i put the icon in line number 5, and the user entered more 4 rows before the icon - the icon will be now in line 9 (its moving with rows).
can I know what line the icon is now? or how many rows it moved?

thanks!
sara
 

Re: icon

Postby robert » Tue Jan 19, 2010 2:19 am

Yes, you can know what line the icon is now on if you keep a reference to the GutterIconInfo you got when you added it:

Code: Select all
GutterIconInfo info = ...;

// ...

// Get the document offset the icon is currently at (the first offset of the line, if
// it was added via addLineTrackingIcon()).
int offs = info.getMarkedOffset();

// Use the text area it was added to to get the line of the offset.
int line = textArea.getLineOfOffset(offs);
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 4 guests

cron