summaryrefslogtreecommitdiff
path: root/FL/Fl_Widget.H
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2020-07-01 18:03:10 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-07-06 20:28:20 +0200
commitf09e17c3c564e8310125a10c03397cbf473ff643 (patch)
tree8d0fd4a28e3686c33aaa140d07ddba26ab28bdc2 /FL/Fl_Widget.H
parentb0e0c355edaa2e23148cb0260ada907aec930f05 (diff)
Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files - update .fl files and generated files accordingly - replace 'http://www.fltk.org' URL's with 'https://...' - replace bug report URL 'str.php' with 'bugs.php' - remove trailing whitespace - fix other whitespace errors flagged by Git - add and/or fix missing or wrong standard headers - convert tabs to spaces in all source files The only relevant code changes are in the fluid/ folder where some .fl files and other source files were used to generate the '$Id' headers and footers.
Diffstat (limited to 'FL/Fl_Widget.H')
-rw-r--r--FL/Fl_Widget.H272
1 files changed, 133 insertions, 139 deletions
diff --git a/FL/Fl_Widget.H b/FL/Fl_Widget.H
index 6ca0787cd..0745b9063 100644
--- a/FL/Fl_Widget.H
+++ b/FL/Fl_Widget.H
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Widget header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2020 by Bill Spitzak and others.
@@ -11,9 +9,9 @@
//
// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// https://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
/** \file
@@ -72,16 +70,16 @@ struct FL_EXPORT Fl_Label {
-/** Fl_Widget is the base class for all widgets in FLTK.
-
+/** Fl_Widget is the base class for all widgets in FLTK.
+
You can't create one of these because the constructor is not public.
- However you can subclass it.
+ However you can subclass it.
- All "property" accessing methods, such as color(), parent(), or argument()
- are implemented as trivial inline functions and thus are as fast and small
- as accessing fields in a structure. Unless otherwise noted, the property
- setting methods such as color(n) or label(s) are also trivial inline
- functions, even if they change the widget's appearance. It is up to the
+ All "property" accessing methods, such as color(), parent(), or argument()
+ are implemented as trivial inline functions and thus are as fast and small
+ as accessing fields in a structure. Unless otherwise noted, the property
+ setting methods such as color(n) or label(s) are also trivial inline
+ functions, even if they change the widget's appearance. It is up to the
user code to call redraw() after these.
*/
class FL_EXPORT Fl_Widget {
@@ -112,10 +110,10 @@ protected:
/** Creates a widget at the given position and size.
- The Fl_Widget is a protected constructor, but all derived widgets have a
- matching public constructor. It takes a value for x(), y(), w(), h(), and
+ The Fl_Widget is a protected constructor, but all derived widgets have a
+ matching public constructor. It takes a value for x(), y(), w(), h(), and
an optional value for label().
-
+
\param[in] x, y the position of the widget relative to the enclosing window
\param[in] w, h size of the widget in pixels
\param[in] label optional text for the widget label
@@ -180,10 +178,10 @@ protected:
public:
/** Destroys the widget.
- Destroying single widgets is not very common. You almost always want to
- destroy the parent group instead, which will destroy all of the child widgets
+ Destroying single widgets is not very common. You almost always want to
+ destroy the parent group instead, which will destroy all of the child widgets
and groups in that group.
-
+
\since FLTK 1.3, the widget's destructor removes the widget from its parent
group, if it is member of a group.
*/
@@ -207,17 +205,17 @@ public:
*/
virtual void draw() = 0;
- /** Handles the specified event.
- You normally don't call this method directly, but instead let FLTK do
+ /** Handles the specified event.
+ You normally don't call this method directly, but instead let FLTK do
it when the user interacts with the widget.
-
- When implemented in a widget, this function must return 0 if the
+
+ When implemented in a widget, this function must return 0 if the
widget does not use the event or 1 otherwise.
- Most of the time, you want to call the inherited handle() method in
- your overridden method so that you don't short-circuit events that you
+ Most of the time, you want to call the inherited handle() method in
+ your overridden method so that you don't short-circuit events that you
don't handle. In this last case you should return the callee retval.
-
+
\param[in] event the kind of event received
\retval 0 if the event was not used or understood
\retval 1 if the event was used and can be deleted
@@ -235,15 +233,15 @@ public:
*/
int is_label_copied() const {return ((flags_ & COPIED_LABEL) ? 1 : 0);}
- /** Returns a pointer to the parent widget.
- Usually this is a Fl_Group or Fl_Window.
+ /** Returns a pointer to the parent widget.
+ Usually this is a Fl_Group or Fl_Window.
\retval NULL if the widget has no parent
\see Fl_Group::add(Fl_Widget*)
*/
Fl_Group* parent() const {return parent_;}
/** Internal use only - "for hacks only".
-
+
It is \em \b STRONGLY recommended not to use this method, because it
short-circuits Fl_Group's normal widget adding and removing methods,
if the widget is already a child widget of another Fl_Group.
@@ -255,7 +253,7 @@ public:
/** Gets the widget type.
Returns the widget type value, which is used for Forms compatibility
and to simulate RTTI.
-
+
\todo Explain "simulate RTTI" (currently only used to decide if a widget
is a window, i.e. type()>=FL_WINDOW ?). Is type() really used in a way
that ensures "Forms compatibility" ?
@@ -289,20 +287,20 @@ public:
/** Changes the size or position of the widget.
- This is a virtual function so that the widget may implement its
+ This is a virtual function so that the widget may implement its
own handling of resizing. The default version does \e not
- call the redraw() method, but instead relies on the parent widget
- to do so because the parent may know a faster way to update the
- display, such as scrolling from the old position.
+ call the redraw() method, but instead relies on the parent widget
+ to do so because the parent may know a faster way to update the
+ display, such as scrolling from the old position.
- Some window managers under X11 call resize() a lot more often
- than needed. Please verify that the position or size of a widget
+ Some window managers under X11 call resize() a lot more often
+ than needed. Please verify that the position or size of a widget
did actually change before doing any extensive calculations.
- position(X, Y) is a shortcut for resize(X, Y, w(), h()),
+ position(X, Y) is a shortcut for resize(X, Y, w(), h()),
and size(W, H) is a shortcut for resize(x(), y(), W, H).
-
- \param[in] x, y new position relative to the parent window
+
+ \param[in] x, y new position relative to the parent window
\param[in] w, h new size
\see position(int,int), size(int,int)
*/
@@ -314,8 +312,8 @@ public:
/** Repositions the window or widget.
position(X, Y) is a shortcut for resize(X, Y, w(), h()).
-
- \param[in] X, Y new position relative to the parent window
+
+ \param[in] X, Y new position relative to the parent window
\see resize(int,int,int,int), size(int,int)
*/
void position(int X,int Y) {resize(X,Y,w_,h_);}
@@ -323,7 +321,7 @@ public:
/** Changes the size of the widget.
size(W, H) is a shortcut for resize(x(), y(), W, H).
-
+
\param[in] W, H new size
\see position(int,int), resize(int,int,int,int)
*/
@@ -337,8 +335,8 @@ public:
Fl_Align align() const {return label_.align_;}
/** Sets the label alignment.
- This controls how the label is displayed next to or inside the widget.
- The default value is FL_ALIGN_CENTER, which centers the label inside
+ This controls how the label is displayed next to or inside the widget.
+ The default value is FL_ALIGN_CENTER, which centers the label inside
the widget.
\param[in] alignment new label alignment
\see align(), Fl_Align
@@ -350,10 +348,10 @@ public:
\see box(Fl_Boxtype), Fl_Boxtype
*/
Fl_Boxtype box() const {return (Fl_Boxtype)box_;}
-
- /** Sets the box type for the widget.
+
+ /** Sets the box type for the widget.
This identifies a routine that draws the background of the widget.
- See Fl_Boxtype for the available types. The default depends on the
+ See Fl_Boxtype for the available types. The default depends on the
widget, but is usually FL_NO_BOX or FL_UP_BOX.
\param[in] new_box the new box type
\see box(), Fl_Boxtype
@@ -366,11 +364,11 @@ public:
*/
Fl_Color color() const {return color_;}
- /** Sets the background color of the widget.
- The color is passed to the box routine. The color is either an index into
- an internal table of RGB colors or an RGB color value generated using
+ /** Sets the background color of the widget.
+ The color is passed to the box routine. The color is either an index into
+ an internal table of RGB colors or an RGB color value generated using
fl_rgb_color().
-
+
The default for most widgets is FL_BACKGROUND_COLOR. Use Fl::set_color()
to redefine colors in the color map.
\param[in] bg background color
@@ -385,18 +383,18 @@ public:
Fl_Color selection_color() const {return color2_;}
/** Sets the selection color.
- The selection color is defined for Forms compatibility and is usually
- used to color the widget when it is selected, although some widgets
- use this color for other purposes. You can set both colors at once
+ The selection color is defined for Forms compatibility and is usually
+ used to color the widget when it is selected, although some widgets
+ use this color for other purposes. You can set both colors at once
with color(Fl_Color bg, Fl_Color sel).
\param[in] a the new selection color
\see selection_color(), color(Fl_Color, Fl_Color)
*/
void selection_color(Fl_Color a) {color2_ = a;}
- /** Sets the background and selection color of the widget.
+ /** Sets the background and selection color of the widget.
- The two color form sets both the background and selection colors.
+ The two color form sets both the background and selection colors.
\param[in] bg background color
\param[in] sel selection color
\see color(unsigned), selection_color(unsigned)
@@ -413,17 +411,17 @@ public:
The label is shown somewhere on or next to the widget.
See \ref common_labels for details about what can be put in a label.
- The passed pointer is stored unchanged in the widget (the string is \em not copied), so if
- you need to set the label to a formatted value, make sure the buffer is
- static, global, or allocated. The copy_label() method can be used
+ The passed pointer is stored unchanged in the widget (the string is \em not copied), so if
+ you need to set the label to a formatted value, make sure the buffer is
+ static, global, or allocated. The copy_label() method can be used
to make a copy of the label string automatically.
\param[in] text pointer to new label text
\see copy_label()
*/
void label(const char* text);
- /** Sets the current label.
- Unlike label(), this method allocates a copy of the label
+ /** Sets the current label.
+ Unlike label(), this method allocates a copy of the label
string instead of using the original string pointer.
The internal copy will automatically be freed whenever you assign
@@ -445,29 +443,29 @@ public:
*/
Fl_Labeltype labeltype() const {return (Fl_Labeltype)label_.type;}
- /** Sets the label type.
- The label type identifies the function that draws the label of the widget.
- This is generally used for special effects such as embossing or for using
- the label() pointer as another form of data such as an icon. The value
+ /** Sets the label type.
+ The label type identifies the function that draws the label of the widget.
+ This is generally used for special effects such as embossing or for using
+ the label() pointer as another form of data such as an icon. The value
FL_NORMAL_LABEL prints the label as plain text.
\param[in] a new label type
\see Fl_Labeltype
*/
void labeltype(Fl_Labeltype a) {label_.type = a;}
- /** Gets the label color.
- The default color is FL_FOREGROUND_COLOR.
+ /** Gets the label color.
+ The default color is FL_FOREGROUND_COLOR.
\return the current label color
*/
Fl_Color labelcolor() const {return label_.color;}
- /** Sets the label color.
- The default color is FL_FOREGROUND_COLOR.
+ /** Sets the label color.
+ The default color is FL_FOREGROUND_COLOR.
\param[in] c the new label color
*/
void labelcolor(Fl_Color c) {label_.color=c;}
- /** Gets the font to use.
+ /** Gets the font to use.
Fonts are identified by indexes into a table. The default value
uses a Helvetica typeface (Arial for Microsoft&reg; Windows&reg;).
The function Fl::set_font() can define new typefaces.
@@ -476,7 +474,7 @@ public:
*/
Fl_Font labelfont() const {return label_.font;}
- /** Sets the font to use.
+ /** Sets the font to use.
Fonts are identified by indexes into a table. The default value
uses a Helvetica typeface (Arial for Microsoft&reg; Windows&reg;).
The function Fl::set_font() can define new typefaces.
@@ -485,7 +483,7 @@ public:
*/
void labelfont(Fl_Font f) {label_.font=f;}
- /** Gets the font size in pixels.
+ /** Gets the font size in pixels.
The default size is 14 pixels.
\return the current font size
*/
@@ -547,8 +545,8 @@ public:
*/
const char *tooltip() const {return tooltip_;}
- void tooltip(const char *text); // see Fl_Tooltip
- void copy_tooltip(const char *text); // see Fl_Tooltip
+ void tooltip(const char *text); // see Fl_Tooltip
+ void copy_tooltip(const char *text); // see Fl_Tooltip
/** Gets the current callback function for the widget.
Each widget has a single callback.
@@ -600,16 +598,16 @@ public:
/** Gets the current user data (long) argument that is passed to the callback function.
\note On platforms with <tt>sizeof(long) \< sizeof(void*)</tt>, particularly
- on Windows 64-bit platforms, this method can truncate stored addresses
- \p (void*) to the size of a \p long value. Use with care and only
- if you are sure that the stored user_data value fits in a \p long
- value because it was stored with argument(long) or another method
- using only \p long values. You may want to use user_data() instead.
+ on Windows 64-bit platforms, this method can truncate stored addresses
+ \p (void*) to the size of a \p long value. Use with care and only
+ if you are sure that the stored user_data value fits in a \p long
+ value because it was stored with argument(long) or another method
+ using only \p long values. You may want to use user_data() instead.
\see user_data()
\todo [Internal] The user_data value must be implemented using
- \p fl_intptr_t or similar to avoid 64-bit platform incompatibilities.
+ \p fl_intptr_t or similar to avoid 64-bit platform incompatibilities.
*/
long argument() const {return (long)(fl_intptr_t)user_data_;}
@@ -633,29 +631,29 @@ public:
This controls when callbacks are done. The following values are useful,
the default value is FL_WHEN_RELEASE:
-
+
\li 0: The callback is not done, but changed() is turned on.
\li FL_WHEN_CHANGED: The callback is done each time the text is
changed by the user.
- \li FL_WHEN_RELEASE: The callback will be done when this widget loses
- the focus, including when the window is unmapped. This is a useful
- value for text fields in a panel where doing the callback on every
- change is wasteful. However the callback will also happen if the
- mouse is moved out of the window, which means it should not do
- anything visible (like pop up an error message).
- You might do better setting this to zero, and scanning all the
- items for changed() when the OK button on a panel is pressed.
- \li FL_WHEN_ENTER_KEY: If the user types the Enter key, the entire
- text is selected, and the callback is done if the text has changed.
- Normally the Enter key will navigate to the next field (or insert
- a newline for a Fl_Multiline_Input) - this changes the behavior.
+ \li FL_WHEN_RELEASE: The callback will be done when this widget loses
+ the focus, including when the window is unmapped. This is a useful
+ value for text fields in a panel where doing the callback on every
+ change is wasteful. However the callback will also happen if the
+ mouse is moved out of the window, which means it should not do
+ anything visible (like pop up an error message).
+ You might do better setting this to zero, and scanning all the
+ items for changed() when the OK button on a panel is pressed.
+ \li FL_WHEN_ENTER_KEY: If the user types the Enter key, the entire
+ text is selected, and the callback is done if the text has changed.
+ Normally the Enter key will navigate to the next field (or insert
+ a newline for a Fl_Multiline_Input) - this changes the behavior.
\li FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED: The Enter key will do the
callback even if the text has not changed. Useful for command fields.
- Fl_Widget::when() is a set of bitflags used by subclasses of
+ Fl_Widget::when() is a set of bitflags used by subclasses of
Fl_Widget to decide when to do the callback.
- If the value is zero then the callback is never done. Other values
- are described in the individual widgets. This field is in the base
+ If the value is zero then the callback is never done. Other values
+ are described in the individual widgets. This field is in the base
class so that you can scan a panel and do_callback() on all the ones
that don't do their own callbacks in response to an "OK" button.
\param[in] i set of flags
@@ -692,20 +690,20 @@ public:
\see hide(), visible(), visible_r()
*/
virtual void show();
-
+
/** Makes a widget invisible.
\see show(), visible(), visible_r()
*/
virtual void hide();
- /** Makes the widget visible.
- You must still redraw the parent widget to see a change in the
+ /** Makes the widget visible.
+ You must still redraw the parent widget to see a change in the
window. Normally you want to use the show() method instead.
*/
void set_visible() {flags_ &= ~INVISIBLE;}
- /** Hides the widget.
- You must still redraw the parent to see a change in the window.
+ /** Hides the widget.
+ You must still redraw the parent to see a change in the window.
Normally you want to use the hide() method instead.
*/
void clear_visible() {flags_ |= INVISIBLE;}
@@ -716,27 +714,27 @@ public:
*/
unsigned int active() const {return !(flags_&INACTIVE);}
- /** Returns whether the widget and all of its parents are active.
+ /** Returns whether the widget and all of its parents are active.
\retval 0 if this or any of the parent widgets are inactive
\see active(), activate(), deactivate()
*/
int active_r() const;
/** Activates the widget.
- Changing this value will send FL_ACTIVATE to the widget if
+ Changing this value will send FL_ACTIVATE to the widget if
active_r() is true.
\see active(), active_r(), deactivate()
*/
void activate();
/** Deactivates the widget.
- Inactive widgets will be drawn "grayed out", e.g. with less contrast
- than the active widget. Inactive widgets will not receive any keyboard
- or mouse button events. Other events (including FL_ENTER, FL_MOVE,
- FL_LEAVE, FL_SHORTCUT, and others) will still be sent. A widget is
- only active if active() is true on it <I>and all of its parents</I>.
+ Inactive widgets will be drawn "grayed out", e.g. with less contrast
+ than the active widget. Inactive widgets will not receive any keyboard
+ or mouse button events. Other events (including FL_ENTER, FL_MOVE,
+ FL_LEAVE, FL_SHORTCUT, and others) will still be sent. A widget is
+ only active if active() is true on it <I>and all of its parents</I>.
- Changing this value will send FL_DEACTIVATE to the widget if
+ Changing this value will send FL_DEACTIVATE to the widget if
active_r() is true.
Currently you cannot deactivate Fl_Window widgets.
@@ -746,22 +744,22 @@ public:
void deactivate();
/** Returns if a widget is used for output only.
- output() means the same as !active() except it does not change how the
- widget is drawn. The widget will not receive any events. This is useful
- for making scrollbars or buttons that work as displays rather than input
+ output() means the same as !active() except it does not change how the
+ widget is drawn. The widget will not receive any events. This is useful
+ for making scrollbars or buttons that work as displays rather than input
devices.
\retval 0 if the widget is used for input and output
- \see set_output(), clear_output()
+ \see set_output(), clear_output()
*/
unsigned int output() const {return (flags_&OUTPUT);}
/** Sets a widget to output only.
- \see output(), clear_output()
+ \see output(), clear_output()
*/
void set_output() {flags_ |= OUTPUT;}
/** Sets a widget to accept input.
- \see set_output(), output()
+ \see set_output(), output()
*/
void clear_output() {flags_ &= ~OUTPUT;}
@@ -815,31 +813,31 @@ public:
void set_active() {flags_ &= ~INACTIVE;}
/** Gives the widget the keyboard focus.
- Tries to make this widget be the Fl::focus() widget, by first sending
- it an FL_FOCUS event, and if it returns non-zero, setting
- Fl::focus() to this widget. You should use this method to
- assign the focus to a widget.
+ Tries to make this widget be the Fl::focus() widget, by first sending
+ it an FL_FOCUS event, and if it returns non-zero, setting
+ Fl::focus() to this widget. You should use this method to
+ assign the focus to a widget.
\return true if the widget accepted the focus.
*/
int take_focus();
- /** Enables keyboard focus navigation with this widget.
+ /** Enables keyboard focus navigation with this widget.
Note, however, that this will not necessarily mean that the widget
will accept focus, but for widgets that can accept focus, this method
enables it if it has been disabled.
- \see visible_focus(), clear_visible_focus(), visible_focus(int)
+ \see visible_focus(), clear_visible_focus(), visible_focus(int)
*/
void set_visible_focus() { flags_ |= VISIBLE_FOCUS; }
- /** Disables keyboard focus navigation with this widget.
+ /** Disables keyboard focus navigation with this widget.
Normally, all widgets participate in keyboard focus navigation.
- \see set_visible_focus(), visible_focus(), visible_focus(int)
+ \see set_visible_focus(), visible_focus(), visible_focus(int)
*/
void clear_visible_focus() { flags_ &= ~VISIBLE_FOCUS; }
- /** Modifies keyboard focus navigation.
+ /** Modifies keyboard focus navigation.
\param[in] v set or clear visible focus
- \see set_visible_focus(), clear_visible_focus(), visible_focus()
+ \see set_visible_focus(), clear_visible_focus(), visible_focus()
*/
void visible_focus(int v) { if (v) set_visible_focus(); else clear_visible_focus(); }
@@ -927,13 +925,13 @@ public:
void redraw();
/** Schedules the drawing of the label.
- Marks the widget or the parent as needing a redraw for the label area
+ Marks the widget or the parent as needing a redraw for the label area
of a widget.
*/
void redraw_label();
- /** Returns non-zero if draw() needs to be called.
- The damage value is actually a bit field that the widget
+ /** Returns non-zero if draw() needs to be called.
+ The damage value is actually a bit field that the widget
subclass can use to figure out what parts to draw.
\return a bitmap of flags describing the kind of damage to the widget
\see damage(uchar), clear_damage(uchar)
@@ -948,7 +946,7 @@ public:
\note Therefore it is possible to set damage bits with this method, but
this should be avoided. Use damage(uchar) instead.
-
+
\param[in] c new bitmask of damage flags (default: 0)
\see damage(uchar), damage()
*/
@@ -973,7 +971,7 @@ public:
/** Sets width ww and height hh accordingly with the label size.
Labels with images will return w() and h() of the image.
-
+
This calls fl_measure() internally. For more information about
the arguments \p ww and \p hh and word wrapping
\see fl_measure(const char*, int&, int&, int)
@@ -991,15 +989,15 @@ public:
non-NULL, then the widget in question is derived from Fl_Group,
and you can use the returned pointer to access its children
or other Fl_Group-specific methods.
-
+
Example:
\code
void my_callback (Fl_Widget *w, void *) {
Fl_Group *g = w->as_group();
- if (g)
- printf ("This group has %d children\n", g->children());
- else
- printf ("This widget is not a group!\n");
+ if (g)
+ printf ("This group has %d children\n", g->children());
+ else
+ printf ("This widget is not a group!\n");
}
\endcode
@@ -1038,7 +1036,7 @@ public:
/** Returns non zero if MAC_USE_ACCENTS_MENU flag is set, 0 otherwise.
*/
int use_accents_menu() { return flags() & MAC_USE_ACCENTS_MENU; }
-
+
/** For back compatibility only.
\deprecated Use selection_color() instead.
*/
@@ -1080,7 +1078,3 @@ public:
#define FL_RESERVED_TYPE 100
#endif
-
-//
-// End of "$Id$".
-//