summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBill Spitzak <spitzak@gmail.com>1999-03-07 08:51:44 +0000
committerBill Spitzak <spitzak@gmail.com>1999-03-07 08:51:44 +0000
commit51d37642ba4f9071ac178328cec7d421d4724187 (patch)
tree6ac5e6ad6e0b210b2b8bf32168752787bdb46db4 /src
parent6c793587e3305a4de1a080bb5663a356392c1075 (diff)
Contributed code for more accurate item_height() in Fl_Browser.
Fixed display of Fl_Choice yet again Tried to remove warning egcs warning messages from Fl_Color_Chooser Fl_Value_Input updates without user having to type Enter git-svn-id: file:///fltk/svn/fltk/trunk@374 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Browser.cxx48
-rw-r--r--src/Fl_Choice.cxx18
-rw-r--r--src/Fl_Color_Chooser.cxx9
-rw-r--r--src/Fl_Menu.cxx6
-rw-r--r--src/Fl_Value_Input.cxx11
5 files changed, 65 insertions, 27 deletions
diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx
index 0d85a22d1..4a7fef20e 100644
--- a/src/Fl_Browser.cxx
+++ b/src/Fl_Browser.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Browser.cxx,v 1.7 1999/01/30 00:39:28 carl Exp $"
+// "$Id: Fl_Browser.cxx,v 1.8 1999/03/07 08:51:41 bill Exp $"
//
// Browser widget for the Fast Light Tool Kit (FLTK).
//
@@ -206,13 +206,43 @@ int Fl_Browser::item_height(void* lv) const {
FL_BLINE* l = (FL_BLINE*)lv;
if (l->flags & NOTDISPLAYED) return 0;
char* str = l->txt;
- int t = textsize()+2;
- if (*str == format_char()) switch (*(str+1)) {
- case 'l': case 'L': t = 26; break;
- case 'm': case 'M': t = 20; break;
- case 's': case 'S': t = 13; break;
+ Fl_Font font;
+ int size;
+ int w, h;
+ int hmax = 0;
+
+ for(;*str;str++)
+ {
+ w = 0; // no wrap
+ font = Fl_Font(0); // default font
+ size = textsize(); // default size
+ while(*str==format_char())
+ {
+ str++;
+ switch (*str++) {
+ case 'l': case 'L': size = 24; break;
+ case 'm': case 'M': size = 18; break;
+ case 's': size = 11; break;
+ case 'b': font = (Fl_Font)(font|FL_BOLD); break;
+ case 'i': font = (Fl_Font)(font|FL_ITALIC); break;
+ case 'f': case 't': font = FL_COURIER; break;
+ case 'S': size = strtol(str,&str,10); break;
+ case 'F': font = (Fl_Font)strtol(str,&str,10); break;
+ case 0: case '@': str--;
+ case '.': goto END_FORMAT;
+ }
+ }
+ END_FORMAT:
+ char* ptr = str;
+ for(;*str && (*str!=column_char());str++) ;
+ char prev = *str;
+ *str = 0;
+ fl_font(font,size);
+ fl_measure(ptr,w,h);
+ *str = prev;
+ if(h>hmax) hmax=h;
}
- return t;
+ return hmax+2;
}
int Fl_Browser::item_width(void* v) const {
@@ -334,7 +364,7 @@ void Fl_Browser::item_draw(void* v, int x, int y, int w, int h) const {
if (((FL_BLINE*)v)->flags & SELECTED)
lcol = contrast(lcol, selection_color());
fl_color(lcol);
- fl_draw(str, x+3, y, w1-6, h, align);
+ fl_draw(str, x+3, y, w1-6, h, e ? Fl_Align(align|FL_ALIGN_CLIP) : align);
if (!e) break; // no more fields...
*e = column_char(); // put the seperator back
x += w1;
@@ -451,5 +481,5 @@ int Fl_Browser::value() const {
}
//
-// End of "$Id: Fl_Browser.cxx,v 1.7 1999/01/30 00:39:28 carl Exp $".
+// End of "$Id: Fl_Browser.cxx,v 1.8 1999/03/07 08:51:41 bill Exp $".
//
diff --git a/src/Fl_Choice.cxx b/src/Fl_Choice.cxx
index da8f0950c..f51a57131 100644
--- a/src/Fl_Choice.cxx
+++ b/src/Fl_Choice.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Choice.cxx,v 1.9 1999/02/23 14:01:17 mike Exp $"
+// "$Id: Fl_Choice.cxx,v 1.10 1999/03/07 08:51:42 bill Exp $"
//
// Choice widget for the Fast Light Tool Kit (FLTK).
//
@@ -38,12 +38,14 @@ void Fl_Choice::draw() {
if (box() == FL_FLAT_BOX) return; // for XForms compatability
int H = labelsize()/2+1;
draw_box(FL_THIN_UP_BOX,x()+w()-3*H,y()+(h()-H)/2,2*H,H,color());
- fl_font(textfont(),textsize());
- fl_color(active_r() ? textcolor() : inactive(textcolor()));
- fl_draw_shortcut = 2; // hack value to make '&' disappear
- int BW = Fl::box_dx(box());
- if (mvalue()) mvalue()->draw( x()+BW+3, y(), w()-2*BW-2-3*H, h(), this);
- fl_draw_shortcut = 0;
+ if (mvalue()) {
+ Fl_Menu_Item m = *mvalue();
+ if (active_r()) m.activate(); else m.deactivate();
+ fl_draw_shortcut = 2; // hack value to make '&' disappear
+ int BW = Fl::box_dx(box());
+ m.draw( x()+BW+3, y(), w()-2*BW-2-3*H, h(), this);
+ fl_draw_shortcut = 0;
+ }
draw_label();
}
@@ -86,5 +88,5 @@ int Fl_Choice::handle(int e) {
}
//
-// End of "$Id: Fl_Choice.cxx,v 1.9 1999/02/23 14:01:17 mike Exp $".
+// End of "$Id: Fl_Choice.cxx,v 1.10 1999/03/07 08:51:42 bill Exp $".
//
diff --git a/src/Fl_Color_Chooser.cxx b/src/Fl_Color_Chooser.cxx
index 4252ac9c0..a51f16c15 100644
--- a/src/Fl_Color_Chooser.cxx
+++ b/src/Fl_Color_Chooser.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Color_Chooser.cxx,v 1.6 1999/01/13 15:47:27 mike Exp $"
+// "$Id: Fl_Color_Chooser.cxx,v 1.7 1999/03/07 08:51:43 bill Exp $"
//
// Color chooser for the Fast Light Tool Kit (FLTK).
//
@@ -402,8 +402,9 @@ int fl_color_chooser(const char* name, double& r, double& g, double& b) {
window.show();
while (window.shown()) {
Fl::wait();
- Fl_Widget* o;
- while ((o = Fl::readqueue())) {
+ for (;;) {
+ Fl_Widget* o = Fl::readqueue();
+ if (!o) break;
if (o == &ok_button) {
r = chooser.r();
g = chooser.g();
@@ -430,5 +431,5 @@ int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b) {
}
//
-// End of "$Id: Fl_Color_Chooser.cxx,v 1.6 1999/01/13 15:47:27 mike Exp $".
+// End of "$Id: Fl_Color_Chooser.cxx,v 1.7 1999/03/07 08:51:43 bill Exp $".
//
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index 4758b8364..1faf9addb 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu.cxx,v 1.17 1999/02/25 19:09:10 bill Exp $"
+// "$Id: Fl_Menu.cxx,v 1.18 1999/03/07 08:51:43 bill Exp $"
//
// Menu code for the Fast Light Tool Kit (FLTK).
//
@@ -175,7 +175,7 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m,
x += 14; w -= 14;
}
- fl_draw_shortcut = 1;
+ if (!fl_draw_shortcut) fl_draw_shortcut = 1;
l.draw(x+3, y, w>6 ? w-6 : 0, h, FL_ALIGN_LEFT);
fl_draw_shortcut = 0;
}
@@ -710,5 +710,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const {
}
//
-// End of "$Id: Fl_Menu.cxx,v 1.17 1999/02/25 19:09:10 bill Exp $".
+// End of "$Id: Fl_Menu.cxx,v 1.18 1999/03/07 08:51:43 bill Exp $".
//
diff --git a/src/Fl_Value_Input.cxx b/src/Fl_Value_Input.cxx
index d1bc1f0bd..63404025c 100644
--- a/src/Fl_Value_Input.cxx
+++ b/src/Fl_Value_Input.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Value_Input.cxx,v 1.5 1999/01/07 19:17:28 mike Exp $"
+// "$Id: Fl_Value_Input.cxx,v 1.6 1999/03/07 08:51:44 bill Exp $"
//
// Value input widget for the Fast Light Tool Kit (FLTK).
//
@@ -32,14 +32,18 @@
#include <FL/Fl_Group.H>
#include <stdlib.h>
+static char hack_o_rama;
+
void Fl_Value_Input::input_cb(Fl_Widget*, void* v) {
Fl_Value_Input& t = *(Fl_Value_Input*)v;
double nv;
if (t.step()>=1.0) nv = strtol(t.input.value(), 0, 0);
else nv = strtod(t.input.value(), 0);
+ hack_o_rama = 1;
t.handle_push();
t.handle_drag(nv);
t.handle_release();
+ hack_o_rama = 0;
}
void Fl_Value_Input::draw() {
@@ -56,6 +60,7 @@ void Fl_Value_Input::resize(int X, int Y, int W, int H) {
}
void Fl_Value_Input::value_damage() {
+ if (hack_o_rama) return;
char buf[128];
format(buf);
input.value(buf);
@@ -113,7 +118,7 @@ Fl_Value_Input::Fl_Value_Input(int x, int y, int w, int h, const char* l)
((Fl_Group*)input.parent())->remove(input);
input.parent(this); // kludge!
input.callback(input_cb, this);
- input.when((Fl_When)(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY));
+ input.when(FL_WHEN_CHANGED);
box(input.box());
color(input.color());
selection_color(input.selection_color());
@@ -122,5 +127,5 @@ Fl_Value_Input::Fl_Value_Input(int x, int y, int w, int h, const char* l)
}
//
-// End of "$Id: Fl_Value_Input.cxx,v 1.5 1999/01/07 19:17:28 mike Exp $".
+// End of "$Id: Fl_Value_Input.cxx,v 1.6 1999/03/07 08:51:44 bill Exp $".
//