I made FL_NORMAL_SIZE into a public int variable. You can now change it

before any widgets are created, in order to change the default size of
the fonts used.  The most useful thing that can be done is to set it to
12 so that the default font size matches Win32.

I also fixed the menubar drawing a bit so that a menubar with a FL_FLAT_BOX
draws correctly.

It should also be documented that "Fl::set_color(Fl_Color(15),0,0,128);"
can be used to get Win32-style highlighting of menus and text items.  This
is not portable to fltk 2.0.

With these changes it should be easier to get fltk to look just like Win32.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1062 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Bill Spitzak
2000-04-11 08:11:56 +00:00
parent 177e3cd076
commit ffd26dfc45
9 changed files with 58 additions and 49 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
//
// "$Id: Enumerations.H,v 1.18.2.9 2000/03/05 06:51:03 bill Exp $"
// "$Id: Enumerations.H,v 1.18.2.10 2000/04/11 08:11:49 bill Exp $"
//
// Enumerations for the Fast Light Tool Kit (FLTK).
//
@@ -265,7 +265,7 @@ enum Fl_Font { // standard fonts
FL_ITALIC = 2 // add this to helvetica, courier, or times
};
#define FL_NORMAL_SIZE 14 // default size of all labels & text
extern FL_EXPORT int FL_NORMAL_SIZE;
enum Fl_Color { // standard colors
FL_BLACK = 0,
@@ -371,5 +371,5 @@ enum Fl_Damage {
#endif
//
// End of "$Id: Enumerations.H,v 1.18.2.9 2000/03/05 06:51:03 bill Exp $".
// End of "$Id: Enumerations.H,v 1.18.2.10 2000/04/11 08:11:49 bill Exp $".
//
+3 -3
View File
@@ -1,5 +1,5 @@
//
// "$Id: forms.H,v 1.7.2.2 2000/03/05 06:51:04 bill Exp $"
// "$Id: forms.H,v 1.7.2.3 2000/04/11 08:11:50 bill Exp $"
//
// Forms emulation header file for the Fast Light Tool Kit (FLTK).
//
@@ -134,7 +134,7 @@ typedef Fl_Window FL_FORM;
// size values are different from XForms, match older Forms:
#define FL_TINY_SIZE 8
#define FL_SMALL_SIZE 11 // 10
#define FL_NORMAL_SIZE 14 // 12
//#define FL_NORMAL_SIZE 14 // 12
#define FL_MEDIUM_SIZE 18 // 14
#define FL_LARGE_SIZE 24 // 18
#define FL_HUGE_SIZE 32 // 24
@@ -838,5 +838,5 @@ inline void fl_draw() {Fl::flush();}
#endif /* define __FORMS_H__ */
//
// End of "$Id: forms.H,v 1.7.2.2 2000/03/05 06:51:04 bill Exp $".
// End of "$Id: forms.H,v 1.7.2.3 2000/04/11 08:11:50 bill Exp $".
//
+3 -3
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Browser_.cxx,v 1.10.2.10 2000/03/17 09:38:18 bill Exp $"
// "$Id: Fl_Browser_.cxx,v 1.10.2.11 2000/04/11 08:11:51 bill Exp $"
//
// Base Browser widget class for the Fast Light Tool Kit (FLTK).
//
@@ -62,7 +62,7 @@ static void hscrollbar_callback(Fl_Widget* s, void*) {
((Fl_Browser_*)(s->parent()))->hposition(int(((Fl_Scrollbar*)s)->value()));
}
int Fl_Browser_::scrollbar_width_ = 17;
int Fl_Browser_::scrollbar_width_ = 16;
// return where to draw the actual box:
void Fl_Browser_::bbox(int& X, int& Y, int& W, int& H) const {
@@ -700,5 +700,5 @@ void Fl_Browser_::item_select(void*, int) {}
int Fl_Browser_::item_selected(void* l) const {return l==selection_;}
//
// End of "$Id: Fl_Browser_.cxx,v 1.10.2.10 2000/03/17 09:38:18 bill Exp $".
// End of "$Id: Fl_Browser_.cxx,v 1.10.2.11 2000/04/11 08:11:51 bill Exp $".
//
+19 -11
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu.cxx,v 1.18.2.2 1999/08/09 06:19:33 bill Exp $"
// "$Id: Fl_Menu.cxx,v 1.18.2.3 2000/04/11 08:11:52 bill Exp $"
//
// Menu code for the Fast Light Tool Kit (FLTK).
//
@@ -199,7 +199,12 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
clear_border();
menu = m;
drawn_selected = -1;
box(button && button->box() ? button->box() : FL_UP_BOX);
if (button) {
box(button->box());
if (box() == FL_NO_BOX || box() == FL_FLAT_BOX) box(FL_UP_BOX);
} else {
box(FL_UP_BOX);
}
color(button ? button->color() : FL_GRAY);
selected = -1;
{int i = 0;
@@ -246,14 +251,15 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
x(X); w(W);
h((numitems ? itemheight*numitems-LEADING : 0)+2*BW+5);
if (selected >= 0)
Y = Y+(Hp-itemheight)/2-selected*itemheight-BW+1;
Y = Y+(Hp-itemheight)/2-selected*itemheight-BW;
else
Y = Y+Hp;
if (m) y(Y-1); else {y(Y-3); w(1); h(1);}
if (m) y(Y); else {y(Y-2); w(1); h(1);}
if (t) {
int ht = menubar_title ? button->h()-6 : Htitle+2*BW+3;
title = new menutitle(X, Y-ht-3, Wtitle, ht, t);
int dy = menubar_title ? Fl::box_dy(button->box())+1 : 2;
int ht = menubar_title ? button->h()-dy*2 : Htitle+2*BW+3;
title = new menutitle(X, Y-ht-dy, Wtitle, ht, t);
} else
title = 0;
}
@@ -302,8 +308,10 @@ void menuwindow::drawentry(const Fl_Menu_Item* m, int i, int erase) {
// the shortcuts and arrows assumme fl_color() was left set by draw():
if (m->submenu()) {
int y1 = y+(h-14)/2;
fl_polygon(x+w-13, y1+2, x+w-13, y1+2+10, x+w-3, y1+2+5);
int sz = (h-5)&-2;
int y1 = y+(h-sz)/2;
int x1 = x+w-sz-3;
fl_polygon(x1, y1, x1, y1+sz, x1+sz, y1+sz/2);
} else if (m->shortcut_) {
Fl_Font f = button ? button->textfont() : FL_HELVETICA;
fl_font(f, button ? button->textsize() : FL_NORMAL_SIZE);
@@ -645,7 +653,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
initial_item = 0;
} else {
nX = cw.x() + cw.w();
nY = cw.y() + 1 + p.item_number * cw.itemheight;
nY = cw.y() + p.item_number * cw.itemheight;
title = 0;
}
if (initial_item) { // bring up submenu containing initial item:
@@ -658,7 +666,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown(
for (int menu = 0; menu <= p.menu_number; menu++) {
menuwindow* t = p.p[menu];
int nx = t->x()+dx; if (nx < 0) {nx = 0; dx = -t->x();}
int ny = t->y()+dy+1; if (ny < 0) {ny = 0; dy = -t->y()-1;}
int ny = t->y()+dy; if (ny < 0) {ny = 0; dy = -t->y();}
t->position(nx, ny);
}
setitem(p.nummenus-1, n->selected);
@@ -728,5 +736,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const {
}
//
// End of "$Id: Fl_Menu.cxx,v 1.18.2.2 1999/08/09 06:19:33 bill Exp $".
// End of "$Id: Fl_Menu.cxx,v 1.18.2.3 2000/04/11 08:11:52 bill Exp $".
//
+3 -3
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Scroll.cxx,v 1.7 1999/01/07 19:17:26 mike Exp $"
// "$Id: Fl_Scroll.cxx,v 1.7.2.1 2000/04/11 08:11:54 bill Exp $"
//
// Scroll widget for the Fast Light Tool Kit (FLTK).
//
@@ -211,7 +211,7 @@ void Fl_Scroll::scrollbar_cb(Fl_Widget* o, void*) {
s->position(s->xposition(), int(((Fl_Scrollbar*)o)->value()));
}
#define SLIDER_WIDTH 17
#define SLIDER_WIDTH 16
Fl_Scroll::Fl_Scroll(int X,int Y,int W,int H,const char* L)
: Fl_Group(X,Y,W,H,L),
@@ -231,5 +231,5 @@ int Fl_Scroll::handle(int event) {
}
//
// End of "$Id: Fl_Scroll.cxx,v 1.7 1999/01/07 19:17:26 mike Exp $".
// End of "$Id: Fl_Scroll.cxx,v 1.7.2.1 2000/04/11 08:11:54 bill Exp $".
//
+14 -16
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Scrollbar.cxx,v 1.7.2.8 2000/03/17 09:38:19 bill Exp $"
// "$Id: Fl_Scrollbar.cxx,v 1.7.2.9 2000/04/11 08:11:54 bill Exp $"
//
// Scroll bar widget for the Fast Light Tool Kit (FLTK).
//
@@ -193,13 +193,12 @@ void Fl_Scrollbar::draw() {
fl_color(labelcolor());
else
fl_color(inactive(labelcolor()));
int w1 = (H-1)|1; // use odd sizes only
int Y1 = Y+w1/2;
int W1 = w1/3;
int X1 = X+w1/2+W1/2;
fl_polygon(X1-W1, Y1, X1, Y1-W1, X1, Y1+W1);
X1 = X+W-(X1-X)-1;
fl_polygon(X1+W1, Y1, X1, Y1+W1, X1, Y1-W1);
int w1 = (H-4)/3; if (w1 < 1) w1 = 1;
int x1 = X+(H-w1-1)/2;
int y1 = Y+(H-2*w1-1)/2;
fl_polygon(x1, y1+w1, x1+w1, y1+2*w1, x1+w1, y1);
x1 += (W-H);
fl_polygon(x1, y1, x1, y1+2*w1, x1+w1, y1+w1);
}
} else { // vertical
if (H < 3*W) {Fl_Slider::draw(X,Y,W,H); return;}
@@ -213,13 +212,12 @@ void Fl_Scrollbar::draw() {
fl_color(labelcolor());
else
fl_color(labelcolor() | 8);
int w1 = (W-1)|1; // use odd sizes only
int X1 = X+w1/2;
int W1 = w1/3;
int Y1 = Y+w1/2+W1/2;
fl_polygon(X1, Y1-W1, X1+W1, Y1, X1-W1, Y1);
Y1 = Y+H-(Y1-Y)-1;
fl_polygon(X1, Y1+W1, X1-W1, Y1, X1+W1, Y1);
int w1 = (W-4)/3; if (w1 < 1) w1 = 1;
int x1 = X+(W-2*w1-1)/2;
int y1 = Y+(W-w1-1)/2;
fl_polygon(x1, y1+w1, x1+2*w1, y1+w1, x1+w1, y1);
y1 += H-W;
fl_polygon(x1, y1, x1+w1, y1+w1, x1+2*w1, y1);
}
}
}
@@ -236,5 +234,5 @@ Fl_Scrollbar::Fl_Scrollbar(int X, int Y, int W, int H, const char* L)
}
//
// End of "$Id: Fl_Scrollbar.cxx,v 1.7.2.8 2000/03/17 09:38:19 bill Exp $".
// End of "$Id: Fl_Scrollbar.cxx,v 1.7.2.9 2000/04/11 08:11:54 bill Exp $".
//
+4 -2
View File
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget.cxx,v 1.5 1999/01/07 19:17:29 mike Exp $"
// "$Id: Fl_Widget.cxx,v 1.5.2.1 2000/04/11 08:11:54 bill Exp $"
//
// Base widget class for the Fast Light Tool Kit (FLTK).
//
@@ -67,6 +67,8 @@ Fl_Widget *Fl::readqueue() {
int Fl_Widget::handle(int) {return 0;}
int FL_NORMAL_SIZE = 14;
Fl_Widget::Fl_Widget(int X, int Y, int W, int H, const char* L) {
x_ = X; y_ = Y; w_ = W; h_ = H;
@@ -196,5 +198,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const {
}
//
// End of "$Id: Fl_Widget.cxx,v 1.5 1999/01/07 19:17:29 mike Exp $".
// End of "$Id: Fl_Widget.cxx,v 1.5.2.1 2000/04/11 08:11:54 bill Exp $".
//
+6 -6
View File
@@ -1,5 +1,5 @@
//
// "$Id: fl_boxtype.cxx,v 1.8 1999/01/07 19:17:36 mike Exp $"
// "$Id: fl_boxtype.cxx,v 1.8.2.1 2000/04/11 08:11:55 bill Exp $"
//
// Box drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -120,9 +120,9 @@ void fl_up_frame(int x, int y, int w, int h, Fl_Color) {
fl_frame2("HHWW",x,y,w,h);
#else
#if BORDER_WIDTH == 2
fl_frame2("AAUWMMTT",x,y,w,h);
fl_frame2("AAWWMMTT",x,y,w,h);
#else
fl_frame("AAAAWUJJUTNN",x,y,w,h);
fl_frame("AAAAWWJJUTNN",x,y,w,h);
#endif
#endif
}
@@ -140,9 +140,9 @@ void fl_down_frame(int x, int y, int w, int h, Fl_Color) {
fl_frame2("WWHH",x,y,w,h);
#else
#if BORDER_WIDTH == 2
fl_frame2("UWMMPPAA",x,y,w,h);
fl_frame2("WWMMPPAA",x,y,w,h);
#else
fl_frame("NNTUJJUWAAAA",x,y,w,h);
fl_frame("NNTUJJWWAAAA",x,y,w,h);
#endif
#endif
}
@@ -282,5 +282,5 @@ const {
}
//
// End of "$Id: fl_boxtype.cxx,v 1.8 1999/01/07 19:17:36 mike Exp $".
// End of "$Id: fl_boxtype.cxx,v 1.8.2.1 2000/04/11 08:11:55 bill Exp $".
//
+3 -2
View File
@@ -1,5 +1,5 @@
//
// "$Id: menubar.cxx,v 1.6.2.2 2000/01/16 04:30:39 bill Exp $"
// "$Id: menubar.cxx,v 1.6.2.3 2000/04/11 08:11:56 bill Exp $"
//
// Menubar test program for the Fast Light Tool Kit (FLTK).
//
@@ -183,6 +183,7 @@ void button_cb(Fl_Widget* w, void*) {
}
int main(int argc, char **argv) {
//Fl::set_color(Fl_Color(15),0,0,128);
for (int i=0; i<99; i++) {
char buf[100];
sprintf(buf,"item %d",i);
@@ -215,5 +216,5 @@ int main(int argc, char **argv) {
}
//
// End of "$Id: menubar.cxx,v 1.6.2.2 2000/01/16 04:30:39 bill Exp $".
// End of "$Id: menubar.cxx,v 1.6.2.3 2000/04/11 08:11:56 bill Exp $".
//