themes: Workaround for bug where a background color of RGB 0,0,0 in Black color schem...
[ntk.git] / src / Fl_Multi_Label.cxx
blobdf117db30f63cb0c89676f450c3371c8b64bc12c
1 //
2 // "$Id: Fl_Multi_Label.cxx 7903 2010-11-28 21:06:39Z matt $"
3 //
4 // Multi-label widget for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 by Bill Spitzak and others.
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 // USA.
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 // Allows two labels to be used on a widget (by having one of them
29 // be one of these it allows an infinte number!)
31 #include <FL/Fl.H>
32 #include <FL/Fl_Widget.H>
33 #include <FL/Fl_Menu_Item.H>
34 #include <FL/Fl_Multi_Label.H>
36 static void multi_labeltype(
37 const Fl_Label* o, int x, int y, int w, int h, Fl_Align a)
39 Fl_Multi_Label* b = (Fl_Multi_Label*)(o->value);
40 Fl_Label local = *o;
41 local.value = b->labela;
42 local.type = b->typea;
43 int W = w; int H = h; local.measure(W, H);
44 local.draw(x,y,w,h,a);
45 if (a & FL_ALIGN_BOTTOM) h -= H;
46 else if (a & FL_ALIGN_TOP) {y += H; h -= H;}
47 else if (a & FL_ALIGN_RIGHT) w -= W;
48 else if (a & FL_ALIGN_LEFT) {x += W; w -= W;}
49 else {int d = (h+H)/2; y += d; h -= d;}
50 local.value = b->labelb;
51 local.type = b->typeb;
52 local.draw(x,y,w,h,a);
55 // measurement is only correct for left-to-right appending...
56 static void multi_measure(const Fl_Label* o, int& w, int& h) {
57 Fl_Multi_Label* b = (Fl_Multi_Label*)(o->value);
58 Fl_Label local = *o;
59 local.value = b->labela;
60 local.type = b->typea;
61 local.measure(w,h);
62 local.value = b->labelb;
63 local.type = b->typeb;
64 int W = 0; int H = 0; local.measure(W,H);
65 w += W; if (H>h) h = H;
68 void Fl_Multi_Label::label(Fl_Widget* o) {
69 Fl::set_labeltype(_FL_MULTI_LABEL, multi_labeltype, multi_measure);
70 o->label(_FL_MULTI_LABEL, (const char*)this);
73 void Fl_Multi_Label::label(Fl_Menu_Item* o) {
74 Fl::set_labeltype(_FL_MULTI_LABEL, multi_labeltype, multi_measure);
75 o->label(_FL_MULTI_LABEL, (const char*)this);
79 // End of "$Id: Fl_Multi_Label.cxx 7903 2010-11-28 21:06:39Z matt $".