diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Clock.cxx | 69 | ||||
| -rw-r--r-- | src/Fl_Menu.cxx | 6 | ||||
| -rw-r--r-- | src/Fl_Menu_Bar.cxx | 7 | ||||
| -rw-r--r-- | src/Fl_Window.cxx | 6 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 24 |
5 files changed, 59 insertions, 53 deletions
diff --git a/src/Fl_Clock.cxx b/src/Fl_Clock.cxx index ace13e0c8..91e9155a2 100644 --- a/src/Fl_Clock.cxx +++ b/src/Fl_Clock.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Clock.cxx,v 1.4 1999/01/07 19:17:18 mike Exp $" +// "$Id: Fl_Clock.cxx,v 1.5 1999/01/13 15:45:49 mike Exp $" // // Clock widget for the Fast Light Tool Kit (FLTK). // @@ -29,9 +29,6 @@ #include <math.h> #include <time.h> -// There really should be a way to make this display something other -// than the current time... - // Original clock display written by Paul Haeberli at SGI. // Modifications by Mark Overmars for Forms // Further changes by Bill Spitzak for fltk @@ -51,7 +48,7 @@ static void drawhand(double ang,const float v[][2],Fl_Color fill,Fl_Color line) fl_pop_matrix(); } -void Fl_Clock::drawhands(Fl_Color fill, Fl_Color line) { +void Fl_Clock_Output::drawhands(Fl_Color fill, Fl_Color line) { drawhand(-360*(hour()+minute()/60.0)/12, hourhand, fill, line); drawhand(-360*(minute()+second()/60.0)/60, minhand, fill, line); drawhand(-360*(second()/60.0), sechand, fill, line); @@ -68,7 +65,7 @@ static void rect(double x, double y, double w, double h) { fl_end_polygon(); } -void Fl_Clock::draw(int x, int y, int w, int h) { +void Fl_Clock_Output::draw(int x, int y, int w, int h) { draw_box(box(), x, y, w, h, type()==FL_ROUND_CLOCK ? FL_GRAY : color()); fl_push_matrix(); fl_translate(x+w/2.0-.5, y+h/2.0-.5); @@ -99,65 +96,75 @@ void Fl_Clock::draw(int x, int y, int w, int h) { fl_pop_matrix(); } -void Fl_Clock::draw() { +void Fl_Clock_Output::draw() { draw(x(), y(), w(), h()); draw_label(); } -void Fl_Clock::value(int h, int m, int s) { +void Fl_Clock_Output::value(int h, int m, int s) { if (h!=hour_ || m!=minute_ || s!=second_) { hour_ = h; minute_ = m; second_ = s; - redraw(); + damage(FL_DAMAGE_CHILD); } } -void Fl_Clock::value(ulong v) { +void Fl_Clock_Output::value(ulong v) { struct tm *timeofday; timeofday = localtime((const time_t *)&v); value(timeofday->tm_hour, timeofday->tm_min, timeofday->tm_sec); } -static void tick(void *v) { - ((Fl_Clock*)v)->value(time(0)); - Fl::add_timeout(1, tick, v); -} - -void Fl_Clock::_Fl_Clock() { +Fl_Clock_Output::Fl_Clock_Output(int x, int y, int w, int h, const char *l) +: Fl_Widget(x, y, w, h, l) { + box(FL_UP_BOX); selection_color(fl_gray_ramp(5)); align(FL_ALIGN_BOTTOM); - value(time(0)); - //Fl::add_timeout(1, tick, this); + hour_ = 0; + minute_ = 0; + second_ = 0; + value_ = 0; } +//////////////////////////////////////////////////////////////// + Fl_Clock::Fl_Clock(int x, int y, int w, int h, const char *l) -: Fl_Widget(x, y, w, h, l) { - box(FL_UP_BOX); - _Fl_Clock(); -} + : Fl_Clock_Output(x, y, w, h, l) {} Fl_Clock::Fl_Clock(uchar t, int x, int y, int w, int h, const char *l) -: Fl_Widget(x, y, w, h, l) { + : Fl_Clock_Output(x, y, w, h, l) { type(t); box(t==FL_ROUND_CLOCK ? FL_NO_BOX : FL_UP_BOX); - _Fl_Clock(); } -Fl_Clock::~Fl_Clock() { - Fl::remove_timeout(tick, this); +#ifndef WIN32 +#include <sys/time.h> +#endif + +static void tick(void *v) { + struct timeval t; + gettimeofday(&t, NULL); + ((Fl_Clock*)v)->value(t.tv_sec); + double delay = 1.0-t.tv_usec*.000001; + if (delay < .1 || delay > .9) delay = 1.0; + Fl::add_timeout(delay, tick, v); } int Fl_Clock::handle(int event) { switch (event) { + case FL_SHOW: + tick(this); + break; case FL_HIDE: Fl::remove_timeout(tick, this); break; - case FL_SHOW: - Fl::remove_timeout(tick, this); - tick(this); } - return 0; + return Fl_Clock_Output::handle(event); +} + +Fl_Clock::~Fl_Clock() { + Fl::remove_timeout(tick, this); } // -// End of "$Id: Fl_Clock.cxx,v 1.4 1999/01/07 19:17:18 mike Exp $". +// End of "$Id: Fl_Clock.cxx,v 1.5 1999/01/13 15:45:49 mike Exp $". // diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 1ecfaa7bc..aa93d015e 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu.cxx,v 1.11 1999/01/07 19:17:22 mike Exp $" +// "$Id: Fl_Menu.cxx,v 1.12 1999/01/13 15:45:49 mike Exp $" // // Menu code for the Fast Light Tool Kit (FLTK). // @@ -138,7 +138,7 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m, b = m ? m->box() : FL_UP_BOX; } else { r = (Fl_Color)(FL_COLOR_CUBE-1); // white - l.color = contrast((Fl_Color)labelcolor_, r); + l.color = contrast((Fl_Color)labelcolor_, r); } } else { l.color = contrast((Fl_Color)labelcolor_, r); @@ -703,5 +703,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const { } // -// End of "$Id: Fl_Menu.cxx,v 1.11 1999/01/07 19:17:22 mike Exp $". +// End of "$Id: Fl_Menu.cxx,v 1.12 1999/01/13 15:45:49 mike Exp $". // diff --git a/src/Fl_Menu_Bar.cxx b/src/Fl_Menu_Bar.cxx index 7d022681b..b01e8cabb 100644 --- a/src/Fl_Menu_Bar.cxx +++ b/src/Fl_Menu_Bar.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Menu_Bar.cxx,v 1.5 1999/01/07 19:17:22 mike Exp $" +// "$Id: Fl_Menu_Bar.cxx,v 1.6 1999/01/13 15:45:49 mike Exp $" // // Menu bar widget for the Fast Light Tool Kit (FLTK). // @@ -40,6 +40,9 @@ void Fl_Menu_Bar::draw() { int Fl_Menu_Bar::handle(int event) { const Fl_Menu_Item* v; if (menu() && menu()->text) switch (event) { + case FL_ENTER: + case FL_LEAVE: + return 1; case FL_PUSH: v = 0; J1: @@ -57,5 +60,5 @@ int Fl_Menu_Bar::handle(int event) { } // -// End of "$Id: Fl_Menu_Bar.cxx,v 1.5 1999/01/07 19:17:22 mike Exp $". +// End of "$Id: Fl_Menu_Bar.cxx,v 1.6 1999/01/13 15:45:49 mike Exp $". // diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index 9119ba59b..54097cddb 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Window.cxx,v 1.5 1999/01/07 19:17:29 mike Exp $" +// "$Id: Fl_Window.cxx,v 1.6 1999/01/13 15:45:49 mike Exp $" // // Window widget class for the Fast Light Tool Kit (FLTK). // @@ -59,7 +59,7 @@ Fl_Window::Fl_Window(int W, int H, const char *l) Fl_Window *Fl_Widget::window() const { for (Fl_Widget *o = parent(); o; o = o->parent()) - if (o->type()>=FL_WINDOW) return (Fl_Window*)o; + if (o->type() >= FL_WINDOW) return (Fl_Window*)o; return 0; } @@ -102,5 +102,5 @@ void Fl_Window::default_callback(Fl_Window* window, void* v) { } // -// End of "$Id: Fl_Window.cxx,v 1.5 1999/01/07 19:17:29 mike Exp $". +// End of "$Id: Fl_Window.cxx,v 1.6 1999/01/13 15:45:49 mike Exp $". // diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index ecaecddc6..c9e34e5ab 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_x.cxx,v 1.20 1999/01/07 19:17:33 mike Exp $" +// "$Id: Fl_x.cxx,v 1.21 1999/01/13 15:45:50 mike Exp $" // // X specific code for the Fast Light Tool Kit (FLTK). // @@ -652,15 +652,6 @@ void Fl_X::make_xid(Fl_Window* w, XVisualInfo *visual, Colormap colormap) (unsigned char *)buffer, p-buffer-1); } - // Set the icon pixmap as needed: - if (w->icon()) { - XWMHints hints; - - hints.icon_pixmap = (Pixmap)w->icon(); - hints.flags = IconPixmapHint; - XSetWMHints(fl_display, x->xid, &hints); - } - if (w->non_modal() && x->next && !fl_disable_transient_for) { // find some other window to be "transient for": Fl_Window* w = x->next->w; @@ -668,13 +659,18 @@ void Fl_X::make_xid(Fl_Window* w, XVisualInfo *visual, Colormap colormap) XSetTransientForHint(fl_display, x->xid, fl_xid(w)); } + XWMHints hints; + hints.flags = 0; if (fl_show_iconic) { - XWMHints hints; hints.flags = StateHint; - hints.initial_state = 3; - XSetWMHints(fl_display, x->xid, &hints); + hints.initial_state = IconicState; fl_show_iconic = 0; } + if (w->icon()) { + hints.icon_pixmap = (Pixmap)w->icon(); + hints.flags |= IconPixmapHint; + } + if (hints.flags) XSetWMHints(fl_display, x->xid, &hints); } XMapWindow(fl_display, x->xid); @@ -823,5 +819,5 @@ void Fl_Window::make_current() { #endif // -// End of "$Id: Fl_x.cxx,v 1.20 1999/01/07 19:17:33 mike Exp $". +// End of "$Id: Fl_x.cxx,v 1.21 1999/01/13 15:45:50 mike Exp $". // |
