FLTK logo

Re: [fltk.general] Re: Scroll text lines ?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Re: Scroll text lines ? matthiasm Apr 30, 2006  
 

On Apr 30, 2006, at 3:03 PM, Anonymous wrote:

Thanks for your advices but the thing is I derived my own class from Fl_box in order to display text lines (with the drawing functions) the way I want to . So I need to know how can I make the scrollbar interact with my own class and the other way around.
Can you help me ?

You can either put your own FlBox inside an Fl_Scroll, or create a scrollbar and move the box (or the text in the box) according to the scrollbar's callbacks.

1: take a look at the "test/scroll" example. It shows how to set up the Fl_Scroll group and how to add items inside, including a self- drawn widget

2: you can do the interaction between the scrollbar and your widget yourself. You need to send data in both directions: whenever the number of text lines in your text widget changes, you must change the range in the Fl_Scrollbar. The help pages for "int Fl_Scrollbar::value (int position, int size, int top, int total)" explain it pretty straight forward. You also need to handle the other direction, the user moving the scroll bar. Here you need to set up a callback for the Fl_Scrollbar. Whenever the callback is called, change the top line that is displayed in your text box accoring to Fl_Scrollbar::value() and call TextBox::redraw().

Matthias

----
http://robowerk.com/



Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.