summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2001-11-03 05:11:34 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2001-11-03 05:11:34 +0000
commitd3acd6c475de7fb811c4bde93ca735e3526ad82f (patch)
tree53f8efcb6ca30eaa0d0528460446e230510cbf26 /src
parent7495dff2470310aa7824c6982df9622a975a8f38 (diff)
Add Fl::visible_focus() method.
Add optional "draw_symbols" argument to fl_draw and fl_measure functions. Fl_Repeat_Button didn't handle keyboard focus properly. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1678 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx6
-rw-r--r--src/Fl_Browser.cxx6
-rw-r--r--src/Fl_File_Browser.cxx10
-rw-r--r--src/Fl_Repeat_Button.cxx5
-rw-r--r--src/Fl_Widget.cxx24
-rw-r--r--src/fl_draw.cxx58
6 files changed, 67 insertions, 42 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 56ede9e44..d9b56e11a 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl.cxx,v 1.24.2.41.2.4 2001/10/18 00:24:19 easysw Exp $"
+// "$Id: Fl.cxx,v 1.24.2.41.2.5 2001/11/03 05:11:34 easysw Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@@ -53,6 +53,8 @@ int Fl::damage_,
Fl::e_keysym;
char *Fl::e_text = (char *)"";
int Fl::e_length;
+int Fl::visible_focus_ = 1;
+
//
// 'Fl:event_inside()' - Return whether or not the mouse event is inside
@@ -790,5 +792,5 @@ void Fl_Window::flush() {
}
//
-// End of "$Id: Fl.cxx,v 1.24.2.41.2.4 2001/10/18 00:24:19 easysw Exp $".
+// End of "$Id: Fl.cxx,v 1.24.2.41.2.5 2001/11/03 05:11:34 easysw Exp $".
//
diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx
index 78a7d716f..8d943f794 100644
--- a/src/Fl_Browser.cxx
+++ b/src/Fl_Browser.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Browser.cxx,v 1.9.2.12.2.1 2001/10/29 03:44:32 easysw Exp $"
+// "$Id: Fl_Browser.cxx,v 1.9.2.12.2.2 2001/11/03 05:11:34 easysw Exp $"
//
// Browser widget for the Fast Light Tool Kit (FLTK).
//
@@ -373,7 +373,7 @@ void Fl_Browser::item_draw(void* v, int x, int y, int w, int h) const {
lcol = fl_contrast(lcol, selection_color());
if (!active_r()) lcol = fl_inactive(lcol);
fl_color(lcol);
- fl_draw(str, x+3, y, w1-6, h, e ? Fl_Align(align|FL_ALIGN_CLIP) : align);
+ fl_draw(str, x+3, y, w1-6, h, e ? Fl_Align(align|FL_ALIGN_CLIP) : align, 0, 0);
if (!e) break; // no more fields...
*e = column_char(); // put the seperator back
x += w1;
@@ -493,5 +493,5 @@ int Fl_Browser::value() const {
}
//
-// End of "$Id: Fl_Browser.cxx,v 1.9.2.12.2.1 2001/10/29 03:44:32 easysw Exp $".
+// End of "$Id: Fl_Browser.cxx,v 1.9.2.12.2.2 2001/11/03 05:11:34 easysw Exp $".
//
diff --git a/src/Fl_File_Browser.cxx b/src/Fl_File_Browser.cxx
index 882d10360..f7ada7dae 100644
--- a/src/Fl_File_Browser.cxx
+++ b/src/Fl_File_Browser.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Browser.cxx,v 1.1.2.3 2001/10/29 21:59:14 easysw Exp $"
+// "$Id: Fl_File_Browser.cxx,v 1.1.2.4 2001/11/03 05:11:34 easysw Exp $"
//
// Fl_File_Browser routines.
//
@@ -325,7 +325,7 @@ Fl_File_Browser::item_draw(void *p, // I - List item data
*ptr = '\0';
fl_draw(fragment, x + width, y, w - width, fl_height(),
- (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP));
+ (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP), 0, 0);
// Point back to the start of the fragment...
ptr = fragment;
@@ -339,7 +339,7 @@ Fl_File_Browser::item_draw(void *p, // I - List item data
*ptr = '\0';
fl_draw(fragment, x + width, y, w - width, fl_height(),
- (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP));
+ (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP), 0, 0);
// Advance to the next column...
column ++;
@@ -362,7 +362,7 @@ Fl_File_Browser::item_draw(void *p, // I - List item data
*ptr = '\0';
fl_draw(fragment, x + width, y, w - width, fl_height(),
- (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP));
+ (Fl_Align)(FL_ALIGN_LEFT | FL_ALIGN_CLIP), 0, 0);
}
}
@@ -566,5 +566,5 @@ Fl_File_Browser::filter(const char *pattern) // I - Pattern string
//
-// End of "$Id: Fl_File_Browser.cxx,v 1.1.2.3 2001/10/29 21:59:14 easysw Exp $".
+// End of "$Id: Fl_File_Browser.cxx,v 1.1.2.4 2001/11/03 05:11:34 easysw Exp $".
//
diff --git a/src/Fl_Repeat_Button.cxx b/src/Fl_Repeat_Button.cxx
index dbe60f473..88e4f44a9 100644
--- a/src/Fl_Repeat_Button.cxx
+++ b/src/Fl_Repeat_Button.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Repeat_Button.cxx,v 1.4.2.4 2001/01/22 15:13:40 easysw Exp $"
+// "$Id: Fl_Repeat_Button.cxx,v 1.4.2.4.2.1 2001/11/03 05:11:34 easysw Exp $"
//
// Repeat button widget for the Fast Light Tool Kit (FLTK).
//
@@ -44,6 +44,7 @@ int Fl_Repeat_Button::handle(int event) {
newval = 0; goto J1;
case FL_PUSH:
case FL_DRAG:
+ take_focus();
newval = Fl::event_inside(this);
J1:
if (value(newval)) {
@@ -61,5 +62,5 @@ int Fl_Repeat_Button::handle(int event) {
}
//
-// End of "$Id: Fl_Repeat_Button.cxx,v 1.4.2.4 2001/01/22 15:13:40 easysw Exp $".
+// End of "$Id: Fl_Repeat_Button.cxx,v 1.4.2.4.2.1 2001/11/03 05:11:34 easysw Exp $".
//
diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx
index ba29643e9..18f34b52f 100644
--- a/src/Fl_Widget.cxx
+++ b/src/Fl_Widget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.5 2001/08/06 03:17:43 easysw Exp $"
+// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.6 2001/11/03 05:11:34 easysw Exp $"
//
// Base widget class for the Fast Light Tool Kit (FLTK).
//
@@ -138,6 +138,7 @@ Fl_Widget::~Fl_Widget() {
// draw a focus box for the widget...
void
Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const {
+ if (!Fl::visible_focus()) return;
switch (B) {
case FL_DOWN_BOX:
case FL_DOWN_FRAME:
@@ -149,11 +150,28 @@ Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const {
break;
}
- fl_color(FL_BLACK);
+ fl_color(fl_contrast(FL_BLACK, color()));
+
+#ifdef WIN32
+ // Windows 95/98/ME do not implement the dotted line style, so draw
+ // every other pixel around the focus area...
+ int i, xx, yy;
+
+ X += Fl::box_dx(B);
+ Y += Fl::box_dy(B);
+ W -= Fl::box_dw(B) + 2;
+ H -= Fl::box_dh(B) + 2;
+
+ for (xx = 0, i = 1; xx < W; xx ++, i ++) if (i & 1) fl_point(X + xx, Y);
+ for (yy = 0; yy < H; yy ++, i ++) if (i & 1) fl_point(X + W, Y + yy);
+ for (xx = W; xx > 0; xx --, i ++) if (i & 1) fl_point(X + xx, Y + H);
+ for (yy = H; yy > 0; yy --, i ++) if (i & 1) fl_point(X, Y + yy);
+#else
fl_line_style(FL_DOT);
fl_rect(X + Fl::box_dx(B), Y + Fl::box_dy(B),
W - Fl::box_dw(B) - 1, H - Fl::box_dh(B) - 1);
fl_line_style(FL_SOLID);
+#endif // WIN32
}
@@ -231,5 +249,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const {
}
//
-// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.5 2001/08/06 03:17:43 easysw Exp $".
+// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.6 2001/11/03 05:11:34 easysw Exp $".
//
diff --git a/src/fl_draw.cxx b/src/fl_draw.cxx
index 14eee12f1..2334941a5 100644
--- a/src/fl_draw.cxx
+++ b/src/fl_draw.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_draw.cxx,v 1.6.2.4.2.5 2001/10/16 20:25:25 easysw Exp $"
+// "$Id: fl_draw.cxx,v 1.6.2.4.2.6 2001/11/03 05:11:34 easysw Exp $"
//
// Label drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -51,8 +51,8 @@ static char* underline_at;
// Sets width to the width of the string in the current font.
static const char*
-expand(const char* from, char* buf, double maxw, int& n, double &width, int wrap) {
-
+expand(const char* from, char* buf, double maxw, int& n, double &width,
+ int wrap, int draw_symbols) {
char* o = buf;
char* e = buf+(MAXBUF-4);
underline_at = 0;
@@ -95,7 +95,7 @@ expand(const char* from, char* buf, double maxw, int& n, double &width, int wrap
} else if (c == 0xA0) { // non-breaking space
*o++ = ' ';
} else if (c == '@') { // Symbol???
- if (p[1] && p[1] != '@') break;
+ if (p[1] && p[1] != '@' && draw_symbols) break;
*o++ = c;
if (p[1]) p++;
} else {
@@ -114,7 +114,7 @@ void fl_draw(
int x, int y, int w, int h, // bounding box
Fl_Align align,
void (*callthis)(const char*,int,int,int),
- Fl_Image* img) {
+ Fl_Image* img, int draw_symbols) {
const char* p;
const char* e;
char buf[MAXBUF];
@@ -132,29 +132,32 @@ void fl_draw(
symbol[1][0] = '\0';
symwidth[1] = 0;
- if (str && str[0] == '@' && str[1] && str[1] != '@') {
- // Start with a symbol...
- for (symptr = symbol[0];
- *str && !isspace(*str) && symptr < (symbol[0] + sizeof(symbol[0]) - 1);
- *symptr++ = *str++);
- *symptr = '\0';
- if (isspace(*str)) str++;
- symwidth[0] = min(w,h);
- }
+ if (draw_symbols) {
+ if (str && str[0] == '@' && str[1] && str[1] != '@') {
+ // Start with a symbol...
+ for (symptr = symbol[0];
+ *str && !isspace(*str) && symptr < (symbol[0] + sizeof(symbol[0]) - 1);
+ *symptr++ = *str++);
+ *symptr = '\0';
+ if (isspace(*str)) str++;
+ symwidth[0] = min(w,h);
+ }
- if (str && (p = strrchr(str, '@')) != NULL && p > (str + 1)) {
- strncpy(symbol[1], p, sizeof(symbol[1]) - 1);
- symbol[1][sizeof(symbol[1]) - 1] = '\0';
- symwidth[1] = min(w,h);
+ if (str && (p = strrchr(str, '@')) != NULL && p > (str + 1)) {
+ strncpy(symbol[1], p, sizeof(symbol[1]) - 1);
+ symbol[1][sizeof(symbol[1]) - 1] = '\0';
+ symwidth[1] = min(w,h);
+ }
}
symtotal = symwidth[0] + symwidth[1];
if (str) {
for (p = str, lines=0; p;) {
- e = expand(p, buf, w - symtotal, buflen, width, align&FL_ALIGN_WRAP);
+ e = expand(p, buf, w - symtotal, buflen, width, align&FL_ALIGN_WRAP,
+ draw_symbols);
lines++;
- if (!*e || *e == '@') break;
+ if (!*e || (*e == '@' && draw_symbols)) break;
p = e;
}
} else lines = 0;
@@ -195,7 +198,7 @@ void fl_draw(
int desc = fl_descent();
for (p=str; ; ypos += height) {
if (lines>1) e = expand(p, buf, w - symtotal, buflen, width,
- align&FL_ALIGN_WRAP);
+ align&FL_ALIGN_WRAP, draw_symbols);
else e = "";
if (width > symoffset) symoffset = (int)(width + 0.5);
@@ -257,15 +260,16 @@ void fl_draw(
const char* str, // the (multi-line) string
int x, int y, int w, int h, // bounding box
Fl_Align align,
- Fl_Image* img) {
+ Fl_Image* img,
+ int draw_symbols) {
if ((!str || !*str) && !img) return;
if (w && h && !fl_not_clipped(x, y, w, h)) return;
if (align & FL_ALIGN_CLIP) fl_clip(x, y, w, h);
- fl_draw(str, x, y, w, h, align, fl_draw, img);
+ fl_draw(str, x, y, w, h, align, fl_draw, img, draw_symbols);
if (align & FL_ALIGN_CLIP) fl_pop_clip();
}
-void fl_measure(const char* str, int& w, int& h) {
+void fl_measure(const char* str, int& w, int& h, int draw_symbols) {
if (!str || !*str) {w = 0; h = 0; return;}
h = fl_height();
const char* p;
@@ -304,10 +308,10 @@ void fl_measure(const char* str, int& w, int& h) {
symtotal = symwidth[0] + symwidth[1];
for (p = str, lines=0; p;) {
- e = expand(p, buf, w - symtotal, buflen, width, w != 0);
+ e = expand(p, buf, w - symtotal, buflen, width, w != 0, draw_symbols);
if (int(width) > W) W = int(width);
lines++;
- if (!*e || *e == '@') break;
+ if (!*e || (*e == '@' && draw_symbols)) break;
p = e;
}
@@ -323,5 +327,5 @@ void fl_measure(const char* str, int& w, int& h) {
}
//
-// End of "$Id: fl_draw.cxx,v 1.6.2.4.2.5 2001/10/16 20:25:25 easysw Exp $".
+// End of "$Id: fl_draw.cxx,v 1.6.2.4.2.6 2001/11/03 05:11:34 easysw Exp $".
//