1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Widget header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2009-01-01 19:11:32 +03:00
|
|
|
// Copyright 1998-2009 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
// USA.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_Widget, Fl_Label classes . */
|
2008-08-11 12:35:34 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef Fl_Widget_H
|
|
|
|
#define Fl_Widget_H
|
|
|
|
|
|
|
|
#include "Enumerations.H"
|
|
|
|
|
|
|
|
class Fl_Widget;
|
|
|
|
class Fl_Window;
|
2001-10-23 01:15:11 +04:00
|
|
|
class Fl_Group;
|
2001-08-06 03:58:54 +04:00
|
|
|
class Fl_Image;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Default callback type definition for all fltk widgets (by far the most used) */
|
1998-10-06 22:21:25 +04:00
|
|
|
typedef void (Fl_Callback )(Fl_Widget*, void*);
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Default callback type pointer definition for all fltk widgets */
|
1999-03-18 23:04:13 +03:00
|
|
|
typedef Fl_Callback* Fl_Callback_p; // needed for BORLAND
|
2008-12-13 21:31:54 +03:00
|
|
|
/** One parameter callback type definition passing only the widget */
|
1998-10-06 22:21:25 +04:00
|
|
|
typedef void (Fl_Callback0)(Fl_Widget*);
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Callback type definition passing the widget and a long data value */
|
1998-10-06 22:21:25 +04:00
|
|
|
typedef void (Fl_Callback1)(Fl_Widget*, long);
|
|
|
|
|
2008-08-11 12:35:34 +04:00
|
|
|
/** This struct stores all information for a text or mixed graphics label.
|
2008-12-13 21:31:54 +03:00
|
|
|
|
|
|
|
\todo For FLTK 1.3, the Fl_Label type will become a widget by itself. That way
|
|
|
|
we will be avoiding a lot of code duplication by handling labels in
|
|
|
|
a similar fashion to widgets containing text. We also provide an easy
|
|
|
|
interface for very complex labels, containing html or vector graphics.
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
struct FL_EXPORT Fl_Label {
|
2008-08-12 18:30:43 +04:00
|
|
|
/** label text */
|
1998-10-06 22:21:25 +04:00
|
|
|
const char* value;
|
2008-08-12 18:30:43 +04:00
|
|
|
/** optional image for an active label */
|
2001-08-06 03:58:54 +04:00
|
|
|
Fl_Image* image;
|
2008-08-12 18:30:43 +04:00
|
|
|
/** optional image for a deactivated label */
|
2001-08-06 03:58:54 +04:00
|
|
|
Fl_Image* deimage;
|
2008-08-12 18:30:43 +04:00
|
|
|
/** label font used in text */
|
2008-04-23 23:09:28 +04:00
|
|
|
Fl_Font font;
|
2008-08-12 18:30:43 +04:00
|
|
|
/** size of label font */
|
2008-08-16 01:11:21 +04:00
|
|
|
Fl_Fontsize size;
|
2008-08-12 18:30:43 +04:00
|
|
|
/** text color */
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color color;
|
2010-01-16 18:56:41 +03:00
|
|
|
/** alignment of label */
|
|
|
|
Fl_Align align_;
|
|
|
|
/** type of label. \see Fl_Labeltype */
|
|
|
|
uchar type;
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Draws the label aligned to the given box */
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw(int,int,int,int, Fl_Align) const ;
|
2008-08-12 19:04:35 +04:00
|
|
|
void measure(int &w, int &h) const ;
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Fl_Widget is the base class for all widgets in FLTK.
|
2008-12-13 21:31:54 +03:00
|
|
|
|
|
|
|
You can't create one of these because the constructor is not public.
|
|
|
|
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
|
|
|
|
user code to call redraw() after these.
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
class FL_EXPORT Fl_Widget {
|
1998-10-06 22:21:25 +04:00
|
|
|
friend class Fl_Group;
|
|
|
|
|
2001-10-23 01:15:11 +04:00
|
|
|
Fl_Group* parent_;
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Callback* callback_;
|
|
|
|
void* user_data_;
|
2008-04-23 19:07:13 +04:00
|
|
|
int x_,y_,w_,h_;
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Label label_;
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int flags_;
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color color_;
|
|
|
|
Fl_Color color2_;
|
2001-10-29 06:44:33 +03:00
|
|
|
uchar type_;
|
1998-10-06 22:21:25 +04:00
|
|
|
uchar damage_;
|
|
|
|
uchar box_;
|
|
|
|
uchar when_;
|
|
|
|
|
2001-08-02 01:24:49 +04:00
|
|
|
const char *tooltip_;
|
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** unimplemented copy ctor */
|
2005-07-15 13:34:53 +04:00
|
|
|
Fl_Widget(const Fl_Widget &);
|
2008-08-12 18:30:43 +04:00
|
|
|
/** unimplemented assignment operator */
|
2005-07-15 13:34:53 +04:00
|
|
|
Fl_Widget& operator=(const Fl_Widget &);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** 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
|
|
|
|
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
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-12-08 01:04:55 +03:00
|
|
|
Fl_Widget(int x, int y, int w, int h, const char *label=0L);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
|
2008-04-23 19:07:13 +04:00
|
|
|
void x(int v) {x_ = v;}
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
|
2008-04-23 19:07:13 +04:00
|
|
|
void y(int v) {y_ = v;}
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
|
2008-04-23 19:07:13 +04:00
|
|
|
void w(int v) {w_ = v;}
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */
|
2008-04-23 19:07:13 +04:00
|
|
|
void h(int v) {h_ = v;}
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Gets the widget flags mask */
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int flags() const {return flags_;}
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Sets a flag in the flags mask */
|
2009-09-28 18:34:52 +04:00
|
|
|
void set_flag(unsigned int c) {flags_ |= c;}
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Clears a flag in the flags mask */
|
2009-09-28 18:34:52 +04:00
|
|
|
void clear_flag(unsigned int c) {flags_ &= ~c;}
|
2008-09-18 23:09:34 +04:00
|
|
|
/** flags possible values enumeration.
|
2008-12-13 21:31:54 +03:00
|
|
|
See activate(), output(), visible(), changed(), set_visible_focus()
|
2008-09-18 23:09:34 +04:00
|
|
|
*/
|
|
|
|
enum {
|
2009-09-28 18:11:50 +04:00
|
|
|
INACTIVE = 1<<0, ///< the widget can't receive focus, and is disabled but potentially visible
|
|
|
|
INVISIBLE = 1<<1, ///< the widget is not drawn but can receive events
|
|
|
|
OUTPUT = 1<<2, ///< for output only
|
|
|
|
NOBORDER = 1<<3, ///< don't draw a decoration (Fl_Window)
|
2009-10-02 23:08:55 +04:00
|
|
|
FORCE_POSITION = 1<<4, ///< don't let the window manager position the window (Fl_Window)
|
2009-09-28 18:11:50 +04:00
|
|
|
NON_MODAL = 1<<5, ///< thisis a hovering toolbar window (Fl_Window)
|
|
|
|
SHORTCUT_LABEL = 1<<6, ///< the label contains a shortcut we need to draw
|
|
|
|
CHANGED = 1<<7, ///< the widget value changed
|
|
|
|
OVERRIDE = 1<<8, ///< position window on top (Fl_Window)
|
|
|
|
VISIBLE_FOCUS = 1<<9, ///< accepts keyboard focus navigation if the widget can have the focus
|
|
|
|
COPIED_LABEL = 1<<10, ///< the widget label is internally copied, its destruction is handled by the widget
|
|
|
|
CLIP_CHILDREN = 1<<11, ///< all drawing within this widget will be clipped (Fl_Group)
|
|
|
|
MENU_WINDOW = 1<<12, ///< a temporary popup window, dismissed by clicking outside (Fl_Window)
|
|
|
|
TOOLTIP_WINDOW = 1<<13, ///< a temporary popup, transparent to events, and dismissed easily (Fl_Window)
|
|
|
|
MODAL = 1<<14, ///< a window blocking input to all other winows (Fl_Window)
|
2009-09-28 18:41:22 +04:00
|
|
|
NO_OVERLAY = 1<<15, ///< window not using a hardware overlay plane (Fl_Menu_Window)
|
2009-10-02 23:08:55 +04:00
|
|
|
GROUP_RELATIVE = 1<<16, ///< position this idget relative to the parent group, not to the window
|
2009-09-28 18:11:50 +04:00
|
|
|
// (space for more flags)
|
|
|
|
USERFLAG3 = 1<<29, ///< reserved for 3rd party extensions
|
|
|
|
USERFLAG2 = 1<<30, ///< reserved for 3rd party extensions
|
|
|
|
USERFLAG1 = 1<<31 ///< reserved for 3rd party extensions
|
2009-09-27 15:39:02 +04:00
|
|
|
};
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw_box() const;
|
2009-03-21 20:08:23 +03:00
|
|
|
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;
|
2010-04-08 03:17:33 +04:00
|
|
|
void draw_backdrop() const;
|
2008-09-18 23:09:34 +04:00
|
|
|
/** draws a focus rectangle around the widget */
|
2001-11-03 08:11:34 +03:00
|
|
|
void draw_focus() {draw_focus(box(),x(),y(),w(),h());}
|
2009-03-21 20:08:23 +03:00
|
|
|
void draw_focus(Fl_Boxtype t, int x,int y,int w,int h) const;
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw_label() const;
|
|
|
|
void draw_label(int, int, int, int) const;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Destroys the widget.
|
2009-02-08 20:26:02 +03:00
|
|
|
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
|
2008-12-13 21:31:54 +03:00
|
|
|
and groups in that group.
|
2009-02-08 20:26:02 +03:00
|
|
|
|
|
|
|
\since FLTK 1.3, the widget's destructor removes the widget from its parent
|
|
|
|
group, if it is member of a group.
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
virtual ~Fl_Widget();
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Draws the widget.
|
|
|
|
Never call this function directly. FLTK will schedule redrawing whenever
|
|
|
|
needed. If your widget must be redrawn as soon as possible, call redraw()
|
|
|
|
instead.
|
2009-02-20 11:15:32 +03:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
Override this function to draw your own widgets.
|
2009-02-20 11:15:32 +03:00
|
|
|
|
|
|
|
If you ever need to call another widget's draw method <I>from within your
|
2009-04-12 13:40:59 +04:00
|
|
|
own draw() method</I>, e.g. for an embedded scrollbar, you can do it
|
|
|
|
(because draw() is virtual) like this:
|
2009-02-20 11:15:32 +03:00
|
|
|
|
|
|
|
\code
|
|
|
|
Fl_Widget *s = &scroll; // scroll is an embedded Fl_Scrollbar
|
|
|
|
s->draw(); // calls Fl_Scrollbar::draw()
|
|
|
|
\endcode
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
virtual void draw() = 0;
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Handles the specified event.
|
2008-12-13 21:31:54 +03:00
|
|
|
You normally don't call this method directly, but instead let FLTK do
|
|
|
|
it when the user interacts with the widget.
|
|
|
|
|
2009-02-08 20:26:02 +03:00
|
|
|
When implemented in a widget, this function must return 0 if the
|
2008-12-13 21:31:54 +03:00
|
|
|
widget does not use the event or 1 otherwise.
|
|
|
|
|
|
|
|
Most of the time, you want to call the inherited handle() method in
|
2009-02-28 12:56:41 +03:00
|
|
|
your overridden method so that you don't short-circuit events that you
|
2008-12-13 21:31:54 +03:00
|
|
|
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
|
|
|
|
\see Fl_Event
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
virtual int handle(int event);
|
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Returns a pointer to the parent widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
Usually this is a Fl_Group or Fl_Window.
|
|
|
|
\retval NULL if the widget has no parent
|
|
|
|
\see Fl_Group::add(Fl_Widget*)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-10-23 01:15:11 +04:00
|
|
|
Fl_Group* parent() const {return parent_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Internal use only - "for hacks only".
|
|
|
|
|
2009-02-08 20:26:02 +03:00
|
|
|
It is \em \b STRONGLY recommended not to use this method, because it
|
2008-12-13 21:31:54 +03:00
|
|
|
short-circuits Fl_Group's normal widget adding and removing methods,
|
|
|
|
if the widget is already a child widget of another Fl_Group.
|
|
|
|
|
|
|
|
Use Fl_Group::add(Fl_Widget*) and/or Fl_Group::remove(Fl_Widget*) instead.
|
|
|
|
*/
|
|
|
|
void parent(Fl_Group* p) {parent_ = p;} // for hacks only, use Fl_Group::add()
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2008-09-17 11:56:15 +04:00
|
|
|
/** Gets the widget type.
|
2008-12-13 21:31:54 +03:00
|
|
|
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" ?
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
uchar type() const {return type_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-09-17 11:56:15 +04:00
|
|
|
/** Sets the widget type.
|
2008-12-13 21:31:54 +03:00
|
|
|
This is used for Forms compatibility.
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void type(uchar t) {type_ = t;}
|
|
|
|
|
2008-09-17 11:56:15 +04:00
|
|
|
/** Gets the widget position in its window.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return the x position relative to the window
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
int x() const {return x_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-09-17 11:56:15 +04:00
|
|
|
/** Gets the widget position in its window.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return the y position relative to the window
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
int y() const {return y_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-09-17 11:56:15 +04:00
|
|
|
/** Gets the widget width.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return the width of the widget in pixels.
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
int w() const {return w_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-09-17 11:56:15 +04:00
|
|
|
/** Gets the widget height.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return the height of the widget in pixels.
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
int h() const {return h_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Changes the size or position of the widget.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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()),
|
|
|
|
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] w, h new size
|
|
|
|
\see position(int,int), size(int,int)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
|
|
|
virtual void resize(int x, int y, int w, int h);
|
|
|
|
|
|
|
|
/** Internal use only. */
|
2002-08-14 20:19:48 +04:00
|
|
|
int damage_resize(int,int,int,int);
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Repositions the window or widget.
|
2009-02-28 12:56:41 +03:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
position(X, Y) is a shortcut for resize(X, Y, w(), h()).
|
|
|
|
|
|
|
|
\param[in] X, Y new position relative to the parent window
|
|
|
|
\see resize(int,int,int,int), size(int,int)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void position(int X,int Y) {resize(X,Y,w_,h_);}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2009-02-28 12:56:41 +03:00
|
|
|
/** Changes the size of the widget.
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
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)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void size(int W,int H) {resize(x_,y_,W,H);}
|
|
|
|
|
2008-08-11 12:35:34 +04:00
|
|
|
/** Gets the label alignment.
|
2009-02-28 12:56:41 +03:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
\return label alignment
|
|
|
|
\see label(), align(Fl_Align), Fl_Align
|
|
|
|
\todo This function should not take uchar as an argument.
|
|
|
|
Apart from the fact that uchar is too short with only 8 bits,
|
|
|
|
it does not provide type safety (in which case we don't need
|
|
|
|
to declare Fl_Align an enum to begin with).
|
|
|
|
*NOTE* The current (FLTK 1.3) implementation (Dec 2008) is such that
|
|
|
|
Fl_Align is (typedef'd to be) "unsigned" (int), but Fl_Widget's
|
|
|
|
"align_" member variable is a bit field of 8 bits only !
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2010-01-16 18:56:41 +03:00
|
|
|
Fl_Align align() const {return label_.align_;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the label alignment.
|
2008-12-13 21:31:54 +03:00
|
|
|
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
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2010-01-16 18:56:41 +03:00
|
|
|
void align(Fl_Align alignment) {label_.align_ = alignment;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Gets the box type of the widget.
|
|
|
|
\return the current box type
|
|
|
|
\see box(Fl_Boxtype), Fl_Boxtype
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
Fl_Boxtype box() const {return (Fl_Boxtype)box_;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the box type for the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
This identifies a routine that draws the background of the widget.
|
|
|
|
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
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
void box(Fl_Boxtype new_box) {box_ = new_box;}
|
|
|
|
|
|
|
|
/** Gets the background color of the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return current background color
|
2009-09-27 15:06:56 +04:00
|
|
|
\see color(Fl_Color), color(Fl_Color, Fl_Color)
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color color() const {return color_;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the background color of the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
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
|
2009-09-27 15:06:56 +04:00
|
|
|
\see color(), color(Fl_Color, Fl_Color), selection_color(Fl_Color)
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-09-27 15:06:56 +04:00
|
|
|
void color(Fl_Color bg) {color_ = bg;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Gets the selection color.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return the current selection color
|
2009-09-27 15:06:56 +04:00
|
|
|
\see selection_color(Fl_Color), color(Fl_Color, Fl_Color)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color selection_color() const {return color2_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** 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
|
2009-09-27 15:06:56 +04:00
|
|
|
with color(Fl_Color bg, Fl_Color sel).
|
2008-12-13 21:31:54 +03:00
|
|
|
\param[in] a the new selection color
|
2009-09-27 15:06:56 +04:00
|
|
|
\see selection_color(), color(Fl_Color, Fl_Color)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2009-09-27 15:06:56 +04:00
|
|
|
void selection_color(Fl_Color a) {color2_ = a;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the background and selection color of the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
|
|
|
|
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)
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-09-27 15:06:56 +04:00
|
|
|
void color(Fl_Color bg, Fl_Color sel) {color_=bg; color2_=sel;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2009-02-08 20:26:02 +03:00
|
|
|
/** Gets the current label text.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return a pointer to the current label text
|
2009-12-08 01:04:55 +03:00
|
|
|
\see label(const char *), copy_label(const char *)
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
const char* label() const {return label_.value;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets the current label pointer.
|
|
|
|
|
|
|
|
The label is shown somewhere on or next to the widget. 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()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
void label(const char* text);
|
|
|
|
|
|
|
|
/** Sets the current label.
|
2008-12-13 21:31:54 +03:00
|
|
|
Unlike label(), this method allocates a copy of the label
|
|
|
|
string instead of using the original string pointer.
|
2009-02-28 12:56:41 +03:00
|
|
|
|
|
|
|
The internal copy will automatically be freed whenever you assign
|
|
|
|
a new label or when the widget is destroyed.
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
\param[in] new_label the new label text
|
|
|
|
\see label()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-12-08 01:04:55 +03:00
|
|
|
void copy_label(const char *new_label);
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Shortcut to set the label text and type in one call.
|
2009-12-08 01:04:55 +03:00
|
|
|
\see label(const char *), labeltype(Fl_Labeltype)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2008-12-13 21:31:54 +03:00
|
|
|
void label(Fl_Labeltype a, const char* b) {label_.type = a; label_.value = b;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Gets the label type.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return the current label type.
|
|
|
|
\see Fl_Labeltype
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
Fl_Labeltype labeltype() const {return (Fl_Labeltype)label_.type;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the label type.
|
2008-12-13 21:31:54 +03:00
|
|
|
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
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void labeltype(Fl_Labeltype a) {label_.type = a;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Gets the label color.
|
2008-12-13 21:31:54 +03:00
|
|
|
The default color is FL_FOREGROUND_COLOR.
|
|
|
|
\return the current label color
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color labelcolor() const {return label_.color;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the label color.
|
2008-12-13 21:31:54 +03:00
|
|
|
The default color is FL_FOREGROUND_COLOR.
|
|
|
|
\param[in] c the new label color
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-09-27 15:06:56 +04:00
|
|
|
void labelcolor(Fl_Color c) {label_.color=c;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Gets the font to use.
|
2009-02-28 12:56:41 +03:00
|
|
|
Fonts are identified by indexes into a table. The default value
|
|
|
|
uses a Helvetica typeface (Arial for Microsoft® Windows®).
|
|
|
|
The function Fl::set_font() can define new typefaces.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return current font used by the label
|
|
|
|
\see Fl_Font
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2008-04-23 23:09:28 +04:00
|
|
|
Fl_Font labelfont() const {return label_.font;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the font to use.
|
2009-02-28 12:56:41 +03:00
|
|
|
Fonts are identified by indexes into a table. The default value
|
|
|
|
uses a Helvetica typeface (Arial for Microsoft® Windows®).
|
|
|
|
The function Fl::set_font() can define new typefaces.
|
2008-12-13 21:31:54 +03:00
|
|
|
\param[in] f the new font for the label
|
|
|
|
\see Fl_Font
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
void labelfont(Fl_Font f) {label_.font=f;}
|
|
|
|
|
|
|
|
/** Gets the font size in pixels.
|
2008-12-13 21:31:54 +03:00
|
|
|
The default size is 14 pixels.
|
|
|
|
\return the current font size
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2008-08-16 01:11:21 +04:00
|
|
|
Fl_Fontsize labelsize() const {return label_.size;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets the font size in pixels.
|
|
|
|
\param[in] pix the new font size
|
|
|
|
\see Fl_Fontsize labelsize()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2008-08-16 01:11:21 +04:00
|
|
|
void labelsize(Fl_Fontsize pix) {label_.size=pix;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Gets the image that is used as part of the widget label.
|
|
|
|
This image is used when drawing the widget in the active state.
|
|
|
|
\return the current image
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-06 03:58:54 +04:00
|
|
|
Fl_Image* image() {return label_.image;}
|
2010-04-08 03:17:33 +04:00
|
|
|
const Fl_Image* image() const {return label_.image;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets the image to use as part of the widget label.
|
|
|
|
This image is used when drawing the widget in the active state.
|
|
|
|
\param[in] img the new image for the label
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
void image(Fl_Image* img) {label_.image=img;}
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets the image to use as part of the widget label.
|
|
|
|
This image is used when drawing the widget in the active state.
|
|
|
|
\param[in] img the new image for the label
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
void image(Fl_Image& img) {label_.image=&img;}
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Gets the image that is used as part of the widget label.
|
|
|
|
This image is used when drawing the widget in the inactive state.
|
|
|
|
\return the current image for the deactivated widget
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-06 03:58:54 +04:00
|
|
|
Fl_Image* deimage() {return label_.deimage;}
|
2010-04-08 03:17:33 +04:00
|
|
|
const Fl_Image* deimage() const {return label_.deimage;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the image to use as part of the widget label.
|
2008-12-13 21:31:54 +03:00
|
|
|
This image is used when drawing the widget in the inactive state.
|
|
|
|
\param[in] img the new image for the deactivated widget
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
void deimage(Fl_Image* img) {label_.deimage=img;}
|
|
|
|
|
|
|
|
/** Sets the image to use as part of the widget label.
|
2008-12-13 21:31:54 +03:00
|
|
|
This image is used when drawing the widget in the inactive state.
|
|
|
|
\param[in] img the new image for the deactivated widget
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
void deimage(Fl_Image& img) {label_.deimage=&img;}
|
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Gets the current tooltip text.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return a pointer to the tooltip text or NULL
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
const char *tooltip() const {return tooltip_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
|
|
|
/** Sets the current tooltip text.
|
2008-12-13 21:31:54 +03:00
|
|
|
Sets a string of text to display in a popup tooltip window when the user
|
|
|
|
hovers the mouse over the widget. The string is <I>not</I> copied, so
|
|
|
|
make sure any formatted string is stored in a static, global,
|
|
|
|
or allocated buffer.
|
2009-02-28 12:56:41 +03:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
If no tooltip is set, the tooltip of the parent is inherited. Setting a
|
|
|
|
tooltip for a group and setting no tooltip for a child will show the
|
|
|
|
group's tooltip instead. To avoid this behavior, you can set the child's
|
|
|
|
tooltip to an empty string ("").
|
|
|
|
\param[in] t new tooltip
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
void tooltip(const char *t);
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Gets the current callback function for the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
Each widget has a single callback.
|
|
|
|
\return current callback
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
Fl_Callback_p callback() const {return callback_;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the current callback function for the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
Each widget has a single callback.
|
|
|
|
\param[in] cb new callback
|
|
|
|
\param[in] p user data
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2008-08-12 17:08:26 +04:00
|
|
|
void callback(Fl_Callback* cb, void* p) {callback_=cb; user_data_=p;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the current callback function for the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
Each widget has a single callback.
|
|
|
|
\param[in] cb new callback
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2008-08-12 17:08:26 +04:00
|
|
|
void callback(Fl_Callback* cb) {callback_=cb;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the current callback function for the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
Each widget has a single callback.
|
|
|
|
\param[in] cb new callback
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2008-08-12 17:08:26 +04:00
|
|
|
void callback(Fl_Callback0*cb) {callback_=(Fl_Callback*)cb;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the current callback function for the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
Each widget has a single callback.
|
|
|
|
\param[in] cb new callback
|
|
|
|
\param[in] p user data
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2008-08-12 17:08:26 +04:00
|
|
|
void callback(Fl_Callback1*cb, long p=0) {callback_=(Fl_Callback*)cb; user_data_=(void*)p;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Gets the user data for this widget.
|
2009-02-28 12:56:41 +03:00
|
|
|
Gets the current user data (void *) argument that is passed to the callback function.
|
2008-12-13 21:31:54 +03:00
|
|
|
\return user data as a pointer
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void* user_data() const {return user_data_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
|
|
|
/** Sets the user data for this widget.
|
2009-02-28 12:56:41 +03:00
|
|
|
Sets the new user data (void *) argument that is passed to the callback function.
|
2008-12-13 21:31:54 +03:00
|
|
|
\param[in] v new user data
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void user_data(void* v) {user_data_ = v;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Gets the current user data (long) argument that is passed to the callback function.
|
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
long argument() const {return (long)user_data_;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Sets the current user data (long) argument that is passed to the callback function.
|
2008-12-13 21:31:54 +03:00
|
|
|
\todo The user data value must be implemented using a \em union to avoid
|
|
|
|
64 bit machine incompatibilities.
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void argument(long v) {user_data_ = (void*)v;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Returns the conditions under which the callback is called.
|
|
|
|
|
|
|
|
You can set the flags with when(uchar), the default value is
|
|
|
|
FL_WHEN_RELEASE.
|
|
|
|
|
|
|
|
\return set of flags
|
|
|
|
\see when(uchar)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
Fl_When when() const {return (Fl_When)when_;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets the flags used to decide when a callback is called.
|
|
|
|
|
|
|
|
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
|
2008-12-13 22:40:26 +03:00
|
|
|
changed by the user.
|
2008-12-13 21:31:54 +03:00
|
|
|
\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
|
2009-02-08 20:26:02 +03:00
|
|
|
a newline for a Fl_Multiline_Input) - this changes the behavior.
|
2008-12-13 21:31:54 +03:00
|
|
|
\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 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
|
|
|
|
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
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void when(uchar i) {when_ = i;}
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Returns whether a widget is visible.
|
|
|
|
\retval 0 if the widget is not drawn and hence invisible.
|
|
|
|
\see show(), hide(), visible_r()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int visible() const {return !(flags_&INVISIBLE);}
|
2009-02-28 12:56:41 +03:00
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Returns whether a widget and all its parents are visible.
|
2008-12-13 21:31:54 +03:00
|
|
|
\retval 0 if the widget or any of its parents are invisible.
|
|
|
|
\see show(), hide(), visible()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
int visible_r() const;
|
2008-08-12 18:30:43 +04:00
|
|
|
|
|
|
|
/** Makes a widget visible.
|
2008-12-13 21:31:54 +03:00
|
|
|
An invisible widget never gets redrawn and does not get events.
|
|
|
|
The visible() method returns true if the widget is set to be
|
|
|
|
visible. The visible_r() method returns true if the widget and
|
|
|
|
all of its parents are visible. A widget is only visible if
|
|
|
|
visible() is true on it <I>and all of its parents</I>.
|
|
|
|
|
|
|
|
Changing it will send FL_SHOW or FL_HIDE events to
|
|
|
|
the widget. <I>Do not change it if the parent is not visible, as this
|
|
|
|
will send false FL_SHOW or FL_HIDE events to the widget</I>.
|
|
|
|
redraw() is called if necessary on this or the parent.
|
|
|
|
|
|
|
|
\see hide(), visible(), visible_r()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2008-11-07 02:24:38 +03:00
|
|
|
virtual void show();
|
2008-08-12 18:30:43 +04:00
|
|
|
|
|
|
|
/** Makes a widget invisible.
|
2008-12-13 21:31:54 +03:00
|
|
|
\see show(), visible(), visible_r()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2008-11-07 02:24:38 +03:00
|
|
|
virtual void hide();
|
2008-08-12 18:30:43 +04:00
|
|
|
|
|
|
|
/** Makes the widget visible.
|
2008-12-13 21:31:54 +03:00
|
|
|
You must still redraw the parent widget to see a change in the
|
|
|
|
window. Normally you want to use the show() method instead.
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void set_visible() {flags_ &= ~INVISIBLE;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Hides the widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
You must still redraw the parent to see a change in the window.
|
|
|
|
Normally you want to use the hide() method instead.
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void clear_visible() {flags_ |= INVISIBLE;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Returns whether the widget is active.
|
2008-12-13 21:31:54 +03:00
|
|
|
\retval 0 if the widget is inactive
|
|
|
|
\see active_r(), activate(), deactivate()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int active() const {return !(flags_&INACTIVE);}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** 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()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
int active_r() const;
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Activates the widget.
|
|
|
|
Changing this value will send FL_ACTIVATE to the widget if
|
|
|
|
active_r() is true.
|
|
|
|
\see active(), active_r(), deactivate()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
void activate();
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** 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>.
|
|
|
|
|
|
|
|
Changing this value will send FL_DEACTIVATE to the widget if
|
|
|
|
active_r() is true.
|
|
|
|
|
|
|
|
Currently you cannot deactivate Fl_Window widgets.
|
|
|
|
|
|
|
|
\see activate(), active(), active_r()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
void deactivate();
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** 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
|
|
|
|
devices.
|
|
|
|
\retval 0 if the widget is used for input and output
|
|
|
|
\see set_output(), clear_output()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int output() const {return (flags_&OUTPUT);}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets a widget to output only.
|
|
|
|
\see output(), clear_output()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void set_output() {flags_ |= OUTPUT;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets a widget to accept input.
|
|
|
|
\see set_output(), output()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void clear_output() {flags_ &= ~OUTPUT;}
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-08-12 21:44:34 +04:00
|
|
|
/** Returns if the widget is able to take events.
|
2008-12-13 21:31:54 +03:00
|
|
|
This is the same as (active() && !output()
|
|
|
|
&& visible()) but is faster.
|
|
|
|
\retval 0 if the widget takes no events
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int takesevents() const {return !(flags_&(INACTIVE|INVISIBLE|OUTPUT));}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-09-18 14:34:22 +04:00
|
|
|
/**
|
2009-02-28 12:56:41 +03:00
|
|
|
Checks if the widget value changed since the last callback.
|
2008-12-13 21:31:54 +03:00
|
|
|
|
|
|
|
"Changed" is a flag that is turned on when the user changes the value
|
|
|
|
stored in the widget. This is only used by subclasses of Fl_Widget that
|
|
|
|
store values, but is in the base class so it is easier to scan all the
|
|
|
|
widgets in a panel and do_callback() on the changed ones in response
|
|
|
|
to an "OK" button.
|
|
|
|
|
|
|
|
Most widgets turn this flag off when they do the callback, and when
|
|
|
|
the program sets the stored value.
|
|
|
|
|
|
|
|
\retval 0 if the value did not change
|
|
|
|
\see set_changed(), clear_changed()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int changed() const {return flags_&CHANGED;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Marks the value of the widget as changed.
|
|
|
|
\see changed(), clear_changed()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void set_changed() {flags_ |= CHANGED;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Marks the value of the widget as unchanged.
|
|
|
|
\see changed(), set_changed()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void clear_changed() {flags_ &= ~CHANGED;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** 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.
|
|
|
|
\return true if the widget accepted the focus.
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
int take_focus();
|
2008-08-12 18:30:43 +04:00
|
|
|
|
|
|
|
/** Enables keyboard focus navigation with this widget.
|
2009-02-28 12:56:41 +03:00
|
|
|
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.
|
2008-12-13 21:31:54 +03:00
|
|
|
\see visible_focus(), clear_visible_focus(), visible_focus(int)
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-07-23 19:07:33 +04:00
|
|
|
void set_visible_focus() { flags_ |= VISIBLE_FOCUS; }
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Disables keyboard focus navigation with this widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
Normally, all widgets participate in keyboard focus navigation.
|
|
|
|
\see set_visible_focus(), visible_focus(), visible_focus(int)
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2002-07-23 19:07:33 +04:00
|
|
|
void clear_visible_focus() { flags_ &= ~VISIBLE_FOCUS; }
|
2008-08-12 18:30:43 +04:00
|
|
|
|
|
|
|
/** Modifies keyboard focus navigation.
|
2008-12-13 21:31:54 +03:00
|
|
|
\param[in] v set or clear visible focus
|
|
|
|
\see set_visible_focus(), clear_visible_focus(), visible_focus()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-07-23 19:07:33 +04:00
|
|
|
void visible_focus(int v) { if (v) set_visible_focus(); else clear_visible_focus(); }
|
2009-02-28 12:56:41 +03:00
|
|
|
|
|
|
|
/** Checks whether this widget has a visible focus.
|
2008-12-13 21:31:54 +03:00
|
|
|
\retval 0 if this widget has no visible focus.
|
|
|
|
\see visible_focus(int), set_visible_focus(), clear_visible_focus()
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int visible_focus() { return flags_ & VISIBLE_FOCUS; }
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2008-08-12 19:04:35 +04:00
|
|
|
/** Sets the default callback for all widgets.
|
2008-12-13 21:31:54 +03:00
|
|
|
Sets the default callback, which puts a pointer to the widget on the queue
|
|
|
|
returned by Fl::readqueue(). You may want to call this from your own callback.
|
|
|
|
\param[in] cb the new callback
|
|
|
|
\param[in] d user data associated with that callback
|
2009-02-28 12:56:41 +03:00
|
|
|
\see callback(), do_callback(), Fl::readqueue()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
static void default_callback(Fl_Widget *cb, void *d);
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Calls the widget callback.
|
2009-02-08 17:44:15 +03:00
|
|
|
Causes a widget to invoke its callback function with default arguments.
|
2008-12-13 21:31:54 +03:00
|
|
|
\see callback()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-02-08 17:44:15 +03:00
|
|
|
void do_callback() {do_callback(this,user_data_);}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Calls the widget callback.
|
2009-02-08 17:44:15 +03:00
|
|
|
Causes a widget to invoke its callback function with arbitrary arguments.
|
2009-03-24 04:40:44 +03:00
|
|
|
\param[in] o call the callback with \p o as the widget argument
|
|
|
|
\param[in] arg call the callback with \p arg as the user data argument
|
2008-12-13 21:31:54 +03:00
|
|
|
\see callback()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2009-02-08 17:44:15 +03:00
|
|
|
void do_callback(Fl_Widget* o,long arg) {do_callback(o,(void*)arg);}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2009-02-28 12:56:41 +03:00
|
|
|
// Causes a widget to invoke its callback function with arbitrary arguments.
|
|
|
|
// Documentation and implementation in Fl_Widget.cxx
|
|
|
|
void do_callback(Fl_Widget* o,void* arg=0);
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Internal use only. */
|
2002-08-14 20:19:48 +04:00
|
|
|
int test_shortcut();
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Internal use only. */
|
2009-12-08 01:04:55 +03:00
|
|
|
static unsigned int label_shortcut(const char *t);
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Internal use only. */
|
2002-08-14 20:19:48 +04:00
|
|
|
static int test_shortcut(const char*);
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Checks if w is a child of this widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
\param[in] w potential child widget
|
2009-03-24 04:40:44 +03:00
|
|
|
\return Returns 1 if \p w is a child of this widget, or is
|
|
|
|
equal to this widget. Returns 0 if \p w is NULL.
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
int contains(const Fl_Widget *w) const ;
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Checks if this widget is a child of w.
|
2009-03-24 04:40:44 +03:00
|
|
|
Returns 1 if this widget is a child of \p w, or is
|
|
|
|
equal to \p w. Returns 0 if \p w is NULL.
|
2008-12-13 21:31:54 +03:00
|
|
|
\param[in] w the possible parent widget.
|
|
|
|
\see contains()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
int inside(const Fl_Widget* w) const {return w ? w->contains(this) : 0;}
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Schedules the drawing of the widget.
|
|
|
|
Marks the widget as needing its draw() routine called.
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
void redraw();
|
2008-08-12 18:30:43 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Schedules the drawing of the label.
|
|
|
|
Marks the widget or the parent as needing a redraw for the label area
|
|
|
|
of a widget.
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-10-04 19:59:29 +04:00
|
|
|
void redraw_label();
|
2008-08-11 12:35:34 +04:00
|
|
|
|
|
|
|
/** Returns non-zero if draw() needs to be called.
|
2008-12-13 21:31:54 +03:00
|
|
|
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)
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
uchar damage() const {return damage_;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2009-09-13 14:04:51 +04:00
|
|
|
/** Clears or sets the damage flags.
|
2008-12-13 21:31:54 +03:00
|
|
|
Damage flags are cleared when parts of the widget drawing is repaired.
|
2009-09-13 14:04:51 +04:00
|
|
|
|
|
|
|
The optional argument \p c specifies the bits that <b>are set</b>
|
|
|
|
after the call (default: 0) and \b not the bits that are cleared!
|
|
|
|
|
|
|
|
\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)
|
2008-12-13 21:31:54 +03:00
|
|
|
\see damage(uchar), damage()
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
void clear_damage(uchar c = 0) {damage_ = c;}
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets the damage bits for the widget.
|
|
|
|
Setting damage bits will schedule the widget for the next redraw.
|
|
|
|
\param[in] c bitmask of flags to set
|
|
|
|
\see damage(), clear_damage(uchar)
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
void damage(uchar c);
|
2008-08-11 12:35:34 +04:00
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** Sets the damage bits for an area inside the widget.
|
|
|
|
Setting damage bits will schedule the widget for the next redraw.
|
|
|
|
\param[in] c bitmask of flags to set
|
|
|
|
\param[in] x, y, w, h size of damaged area
|
|
|
|
\see damage(), clear_damage(uchar)
|
2008-08-11 12:35:34 +04:00
|
|
|
*/
|
|
|
|
void damage(uchar c, int x, int y, int w, int h);
|
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
void draw_label(int, int, int, int, Fl_Align) const;
|
2008-12-13 21:31:54 +03:00
|
|
|
|
2009-02-28 12:56:41 +03:00
|
|
|
/** Sets width ww and height hh accordingly with the label size.
|
2008-12-13 21:31:54 +03:00
|
|
|
Labels with images will return w() and h() of the image.
|
|
|
|
*/
|
2008-09-14 16:45:42 +04:00
|
|
|
void measure_label(int& ww, int& hh) {label_.measure(ww, hh);}
|
2001-08-02 01:24:49 +04:00
|
|
|
|
2008-08-12 18:30:43 +04:00
|
|
|
/** Returns a pointer to the primary Fl_Window widget.
|
2008-12-13 21:31:54 +03:00
|
|
|
\retval NULL if no window is associated with this widget.
|
|
|
|
\note for an Fl_Window widget, this returns its <I>parent</I> window
|
|
|
|
(if any), not <I>this</I> window.
|
2008-08-12 18:30:43 +04:00
|
|
|
*/
|
2002-08-14 20:19:48 +04:00
|
|
|
Fl_Window* window() const ;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2010-02-13 15:25:58 +03:00
|
|
|
/** Returns an Fl_Group pointer if this widget is an Fl_Group.
|
|
|
|
|
|
|
|
\retval NULL if this widget is not derived from Fl_Group.
|
|
|
|
\note This method is provided to avoid dynamic_cast.
|
|
|
|
\todo More documentation ...
|
|
|
|
*/
|
2010-03-17 01:51:31 +03:00
|
|
|
virtual Fl_Group* as_group() {return 0;}
|
2010-02-13 15:25:58 +03:00
|
|
|
|
|
|
|
/** Returns an Fl_Window pointer if this widget is an Fl_Window.
|
2010-03-17 01:51:31 +03:00
|
|
|
|
|
|
|
\retval NULL if this widget is not derived from Fl_Window.
|
|
|
|
\note This method is provided to avoid dynamic_cast.
|
|
|
|
\todo More documentation ...
|
|
|
|
*/
|
|
|
|
virtual Fl_Window* as_window() {return 0;}
|
2010-02-13 15:25:58 +03:00
|
|
|
|
2010-03-17 01:51:31 +03:00
|
|
|
/** Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window.
|
|
|
|
\retval NULL if this widget is not derived from Fl_Gl_Window.
|
|
|
|
\note This method is provided to avoid dynamic_cast.
|
|
|
|
\todo More documentation ...
|
2010-02-13 15:25:58 +03:00
|
|
|
*/
|
2010-03-17 01:51:31 +03:00
|
|
|
virtual class Fl_Gl_Window* as_gl_window() {return 0;}
|
|
|
|
|
2008-12-13 21:31:54 +03:00
|
|
|
/** For back compatibility only.
|
|
|
|
\deprecated Use selection_color() instead.
|
|
|
|
*/
|
2001-08-02 01:24:49 +04:00
|
|
|
Fl_Color color2() const {return (Fl_Color)color2_;}
|
2008-12-13 21:31:54 +03:00
|
|
|
|
|
|
|
/** For back compatibility only.
|
|
|
|
\deprecated Use selection_color(unsigned) instead.
|
|
|
|
*/
|
2001-10-29 06:44:33 +03:00
|
|
|
void color2(unsigned a) {color2_ = a;}
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
2008-09-18 23:09:34 +04:00
|
|
|
/**
|
|
|
|
Reserved type numbers (necessary for my cheapo RTTI) start here.
|
2009-02-08 20:26:02 +03:00
|
|
|
Grep the header files for "RESERVED_TYPE" to find the next available
|
2008-09-18 23:09:34 +04:00
|
|
|
number.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
#define FL_RESERVED_TYPE 100
|
|
|
|
|
|
|
|
#endif
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|