mirror of
https://github.com/fltk/fltk.git
synced 2026-05-31 05:35:29 +08:00
Improve focus box drawing and documentation
Add new method Fl_Widget::draw_focus(Fl_Boxtype t, int x, int y, int w, int h, Fl_Color bg) ... with background color for correct contrast testing (in Fl_Tabs) Draw the focus box of the "tabs" of Fl_Tabs widgets with the correct boxtype and background color. Make 'unsigned int visible_focus()' const so it can be used in 'const' methods. Do not draw the focus box if the per-widget focus box option is off.
This commit is contained in:
+23
-4
@@ -169,9 +169,28 @@ protected:
|
||||
void draw_box(Fl_Boxtype t, Fl_Color c) const;
|
||||
void draw_box(Fl_Boxtype t, int x,int y,int w,int h, Fl_Color c) const;
|
||||
void draw_backdrop() const;
|
||||
/** draws a focus rectangle around the widget */
|
||||
void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
|
||||
void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const;
|
||||
|
||||
/** Draws a focus rectangle around the widget.
|
||||
This method uses the widget's boxtype and coordinates and its
|
||||
background color color().
|
||||
\see Fl_Widget::draw_focus(Fl_Boxtype, int, int, int, int, Fl_Color) const
|
||||
*/
|
||||
void draw_focus() const {
|
||||
draw_focus(box(), x(), y(), w(), h(), color());
|
||||
}
|
||||
|
||||
/** Draws a focus rectangle around the widget.
|
||||
This method uses the given boxtype and coordinates and the widget's
|
||||
background color color().
|
||||
\see Fl_Widget::draw_focus(Fl_Boxtype, int, int, int, int, Fl_Color) const
|
||||
*/
|
||||
void draw_focus(Fl_Boxtype t, int X, int Y, int W, int H) const {
|
||||
draw_focus(t, X, Y, W, H, color());
|
||||
|
||||
}
|
||||
// See documentation in Fl_Widget.cxx
|
||||
void draw_focus(Fl_Boxtype t, int x, int y, int w, int h, Fl_Color bg) const;
|
||||
|
||||
void draw_label() const;
|
||||
void draw_label(int, int, int, int) const;
|
||||
|
||||
@@ -845,7 +864,7 @@ public:
|
||||
\retval 0 if this widget has no visible focus.
|
||||
\see visible_focus(int), set_visible_focus(), clear_visible_focus()
|
||||
*/
|
||||
unsigned int visible_focus() { return flags_ & VISIBLE_FOCUS; }
|
||||
unsigned int visible_focus() const { return flags_ & VISIBLE_FOCUS; }
|
||||
|
||||
/** The default callback for all widgets that don't set a callback.
|
||||
|
||||
|
||||
+6
-1
@@ -299,7 +299,12 @@ inline void fl_rect(Fl_Rect r) {
|
||||
fl_rect(r.x(), r.y(), r.w(), r.h());
|
||||
}
|
||||
|
||||
/** Draw a dotted rectangle, used to indicate keyboard focus on a widget. */
|
||||
/** Draw a dotted rectangle, used to indicate keyboard focus on a widget.
|
||||
|
||||
This method draws the rectangle in the current color and independent of
|
||||
the Fl::visible_focus() option. You may need to set the current color
|
||||
with fl_color() before you call this.
|
||||
*/
|
||||
inline void fl_focus_rect(int x, int y, int w, int h) {
|
||||
fl_graphics_driver->focus_rect(x, y, w, h);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user