pushparaj muthu wrote:
Hi Albrecht

[...]

How to find out  how many lines displayed without scrolling

and fill Fl_Text_Buffer only with given ( some x value ) the number of lines
.


Regards
Pushparaj.M

I'm afraid we can't write your program. Please try yourself, and ask precise questions, if you don't succeed. For a start, I'll append a small example program that does something you asked for ... :-)

Albrecht
// Fill Fl_Text_Display with text (page by page)

// compile with fltk-config --compile text_buf.cxx

#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Text_Buffer.H>
#include <FL/Fl_Button.H>

Fl_Text_Display *td = 0;
Fl_Text_Buffer *tb = 0;

int nline = 0;

void next_cb(Fl_Widget *w, void *data)
{
  char tbuf[120];

  // calculate displayable lines (approximately)

  int lines = td->h()/td->textsize()-2;

  // clear text buffer and fill it with n lines

  tb->text(""); // clear buffer

  for (int i=0; i<lines; i++) {
    sprintf (tbuf,"This is line number %d ...\n",++nline);
    tb->append(tbuf);
  }
  td->redraw();
}

int main() {
     Fl_Window win(600, 600);
     
     td = new Fl_Text_Display(10,10,580,500);
     td->textsize(20);
     td->textfont(FL_COURIER);
     Fl_Button *b = new Fl_Button(20,530,60,30,"Next");
     b->callback(next_cb);

     win.end();

     tb = new Fl_Text_Buffer();
     td->buffer(tb);

     next_cb(b,(void *)0); // fill buffer
     win.show();
     return(Fl::run());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to