mirror of
https://github.com/fltk/fltk.git
synced 2026-06-05 16:12:13 +08:00
Allow to disable shadows in Fl_Clock and derived widgets.
As discussed on 2017-05-15 in fltk.general, thread "Fl_clock". git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12237 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -17,6 +17,9 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2017
|
|||||||
|
|
||||||
New Features and Extensions
|
New Features and Extensions
|
||||||
|
|
||||||
|
- (add new items here)
|
||||||
|
- New method shadow(int) allows to disable the shadows of the hands
|
||||||
|
of Fl_Clock, Fl_Clock_Output, and derived widgets.
|
||||||
- New method Fl_Tabs::tab_align() allows to set alignment of tab labels,
|
- New method Fl_Tabs::tab_align() allows to set alignment of tab labels,
|
||||||
particularly to support icons on tab labels (STR #3076).
|
particularly to support icons on tab labels (STR #3076).
|
||||||
- Added '--enable-print' option to configure effective under X11 platforms
|
- Added '--enable-print' option to configure effective under X11 platforms
|
||||||
@@ -52,7 +55,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2017
|
|||||||
- Fl_Spinner now handles Up and Down keys when the input field has
|
- Fl_Spinner now handles Up and Down keys when the input field has
|
||||||
keyboard focus (STR #2989).
|
keyboard focus (STR #2989).
|
||||||
- Renamed test/help.cxx demo program to test/help_dialog.cxx to avoid
|
- Renamed test/help.cxx demo program to test/help_dialog.cxx to avoid
|
||||||
name conflict with CMake auto-generated target 'help'.
|
name conflict with CMake's auto-generated target 'help'.
|
||||||
- Many documentation fixes, clarifications, and enhancements.
|
- Many documentation fixes, clarifications, and enhancements.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
class FL_EXPORT Fl_Clock_Output : public Fl_Widget {
|
class FL_EXPORT Fl_Clock_Output : public Fl_Widget {
|
||||||
int hour_, minute_, second_;
|
int hour_, minute_, second_;
|
||||||
ulong value_;
|
ulong value_;
|
||||||
|
int shadow_; // draw shadows of hands
|
||||||
void drawhands(Fl_Color,Fl_Color); // part of draw
|
void drawhands(Fl_Color,Fl_Color); // part of draw
|
||||||
protected:
|
protected:
|
||||||
void draw();
|
void draw();
|
||||||
@@ -103,6 +104,29 @@ public:
|
|||||||
\see value(), hour(), minute()
|
\see value(), hour(), minute()
|
||||||
*/
|
*/
|
||||||
int second() const {return second_;}
|
int second() const {return second_;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the shadow drawing mode of the hands.
|
||||||
|
|
||||||
|
\returns shadow drawing mode of the hands
|
||||||
|
\retval 0 no shadows
|
||||||
|
\retval 1 draw shadows of hands (default)
|
||||||
|
*/
|
||||||
|
int shadow() const {return shadow_;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the shadow drawing mode of the hands.
|
||||||
|
|
||||||
|
Enable (1) or disable (0) drawing the hands with shadows.
|
||||||
|
|
||||||
|
Values except 0 and 1 are reserved for future extensions and
|
||||||
|
yield undefined behavior.
|
||||||
|
|
||||||
|
The default is to draw the shadows (1).
|
||||||
|
|
||||||
|
\param[in] mode 1 = shadows (default), 0 = no shadows
|
||||||
|
*/
|
||||||
|
void shadow(int mode) { shadow_ = mode ? 1 : 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// a Fl_Clock displays the current time always by using a timeout:
|
// a Fl_Clock displays the current time always by using a timeout:
|
||||||
|
|||||||
+7
-1
@@ -74,7 +74,6 @@ static void rect(double x, double y, double w, double h) {
|
|||||||
*/
|
*/
|
||||||
void Fl_Clock_Output::draw(int X, int Y, int W, int H) {
|
void Fl_Clock_Output::draw(int X, int Y, int W, int H) {
|
||||||
Fl_Color box_color = type()==FL_ROUND_CLOCK ? FL_GRAY : color();
|
Fl_Color box_color = type()==FL_ROUND_CLOCK ? FL_GRAY : color();
|
||||||
Fl_Color shadow_color = fl_color_average(box_color, FL_BLACK, 0.5);
|
|
||||||
draw_box(box(), X, Y, W, H, box_color);
|
draw_box(box(), X, Y, W, H, box_color);
|
||||||
fl_push_matrix();
|
fl_push_matrix();
|
||||||
fl_translate(X+W/2.0-.5, Y+H/2.0-.5);
|
fl_translate(X+W/2.0-.5, Y+H/2.0-.5);
|
||||||
@@ -85,11 +84,16 @@ void Fl_Clock_Output::draw(int X, int Y, int W, int H) {
|
|||||||
fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
|
fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
|
||||||
fl_begin_loop(); fl_circle(0,0,14); fl_end_loop();
|
fl_begin_loop(); fl_circle(0,0,14); fl_end_loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the shadows:
|
// draw the shadows:
|
||||||
|
if (shadow_) {
|
||||||
|
Fl_Color shadow_color = fl_color_average(box_color, FL_BLACK, 0.5);
|
||||||
fl_push_matrix();
|
fl_push_matrix();
|
||||||
fl_translate(0.60, 0.60);
|
fl_translate(0.60, 0.60);
|
||||||
drawhands(shadow_color, shadow_color);
|
drawhands(shadow_color, shadow_color);
|
||||||
fl_pop_matrix();
|
fl_pop_matrix();
|
||||||
|
}
|
||||||
|
|
||||||
// draw the tick marks:
|
// draw the tick marks:
|
||||||
fl_push_matrix();
|
fl_push_matrix();
|
||||||
fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
|
fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
|
||||||
@@ -100,6 +104,7 @@ void Fl_Clock_Output::draw(int X, int Y, int W, int H) {
|
|||||||
fl_rotate(-30);
|
fl_rotate(-30);
|
||||||
}
|
}
|
||||||
fl_pop_matrix();
|
fl_pop_matrix();
|
||||||
|
|
||||||
// draw the hands:
|
// draw the hands:
|
||||||
drawhands(selection_color(), FL_FOREGROUND_COLOR); // color was 54
|
drawhands(selection_color(), FL_FOREGROUND_COLOR); // color was 54
|
||||||
fl_pop_matrix();
|
fl_pop_matrix();
|
||||||
@@ -160,6 +165,7 @@ Fl_Clock_Output::Fl_Clock_Output(int X, int Y, int W, int H, const char *L)
|
|||||||
minute_ = 0;
|
minute_ = 0;
|
||||||
second_ = 0;
|
second_ = 0;
|
||||||
value_ = 0;
|
value_ = 0;
|
||||||
|
shadow_ = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
+8
-2
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// Clock test program for the Fast Light Tool Kit (FLTK).
|
// Clock test program for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
// Copyright 1998-2017 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -21,13 +21,19 @@
|
|||||||
#include <FL/Fl_Clock.H>
|
#include <FL/Fl_Clock.H>
|
||||||
#include <FL/Fl_Round_Clock.H>
|
#include <FL/Fl_Round_Clock.H>
|
||||||
|
|
||||||
|
const int dev_test = 0; // 1 = enable non-standard colors and no-shadow tests
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
Fl_Double_Window window(220,220,"Fl_Clock");
|
Fl_Double_Window window(220,220,"Fl_Clock");
|
||||||
Fl_Clock c1(0,0,220,220); // c1.color(2,1);
|
Fl_Clock c1(0,0,220,220); // c1.color(2,1);
|
||||||
window.resizable(c1);
|
window.resizable(c1);
|
||||||
window.end();
|
window.end();
|
||||||
Fl_Double_Window window2(220,220,"Fl_Round_Clock");
|
Fl_Double_Window window2(220,220,"Fl_Round_Clock");
|
||||||
Fl_Round_Clock c2(0,0,220,220); // c2.color(3,4);
|
Fl_Round_Clock c2(0,0,220,220);
|
||||||
|
if (dev_test) {
|
||||||
|
c2.color(FL_YELLOW,FL_RED); // set background and hands colors, resp.
|
||||||
|
c2.shadow(0); // disable shadows of the hands
|
||||||
|
}
|
||||||
window2.resizable(c2);
|
window2.resizable(c2);
|
||||||
window2.end();
|
window2.end();
|
||||||
// my machine had a clock* Xresource set for another program, so
|
// my machine had a clock* Xresource set for another program, so
|
||||||
|
|||||||
Reference in New Issue
Block a user