> > On 23.04.2012, at 11:09, MacArthur, Ian (SELEX GALILEO, UK) wrote: > > >=20 > >> I am using FLTK Version 1.3 > >> Can Fl_Text_Display text have a background color ? > >> It seems to me it should be in Style_Table_Entry somewhere. > >> eg : I would like my Fl_Text_Display to look like > >> ---------------------------------------------------------- > >> - This line has yellow background black foreground - > >> - - > >> - This line has white background blue foreground - > >> - - > >> - etc - > >> ---------------------------------------------------------- > >>=20 > >> Please. Thanks. > >=20 > > Hmm, I don't think out style logic has a case for handling background = > colour settings... Which seems like a useful thing to have... > >=20 > > Might be possible to do something using the highlight_data() method = > perhaps? I really don't know... > > No, we only have two different types of selection, which change the = > background color for a range of text.= > I need the GENERAL CASE which is to to set a (possibly) different foreground AND BACKGROUND color for each char. Consider the following.
#include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Text_Display.H> Fl_Text_Display::Style_Table_Entry stable[] = { { FL_RED, FL_COURIER, 18 }, // A - Red { FL_BLUE, FL_COURIER, 18 }, // B - Blue { FL_MAGENTA, FL_COURIER, 18 }, // C - Magenta }; int main() { // Fl_Text_Display example with color styles . -erco int w = 640; int h = 480; Fl_Window *win = new Fl_Window(w, h, "Display"); Fl_Text_Display *disp = new Fl_Text_Display(10,10,w-20,h-20); Fl_Text_Buffer *tbuff = new Fl_Text_Buffer(); Fl_Text_Buffer *sbuff = new Fl_Text_Buffer(); disp->buffer(tbuff); int stable_size = sizeof(stable)/sizeof(stable[0]); disp->highlight_data(sbuff, stable, stable_size, 'A', 0, 0); tbuff->text("red line 1\nblu line 2\nmag line 3\n"); tbuff->replace(2,7,"VWXYZ"); sbuff->text("AAAAAAAAAA\nBBBBBBBBBB\nCCCCCCCCCC\n"); sbuff->replace(2,7,"BACCD"); win->resizable(*disp); win->show(); return(Fl::run()); } By using repeated replaces the entire display's colours can be controlled BUT NOT THE BACKGROUND. Why can't each Style_Table_Entry contain background color information somehow? _______________________________________________ fltk-dev mailing list fltk-dev@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-dev