diff options
Diffstat (limited to 'common/fltk/FL')
144 files changed, 24988 insertions, 0 deletions
diff --git a/common/fltk/FL/Enumerations.H b/common/fltk/FL/Enumerations.H new file mode 100644 index 00000000..093422bf --- /dev/null +++ b/common/fltk/FL/Enumerations.H @@ -0,0 +1,959 @@ +// +// "$Id: Enumerations.H 8710 2011-05-21 21:55:59Z manolo $" +// +// Enumerations for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file + This file contains type definitions and general enumerations. + */ + +#ifndef Fl_Enumerations_H +#define Fl_Enumerations_H + +# include "Fl_Export.H" +# include "fl_types.h" + +/** \name Version Numbers + + FLTK defines some constants to help the programmer to + find out, for which FLTK version a program is compiled. + + The following constants are defined: + */ +/*@{*/ + +/** + The major release version of this FLTK library. + \sa FL_VERSION + */ +#define FL_MAJOR_VERSION 1 + +/** + The minor release version for this library. + + FLTK remains mostly source-code compatible between minor version changes. + */ +#define FL_MINOR_VERSION 3 + +/** + The patch version for this library. + + FLTK remains binary compatible between patches. + */ +#define FL_PATCH_VERSION 0 + +/** + The FLTK version number as a \em double. + + FL_VERSION is a double that describes the major and minor version numbers. + Version 1.1 is actually stored as 1.01 to allow for more than 9 minor + releases. + + The FL_MAJOR_VERSION, FL_MINOR_VERSION, and FL_PATCH_VERSION constants + give the integral values for the major, minor, and patch releases + respectively. + */ +#define FL_VERSION ((double)FL_MAJOR_VERSION + \ + (double)FL_MINOR_VERSION * 0.01 + \ + (double)FL_PATCH_VERSION * 0.0001) + +/*@}*/ // group: Version Numbers + +/** + Every time a user moves the mouse pointer, clicks a button, + or presses a key, an event is generated and sent to your + application. Events can also come from other programs like the + window manager. + + Events are identified by the integer argument passed to the + Fl_Widget::handle() virtual method. Other information about the + most recent event is stored in static locations and acquired by + calling the Fl::event_*() methods. This static information remains + valid until the next event is read from the window system, so it + is ok to look at it outside of the handle() method. + + \sa Fl::event_text(), Fl::event_key(), class Fl:: + */ +enum Fl_Event { // events + /** No event. */ + FL_NO_EVENT = 0, + + /** A mouse button has gone down with the mouse pointing at this + widget. You can find out what button by calling Fl::event_button(). + You find out the mouse position by calling Fl::event_x() and + Fl::event_y(). + + A widget indicates that it "wants" the mouse click by returning non-zero + from its Fl_Widget::handle() method. It will then become the + Fl::pushed() widget and will get FL_DRAG and the matching FL_RELEASE events. + If Fl_Widget::handle() returns zero then FLTK will try sending the FL_PUSH + to another widget. + */ + FL_PUSH = 1, + + /** A mouse button has been released. You can find out what button by + calling Fl::event_button(). + + In order to receive the FL_RELEASE event, the widget must return + non-zero when handling FL_PUSH. + */ + FL_RELEASE = 2, + + /** The mouse has been moved to point at this widget. This can + be used for highlighting feedback. If a widget wants to + highlight or otherwise track the mouse, it indicates this by + returning non-zero from its handle() method. It then + becomes the Fl::belowmouse() widget and will receive + FL_MOVE and FL_LEAVE events. + */ + FL_ENTER = 3, + + /** The mouse has moved out of the widget. + In order to receive the FL_LEAVE event, the widget must + return non-zero when handling FL_ENTER. + */ + FL_LEAVE = 4, + + /** The mouse has moved with a button held down. The current button state + is in Fl::event_state(). The mouse position is in Fl::event_x() and + Fl::event_y(). + + In order to receive FL_DRAG events, the widget must return non-zero + when handling FL_PUSH. + */ + FL_DRAG = 5, + + /** This indicates an <I>attempt</I> to give a widget the keyboard focus. + + If a widget wants the focus, it should change itself to display the + fact that it has the focus, and return non-zero from its handle() method. + It then becomes the Fl::focus() widget and gets FL_KEYDOWN, FL_KEYUP, + and FL_UNFOCUS events. + + The focus will change either because the window manager changed which + window gets the focus, or because the user tried to navigate using tab, + arrows, or other keys. You can check Fl::event_key() to figure out why + it moved. For navigation it will be the key pressed and for interaction + with the window manager it will be zero. + */ + FL_FOCUS = 6, + + /** This event is sent to the previous Fl::focus() widget when another + widget gets the focus or the window loses focus. + */ + FL_UNFOCUS = 7, + + /** A key was pressed (FL_KEYDOWN) or released (FL_KEYUP). + Fl_KEYBOARD is a synonym for FL_KEYDOWN. + The key can be found in Fl::event_key(). + The text that the key should insert can be found with Fl::event_text() + and its length is in Fl::event_length(). If you use the key handle() + should return 1. If you return zero then FLTK assumes you ignored the + key and will then attempt to send it to a parent widget. If none of + them want it, it will change the event into a FL_SHORTCUT event. + + To receive FL_KEYBOARD events you must also respond to the FL_FOCUS + and FL_UNFOCUS events. + + If you are writing a text-editing widget you may also want to call + the Fl::compose() function to translate individual keystrokes into + non-ASCII characters. + + FL_KEYUP events are sent to the widget that currently has focus. This + is not necessarily the same widget that received the corresponding + FL_KEYDOWN event because focus may have changed between events. + */ + FL_KEYDOWN = 8, + + /** Equivalent to FL_KEYDOWN. + \see FL_KEYDOWN + */ + FL_KEYBOARD = 8, + + /** Key release event. + \see FL_KEYDOWN + */ + FL_KEYUP = 9, + + /** The user clicked the close button of a window. + This event is used internally only to trigger the callback of + Fl_Window derived classed. The default callback closes the + window calling Fl_Window::hide(). + */ + FL_CLOSE = 10, + + /** The mouse has moved without any mouse buttons held down. + This event is sent to the Fl::belowmouse() widget. + + In order to receive FL_MOVE events, the widget must return + non-zero when handling FL_ENTER. + */ + FL_MOVE = 11, + + /** If the Fl::focus() widget is zero or ignores an FL_KEYBOARD + event then FLTK tries sending this event to every widget it + can, until one of them returns non-zero. FL_SHORTCUT is first + sent to the Fl::belowmouse() widget, then its parents and siblings, + and eventually to every widget in the window, trying to find an + object that returns non-zero. FLTK tries really hard to not to ignore + any keystrokes! + + You can also make "global" shortcuts by using Fl::add_handler(). A + global shortcut will work no matter what windows are displayed or + which one has the focus. + */ + FL_SHORTCUT = 12, + + /** This widget is no longer active, due to Fl_Widget::deactivate() + being called on it or one of its parents. Fl_Widget::active() may + still be true after this, the widget is only active if Fl_Widget::active() + is true on it and all its parents (use Fl_Widget::active_r() to check this). + */ + FL_DEACTIVATE = 13, + + /** This widget is now active, due to Fl_Widget::activate() being + called on it or one of its parents. + */ + FL_ACTIVATE = 14, + + /** This widget is no longer visible, due to Fl_Widget::hide() being + called on it or one of its parents, or due to a parent window being + minimized. Fl_Widget::visible() may still be true after this, but the + widget is visible only if visible() is true for it and all its + parents (use Fl_Widget::visible_r() to check this). + */ + FL_HIDE = 15, + + /** This widget is visible again, due to Fl_Widget::show() being called on + it or one of its parents, or due to a parent window being restored. + Child Fl_Windows respond to this by actually creating the window if not + done already, so if you subclass a window, be sure to pass FL_SHOW + to the base class Fl_Widget::handle() method! + */ + FL_SHOW = 16, + + /** You should get this event some time after you call Fl::paste(). + The contents of Fl::event_text() is the text to insert and the number + of characters is in Fl::event_length(). + */ + FL_PASTE = 17, + + /** The Fl::selection_owner() will get this event before the selection is + moved to another widget. This indicates that some other widget or program + has claimed the selection. Motif programs used this to clear the selection + indication. Most modern programs ignore this. + */ + FL_SELECTIONCLEAR = 18, + + /** The user has moved the mouse wheel. The Fl::event_dx() and Fl::event_dy() + methods can be used to find the amount to scroll horizontally and vertically. + */ + FL_MOUSEWHEEL = 19, + + /** The mouse has been moved to point at this widget. A widget that is + interested in receiving drag'n'drop data must return 1 to receive + FL_DND_DRAG, FL_DND_LEAVE and FL_DND_RELEASE events. + */ + FL_DND_ENTER = 20, + + /** The mouse has been moved inside a widget while dragging data. A + widget that is interested in receiving drag'n'drop data should + indicate the possible drop position. + */ + FL_DND_DRAG = 21, + + /** The mouse has moved out of the widget. + */ + FL_DND_LEAVE = 22, + + /** The user has released the mouse button dropping data into the widget. + If the widget returns 1, it will receive the data in the immediately + following FL_PASTE event. + */ + FL_DND_RELEASE = 23 +}; + +/** \name When Conditions */ +/*@{*/ +/** These constants determine when a callback is performed. + + \sa Fl_Widget::when(); + \todo doxygen comments for values are incomplete and maybe wrong or unclear + */ +enum Fl_When { // Fl_Widget::when(): + FL_WHEN_NEVER = 0, ///< Never call the callback + FL_WHEN_CHANGED = 1, ///< Do the callback only when the widget value changes + FL_WHEN_NOT_CHANGED = 2, ///< Do the callback whenever the user interacts with the widget + FL_WHEN_RELEASE = 4, ///< Do the callback when the button or key is released and the value changes + FL_WHEN_RELEASE_ALWAYS= 6, ///< Do the callback when the button or key is released, even if the value doesn't change + FL_WHEN_ENTER_KEY = 8, ///< Do the callback when the user presses the ENTER key and the value changes + FL_WHEN_ENTER_KEY_ALWAYS=10, ///< Do the callback when the user presses the ENTER key, even if the value doesn't change + FL_WHEN_ENTER_KEY_CHANGED=11 ///< ? +}; + +/*@}*/ // group: When Conditions + +/** \name Mouse and Keyboard Events + + This and the following constants define the non-ASCII keys on the + keyboard for FL_KEYBOARD and FL_SHORTCUT events. + + \todo FL_Button and FL_key... constants could be structured better + (use an enum or some doxygen grouping ?) + + \sa Fl::event_key() and Fl::get_key(int) (use ascii letters for all other keys): + */ + +/*@{*/ + +// FIXME: These codes collide with valid Unicode keys + +#define FL_Button 0xfee8 ///< A mouse button; use Fl_Button + n for mouse button n. +#define FL_BackSpace 0xff08 ///< The backspace key. +#define FL_Tab 0xff09 ///< The tab key. +#define FL_Enter 0xff0d ///< The enter key. +#define FL_Pause 0xff13 ///< The pause key. +#define FL_Scroll_Lock 0xff14 ///< The scroll lock key. +#define FL_Escape 0xff1b ///< The escape key. +#define FL_Home 0xff50 ///< The home key. +#define FL_Left 0xff51 ///< The left arrow key. +#define FL_Up 0xff52 ///< The up arrow key. +#define FL_Right 0xff53 ///< The right arrow key. +#define FL_Down 0xff54 ///< The down arrow key. +#define FL_Page_Up 0xff55 ///< The page-up key. +#define FL_Page_Down 0xff56 ///< The page-down key. +#define FL_End 0xff57 ///< The end key. +#define FL_Print 0xff61 ///< The print (or print-screen) key. +#define FL_Insert 0xff63 ///< The insert key. +#define FL_Menu 0xff67 ///< The menu key. +#define FL_Help 0xff68 ///< The 'help' key on Mac keyboards +#define FL_Num_Lock 0xff7f ///< The num lock key. +#define FL_KP 0xff80 ///< One of the keypad numbers; use FL_KP + n for number n. +#define FL_KP_Enter 0xff8d ///< The enter key on the keypad, same as Fl_KP+'\\r'. +#define FL_KP_Last 0xffbd ///< The last keypad key; use to range-check keypad. +#define FL_F 0xffbd ///< One of the function keys; use FL_F + n for function key n. +#define FL_F_Last 0xffe0 ///< The last function key; use to range-check function keys. +#define FL_Shift_L 0xffe1 ///< The lefthand shift key. +#define FL_Shift_R 0xffe2 ///< The righthand shift key. +#define FL_Control_L 0xffe3 ///< The lefthand control key. +#define FL_Control_R 0xffe4 ///< The righthand control key. +#define FL_Caps_Lock 0xffe5 ///< The caps lock key. +#define FL_Meta_L 0xffe7 ///< The left meta/Windows key. +#define FL_Meta_R 0xffe8 ///< The right meta/Windows key. +#define FL_Alt_L 0xffe9 ///< The left alt key. +#define FL_Alt_R 0xffea ///< The right alt key. +#define FL_Delete 0xffff ///< The delete key. + +// These use the Private Use Area (PUA) of the Basic Multilingual Plane +// of Unicode. Guaranteed not to conflict with a proper Unicode character. + +// These primarily map to the XFree86 keysym range +#define FL_Volume_Down 0xEF11 /* Volume control down */ +#define FL_Volume_Mute 0xEF12 /* Mute sound from the system */ +#define FL_Volume_Up 0xEF13 /* Volume control up */ +#define FL_Media_Play 0xEF14 /* Start playing of audio */ +#define FL_Media_Stop 0xEF15 /* Stop playing audio */ +#define FL_Media_Prev 0xEF16 /* Previous track */ +#define FL_Media_Next 0xEF17 /* Next track */ +#define FL_Home_Page 0xEF18 /* Display user's home page */ +#define FL_Mail 0xEF19 /* Invoke user's mail program */ +#define FL_Search 0xEF1B /* Search */ +#define FL_Back 0xEF26 /* Like back on a browser */ +#define FL_Forward 0xEF27 /* Like forward on a browser */ +#define FL_Stop 0xEF28 /* Stop current operation */ +#define FL_Refresh 0xEF29 /* Refresh the page */ +#define FL_Sleep 0xEF2F /* Put system to sleep */ +#define FL_Favorites 0xEF30 /* Show favorite locations */ + +/*@}*/ // group: Mouse and Keyboard Events + +/** \name Mouse Buttons + + These constants define the button numbers for FL_PUSH and FL_RELEASE events. + + \sa Fl::event_button() +*/ + +/*@{*/ + +#define FL_LEFT_MOUSE 1 ///< The left mouse button +#define FL_MIDDLE_MOUSE 2 ///< The middle mouse button +#define FL_RIGHT_MOUSE 3 ///< The right mouse button + +/*@}*/ // group: Mouse Buttons + + +/** \name Event States + + The following constants define bits in the Fl::event_state() value. +*/ + +/*@{*/ // group: Event States + +// FIXME: it would be nice to have the modifiers in the upper 8 bit so that +// a unicode ke (24bit) can be sent as an unsigned with the modifiers. + +#define FL_SHIFT 0x00010000 ///< One of the shift keys is down +#define FL_CAPS_LOCK 0x00020000 ///< The caps lock is on +#define FL_CTRL 0x00040000 ///< One of the ctrl keys is down +#define FL_ALT 0x00080000 ///< One of the alt keys is down +#define FL_NUM_LOCK 0x00100000 ///< The num lock is on + // most X servers do this? +#define FL_META 0x00400000 ///< One of the meta/Windows keys is down + // correct for XFree86 +#define FL_SCROLL_LOCK 0x00800000 ///< The scroll lock is on + // correct for XFree86 +#define FL_BUTTON1 0x01000000 ///< Mouse button 1 is pushed +#define FL_BUTTON2 0x02000000 ///< Mouse button 2 is pushed +#define FL_BUTTON3 0x04000000 ///< Mouse button 3 is pushed +#define FL_BUTTONS 0x7f000000 ///< Any mouse button is pushed +#define FL_BUTTON(n) (0x00800000<<(n)) ///< Mouse button n (n > 0) is pushed + +#define FL_KEY_MASK 0x0000ffff ///< All keys are 16 bit for now + // FIXME: Unicode needs 24 bits! + +#ifdef __APPLE__ +# define FL_COMMAND FL_META ///< An alias for FL_CTRL on WIN32 and X11, or FL_META on MacOS X +# define FL_CONTROL FL_CTRL ///< An alias for FL_META on WIN32 and X11, or FL_CTRL on MacOS X +#else +# define FL_COMMAND FL_CTRL ///< An alias for FL_CTRL on WIN32 and X11, or FL_META on MacOS X +# define FL_CONTROL FL_META ///< An alias for FL_META on WIN32 and X11, or FL_CTRL on MacOS X +#endif // __APPLE__ + +/*@}*/ // group: Event States + +/** \name Box Types + \brief FLTK standard box types + + This enum defines the standard box types included with FLTK. + + FL_NO_BOX means nothing is drawn at all, so whatever is already + on the screen remains. The FL_..._FRAME types only draw their edges, + leaving the interior unchanged. The blue color in Figure 1 + is the area that is not drawn by the frame types. + + \image html boxtypes.png "Figure 1: FLTK standard box types" + \image latex boxtypes.png "FLTK standard box types" width=10cm + \todo Description of boxtypes is incomplete. + See below for the defined enum Fl_Boxtype. + \see src/Fl_get_system_colors.cxx +*/ +/*@{*/ +enum Fl_Boxtype { // boxtypes (if you change these you must fix fl_boxtype.C): + + FL_NO_BOX = 0, ///< nothing is drawn at all, this box is invisible + FL_FLAT_BOX, ///< a flat box + FL_UP_BOX, ///< see figure 1 + FL_DOWN_BOX, ///< see figure 1 + FL_UP_FRAME, ///< see figure 1 + FL_DOWN_FRAME, ///< see figure 1 + FL_THIN_UP_BOX, ///< see figure 1 + FL_THIN_DOWN_BOX, ///< see figure 1 + FL_THIN_UP_FRAME, ///< see figure 1 + FL_THIN_DOWN_FRAME, ///< see figure 1 + FL_ENGRAVED_BOX, ///< see figure 1 + FL_EMBOSSED_BOX, ///< see figure 1 + FL_ENGRAVED_FRAME, ///< see figure 1 + FL_EMBOSSED_FRAME, ///< see figure 1 + FL_BORDER_BOX, ///< see figure 1 + _FL_SHADOW_BOX, ///< see figure 1 + FL_BORDER_FRAME, ///< see figure 1 + _FL_SHADOW_FRAME, ///< see figure 1 + _FL_ROUNDED_BOX, ///< see figure 1 + _FL_RSHADOW_BOX, ///< see figure 1 + _FL_ROUNDED_FRAME, ///< see figure 1 + _FL_RFLAT_BOX, ///< see figure 1 + _FL_ROUND_UP_BOX, ///< see figure 1 + _FL_ROUND_DOWN_BOX, ///< see figure 1 + _FL_DIAMOND_UP_BOX, ///< see figure 1 + _FL_DIAMOND_DOWN_BOX, ///< see figure 1 + _FL_OVAL_BOX, ///< see figure 1 + _FL_OSHADOW_BOX, ///< see figure 1 + _FL_OVAL_FRAME, ///< see figure 1 + _FL_OFLAT_BOX, ///< see figure 1 + _FL_PLASTIC_UP_BOX, ///< plastic version of FL_UP_BOX + _FL_PLASTIC_DOWN_BOX, ///< plastic version of FL_DOWN_BOX + _FL_PLASTIC_UP_FRAME, ///< plastic version of FL_UP_FRAME + _FL_PLASTIC_DOWN_FRAME, ///< plastic version of FL_DOWN_FRAME + _FL_PLASTIC_THIN_UP_BOX, ///< plastic version of FL_THIN_UP_BOX + _FL_PLASTIC_THIN_DOWN_BOX, ///< plastic version of FL_THIN_DOWN_BOX + _FL_PLASTIC_ROUND_UP_BOX, ///< plastic version of FL_ROUND_UP_BOX + _FL_PLASTIC_ROUND_DOWN_BOX, ///< plastic version of FL_ROUND_DOWN_BOX + _FL_GTK_UP_BOX, ///< gtk+ version of FL_UP_BOX + _FL_GTK_DOWN_BOX, ///< gtk+ version of FL_DOWN_BOX + _FL_GTK_UP_FRAME, ///< gtk+ version of FL_UP_FRAME + _FL_GTK_DOWN_FRAME, ///< gtk+ version of FL_DOWN_RAME + _FL_GTK_THIN_UP_BOX, ///< gtk+ version of FL_THIN_UP_BOX + _FL_GTK_THIN_DOWN_BOX, ///< gtk+ version of FL_THIN_DOWN_BOX + _FL_GTK_THIN_UP_FRAME, ///< gtk+ version of FL_UP_FRAME + _FL_GTK_THIN_DOWN_FRAME, ///< gtk+ version of FL_THIN_DOWN_FRAME + _FL_GTK_ROUND_UP_BOX, ///< gtk+ version of FL_ROUND_UP_BOX + _FL_GTK_ROUND_DOWN_BOX, ///< gtk+ version of FL_ROUND_DOWN_BOX + FL_FREE_BOXTYPE ///< the first free box type for creation of new box types +}; +extern FL_EXPORT Fl_Boxtype fl_define_FL_ROUND_UP_BOX(); +#define FL_ROUND_UP_BOX fl_define_FL_ROUND_UP_BOX() +#define FL_ROUND_DOWN_BOX (Fl_Boxtype)(fl_define_FL_ROUND_UP_BOX()+1) +extern FL_EXPORT Fl_Boxtype fl_define_FL_SHADOW_BOX(); +#define FL_SHADOW_BOX fl_define_FL_SHADOW_BOX() +#define FL_SHADOW_FRAME (Fl_Boxtype)(fl_define_FL_SHADOW_BOX()+2) +extern FL_EXPORT Fl_Boxtype fl_define_FL_ROUNDED_BOX(); +#define FL_ROUNDED_BOX fl_define_FL_ROUNDED_BOX() +#define FL_ROUNDED_FRAME (Fl_Boxtype)(fl_define_FL_ROUNDED_BOX()+2) +extern FL_EXPORT Fl_Boxtype fl_define_FL_RFLAT_BOX(); +#define FL_RFLAT_BOX fl_define_FL_RFLAT_BOX() +extern FL_EXPORT Fl_Boxtype fl_define_FL_RSHADOW_BOX(); +#define FL_RSHADOW_BOX fl_define_FL_RSHADOW_BOX() +extern FL_EXPORT Fl_Boxtype fl_define_FL_DIAMOND_BOX(); +#define FL_DIAMOND_UP_BOX fl_define_FL_DIAMOND_BOX() +#define FL_DIAMOND_DOWN_BOX (Fl_Boxtype)(fl_define_FL_DIAMOND_BOX()+1) +extern FL_EXPORT Fl_Boxtype fl_define_FL_OVAL_BOX(); +#define FL_OVAL_BOX fl_define_FL_OVAL_BOX() +#define FL_OSHADOW_BOX (Fl_Boxtype)(fl_define_FL_OVAL_BOX()+1) +#define FL_OVAL_FRAME (Fl_Boxtype)(fl_define_FL_OVAL_BOX()+2) +#define FL_OFLAT_BOX (Fl_Boxtype)(fl_define_FL_OVAL_BOX()+3) + +extern FL_EXPORT Fl_Boxtype fl_define_FL_PLASTIC_UP_BOX(); +#define FL_PLASTIC_UP_BOX fl_define_FL_PLASTIC_UP_BOX() +#define FL_PLASTIC_DOWN_BOX (Fl_Boxtype)(fl_define_FL_PLASTIC_UP_BOX()+1) +#define FL_PLASTIC_UP_FRAME (Fl_Boxtype)(fl_define_FL_PLASTIC_UP_BOX()+2) +#define FL_PLASTIC_DOWN_FRAME (Fl_Boxtype)(fl_define_FL_PLASTIC_UP_BOX()+3) +#define FL_PLASTIC_THIN_UP_BOX (Fl_Boxtype)(fl_define_FL_PLASTIC_UP_BOX()+4) +#define FL_PLASTIC_THIN_DOWN_BOX (Fl_Boxtype)(fl_define_FL_PLASTIC_UP_BOX()+5) +#define FL_PLASTIC_ROUND_UP_BOX (Fl_Boxtype)(fl_define_FL_PLASTIC_UP_BOX()+6) +#define FL_PLASTIC_ROUND_DOWN_BOX (Fl_Boxtype)(fl_define_FL_PLASTIC_UP_BOX()+7) + +extern FL_EXPORT Fl_Boxtype fl_define_FL_GTK_UP_BOX(); +#define FL_GTK_UP_BOX fl_define_FL_GTK_UP_BOX() +#define FL_GTK_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+1) +#define FL_GTK_UP_FRAME (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+2) +#define FL_GTK_DOWN_FRAME (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+3) +#define FL_GTK_THIN_UP_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+4) +#define FL_GTK_THIN_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+5) +#define FL_GTK_THIN_UP_FRAME (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+6) +#define FL_GTK_THIN_DOWN_FRAME (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+7) +#define FL_GTK_ROUND_UP_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+8) +#define FL_GTK_ROUND_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GTK_UP_BOX()+9) + +// conversions of box types to other boxtypes: +/** + Get the filled version of a frame. + If no filled version of a given frame exists, the behavior of this function + is undefined and some random box or frame is returned. + */ +inline Fl_Boxtype fl_box(Fl_Boxtype b) { + return (Fl_Boxtype)((b<FL_UP_BOX||b%4>1)?b:(b-2)); +} +/** + Get the "pressed" or "down" version of a box. + If no "down" version of a given box exists, the behavior of this function + is undefined and some random box or frame is returned. + */ +inline Fl_Boxtype fl_down(Fl_Boxtype b) { + return (Fl_Boxtype)((b<FL_UP_BOX)?b:(b|1)); +} +/** + Get the unfilled, frame only version of a box. + If no frame version of a given box exists, the behavior of this function + is undefined and some random box or frame is returned. + */ +inline Fl_Boxtype fl_frame(Fl_Boxtype b) { + return (Fl_Boxtype)((b%4<2)?b:(b+2)); +} + +// back-compatibility box types: +#define FL_FRAME FL_ENGRAVED_FRAME +#define FL_FRAME_BOX FL_ENGRAVED_BOX +#define FL_CIRCLE_BOX FL_ROUND_DOWN_BOX +#define FL_DIAMOND_BOX FL_DIAMOND_DOWN_BOX + +/*@}*/ // group: Box Types + +/** + The labeltype() method sets the type of the label. + + The following standard label types are included: + + \todo The doxygen comments are incomplete, and some labeltypes + are starting with an underscore. Also, there are three + external functions undocumented (yet): + - fl_define_FL_SHADOW_LABEL() + - fl_define_FL_ENGRAVED_LABEL() + - fl_define_FL_EMBOSSED_LABEL() +*/ +enum Fl_Labeltype { // labeltypes: + FL_NORMAL_LABEL = 0, ///< draws the text (0) + FL_NO_LABEL, ///< does nothing + _FL_SHADOW_LABEL, ///< draws a drop shadow under the text + _FL_ENGRAVED_LABEL, ///< draws edges as though the text is engraved + _FL_EMBOSSED_LABEL, ///< draws edges as though the text is raised + _FL_MULTI_LABEL, ///< ? + _FL_ICON_LABEL, ///< draws the icon associated with the text + _FL_IMAGE_LABEL, ///< ? + + FL_FREE_LABELTYPE ///< first free labeltype to use for creating own labeltypes +}; + +/** + Sets the current label type and return its corresponding Fl_Labeltype value. + @{ +*/ +#define FL_SYMBOL_LABEL FL_NORMAL_LABEL +extern Fl_Labeltype FL_EXPORT fl_define_FL_SHADOW_LABEL(); +#define FL_SHADOW_LABEL fl_define_FL_SHADOW_LABEL() +extern Fl_Labeltype FL_EXPORT fl_define_FL_ENGRAVED_LABEL(); +#define FL_ENGRAVED_LABEL fl_define_FL_ENGRAVED_LABEL() +extern Fl_Labeltype FL_EXPORT fl_define_FL_EMBOSSED_LABEL(); +#define FL_EMBOSSED_LABEL fl_define_FL_EMBOSSED_LABEL() +/** @} */ + +/** \name Alignment Flags + Flags to control the label alignment. + This controls how the label is displayed next to or inside the widget. + The default value is FL_ALIGN_CENTER for most widgets, which centers the label + inside the widget. + + Flags can be or'd to achieve a combination of alignments. + + \code + Outside alignments: + TOP_LEFT TOP TOP_RIGHT + LEFT_TOP+---------------------------------+RIGHT_TOP + | | + LEFT| |RIGHT + | | + LEFT_BOTTOM+---------------------------------+RIGHT_BOTTOM + BOTTOM_RIGHT BOTTOM BOTTOM_LEFT + + Inside alignments: + +---------------------------------+ + |TOP_LEFT TOP TOP_RIGHT| + | | + |LEFT RIGHT| + | | + |BOTTOM_RIGHT BOTTOM BOTTOM_LEFT| + +---------------------------------+ + \endcode + \see #FL_ALIGN_CENTER, etc. + */ +/*@{*/ +/** FLTK type for alignment control */ +typedef unsigned Fl_Align; + /** Align the label horizontally in the middle. */ +const Fl_Align FL_ALIGN_CENTER = (Fl_Align)0; + /** Align the label at the top of the widget. Inside labels appear below the top, + outside labels are drawn on top of the widget. */ +const Fl_Align FL_ALIGN_TOP = (Fl_Align)1; + /** Align the label at the bottom of the widget. */ +const Fl_Align FL_ALIGN_BOTTOM = (Fl_Align)2; + /** Align the label at the left of the widget. Inside labels appear left-justified + starting at the left side of the widget, outside labels are right-justified and + drawn to the left of the widget. */ +const Fl_Align FL_ALIGN_LEFT = (Fl_Align)4; + /** Align the label to the right of the widget. */ +const Fl_Align FL_ALIGN_RIGHT = (Fl_Align)8; + /** Draw the label inside of the widget. */ +const Fl_Align FL_ALIGN_INSIDE = (Fl_Align)16; + /** If the label contains an image, draw the text on top of the image. */ +const Fl_Align FL_ALIGN_TEXT_OVER_IMAGE = (Fl_Align)0x0020; + /** If the label contains an image, draw the text below the image. */ +const Fl_Align FL_ALIGN_IMAGE_OVER_TEXT = (Fl_Align)0x0000; + /** All parts of the label that are lager than the widget will not be drawn . */ +const Fl_Align FL_ALIGN_CLIP = (Fl_Align)64; + /** Wrap text that does not fit the width of the widget. */ +const Fl_Align FL_ALIGN_WRAP = (Fl_Align)128; + /** If the label contains an image, draw the text to the right of the image. */ +const Fl_Align FL_ALIGN_IMAGE_NEXT_TO_TEXT = (Fl_Align)0x0100; + /** If the label contains an image, draw the text to the left of the image. */ +const Fl_Align FL_ALIGN_TEXT_NEXT_TO_IMAGE = (Fl_Align)0x0120; +/** If the label contains an image, draw the image or deimage in the background. */ +const Fl_Align FL_ALIGN_IMAGE_BACKDROP = (Fl_Align)0x0200; +const Fl_Align FL_ALIGN_TOP_LEFT = FL_ALIGN_TOP | FL_ALIGN_LEFT; +const Fl_Align FL_ALIGN_TOP_RIGHT = FL_ALIGN_TOP | FL_ALIGN_RIGHT; +const Fl_Align FL_ALIGN_BOTTOM_LEFT = FL_ALIGN_BOTTOM | FL_ALIGN_LEFT; +const Fl_Align FL_ALIGN_BOTTOM_RIGHT = FL_ALIGN_BOTTOM | FL_ALIGN_RIGHT; +const Fl_Align FL_ALIGN_LEFT_TOP = 0x0007; // magic value +const Fl_Align FL_ALIGN_RIGHT_TOP = 0x000b; // magic value +const Fl_Align FL_ALIGN_LEFT_BOTTOM = 0x000d; // magic value +const Fl_Align FL_ALIGN_RIGHT_BOTTOM = 0x000e; // magic value +const Fl_Align FL_ALIGN_NOWRAP = (Fl_Align)0; // for back compatibility +const Fl_Align FL_ALIGN_POSITION_MASK = 0x000f; // left, right, top, bottom +const Fl_Align FL_ALIGN_IMAGE_MASK = 0x0320; // l/r, t/b, backdrop +/*@}*/ + + +/** \name Font Numbers + The following constants define the standard FLTK fonts: + */ +/*@{*/ +/** A font number is an index into the internal font table. */ +typedef int Fl_Font; + +const Fl_Font FL_HELVETICA = 0; ///< Helvetica (or Arial) normal (0) +const Fl_Font FL_HELVETICA_BOLD = 1; ///< Helvetica (or Arial) bold +const Fl_Font FL_HELVETICA_ITALIC = 2; ///< Helvetica (or Arial) oblique +const Fl_Font FL_HELVETICA_BOLD_ITALIC = 3; ///< Helvetica (or Arial) bold-oblique +const Fl_Font FL_COURIER = 4; ///< Courier normal +const Fl_Font FL_COURIER_BOLD = 5; ///< Courier bold +const Fl_Font FL_COURIER_ITALIC = 6; ///< Courier italic +const Fl_Font FL_COURIER_BOLD_ITALIC = 7; ///< Courier bold-italic +const Fl_Font FL_TIMES = 8; ///< Times roman +const Fl_Font FL_TIMES_BOLD = 9; ///< Times roman bold +const Fl_Font FL_TIMES_ITALIC = 10; ///< Times roman italic +const Fl_Font FL_TIMES_BOLD_ITALIC = 11; ///< Times roman bold-italic +const Fl_Font FL_SYMBOL = 12; ///< Standard symbol font +const Fl_Font FL_SCREEN = 13; ///< Default monospaced screen font +const Fl_Font FL_SCREEN_BOLD = 14; ///< Default monospaced bold screen font +const Fl_Font FL_ZAPF_DINGBATS = 15; ///< Zapf-dingbats font + +const Fl_Font FL_FREE_FONT = 16; ///< first one to allocate +const Fl_Font FL_BOLD = 1; ///< add this to helvetica, courier, or times +const Fl_Font FL_ITALIC = 2; ///< add this to helvetica, courier, or times +const Fl_Font FL_BOLD_ITALIC = 3; ///< add this to helvetica, courier, or times + +/*@}*/ + +/** Size of a font in pixels. + This is the approximate height of a font in pixels. + */ +typedef int Fl_Fontsize; + +extern FL_EXPORT Fl_Fontsize FL_NORMAL_SIZE; ///< normal font size + +/** \name Colors + The Fl_Color type holds an FLTK color value. + + Colors are either 8-bit indexes into a virtual colormap + or 24-bit RGB color values. + + Color indices occupy the lower 8 bits of the value, while + RGB colors occupy the upper 24 bits, for a byte organization of RGBI. + +<pre> + Fl_Color => 0xrrggbbii + | | | | + | | | +--- index between 0 and 255 + | | +----- blue color component (8 bit) + | +------- green component (8 bit) + +--------- red component (8 bit) + </pre> + + A color can have either an index or an rgb value. Colors with rgb set + and an index >0 are reserved for special use. + + */ +/*@{*/ +/** an FLTK color value */ +typedef unsigned int Fl_Color; + +// Standard colors. These are used as default colors in widgets and altered as necessary +const Fl_Color FL_FOREGROUND_COLOR = 0; ///< the default foreground color (0) used for labels and text +const Fl_Color FL_BACKGROUND2_COLOR = 7; ///< the default background color for text, list, and valuator widgets +const Fl_Color FL_INACTIVE_COLOR = 8; ///< the inactive foreground color +const Fl_Color FL_SELECTION_COLOR = 15; ///< the default selection/highlight color + + // boxtypes generally limit themselves to these colors so + // the whole ramp is not allocated: + +const Fl_Color FL_GRAY0 = 32; // 'A' +const Fl_Color FL_DARK3 = 39; // 'H' +const Fl_Color FL_DARK2 = 45; // 'N' +const Fl_Color FL_DARK1 = 47; // 'P' +const Fl_Color FL_BACKGROUND_COLOR = 49; // 'R' default background color +const Fl_Color FL_LIGHT1 = 50; // 'S' +const Fl_Color FL_LIGHT2 = 52; // 'U' +const Fl_Color FL_LIGHT3 = 54; // 'W' + + // FLTK provides a 5x8x5 color cube that is used with colormap visuals + +const Fl_Color FL_BLACK = 56; +const Fl_Color FL_RED = 88; +const Fl_Color FL_GREEN = 63; +const Fl_Color FL_YELLOW = 95; +const Fl_Color FL_BLUE = 216; +const Fl_Color FL_MAGENTA = 248; +const Fl_Color FL_CYAN = 223; +const Fl_Color FL_DARK_RED = 72; + +const Fl_Color FL_DARK_GREEN = 60; +const Fl_Color FL_DARK_YELLOW = 76; +const Fl_Color FL_DARK_BLUE = 136; +const Fl_Color FL_DARK_MAGENTA = 152; +const Fl_Color FL_DARK_CYAN = 140; + +const Fl_Color FL_WHITE = 255; + + +#define FL_FREE_COLOR (Fl_Color)16 +#define FL_NUM_FREE_COLOR 16 +#define FL_GRAY_RAMP (Fl_Color)32 +#define FL_NUM_GRAY 24 +#define FL_GRAY FL_BACKGROUND_COLOR +#define FL_COLOR_CUBE (Fl_Color)56 +#define FL_NUM_RED 5 +#define FL_NUM_GREEN 8 +#define FL_NUM_BLUE 5 + +FL_EXPORT Fl_Color fl_inactive(Fl_Color c); + +FL_EXPORT Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg); + +FL_EXPORT Fl_Color fl_color_average(Fl_Color c1, Fl_Color c2, float weight); + +/** Returns a lighter version of the specified color. */ +inline Fl_Color fl_lighter(Fl_Color c) { return fl_color_average(c, FL_WHITE, .67f); } + +/** Returns a darker version of the specified color. */ +inline Fl_Color fl_darker(Fl_Color c) { return fl_color_average(c, FL_BLACK, .67f); } + +/** Returns the 24-bit color value closest to \p r, \p g, \p b. */ +inline Fl_Color fl_rgb_color(uchar r, uchar g, uchar b) { + if (!r && !g && !b) return FL_BLACK; + else return (Fl_Color)(((((r << 8) | g) << 8) | b) << 8); +} + +/** Returns the 24-bit color value closest to \p g (grayscale). */ +inline Fl_Color fl_rgb_color(uchar g) { + if (!g) return FL_BLACK; + else return (Fl_Color)(((((g << 8) | g) << 8) | g) << 8); +} + +/** Returns a gray color value from black (i == 0) to white (i == FL_NUM_GRAY - 1). + FL_NUM_GRAY is defined to be 24 in the current FLTK release. + To get the closest FLTK gray value to an 8-bit grayscale color 'I' use: + + \code + fl_gray_ramp(I * (FL_NUM_GRAY - 1) / 255) + \endcode +*/ +inline Fl_Color fl_gray_ramp(int i) {return (Fl_Color)(i+FL_GRAY_RAMP);} + +/** Returns a color out of the color cube. + + \p r must be in the range 0 to FL_NUM_RED (5) minus 1, + \p g must be in the range 0 to FL_NUM_GREEN (8) minus 1, + \p b must be in the range 0 to FL_NUM_BLUE (5) minus 1. + + To get the closest color to a 8-bit set of R,G,B values use: + + \code + fl_color_cube(R * (FL_NUM_RED - 1) / 255, + G * (FL_NUM_GREEN - 1) / 255, + B * (FL_NUM_BLUE - 1) / 255); + \endcode + */ +inline Fl_Color fl_color_cube(int r, int g, int b) { + return (Fl_Color)((b*FL_NUM_RED + r) * FL_NUM_GREEN + g + FL_COLOR_CUBE);} + +/*@}*/ // group: Colors + +/** \name Cursors */ +/*@{*/ + +/** The following constants define the mouse cursors that are available in FLTK. + + The double-headed arrows are bitmaps provided by FLTK on X, the others + are provided by system-defined cursors. + + \todo enum Fl_Cursor needs maybe an image. +*/ +enum Fl_Cursor { + FL_CURSOR_DEFAULT = 0, /**< the default cursor, usually an arrow. */ + FL_CURSOR_ARROW = 35, /**< an arrow pointer. */ + FL_CURSOR_CROSS = 66, /**< crosshair. */ + FL_CURSOR_WAIT = 76, /**< watch or hourglass. */ + FL_CURSOR_INSERT = 77, /**< I-beam. */ + FL_CURSOR_HAND = 31, /**< hand (uparrow on MSWindows). */ + FL_CURSOR_HELP = 47, /**< question mark. */ + FL_CURSOR_MOVE = 27, /**< 4-pointed arrow. */ + // fltk provides bitmaps for these: + FL_CURSOR_NS = 78, /**< up/down arrow. */ + FL_CURSOR_WE = 79, /**< left/right arrow. */ + FL_CURSOR_NWSE = 80, /**< diagonal arrow. */ + FL_CURSOR_NESW = 81, /**< diagonal arrow. */ + FL_CURSOR_NONE =255, /**< invisible. */ + // for back compatibility (non MSWindows ones): + FL_CURSOR_N = 70, /**< for back compatibility. */ + FL_CURSOR_NE = 69, /**< for back compatibility. */ + FL_CURSOR_E = 49, /**< for back compatibility. */ + FL_CURSOR_SE = 8, /**< for back compatibility. */ + FL_CURSOR_S = 9, /**< for back compatibility. */ + FL_CURSOR_SW = 7, /**< for back compatibility. */ + FL_CURSOR_W = 36, /**< for back compatibility. */ + FL_CURSOR_NW = 68 /**< for back compatibility. */ +}; +/*@}*/ // group: Cursors + +/** FD "when" conditions */ +enum { // values for "when" passed to Fl::add_fd() + FL_READ = 1, /**< Call the callback when there is data to be read. */ + FL_WRITE = 4, /**< Call the callback when data can be written without blocking. */ + FL_EXCEPT = 8 /**< Call the callback if an exception occurs on the file. */ +}; + +/** visual types and Fl_Gl_Window::mode() (values match Glut) */ +enum Fl_Mode { + FL_RGB = 0, + FL_INDEX = 1, + FL_SINGLE = 0, + FL_DOUBLE = 2, + FL_ACCUM = 4, + FL_ALPHA = 8, + FL_DEPTH = 16, + FL_STENCIL = 32, + FL_RGB8 = 64, + FL_MULTISAMPLE= 128, + FL_STEREO = 256, + FL_FAKE_SINGLE = 512 // Fake single buffered windows using double-buffer +}; + +// image alpha blending + +#define FL_IMAGE_WITH_ALPHA 0x40000000 + +/** Damage masks */ +enum Fl_Damage { + FL_DAMAGE_CHILD = 0x01, /**< A child needs to be redrawn. */ + FL_DAMAGE_EXPOSE = 0x02, /**< The window was exposed. */ + FL_DAMAGE_SCROLL = 0x04, /**< The Fl_Scroll widget was scrolled. */ + FL_DAMAGE_OVERLAY = 0x08, /**< The overlay planes need to be redrawn. */ + FL_DAMAGE_USER1 = 0x10, /**< First user-defined damage bit. */ + FL_DAMAGE_USER2 = 0x20, /**< Second user-defined damage bit. */ + FL_DAMAGE_ALL = 0x80 /**< Everything needs to be redrawn. */ +}; + +// FLTK 1.0.x compatibility definitions... +# ifdef FLTK_1_0_COMPAT +# define contrast fl_contrast +# define down fl_down +# define frame fl_frame +# define inactive fl_inactive +# endif // FLTK_1_0_COMPAT + +#endif + +// +// End of "$Id: Enumerations.H 8710 2011-05-21 21:55:59Z manolo $". +// diff --git a/common/fltk/FL/Fl.H b/common/fltk/FL/Fl.H new file mode 100644 index 00000000..9aaa1edd --- /dev/null +++ b/common/fltk/FL/Fl.H @@ -0,0 +1,1174 @@ +// +// "$Id: Fl.H 8724 2011-05-23 18:01:29Z manolo $" +// +// Main header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file + Fl static class. + */ + +#ifndef Fl_H +# define Fl_H + +#ifdef FLTK_HAVE_CAIRO +# include <FL/Fl_Cairo.H> +#endif + +# include "fl_utf8.h" +# include "Enumerations.H" +# ifndef Fl_Object +# define Fl_Object Fl_Widget /**< for back compatibility - use Fl_Widget! */ +# endif + +# ifdef check +# undef check +# endif + + +class Fl_Widget; +class Fl_Window; +class Fl_Image; +struct Fl_Label; + + +/** \defgroup callback_functions Callback function typedefs + \brief Typedefs defined in <FL/Fl.H> for callback or handler functions passed as function parameters. + + FLTK uses callback functions as parameters for some function calls, e.g. to + set up global event handlers (Fl::add_handler()), to add a timeout handler + (Fl::add_timeout()), and many more. + + The typedefs defined in this group describe the function parameters used to set + up or clear the callback functions and should also be referenced to define the + callback function to handle such events in the user's code. + + \see Fl::add_handler(), Fl::add_timeout(), Fl::repeat_timeout(), + Fl::remove_timeout() and others + @{ */ + +/** Signature of some label drawing functions passed as parameters */ +typedef void (Fl_Label_Draw_F)(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align); + +/** Signature of some label measurement functions passed as parameters */ +typedef void (Fl_Label_Measure_F)(const Fl_Label *label, int &width, int &height); + +/** Signature of some box drawing functions passed as parameters */ +typedef void (Fl_Box_Draw_F)(int x, int y, int w, int h, Fl_Color color); + +/** Signature of some timeout callback functions passed as parameters */ +typedef void (*Fl_Timeout_Handler)(void *data); + +/** Signature of some wakeup callback functions passed as parameters */ +typedef void (*Fl_Awake_Handler)(void *data); + +/** Signature of add_idle callback functions passed as parameters */ +typedef void (*Fl_Idle_Handler)(void *data); + +/** Signature of set_idle callback functions passed as parameters */ +typedef void (*Fl_Old_Idle_Handler)(); + +/** Signature of add_fd functions passed as parameters */ +typedef void (*Fl_FD_Handler)(int fd, void *data); + +/** Signature of add_handler functions passed as parameters */ +typedef int (*Fl_Event_Handler)(int event); + +/** Signature of set_abort functions passed as parameters */ +typedef void (*Fl_Abort_Handler)(const char *format,...); + +/** Signature of set_atclose functions passed as parameters */ +typedef void (*Fl_Atclose_Handler)(Fl_Window *window, void *data); + +/** Signature of args functions passed as parameters */ +typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i); + +/** Signature of event_dispatch functions passed as parameters. + \see Fl::event_dispatch(Fl_Event_Dispatch) */ +typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w); + +/** @} */ /* group callback_functions */ + + +/** + The Fl is the FLTK global (static) class containing + state information and global methods for the current application. +*/ +class FL_EXPORT Fl { + Fl() {}; // no constructor! + +public: // should be private! +#ifndef FL_DOXYGEN + static int e_number; + static int e_x; + static int e_y; + static int e_x_root; + static int e_y_root; + static int e_dx; + static int e_dy; + static int e_state; + static int e_clicks; + static int e_is_click; + static int e_keysym; + static char* e_text; + static int e_length; + static Fl_Event_Dispatch e_dispatch; + static Fl_Widget* belowmouse_; + static Fl_Widget* pushed_; + static Fl_Widget* focus_; + static int damage_; + static Fl_Widget* selection_owner_; + static Fl_Window* modal_; + static Fl_Window* grab_; + static int compose_state; +#endif + /** + If true then flush() will do something. + */ + static void damage(int d) {damage_ = d;} + +public: + /** Enumerator for global FLTK options. + These options can be set system wide, per user, or for the running + application only. + \see Fl::option(Fl_Option, bool) + \see Fl::option(Fl_Option) + */ + typedef enum { + /// When switched on, moving the text cursor beyond the start or end of + /// a text in a text widget will change focus to the next text widget. + /// When switched off, the cursor will stop at the end of the text. + /// Pressing Tab or Ctrl-Tab will advance the keyboard focus. + OPTION_ARROW_FOCUS = 0, + // When switched on, FLTK will use the file chooser dialog that comes + // with your operating system whenever possible. When switched off, FLTK + // will present its own file chooser. + // \todo implement me + // OPTION_NATIVE_FILECHOOSER, + // When Filechooser Preview is enabled, the FLTK or native file chooser + // will show a preview of a selected file (if possible) before the user + // decides to choose the file. + // \todo implement me + //OPTION_FILECHOOSER_PREVIEW, + /// If visible focus is switched on, FLTK will draw a dotted rectangle + /// inside the widget that will receive the next keystroke. If switched + /// off, no such indicator will be drawn and keyboard navigation + /// is disabled. + OPTION_VISIBLE_FOCUS, + /// If text drag-and-drop is enabled, the user can select and drag text + /// from any text widget. If disabled, no dragging is possible, however + /// dropping text from other applications still works. + OPTION_DND_TEXT, + /// If tooltips are enabled, hovering the mouse over a widget with a + /// tooltip text will open a little tooltip window until the mouse leaves + /// the widget. If disabled, no tooltip is shown. + OPTION_SHOW_TOOLTIPS, + // don't change this, leave it always as the last element + /// For internal use only. + OPTION_LAST + } Fl_Option; + +private: + static unsigned char options_[OPTION_LAST]; + static unsigned char options_read_; + +public: + /* + Return a global setting for all FLTK applications, possibly overridden + by a setting specifically for this application. + */ + static bool option(Fl_Option opt); + + /* + Override an option while the application is running. + */ + static void option(Fl_Option opt, bool val); + + /** + The currently executing idle callback function: DO NOT USE THIS DIRECTLY! + + This is now used as part of a higher level system allowing multiple + idle callback functions to be called. + \see add_idle(), remove_idle() + */ + static void (*idle)(); + +#ifndef FL_DOXYGEN + static Fl_Awake_Handler *awake_ring_; + static void **awake_data_; + static int awake_ring_size_; + static int awake_ring_head_; + static int awake_ring_tail_; + static const char* scheme_; + static Fl_Image* scheme_bg_; + + static int e_original_keysym; // late addition + static int scrollbar_size_; +#endif + + + static int add_awake_handler_(Fl_Awake_Handler, void*); + static int get_awake_handler_(Fl_Awake_Handler&, void*&); + +public: + + // API version number + static double version(); + + // argument parsers: + static int arg(int argc, char **argv, int& i); + static int args(int argc, char **argv, int& i, Fl_Args_Handler cb = 0); + static void args(int argc, char **argv); + /** + Usage string displayed if Fl::args() detects an invalid argument. + This may be changed to point to customized text at run-time. + */ + static const char* const help; + + // things called by initialization: + static void display(const char*); + static int visual(int); + /** + This does the same thing as Fl::visual(int) but also requires OpenGL + drawing to work. This <I>must</I> be done if you want to draw in + normal windows with OpenGL with gl_start() and gl_end(). + It may be useful to call this so your X windows use the same visual + as an Fl_Gl_Window, which on some servers will reduce colormap flashing. + + See Fl_Gl_Window for a list of additional values for the argument. + */ + static int gl_visual(int, int *alist=0); // platform dependent + static void own_colormap(); + static void get_system_colors(); + static void foreground(uchar, uchar, uchar); + static void background(uchar, uchar, uchar); + static void background2(uchar, uchar, uchar); + + // schemes: + static int scheme(const char*); + /** See void scheme(const char *name) */ + static const char* scheme() {return scheme_;} + /** + Called by scheme according to scheme name. + Loads or reloads the current scheme selection. + See void scheme(const char *name) + */ + static int reload_scheme(); // platform dependent + static int scrollbar_size(); + static void scrollbar_size(int W); + + // execution: + static int wait(); + static double wait(double time); + static int check(); + static int ready(); + static int run(); + static Fl_Widget* readqueue(); + /** + Adds a one-shot timeout callback. The function will be called by + Fl::wait() at <i>t</i> seconds after this function is called. + The optional void* argument is passed to the callback. + + You can have multiple timeout callbacks. To remove a timeout + callback use Fl::remove_timeout(). + + If you need more accurate, repeated timeouts, use Fl::repeat_timeout() to + reschedule the subsequent timeouts. + + The following code will print "TICK" each second on + stdout with a fair degree of accuracy: + + \code + void callback(void*) { + puts("TICK"); + Fl::repeat_timeout(1.0, callback); + } + + int main() { + Fl::add_timeout(1.0, callback); + return Fl::run(); + } + \endcode + */ + static void add_timeout(double t, Fl_Timeout_Handler,void* = 0); // platform dependent + /** + Repeats a timeout callback from the expiration of the + previous timeout, allowing for more accurate timing. You may only call + this method inside a timeout callback. + + The following code will print "TICK" each second on + stdout with a fair degree of accuracy: + + \code + void callback(void*) { + puts("TICK"); + Fl::repeat_timeout(1.0, callback); + } + + int main() { + Fl::add_timeout(1.0, callback); + return Fl::run(); + } + \endcode + */ + static void repeat_timeout(double t, Fl_Timeout_Handler, void* = 0); // platform dependent + static int has_timeout(Fl_Timeout_Handler, void* = 0); + static void remove_timeout(Fl_Timeout_Handler, void* = 0); + static void add_check(Fl_Timeout_Handler, void* = 0); + static int has_check(Fl_Timeout_Handler, void* = 0); + static void remove_check(Fl_Timeout_Handler, void* = 0); + /** + Adds file descriptor fd to listen to. + + When the fd becomes ready for reading Fl::wait() will call the + callback and then return. The callback is passed the fd and the + arbitrary void* argument. + + The second version takes a when bitfield, with the bits + FL_READ, FL_WRITE, and FL_EXCEPT defined, + to indicate when the callback should be done. + + There can only be one callback of each type for a file descriptor. + Fl::remove_fd() gets rid of <I>all</I> the callbacks for a given + file descriptor. + + Under UNIX <I>any</I> file descriptor can be monitored (files, + devices, pipes, sockets, etc.). Due to limitations in Microsoft Windows, + WIN32 applications can only monitor sockets. + */ + static void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0); // platform dependent + /** See void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0) */ + static void add_fd(int fd, Fl_FD_Handler cb, void* = 0); // platform dependent + /** Removes a file descriptor handler. */ + static void remove_fd(int, int when); // platform dependent + /** Removes a file descriptor handler. */ + static void remove_fd(int); // platform dependent + + static void add_idle(Fl_Idle_Handler cb, void* data = 0); + static int has_idle(Fl_Idle_Handler cb, void* data = 0); + static void remove_idle(Fl_Idle_Handler cb, void* data = 0); + /** If true then flush() will do something. */ + static int damage() {return damage_;} + static void redraw(); + static void flush(); + /** \addtogroup group_comdlg + @{ */ + /** + FLTK calls Fl::warning() to output a warning message. + + The default version on Windows returns \e without printing a warning + message, because Windows programs normally don't have stderr (a console + window) enabled. + + The default version on all other platforms prints the warning message to stderr. + + You can override the behavior by setting the function pointer to your + own routine. + + Fl::warning() means that there was a recoverable problem, the display may + be messed up, but the user can probably keep working - all X protocol + errors call this, for example. The default implementation returns after + displaying the message. + \note \#include <FL/Fl.H> + */ + static void (*warning)(const char*, ...); + /** + FLTK calls Fl::error() to output a normal error message. + + The default version on Windows displays the error message in a MessageBox window. + + The default version on all other platforms prints the error message to stderr. + + You can override the behavior by setting the function pointer to your + own routine. + + Fl::error() means there is a recoverable error such as the inability to read + an image file. The default implementation returns after displaying the message. + \note \#include <FL/Fl.H> + */ + static void (*error)(const char*, ...); + /** + FLTK calls Fl::fatal() to output a fatal error message. + + The default version on Windows displays the error message in a MessageBox window. + + The default version on all other platforms prints the error message to stderr. + + You can override the behavior by setting the function pointer to your + own routine. + + Fl::fatal() must not return, as FLTK is in an unusable state, however your + version may be able to use longjmp or an exception to continue, as long as + it does not call FLTK again. The default implementation exits with status 1 + after displaying the message. + \note \#include <FL/Fl.H> + */ + static void (*fatal)(const char*, ...); + /** @} */ + + /** \defgroup fl_windows Windows handling functions + \brief Windows and standard dialogs handling declared in <FL/Fl.H> + @{ */ + static Fl_Window* first_window(); + static void first_window(Fl_Window*); + static Fl_Window* next_window(const Fl_Window*); + + /** + Returns the top-most modal() window currently shown. + + This is the most recently shown() window with modal() true, or NULL + if there are no modal() windows shown(). + The modal() window has its handle() method called + for all events, and no other windows will have handle() + called (grab() overrides this). + */ + static Fl_Window* modal() {return modal_;} + /** Returns the window that currently receives all events. + + \return The window that currently receives all events, + or NULL if event grabbing is currently OFF. + */ + static Fl_Window* grab() {return grab_;} + /** Selects the window to grab. + This is used when pop-up menu systems are active. + + Send all events to the passed window no matter where the pointer or + focus is (including in other programs). The window <I>does not have + to be shown()</I> , this lets the handle() method of a + "dummy" window override all event handling and allows you to + map and unmap a complex set of windows (under both X and WIN32 + <I>some</I> window must be mapped because the system interface needs a + window id). + + If grab() is on it will also affect show() of windows by doing + system-specific operations (on X it turns on override-redirect). + These are designed to make menus popup reliably + and faster on the system. + + To turn off grabbing do Fl::grab(0). + + <I>Be careful that your program does not enter an infinite loop + while grab() is on. On X this will lock up your screen!</I> + To avoid this potential lockup, all newer operating systems seem to + limit mouse pointer grabbing to the time during which a mouse button + is held down. Some OS's may not support grabbing at all. + */ + static void grab(Fl_Window*); // platform dependent + /** @} */ + + /** \defgroup fl_events Events handling functions + Fl class events handling API declared in <FL/Fl.H> + @{ + */ + // event information: + /** + Returns the last event that was processed. This can be used + to determine if a callback is being done in response to a + keypress, mouse click, etc. + */ + static int event() {return e_number;} + /** + Returns the mouse position of the event relative to the Fl_Window + it was passed to. + */ + static int event_x() {return e_x;} + /** + Returns the mouse position of the event relative to the Fl_Window + it was passed to. + */ + static int event_y() {return e_y;} + /** + Returns the mouse position on the screen of the event. To find the + absolute position of an Fl_Window on the screen, use the + difference between event_x_root(),event_y_root() and + event_x(),event_y(). + */ + static int event_x_root() {return e_x_root;} + /** + Returns the mouse position on the screen of the event. To find the + absolute position of an Fl_Window on the screen, use the + difference between event_x_root(),event_y_root() and + event_x(),event_y(). + */ + static int event_y_root() {return e_y_root;} + /** + Returns the current horizontal mouse scrolling associated with the + FL_MOUSEWHEEL event. Right is positive. + */ + static int event_dx() {return e_dx;} + /** + Returns the current vertical mouse scrolling associated with the + FL_MOUSEWHEEL event. Down is positive. + */ + static int event_dy() {return e_dy;} + /** + Return where the mouse is on the screen by doing a round-trip query to + the server. You should use Fl::event_x_root() and + Fl::event_y_root() if possible, but this is necessary if you are + not sure if a mouse event has been processed recently (such as to + position your first window). If the display is not open, this will + open it. + */ + static void get_mouse(int &,int &); // platform dependent + /** + Returns non zero if we had a double click event. + \retval Non-zero if the most recent FL_PUSH or FL_KEYBOARD was a "double click". + \retval N-1 for N clicks. + A double click is counted if the same button is pressed + again while event_is_click() is true. + + */ + static int event_clicks() {return e_clicks;} + /** + Manually sets the number returned by Fl::event_clicks(). + This can be used to set it to zero so that + later code does not think an item was double-clicked. + \param[in] i corresponds to no double-click if 0, i+1 mouse clicks otherwise + \see int event_clicks() + */ + static void event_clicks(int i) {e_clicks = i;} + /** + Returns non-zero if the mouse has not moved far enough + and not enough time has passed since the last FL_PUSH or + FL_KEYBOARD event for it to be considered a "drag" rather than a + "click". You can test this on FL_DRAG, FL_RELEASE, + and FL_MOVE events. + */ + static int event_is_click() {return e_is_click;} + /** + Clears the value returned by Fl::event_is_click(). + Useful to prevent the <I>next</I> + click from being counted as a double-click or to make a popup menu + pick an item with a single click. Don't pass non-zero to this. + */ + static void event_is_click(int i) {e_is_click = i;} + /** + Gets which particular mouse button caused the current event. + This returns garbage if the most recent event was not a FL_PUSH or FL_RELEASE event. + \retval FL_LEFT_MOUSE \retval FL_MIDDLE_MOUSE \retval FL_RIGHT_MOUSE. + \see Fl::event_buttons() + */ + static int event_button() {return e_keysym-FL_Button;} + /** + This is a bitfield of what shift states were on and what mouse buttons + were held down during the most recent event. The second version + returns non-zero if any of the passed bits are turned on. + The legal bits are: + + \li FL_SHIFT + \li FL_CAPS_LOCK + \li FL_CTRL + \li FL_ALT + \li FL_NUM_LOCK + \li FL_META + \li FL_SCROLL_LOCK + \li FL_BUTTON1 + \li FL_BUTTON2 + \li FL_BUTTON3 + + X servers do not agree on shift states, and FL_NUM_LOCK, FL_META, and + FL_SCROLL_LOCK may not work. The values were selected to match the + XFree86 server on Linux. In addition there is a bug in the way X works + so that the shift state is not correctly reported until the first event + <I>after</I> the shift key is pressed or released. + */ + static int event_state() {return e_state;} + /** See int event_state() */ + static int event_state(int i) {return e_state&i;} + /** + Gets which key on the keyboard was last pushed. + + The returned integer 'key code' is not necessarily a text + equivalent for the keystroke. For instance: if someone presses '5' on the + numeric keypad with numlock on, Fl::event_key() may return the 'key code' + for this key, and NOT the character '5'. To always get the '5', use Fl::event_text() instead. + + \returns an integer 'key code', or 0 if the last event was not a key press or release. + \see int event_key(int), event_text(), compose(int&). + */ + static int event_key() {return e_keysym;} + /** + Returns the keycode of the last key event, regardless of the NumLock state. + + If NumLock is deactivated, FLTK translates events from the + numeric keypad into the corresponding arrow key events. + event_key() returns the translated key code, whereas + event_original_key() returns the keycode before NumLock translation. + */ + static int event_original_key(){return e_original_keysym;} + /** + Returns true if the given \p key was held + down (or pressed) <I>during</I> the last event. This is constant until + the next event is read from the server. + + Fl::get_key(int) returns true if the given key is held down <I>now</I>. + Under X this requires a round-trip to the server and is <I>much</I> + slower than Fl::event_key(int). + + Keys are identified by the <I>unshifted</I> values. FLTK defines a + set of symbols that should work on most modern machines for every key + on the keyboard: + + \li All keys on the main keyboard producing a printable ASCII + character use the value of that ASCII character (as though shift, + ctrl, and caps lock were not on). The space bar is 32. + \li All keys on the numeric keypad producing a printable ASCII + character use the value of that ASCII character plus FL_KP. + The highest possible value is FL_KP_Last so you can + range-check to see if something is on the keypad. + \li All numbered function keys use the number on the function key plus + FL_F. The highest possible number is FL_F_Last, so you + can range-check a value. + \li Buttons on the mouse are considered keys, and use the button + number (where the left button is 1) plus FL_Button. + \li All other keys on the keypad have a symbol: FL_Escape, + FL_BackSpace, FL_Tab, FL_Enter, FL_Print, FL_Scroll_Lock, FL_Pause, + FL_Insert, FL_Home, FL_Page_Up, FL_Delete, FL_End, FL_Page_Down, + FL_Left, FL_Up, FL_Right, FL_Down, FL_Shift_L, FL_Shift_R, + FL_Control_L, FL_Control_R, FL_Caps_Lock, FL_Alt_L, FL_Alt_R, + FL_Meta_L, FL_Meta_R, FL_Menu, FL_Num_Lock, FL_KP_Enter. Be + careful not to confuse these with the very similar, but all-caps, + symbols used by Fl::event_state(). + + On X Fl::get_key(FL_Button+n) does not work. + + On WIN32 Fl::get_key(FL_KP_Enter) and Fl::event_key(FL_KP_Enter) do not work. + */ + static int event_key(int key); + /** + Returns true if the given \p key is held down <I>now</I>. + Under X this requires a round-trip to the server and is <I>much</I> + slower than Fl::event_key(int). \see event_key(int) + */ + static int get_key(int key); // platform dependent + /** + Returns the text associated with the current event, including FL_PASTE or FL_DND_RELEASE events. + This can be used in response to FL_KEYUP, FL_KEYDOWN, FL_PASTE, FL_DND_RELEASE. + + When responding to FL_KEYUP/FL_KEYDOWN, use this function instead of Fl::event_key() + to get the text equivalent of keystrokes suitable for inserting into strings + and text widgets. + + The returned string is guaranteed to be be NULL terminated. + However, see Fl::event_length() for the actual length of the string, + in case the string itself contains NULLs that are part of the text data. + + \returns A NULL terminated text string equivalent of the last keystroke. + */ + static const char* event_text() {return e_text;} + /** + Returns the length of the text in Fl::event_text(). There + will always be a nul at this position in the text. However there may + be a nul before that if the keystroke translates to a nul character or + you paste a nul character. + */ + static int event_length() {return e_length;} + + static int compose(int &del); + static void compose_reset(); + static int event_inside(int,int,int,int); + static int event_inside(const Fl_Widget*); + static int test_shortcut(Fl_Shortcut); + + // event destinations: + static int handle(int, Fl_Window*); + static int handle_(int, Fl_Window*); + /** Gets the widget that is below the mouse. + \see belowmouse(Fl_Widget*) */ + static Fl_Widget* belowmouse() {return belowmouse_;} + static void belowmouse(Fl_Widget*); + /** Gets the widget that is being pushed. + \see void pushed(Fl_Widget*) */ + static Fl_Widget* pushed() {return pushed_;} + static void pushed(Fl_Widget*); + /** Gets the current Fl::focus() widget. \sa Fl::focus(Fl_Widget*) */ + static Fl_Widget* focus() {return focus_;} + static void focus(Fl_Widget*); + static void add_handler(Fl_Event_Handler h); + static void remove_handler(Fl_Event_Handler h); + static void event_dispatch(Fl_Event_Dispatch d); + static Fl_Event_Dispatch event_dispatch(); + /** @} */ + + /** \defgroup fl_clipboard Selection & Clipboard functions + FLTK global copy/cut/paste functions declared in <FL/Fl.H> + @{ */ + // cut/paste: + /** + Copies the data pointed to by \p stuff to the selection buffer + (\p destination is 0) or + the clipboard (\p destination is 1); \p len is the number of relevant + bytes in \p stuff. + The selection buffer is used for + middle-mouse pastes and for drag-and-drop selections. The + clipboard is used for traditional copy/cut/paste operations. + */ + static void copy(const char* stuff, int len, int destination = 0); // platform dependent + /** + Pastes the data from the selection buffer (\p source is 0) or the clipboard + (\p source is 1) into \p receiver. + Set things up so the receiver widget will be called with an FL_PASTE event some + time in the future with the data from the specified \p source in Fl::event_text() + and the number of characters in Fl::event_length(). + The receiver + should be prepared to be called \e directly by this, or for + it to happen \e later, or possibly <i>not at all</i>. This + allows the window system to take as long as necessary to retrieve + the paste buffer (or even to screw up completely) without complex + and error-prone synchronization code in FLTK. + + The selection buffer is used for middle-mouse pastes and for + drag-and-drop selections. The clipboard is used for traditional + copy/cut/paste operations. + */ + static void paste(Fl_Widget &receiver, int source /*=0*/); // platform dependent + /** + Initiate a Drag And Drop operation. The selection buffer should be + filled with relevant data before calling this method. FLTK will + then initiate the system wide drag and drop handling. Dropped data + will be marked as <i>text</i>. + + Create a selection first using: + Fl::copy(const char *stuff, int len, 0) + */ + static int dnd(); // platform dependent + + // These are for back-compatibility only: + /** back-compatibility only: Gets the widget owning the current selection + \see Fl_Widget* selection_owner(Fl_Widget*) */ + static Fl_Widget* selection_owner() {return selection_owner_;} + static void selection_owner(Fl_Widget*); + static void selection(Fl_Widget &owner, const char*, int len); + static void paste(Fl_Widget &receiver); +/** @} */ +/** \defgroup fl_screen Screen functions + fl global screen functions declared in <FL/Fl.H> + @{ */ + // screen size: + /** Returns the origin of the current screen work area, where 0 indicates the left side of the screen. */ + static int x(); // platform dependent + /** Returns the origin of the current screen work area, where 0 indicates the top edge of the screen. */ + static int y(); // platform dependent + /** Returns the width of the screen work area in pixels. */ + static int w(); // platform dependent + /** Returns the height of the screen work area in pixels. */ + static int h(); // platform dependent + + // multi-head support: + static int screen_count(); + /** + Gets the bounding box of a screen that contains the mouse pointer. + \param[out] X,Y,W,H the corresponding screen bounding box + \see void screen_xywh(int &x, int &y, int &w, int &h, int mx, int my) + */ + static void screen_xywh(int &X, int &Y, int &W, int &H) { + screen_xywh(X, Y, W, H, e_x_root, e_y_root); + } + static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my); + static void screen_xywh(int &X, int &Y, int &W, int &H, int n); + static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh); + static void screen_dpi(float &h, float &v, int n=0); + + /** @} */ + + /** \defgroup fl_attributes Color & Font functions + fl global color, font functions. + These functions are declared in <FL/Fl.H> or <FL/fl_draw.H>. + @{ */ + + // color map: + static void set_color(Fl_Color, uchar, uchar, uchar); + /** + Sets an entry in the fl_color index table. You can set it to any + 8-bit RGB color. The color is not allocated until fl_color(i) is used. + */ + static void set_color(Fl_Color i, unsigned c); // platform dependent + static unsigned get_color(Fl_Color i); + static void get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue); + /** + Frees the specified color from the colormap, if applicable. + If overlay is non-zero then the color is freed from the + overlay colormap. + */ + static void free_color(Fl_Color i, int overlay = 0); // platform dependent + + // fonts: + static const char* get_font(Fl_Font); + /** + Get a human-readable string describing the family of this face. This + is useful if you are presenting a choice to the user. There is no + guarantee that each face has a different name. The return value points + to a static buffer that is overwritten each call. + + The integer pointed to by \p attributes (if the pointer is not + zero) is set to zero, FL_BOLD or FL_ITALIC or + FL_BOLD | FL_ITALIC. To locate a "family" of fonts, search + forward and back for a set with non-zero attributes, these faces along + with the face with a zero attribute before them constitute a family. + */ + static const char* get_font_name(Fl_Font, int* attributes = 0); + /** + Return an array of sizes in \p sizep. The return value is the + length of this array. The sizes are sorted from smallest to largest + and indicate what sizes can be given to fl_font() that will + be matched exactly (fl_font() will pick the closest size for + other sizes). A zero in the first location of the array indicates a + scalable font, where any size works, although the array may list sizes + that work "better" than others. Warning: the returned array + points at a static buffer that is overwritten each call. Under X this + will open the display. + */ + static int get_font_sizes(Fl_Font, int*& sizep); + static void set_font(Fl_Font, const char*); + static void set_font(Fl_Font, Fl_Font); + /** + FLTK will open the display, and add every fonts on the server to the + face table. It will attempt to put "families" of faces together, so + that the normal one is first, followed by bold, italic, and bold + italic. + + The optional argument is a string to describe the set of fonts to + add. Passing NULL will select only fonts that have the + ISO8859-1 character set (and are thus usable by normal text). Passing + "-*" will select all fonts with any encoding as long as they have + normal X font names with dashes in them. Passing "*" will list every + font that exists (on X this may produce some strange output). Other + values may be useful but are system dependent. With WIN32 NULL + selects fonts with ISO8859-1 encoding and non-NULL selects + all fonts. + + The return value is how many faces are in the table after this is done. + */ + static Fl_Font set_fonts(const char* = 0); // platform dependent + + /** @} */ + /** \defgroup fl_drawings Drawing functions + FLTK global graphics and GUI drawing functions. + These functions are declared in <FL/fl_draw.H>, + and in <FL/x.H> for offscreen buffer-related ones. + @{ */ + // <Hack to re-order the 'Drawing functions' group> + /** @} */ + + // labeltypes: + static void set_labeltype(Fl_Labeltype,Fl_Label_Draw_F*,Fl_Label_Measure_F*); + /** Sets the functions to call to draw and measure a specific labeltype. */ + static void set_labeltype(Fl_Labeltype, Fl_Labeltype from); // is it defined ? + + // boxtypes: + static Fl_Box_Draw_F *get_boxtype(Fl_Boxtype); + static void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F*,uchar,uchar,uchar,uchar); + static void set_boxtype(Fl_Boxtype, Fl_Boxtype from); + static int box_dx(Fl_Boxtype); + static int box_dy(Fl_Boxtype); + static int box_dw(Fl_Boxtype); + static int box_dh(Fl_Boxtype); + static int draw_box_active(); + + // back compatibility: + /** \addtogroup fl_windows + @{ */ + /** For back compatibility, sets the void Fl::fatal handler callback */ + static void set_abort(Fl_Abort_Handler f) {fatal = f;} + static void (*atclose)(Fl_Window*,void*); + static void default_atclose(Fl_Window*,void*); + /** For back compatibility, sets the Fl::atclose handler callback. You + can now simply change the callback for the window instead. + \see Fl_Window::callback(Fl_Callback*) */ + static void set_atclose(Fl_Atclose_Handler f) {atclose = f;} + /** @} */ + + /** \addtogroup fl_events + @{ */ + /** Returns non-zero if the Shift key is pressed. */ + static int event_shift() {return e_state&FL_SHIFT;} + /** Returns non-zero if the Control key is pressed. */ + static int event_ctrl() {return e_state&FL_CTRL;} + /** Returns non-zero if the FL_COMMAND key is pressed, either FL_CTRL or on OSX FL_META. */ + static int event_command() {return e_state&FL_COMMAND;} + /** Returns non-zero if the Alt key is pressed. */ + static int event_alt() {return e_state&FL_ALT;} + /** + Returns the mouse buttons state bits; if non-zero, then at least one + button is pressed now. This function returns the button state at the + time of the event. During an FL_RELEASE event, the state + of the released button will be 0. To find out, which button + caused an FL_RELEASE event, you can use Fl::event_button() instead. + \return a bit mask value like { [FL_BUTTON1] | [FL_BUTTON2] | [FL_BUTTON3] } + */ + static int event_buttons() {return e_state&0x7f000000;} + /** + Returns non-zero if mouse button 1 is currently held down. + For more details, see Fl::event_buttons(). + */ + static int event_button1() {return e_state&FL_BUTTON1;} + /** + Returns non-zero if button 2 is currently held down. + For more details, see Fl::event_buttons(). + */ + static int event_button2() {return e_state&FL_BUTTON2;} + /** + Returns non-zero if button 3 is currently held down. + For more details, see Fl::event_buttons(). + */ + static int event_button3() {return e_state&FL_BUTTON3;} + /** @} */ + + /** + Sets an idle callback. + + \deprecated This method is obsolete - use the add_idle() method instead. + */ + static void set_idle(Fl_Old_Idle_Handler cb) {idle = cb;} + /** See grab(Fl_Window*) */ + static void grab(Fl_Window& win) {grab(&win);} + /** Releases the current grabbed window, equals grab(0). + \deprecated Use Fl::grab(0) instead. + \see grab(Fl_Window*) */ + static void release() {grab(0);} + + // Visible focus methods... + /** + Gets or sets the visible keyboard focus on buttons and other + non-text widgets. The default mode is to enable keyboard focus + for all widgets. + */ + static void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, (v!=0)); } + /** + Gets or sets the visible keyboard focus on buttons and other + non-text widgets. The default mode is to enable keyboard focus + for all widgets. + */ + static int visible_focus() { return option(OPTION_VISIBLE_FOCUS); } + + // Drag-n-drop text operation methods... + /** + Gets or sets whether drag and drop text operations are supported. + This specifically affects whether selected text can + be dragged from text fields or dragged within a text field as a + cut/paste shortcut. + */ + static void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); } + /** + Gets or sets whether drag and drop text operations are + supported. This specifically affects whether selected text can + be dragged from text fields or dragged within a text field as a + cut/paste shortcut. + */ + static int dnd_text_ops() { return option(OPTION_DND_TEXT); } + /** \defgroup fl_multithread Multithreading support functions + fl multithreading support functions declared in <FL/Fl.H> + @{ */ + + // Multithreading support: + static int lock(); + static void unlock(); + static void awake(void* message = 0); + /** See void awake(void* message=0). */ + static int awake(Fl_Awake_Handler cb, void* message = 0); + /** + The thread_message() method returns the last message + that was sent from a child by the awake() method. + + See also: \ref advanced_multithreading + */ + static void* thread_message(); // platform dependent + /** @} */ + + /** \defgroup fl_del_widget Safe widget deletion support functions + + These functions, declared in <FL/Fl.H>, support deletion of widgets inside callbacks. + + Fl::delete_widget() should be called when deleting widgets + or complete widget trees (Fl_Group, Fl_Window, ...) inside + callbacks. + + The other functions are intended for internal use. The preferred + way to use them is by using the helper class Fl_Widget_Tracker. + + The following is to show how it works ... + + There are three groups of related methods: + + -# scheduled widget deletion + - Fl::delete_widget() schedules widgets for deletion + - Fl::do_widget_deletion() deletes all scheduled widgets + -# widget watch list ("smart pointers") + - Fl::watch_widget_pointer() adds a widget pointer to the watch list + - Fl::release_widget_pointer() removes a widget pointer from the watch list + - Fl::clear_widget_pointer() clears a widget pointer \e in the watch list + -# the class Fl_Widget_Tracker: + - the constructor calls Fl::watch_widget_pointer() + - the destructor calls Fl::release_widget_pointer() + - the access methods can be used to test, if a widget has been deleted + \see Fl_Widget_Tracker. + + @{ */ + // Widget deletion: + static void delete_widget(Fl_Widget *w); + static void do_widget_deletion(); + static void watch_widget_pointer(Fl_Widget *&w); + static void release_widget_pointer(Fl_Widget *&w); + static void clear_widget_pointer(Fl_Widget const *w); + /** @} */ + +#ifdef FLTK_HAVE_CAIRO + /** \defgroup group_cairo Cairo support functions and classes + @{ + */ +public: + // Cairo support API + static cairo_t * cairo_make_current(Fl_Window* w); + /** when FLTK_HAVE_CAIRO is defined and cairo_autolink_context() is true, + any current window dc is linked to a current context. + This is not the default, because it may not be necessary + to add cairo support to all fltk supported windows. + When you wish to associate a cairo context in this mode, + you need to call explicitly in your draw() overridden method, + FL::cairo_make_current(Fl_Window*). This will create a cairo context + but only for this Window. + Still in custom cairo application it is possible to handle + completely this process automatically by setting \p alink to true. + In this last case, you don't need anymore to call Fl::cairo_make_current(). + You can use Fl::cairo_cc() to get the current cairo context anytime. + \note Only available when configure has the --enable-cairo option + */ + static void cairo_autolink_context(bool alink) {cairo_state_.autolink(alink);} + /** + Gets the current autolink mode for cairo support. + \retval false if no cairo context autolink is made for each window. + \retval true if any fltk window is attached a cairo context when it + is current. \see void cairo_autolink_context(bool alink) + \note Only available when configure has the --enable-cairo option + */ + static bool cairo_autolink_context() {return cairo_state_.autolink();} + /** Gets the current cairo context linked with a fltk window. */ + static cairo_t * cairo_cc() { return cairo_state_.cc(); } + /** Sets the current cairo context to \p c. + Set \p own to true if you want fltk to handle this cc deletion. + \note Only available when configure has the --enable-cairo option +*/ + static void cairo_cc(cairo_t * c, bool own=false){ cairo_state_.cc(c, own); } + +private: + static cairo_t * cairo_make_current(void* gc); + static cairo_t * cairo_make_current(void* gc, int W, int H); + static Fl_Cairo_State cairo_state_; +public: + /** @} */ + +#endif // FLTK_HAVE_CAIRO + +}; + +/** + This class should be used to control safe widget deletion. + + You can use an Fl_Widget_Tracker object to watch another widget, if you + need to know, if this widget has been deleted during a callback. + + This simplifies the use of the "safe widget deletion" methods + Fl::watch_widget_pointer() and Fl::release_widget_pointer() and + makes their use more reliable, because the destructor autmatically + releases the widget pointer from the widget watch list. + + It is intended to be used as an automatic (local/stack) variable, + such that the automatic destructor is called when the object's + scope is left. This ensures that no stale widget pointers are + left in the widget watch list (see example below). + + You can also create Fl_Widget_Tracker objects with \c new, but then it + is your responsibility to delete the object (and thus remove the + widget pointer from the watch list) when it is not needed any more. + + Example: + + \code + int MyClass::handle (int event) { + + if (...) { + Fl_Widget_Tracker wp(this); // watch myself + do_callback(); // call the callback + + if (wp.deleted()) return 1; // exit, if deleted + + // Now we are sure that the widget has not been deleted. + // It is safe to access the widget + + clear_changed(); // access the widget + } + } + \endcode + +*/ +class FL_EXPORT Fl_Widget_Tracker { + + Fl_Widget* wp_; + +public: + + Fl_Widget_Tracker(Fl_Widget *wi); + ~Fl_Widget_Tracker(); + + /** + Returns a pointer to the watched widget. + + This pointer is \c NULL, if the widget has been deleted. + */ + Fl_Widget *widget() {return wp_;} + + /** + Returns 1, if the watched widget has been deleted. + + This is a convenience method. You can also use something like + + <tt> if (wp.widget() == 0) // ...</tt> + + where \p wp is an Fl_Widget_Tracker object. + */ + int deleted() {return wp_ == 0;} + + /** + Returns 1, if the watched widget exists (has not been deleted). + + This is a convenience method. You can also use something like + + <tt> if (wp.widget() != 0) // ...</tt> + + where \p wp is an Fl_Widget_Tracker object. + */ + int exists() {return wp_ != 0;} + +}; + + /** \defgroup fl_unicode Unicode and UTF-8 functions + fl global Unicode and UTF-8 handling functions declared in <FL/fl_utf8.h> + @{ */ + /** @} */ + +#endif // !Fl_H + +// +// End of "$Id: Fl.H 8724 2011-05-23 18:01:29Z manolo $". +// diff --git a/common/fltk/FL/Fl_Adjuster.H b/common/fltk/FL/Fl_Adjuster.H new file mode 100644 index 00000000..d0c66173 --- /dev/null +++ b/common/fltk/FL/Fl_Adjuster.H @@ -0,0 +1,82 @@ +// +// "$Id: Fl_Adjuster.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Adjuster widget header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Adjuster widget . */ + +// 3-button "slider", made for Nuke + +#ifndef Fl_Adjuster_H +#define Fl_Adjuster_H + +#ifndef Fl_Valuator_H +#include "Fl_Valuator.H" +#endif + +/** + The Fl_Adjuster widget was stolen from Prisms, and has proven + to be very useful for values that need a large dynamic range. + \image html adjuster1.png + \image latex adjuster1.png "Fl_Adjuster" width=4cm + <P>When you press a button and drag to the right the value increases. + When you drag to the left it decreases. The largest button adjusts by + 100 * step(), the next by 10 * step() and that + smallest button by step(). Clicking on the buttons + increments by 10 times the amount dragging by a pixel does. Shift + + click decrements by 10 times the amount. +*/ +class FL_EXPORT Fl_Adjuster : public Fl_Valuator { + int drag; + int ix; + int soft_; +protected: + void draw(); + int handle(int); + void value_damage(); +public: + Fl_Adjuster(int X,int Y,int W,int H,const char *l=0); + /** + If "soft" is turned on, the user is allowed to drag the value outside + the range. If they drag the value to one of the ends, let go, then + grab again and continue to drag, they can get to any value. Default is + one. + */ + void soft(int s) {soft_ = s;} + /** + If "soft" is turned on, the user is allowed to drag the value outside + the range. If they drag the value to one of the ends, let go, then + grab again and continue to drag, they can get to any value. Default is + one. + */ + int soft() const {return soft_;} +}; + +#endif + +// +// End of "$Id: Fl_Adjuster.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_BMP_Image.H b/common/fltk/FL/Fl_BMP_Image.H new file mode 100644 index 00000000..2204dc06 --- /dev/null +++ b/common/fltk/FL/Fl_BMP_Image.H @@ -0,0 +1,50 @@ +// +// "$Id: Fl_BMP_Image.H 7903 2010-11-28 21:06:39Z matt $" +// +// BMP image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_BMP_Image widget . */ + +#ifndef Fl_BMP_Image_H +#define Fl_BMP_Image_H +# include "Fl_Image.H" + +/** + The Fl_BMP_Image class supports loading, caching, + and drawing of Windows Bitmap (BMP) image files. +*/ +class FL_EXPORT Fl_BMP_Image : public Fl_RGB_Image { + + public: + + Fl_BMP_Image(const char* filename); +}; + +#endif + +// +// End of "$Id: Fl_BMP_Image.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Bitmap.H b/common/fltk/FL/Fl_Bitmap.H new file mode 100644 index 00000000..35256c74 --- /dev/null +++ b/common/fltk/FL/Fl_Bitmap.H @@ -0,0 +1,85 @@ +// +// "$Id: Fl_Bitmap.H 7903 2010-11-28 21:06:39Z matt $" +// +// Bitmap header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Bitmap widget . */ + +#ifndef Fl_Bitmap_H +#define Fl_Bitmap_H +# include "Fl_Image.H" + +class Fl_Widget; +struct Fl_Menu_Item; + +/** + The Fl_Bitmap class supports caching and drawing of mono-color + (bitmap) images. Images are drawn using the current color. +*/ +class FL_EXPORT Fl_Bitmap : public Fl_Image { + friend class Fl_Quartz_Graphics_Driver; + friend class Fl_GDI_Graphics_Driver; + friend class Fl_Xlib_Graphics_Driver; +public: + + /** pointer to raw bitmap data */ + const uchar *array; + /** Non-zero if array points to bitmap data allocated internally */ + int alloc_array; + + private: + +#if defined(__APPLE__) || defined(WIN32) + /** for internal use */ + void *id_; +#else + /** for internal use */ + unsigned id_; +#endif // __APPLE__ || WIN32 + + public: + + /** The constructors create a new bitmap from the specified bitmap data */ + Fl_Bitmap(const uchar *bits, int W, int H) : + Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0) {data((const char **)&array, 1);} + /** The constructors create a new bitmap from the specified bitmap data */ + Fl_Bitmap(const char *bits, int W, int H) : + Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id_(0) {data((const char **)&array, 1);} + virtual ~Fl_Bitmap(); + virtual Fl_Image *copy(int W, int H); + Fl_Image *copy() { return copy(w(), h()); } + virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); + void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} + virtual void label(Fl_Widget*w); + virtual void label(Fl_Menu_Item*m); + virtual void uncache(); +}; + +#endif + +// +// End of "$Id: Fl_Bitmap.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Box.H b/common/fltk/FL/Fl_Box.H new file mode 100644 index 00000000..9de875df --- /dev/null +++ b/common/fltk/FL/Fl_Box.H @@ -0,0 +1,69 @@ +// +// "$Id: Fl_Box.H 7903 2010-11-28 21:06:39Z matt $" +// +// Box header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Box widget . */ + +#ifndef Fl_Box_H +#define Fl_Box_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +/** + This widget simply draws its box, and possibly it's label. Putting it + before some other widgets and making it big enough to surround them + will let you draw a frame around them. +*/ +class FL_EXPORT Fl_Box : public Fl_Widget { +protected: + void draw(); +public: + /** + - The first constructor sets box() to FL_NO_BOX, which + means it is invisible. However such widgets are useful as placeholders + or Fl_Group::resizable() + values. To change the box to something visible, use box(n). + - The second form of the constructor sets the box to the specified box + type. + <P>The destructor removes the box. + */ + Fl_Box(int X, int Y, int W, int H, const char *l=0) + : Fl_Widget(X,Y,W,H,l) {} + /** See Fl_Box::Fl_Box(int x, int y, int w, int h, const char * = 0) */ + Fl_Box(Fl_Boxtype b, int X, int Y, int W, int H, const char *l) + : Fl_Widget(X,Y,W,H,l) {box(b);} + + virtual int handle(int); +}; + +#endif + +// +// End of "$Id: Fl_Box.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Browser.H b/common/fltk/FL/Fl_Browser.H new file mode 100644 index 00000000..b7cc0656 --- /dev/null +++ b/common/fltk/FL/Fl_Browser.H @@ -0,0 +1,324 @@ +// +// "$Id: Fl_Browser.H 8623 2011-04-24 17:09:41Z AlbrechtS $" +// +// Browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Browser widget . */ + +// Forms-compatible browser. Probably useful for other +// lists of textual data. Notice that the line numbers +// start from 1, and 0 means "no line". + +#ifndef Fl_Browser_H +#define Fl_Browser_H + +#include "Fl_Browser_.H" +#include "Fl_Image.H" + +struct FL_BLINE; + +/** + The Fl_Browser widget displays a scrolling list of text + lines, and manages all the storage for the text. This is not a text + editor or spreadsheet! But it is useful for showing a vertical list of + named objects to the user. + + Each line in the browser is identified by number. <I>The numbers + start at one</I> (this is so that zero can be reserved for "no line" in + the selective browsers). <I>Unless otherwise noted, the methods do not + check to see if the passed line number is in range and legal. It must + always be greater than zero and <= size().</I> + + Each line contains a null-terminated string of text and a void * + data pointer. The text string is displayed, the void * + pointer can be used by the callbacks to reference the object the text + describes. + + The base class does nothing when the user clicks on it. The + subclasses + Fl_Select_Browser, + Fl_Hold_Browser, and + Fl_Multi_Browser react to user clicks to select lines in + the browser and do callbacks. + + The base class + Fl_Browser_ provides the scrolling and selection mechanisms of + this and all the subclasses, but the dimensions and appearance of each + item are determined by the subclass. You can use Fl_Browser_ + to display information other than text, or text that is dynamically + produced from your own data structures. If you find that loading the + browser is a lot of work or is inefficient, you may want to make a + subclass of Fl_Browser_. + + Some common coding patterns used for working with Fl_Browser: + \code + // How to loop through all the items in the browser + for ( int t=1; t<=browser->size(); t++ ) { // index 1 based..! + printf("item #%d, label='%s'\n", t, browser->text(t)); + } + \endcode + + Note: If you are <I>subclassing</I> Fl_Browser, it's more efficient + to use the protected methods item_first() and item_next(), since + Fl_Browser internally uses linked lists to manage the browser's items. + For more info, see find_item(int). +*/ +class FL_EXPORT Fl_Browser : public Fl_Browser_ { + + FL_BLINE *first; // the array of lines + FL_BLINE *last; + FL_BLINE *cache; + int cacheline; // line number of cache + int lines; // Number of lines + int full_height_; + const int* column_widths_; + char format_char_; // alternative to @-sign + char column_char_; // alternative to tab + +protected: + + // required routines for Fl_Browser_ subclass: + void* item_first() const ; + void* item_next(void* item) const ; + void* item_prev(void* item) const ; + void* item_last()const ; + int item_selected(void* item) const ; + void item_select(void* item, int val); + int item_height(void* item) const ; + int item_width(void* item) const ; + void item_draw(void* item, int X, int Y, int W, int H) const ; + int full_height() const ; + int incr_height() const ; + const char *item_text(void *item) const; + /** Swap the items \p a and \p b. + You must call redraw() to make any changes visible. + \param[in] a,b the items to be swapped. + \see swap(int,int), item_swap() + */ + void item_swap(void *a, void *b) { swap((FL_BLINE*)a, (FL_BLINE*)b); } + /** Return the item at specified \p line. + \param[in] line The line of the item to return. (1 based) + \returns The item, or NULL if line out of range. + \see item_at(), find_line(), lineno() + */ + void *item_at(int line) const { return (void*)find_line(line); } + + FL_BLINE* find_line(int line) const ; + FL_BLINE* _remove(int line) ; + void insert(int line, FL_BLINE* item); + int lineno(void *item) const ; + void swap(FL_BLINE *a, FL_BLINE *b); + +public: + + void remove(int line); + void add(const char* newtext, void* d = 0); + void insert(int line, const char* newtext, void* d = 0); + void move(int to, int from); + int load(const char* filename); + void swap(int a, int b); + void clear(); + + /** + Returns how many lines are in the browser. + The last line number is equal to this. + Returns 0 if browser is empty. + */ + int size() const { return lines; } + void size(int W, int H) { Fl_Widget::size(W, H); } + + int topline() const ; + /** For internal use only? */ + enum Fl_Line_Position { TOP, BOTTOM, MIDDLE }; + void lineposition(int line, Fl_Line_Position pos); + /** + Scrolls the browser so the top item in the browser + is showing the specified \p line. + \param[in] line The line to be displayed at the top. + \see topline(), middleline(), bottomline(), displayed(), lineposition() + */ + void topline(int line) { lineposition(line, TOP); } + /** + Scrolls the browser so the bottom item in the browser + is showing the specified \p line. + \param[in] line The line to be displayed at the bottom. + \see topline(), middleline(), bottomline(), displayed(), lineposition() + */ + void bottomline(int line) { lineposition(line, BOTTOM); } + /** + Scrolls the browser so the middle item in the browser + is showing the specified \p line. + \param[in] line The line to be displayed in the middle. + \see topline(), middleline(), bottomline(), displayed(), lineposition() + */ + void middleline(int line) { lineposition(line, MIDDLE); } + + int select(int line, int val=1); + int selected(int line) const ; + void show(int line); + /** Shows the entire Fl_Browser widget -- opposite of hide(). */ + void show() { Fl_Widget::show(); } + void hide(int line); + /** Hides the entire Fl_Browser widget -- opposite of show(). */ + void hide() { Fl_Widget::hide(); } + int visible(int line) const ; + + int value() const ; + /** + Sets the browser's value(), which selects the specified \p line. + This is the same as calling select(line). + \see select(), selected(), value(), item_select(), item_selected() + */ + void value(int line) { select(line); } + const char* text(int line) const ; + void text(int line, const char* newtext); + void* data(int line) const ; + void data(int line, void* d); + + Fl_Browser(int X, int Y, int W, int H, const char *L = 0); + /** + The destructor deletes all list items and destroys the browser. + */ + ~Fl_Browser() { clear(); } + + /** + Gets the current format code prefix character, which by default is '\@'. + A string of formatting codes at the start of each column are stripped off + and used to modify how the rest of the line is printed: + + \li <tt>'\@.'</tt> Print rest of line, don't look for more '\@' signs + \li <tt>'\@\@'</tt> Print rest of line starting with '\@' + \li <tt>'\@l'</tt> Use a LARGE (24 point) font + \li <tt>'\@m'</tt> Use a medium large (18 point) font + \li <tt>'\@s'</tt> Use a <SMALL>small</SMALL> (11 point) font + \li <tt>'\@b'</tt> Use a <B>bold</B> font (adds FL_BOLD to font) + \li <tt>'\@i'</tt> Use an <I>italic</I> font (adds FL_ITALIC to font) + \li <tt>'\@f' or '\@t'</tt> Use a fixed-pitch + font (sets font to FL_COURIER) + \li <tt>'\@c'</tt> Center the line horizontally + \li <tt>'\@r'</tt> Right-justify the text + \li <tt>'\@B0', '\@B1', ... '\@B255'</tt> Fill the backgound with + fl_color(n) + \li <tt>'\@C0', '\@C1', ... '\@C255'</tt> Use fl_color(n) to draw the text + \li <tt>'\@F0', '\@F1', ...</tt> Use fl_font(n) to draw the text + \li <tt>'\@S1', '\@S2', ...</tt> Use point size n to draw the text + \li <tt>'\@u' or '\@_'</tt> Underline the text. + \li <tt>'\@-'</tt> draw an engraved line through the middle. + + Notice that the '\@.' command can be used to reliably + terminate the parsing. To print a random string in a random color, use + <tt>sprintf("@C%d@.%s", color, string)</tt> and it will work even if the + string starts with a digit or has the format character in it. + */ + char format_char() const { return format_char_; } + /** + Sets the current format code prefix character to \p c. + The default prefix is '\@'. Set the prefix to 0 to disable formatting. + \see format_char() for list of '\@' codes + */ + void format_char(char c) { format_char_ = c; } + /** + Gets the current column separator character. + The default is '\\t' (tab). + \see column_char(), column_widths() + */ + char column_char() const { return column_char_; } + /** + Sets the column separator to c. + This will only have an effect if you also set column_widths(). + The default is '\\t' (tab). + \see column_char(), column_widths() + */ + void column_char(char c) { column_char_ = c; } + /** + Gets the current column width array. + This array is zero-terminated and specifies the widths in pixels of + each column. The text is split at each column_char() and each part is + formatted into it's own column. After the last column any remaining + text is formatted into the space between the last column and the + right edge of the browser, even if the text contains instances of + column_char() . The default value is a one-element array of just + a zero, which means there are no columns. + + Example: + \code + Fl_Browser *b = new Fl_Browser(..); + int widths[] = { 50, 50, 50, 70, 70, 40, 40, 70, 70, 50, 0 }; // widths for each column + b->column_widths(widths); // assign array to widget + b->column_char('\t'); // use tab as the column character + b->add("USER\tPID\tCPU\tMEM\tVSZ\tRSS\tTTY\tSTAT\tSTART\tTIME\tCOMMAND"); + b->add("root\t2888\t0.0\t0.0\t1352\t0\ttty3\tSW\tAug15\t0:00\t@b@f/sbin/mingetty tty3"); + b->add("root\t13115\t0.0\t0.0\t1352\t0\ttty2\tSW\tAug30\t0:00\t@b@f/sbin/mingetty tty2"); + [..] + \endcode + \see column_char(), column_widths() + */ + const int* column_widths() const { return column_widths_; } + /** + Sets the current array to \p arr. Make sure the last entry is zero. + \see column_char(), column_widths() + */ + void column_widths(const int* arr) { column_widths_ = arr; } + + /** + Returns non-zero if \p line has been scrolled to a position where it is being displayed. + Checks to see if the item's vertical position is within the top and bottom + edges of the display window. This does NOT take into account the hide()/show() + status of the widget or item. + \param[in] line The line to be checked + \returns 1 if visible, 0 if not visible. + \see topline(), middleline(), bottomline(), displayed(), lineposition() + */ + int displayed(int line) const { return Fl_Browser_::displayed(find_line(line)); } + + /** + Make the item at the specified \p line visible(). + Functionally similar to show(int line). + If \p line is out of range, redisplay top or bottom of list as appropriate. + \param[in] line The line to be made visible. + \see show(int), hide(int), display(), visible(), make_visible() + */ + void make_visible(int line) { + if (line < 1) Fl_Browser_::display(find_line(1)); + else if (line > lines) Fl_Browser_::display(find_line(lines)); + else Fl_Browser_::display(find_line(line)); + } + + // icon support + void icon(int line, Fl_Image* icon); + Fl_Image* icon(int line) const; + void remove_icon(int line); + + /** For back compatibility only. */ + void replace(int a, const char* b) { text(a, b); } + void display(int line, int val=1); +}; + +#endif + +// +// End of "$Id: Fl_Browser.H 8623 2011-04-24 17:09:41Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Browser_.H b/common/fltk/FL/Fl_Browser_.H new file mode 100644 index 00000000..5bcf7e16 --- /dev/null +++ b/common/fltk/FL/Fl_Browser_.H @@ -0,0 +1,378 @@ +// +// "$Id: Fl_Browser_.H 8275 2011-01-13 22:07:31Z manolo $" +// +// Common browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Browser_ widget . */ + +// Yes, I know this should be a template... + +#ifndef Fl_Browser__H +#define Fl_Browser__H + +#ifndef Fl_Group_H +#include "Fl_Group.H" +#endif +#include "Fl_Scrollbar.H" +#include <FL/Fl.H> // Fl::scrollbar_size() + +#define FL_NORMAL_BROWSER 0 /**< type() of Fl_Browser */ +#define FL_SELECT_BROWSER 1 /**< type() of FL_Select_Browser */ +#define FL_HOLD_BROWSER 2 /**< type() of Fl_Hold_Browser */ +#define FL_MULTI_BROWSER 3 /**< type() of Fl_Multi_Browser */ + +#define FL_SORT_ASCENDING 0 /**< sort browser items in ascending alphabetic order. */ +#define FL_SORT_DESCENDING 1 /**< sort in descending order */ + +/** + This is the base class for browsers. To be useful it must be + subclassed and several virtual functions defined. The Forms-compatible + browser and the file chooser's browser are subclassed off of this. + + This has been designed so that the subclass has complete control + over the storage of the data, although because next() and + prev() functions are used to index, it works best as a linked list + or as a large block of characters in which the line breaks must be + searched for. + + A great deal of work has been done so that the "height" of a data + object does not need to be determined until it is drawn. This is + useful if actually figuring out the size of an object requires + accessing image data or doing stat() on a file or doing some + other slow operation. +*/ +class FL_EXPORT Fl_Browser_ : public Fl_Group { + int position_; // where user wants it scrolled to + int real_position_; // the current vertical scrolling position + int hposition_; // where user wants it panned to + int real_hposition_; // the current horizontal scrolling position + int offset_; // how far down top_ item the real_position is + int max_width; // widest object seen so far + uchar has_scrollbar_; // which scrollbars are enabled + Fl_Font textfont_; + Fl_Fontsize textsize_; + Fl_Color textcolor_; + void* top_; // which item scrolling position is in + void* selection_; // which is selected (except for FL_MULTI_BROWSER) + void *redraw1,*redraw2; // minimal update pointers + void* max_width_item; // which item has max_width_ + int scrollbar_size_; // size of scrollbar trough + + void update_top(); + +protected: + + // All of the following must be supplied by the subclass: + /** + This method must be provided by the subclass + to return the first item in the list. + \see item_first(), item_next(), item_last(), item_prev() + */ + virtual void *item_first() const = 0; + /** + This method must be provided by the subclass + to return the item in the list after \p item. + \see item_first(), item_next(), item_last(), item_prev() + */ + virtual void *item_next(void *item) const = 0; + /** + This method must be provided by the subclass + to return the item in the list before \p item. + \see item_first(), item_next(), item_last(), item_prev() + */ + virtual void *item_prev(void *item) const = 0; + /** + This method must be provided by the subclass + to return the last item in the list. + \see item_first(), item_next(), item_last(), item_prev() + */ + virtual void *item_last() const { return 0L; } + /** + This method must be provided by the subclass to return + the height of \p item in pixels. + Allow for two additional pixels for the list selection box. + \param[in] item The item whose height is returned. + \returns The height of the specified \p item in pixels. + \see item_height(), item_width(), item_quick_height() + */ + virtual int item_height(void *item) const = 0; + /** + This method must be provided by the subclass to return the width of the + \p item in pixels. Allow for two additional pixels for the list + selection box. + \param[in] item The item whose width is returned. + \returns The width of the item in pixels. + */ + virtual int item_width(void *item) const = 0; + virtual int item_quick_height(void *item) const ; + /** + This method must be provided by the subclass to draw the \p item + in the area indicated by \p X, \p Y, \p W, \p H. + */ + virtual void item_draw(void *item,int X,int Y,int W,int H) const = 0; + /** + This optional method returns a string (label) that may be used for sorting. + \param[in] item The item whose label text is returned. + \returns The item's text label. (Can be NULL if blank) + */ + virtual const char *item_text(void *item) const { (void)item; return 0L; } + /** + This optional method should be provided by the subclass + to efficiently swap browser items \p a and \p b, such as for sorting. + \param[in] a,b The two items to be swapped. + */ + virtual void item_swap(void *a,void *b) { (void)a; (void)b; } + /** + This method must be provided by the subclass + to return the item for the specified \p index. + \param[in] index The \p index of the item to be returned + \returns The item at the specified \p index. + */ + virtual void *item_at(int index) const { (void)index; return 0L; } + // you don't have to provide these but it may help speed it up: + virtual int full_width() const ; // current width of all items + virtual int full_height() const ; // current height of all items + virtual int incr_height() const ; // average height of an item + // These only need to be done by subclass if you want a multi-browser: + virtual void item_select(void *item,int val=1); + virtual int item_selected(void *item) const ; + + // things the subclass may want to call: + /** + Returns the item that appears at the top of the list. + */ + void *top() const { return top_; } + /** + Returns the item currently selected, or NULL if there is no selection. + + For multiple selection browsers this call returns the currently focused item, + even if it is not selected. To find all selected items, call + Fl_Multi_Browser::selected() for every item in question. + */ + void *selection() const { return selection_; } + void new_list(); // completely clobber all data, as though list replaced + void deleting(void *item); // get rid of any pointers to item + void replacing(void *a,void *b); // change a pointers to b + void swapping(void *a,void *b); // exchange pointers a and b + void inserting(void *a,void *b); // insert b near a + int displayed(void *item) const ; // true if this item is visible + void redraw_line(void *item); // minimal update, no change in size + /** + This method will cause the entire list to be redrawn. + \see redraw_lines(), redraw_line() + */ + void redraw_lines() { damage(FL_DAMAGE_SCROLL); } // redraw all of them + void bbox(int &X,int &Y,int &W,int &H) const; + int leftedge() const; // x position after scrollbar & border + void *find_item(int ypos); // item under mouse + + void draw(); + Fl_Browser_(int X,int Y,int W,int H,const char *L=0); + +public: + + /** + Vertical scrollbar. Public, so that it can be accessed directly. + */ + Fl_Scrollbar scrollbar; + /** + Horizontal scrollbar. Public, so that it can be accessed directly. + */ + Fl_Scrollbar hscrollbar; + + int handle(int event); + void resize(int X,int Y,int W,int H); + + int select(void *item,int val=1,int docallbacks=0); + int select_only(void *item,int docallbacks=0); + int deselect(int docallbacks=0); + /** + Gets the vertical scroll position of the list as a pixel position \p pos. + The position returned is how many pixels of the list are scrolled off the top edge + of the screen. Example: A position of '3' indicates the top 3 pixels of + the list are scrolled off the top edge of the screen. + \see position(), hposition() + */ + int position() const { return position_; } + void position(int pos); // scroll to here + /** + Gets the horizontal scroll position of the list as a pixel position \p pos. + The position returned is how many pixels of the list are scrolled off the left edge + of the screen. Example: A position of '18' indicates the left 18 pixels of + the list are scrolled off the left edge of the screen. + \see position(), hposition() + */ + int hposition() const { return hposition_; } + void hposition(int); // pan to here + void display(void *item); // scroll so this item is shown + + /** + Values for has_scrollbar(). + */ + /** Anonymous enum bit flags for has_scrollbar(). + - bit 0: horizontal + - bit 1: vertical + - bit 2: 'always' (to be combined with bits 0 and 1) + - bit 3-31: reserved for future use + */ + enum { // values for has_scrollbar() + HORIZONTAL = 1, ///< Only show horizontal scrollbar. + VERTICAL = 2, ///< Only show vertical scrollbar. + BOTH = 3, ///< Show both scrollbars. (default) + ALWAYS_ON = 4, ///< Specified scrollbar(s) should 'always' be shown (to be used with HORIZONTAL/VERTICAL) + HORIZONTAL_ALWAYS = 5, ///< Horizontal scrollbar always on. + VERTICAL_ALWAYS = 6, ///< Vertical scrollbar always on. + BOTH_ALWAYS = 7 ///< Both scrollbars always on. + }; + /** + Returns the current scrollbar mode, see Fl_Browser_::has_scrollbar(uchar) + */ + uchar has_scrollbar() const { return has_scrollbar_; } + /** + Sets whether the widget should have scrollbars or not (default Fl_Browser_::BOTH). + By default you can scroll in both directions, and the scrollbars + disappear if the data will fit in the widget. + has_scrollbar() changes this based on the value of \p mode: + + - 0 - No scrollbars. + + - Fl_Browser_::HORIZONTAL - Only a horizontal scrollbar. + + - Fl_Browser_::VERTICAL - Only a vertical scrollbar. + + - Fl_Browser_::BOTH - The default is both scrollbars. + + - Fl_Browser_::HORIZONTAL_ALWAYS - Horizontal scrollbar always on, + vertical always off. + + - Fl_Browser_::VERTICAL_ALWAYS - Vertical scrollbar always on, + horizontal always off. + + - Fl_Browser_::BOTH_ALWAYS - Both always on. + */ + void has_scrollbar(uchar mode) { has_scrollbar_ = mode; } + + /** + Gets the default text font for the lines in the browser. + \see textfont(), textsize(), textcolor() + */ + Fl_Font textfont() const { return textfont_; } + /** + Sets the default text font for the lines in the browser to \p font. + */ + void textfont(Fl_Font font) { textfont_ = font; } + + /** + Gets the default text size (in pixels) for the lines in the browser. + */ + Fl_Fontsize textsize() const { return textsize_; } + /** + Sets the default text size (in pixels) for the lines in the browser to \p size. + */ + void textsize(Fl_Fontsize size) { textsize_ = size; } + + /** + Gets the default text color for the lines in the browser. + */ + Fl_Color textcolor() const { return textcolor_; } + /** + Sets the default text color for the lines in the browser to color \p col. + */ + void textcolor(Fl_Color col) { textcolor_ = col; } + + /** + Gets the current size of the scrollbars' troughs, in pixels. + + If this value is zero (default), this widget will use the + Fl::scrollbar_size() value as the scrollbar's width. + + \returns Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used. + \see Fl::scrollbar_size(int) + */ + int scrollbar_size() const { + return(scrollbar_size_); + } + /** + Sets the pixel size of the scrollbars' troughs to the \p size, in pixels. + + Normally you should not need this method, and should use + Fl::scrollbar_size(int) instead to manage the size of ALL + your widgets' scrollbars. This ensures your application + has a consistent UI, is the default behavior, and is normally + what you want. + + Only use THIS method if you really need to override the global + scrollbar size. The need for this should be rare. + + Setting \p size to the special value of 0 causes the widget to + track the global Fl::scrollbar_size(), which is the default. + + \param[in] size Sets the scrollbar size in pixels.\n + If 0 (default), scrollbar size tracks the global Fl::scrollbar_size() + \see Fl::scrollbar_size() + */ + void scrollbar_size(int size) { + scrollbar_size_ = size; + } + /** + This method has been deprecated, existing for backwards compatibility only. + Use scrollbar_size() instead. + This method always returns the global value Fl::scrollbar_size(). + \returns Always returns the global value Fl::scrollbar_size(). + \todo This method should eventually be removed in 1.4+ + */ + int scrollbar_width() const { + return(Fl::scrollbar_size()); + } + /** + This method has been deprecated, existing for backwards compatibility only. + Use scrollbar_size(int) instead. + This method sets the global Fl::scrollbar_size(), and forces this + instance of the widget to use it. + \todo This method should eventually be removed in 1.4+ + */ + void scrollbar_width(int width) { + Fl::scrollbar_size(width); + scrollbar_size_ = 0; + } + /** + Moves the vertical scrollbar to the righthand side of the list. + For back compatibility. + */ + void scrollbar_right() { scrollbar.align(FL_ALIGN_RIGHT); } + /** + Moves the vertical scrollbar to the lefthand side of the list. + For back compatibility. + */ + void scrollbar_left() { scrollbar.align(FL_ALIGN_LEFT); } + void sort(int flags=0); +}; + +#endif + +// +// End of "$Id: Fl_Browser_.H 8275 2011-01-13 22:07:31Z manolo $". +// diff --git a/common/fltk/FL/Fl_Button.H b/common/fltk/FL/Fl_Button.H new file mode 100644 index 00000000..39050dc4 --- /dev/null +++ b/common/fltk/FL/Fl_Button.H @@ -0,0 +1,180 @@ +// +// "$Id: Fl_Button.H 7903 2010-11-28 21:06:39Z matt $" +// +// Button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Button widget . */ + +#ifndef Fl_Button_H +#define Fl_Button_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +// values for type() +#define FL_NORMAL_BUTTON 0 /**< value() will be set to 1 during the press of the button and + reverts back to 0 when the button is released */ +#define FL_TOGGLE_BUTTON 1 ///< value() toggles between 0 and 1 at every click of the button +#define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2) /**< is set to 1 at button press, and all other + buttons in the same group with <tt>type() == FL_RADIO_BUTTON</tt> + are set to zero.*/ +#define FL_HIDDEN_BUTTON 3 ///< for Forms compatibility + +extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*); + +class Fl_Widget_Tracker; + +/** + \class Fl_Button + \brief Buttons generate callbacks when they are clicked by the user. + + You control exactly when and how by changing the values for type() and + when(). Buttons can also generate callbacks in response to \c FL_SHORTCUT + events. The button can either have an explicit shortcut(int s) value or a + letter shortcut can be indicated in the label() with an '\&' character + before it. For the label shortcut it does not matter if \e Alt is held + down, but if you have an input field in the same window, the user will have + to hold down the \e Alt key so that the input field does not eat the event + first as an \c FL_KEYBOARD event. + + \todo Refactor the doxygen comments for Fl_Button type() documentation. + + For an Fl_Button object, the type() call returns one of: + \li \c FL_NORMAL_BUTTON (0): value() remains unchanged after button press. + \li \c FL_TOGGLE_BUTTON: value() is inverted after button press. + \li \c FL_RADIO_BUTTON: value() is set to 1 after button press, and all other + buttons in the current group with <tt>type() == FL_RADIO_BUTTON</tt> + are set to zero. + + \todo Refactor the doxygen comments for Fl_Button when() documentation. + + For an Fl_Button object, the following when() values are useful, the default + being \c FL_WHEN_RELEASE: + \li \c 0: The callback is not done, instead changed() is turned on. + \li \c FL_WHEN_RELEASE: The callback is done after the user successfully + clicks the button, or when a shortcut is typed. + \li \c FL_WHEN_CHANGED: The callback is done each time the value() changes + (when the user pushes and releases the button, and as the mouse is + dragged around in and out of the button). +*/ +class FL_EXPORT Fl_Button : public Fl_Widget { + + int shortcut_; + char value_; + char oldval; + uchar down_box_; + +protected: + + static Fl_Widget_Tracker *key_release_tracker; + static void key_release_timeout(void*); + void simulate_key_action(); + + virtual void draw(); + +public: + + virtual int handle(int); + + Fl_Button(int X, int Y, int W, int H, const char *L = 0); + + int value(int v); + + /** + Returns the current value of the button (0 or 1). + */ + char value() const {return value_;} + + /** + Same as \c value(1). + \see value(int v) + */ + int set() {return value(1);} + + /** + Same as \c value(0). + \see value(int v) + */ + int clear() {return value(0);} + + void setonly(); // this should only be called on FL_RADIO_BUTTONs + + /** + Returns the current shortcut key for the button. + \retval int + */ + int shortcut() const {return shortcut_;} + + /** + Sets the shortcut key to \c s. + Setting this overrides the use of '\&' in the label(). + The value is a bitwise OR of a key and a set of shift flags, for example: + <tt>FL_ALT | 'a'</tt>, or + <tt>FL_ALT | (FL_F + 10)</tt>, or just + <tt>'a'</tt>. + A value of 0 disables the shortcut. + + The key can be any value returned by Fl::event_key(), but will usually be + an ASCII letter. Use a lower-case letter unless you require the shift key + to be held down. + + The shift flags can be any set of values accepted by Fl::event_state(). + If the bit is on, that shift key must be pushed. Meta, Alt, Ctrl, and + Shift must be off if they are not in the shift flags (zero for the other + bits indicates a "don't care" setting). + \param[in] s bitwise OR of key and shift flags + */ + void shortcut(int s) {shortcut_ = s;} + + /** + Returns the current down box type, which is drawn when value() is non-zero. + \retval Fl_Boxtype + */ + Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;} + + /** + Sets the down box type. The default value of 0 causes FLTK to figure out + the correct matching down version of box(). + \param[in] b down box type + */ + void down_box(Fl_Boxtype b) {down_box_ = b;} + + /// (for backwards compatibility) + void shortcut(const char *s) {shortcut(fl_old_shortcut(s));} + + /// (for backwards compatibility) + Fl_Color down_color() const {return selection_color();} + + /// (for backwards compatibility) + void down_color(unsigned c) {selection_color(c);} +}; + +#endif + +// +// End of "$Id: Fl_Button.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Cairo.H b/common/fltk/FL/Fl_Cairo.H new file mode 100644 index 00000000..4f3b5232 --- /dev/null +++ b/common/fltk/FL/Fl_Cairo.H @@ -0,0 +1,97 @@ +// +// "$Id: Fl_Cairo.H 8198 2011-01-06 10:24:58Z manolo $" +// +// Main header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Handling transparently platform dependent cairo include files +*/ + +#ifndef FL_CAIRO_H +# define FL_CAIRO_H +# ifdef FLTK_HAVE_CAIRO + +// Cairo is currently supported for the following platforms: +// Win32, Apple Quartz, X11 + +# include <FL/Fl_Export.H> + +# if defined(USE_X11) // X11 +# include <cairo-xlib.h> +# elif defined(WIN32) +# include <cairo-win32.h> +# elif defined(__APPLE_QUARTZ__) +# include <cairo-quartz.h> +# else +# error Cairo is not supported on that platform. +# endif + +/** + \addtogroup group_cairo + @{ +*/ + +/** + Contains all the necessary info on the current cairo context. + A private internal & unique corresponding object is created to + permit cairo context state handling while keeping it opaque. + For internal use only. + \note Only available when configure has the --enable-cairo option +*/ +class FL_EXPORT Fl_Cairo_State { +public: + Fl_Cairo_State() : cc_(0), own_cc_(false), autolink_(false), window_(0), gc_(0) {} + + // access attributes + cairo_t* cc() const {return cc_;} ///< Gets the current cairo context + bool autolink() const {return autolink_;} ///< Gets the autolink option. See Fl::cairo_autolink_context(bool) + /** Sets the current cairo context, \p own indicates cc deletion is handle externally by user */ + void cc(cairo_t* c, bool own=true) { + if (cc_ && own_cc_) cairo_destroy(cc_); + cc_=c; + if (!cc_) window_=0; + own_cc_=own; + } + void autolink(bool b); ///< Sets the autolink option, only available with --enable-cairoext + void window(void* w) {window_=w;} ///< Sets the window \p w to keep track on + void* window() const {return window_;} ///< Gets the last window attached to a cc + void gc(void* c) {gc_=c;} ///< Sets the gc \p c to keep track on + void* gc() const {return gc_;} ///< Gets the last gc attached to a cc + +private: + cairo_t * cc_; // contains the unique autoupdated cairo context + bool own_cc_; // indicates whether we must delete the cc, useful for internal cleanup + bool autolink_; // true by default, permits to prevent the automatic cairo mapping on fltk windows for custom cairo implementations + void* window_, *gc_; // for keeping track internally of last win+gc treated +}; + +/** @} */ + +# endif // FLTK_HAVE_CAIRO +#endif // FL_CAIRO_H + +// +// End of "$Id: Fl_Cairo.H 8198 2011-01-06 10:24:58Z manolo $" . +// diff --git a/common/fltk/FL/Fl_Cairo_Window.H b/common/fltk/FL/Fl_Cairo_Window.H new file mode 100644 index 00000000..e8bc75c0 --- /dev/null +++ b/common/fltk/FL/Fl_Cairo_Window.H @@ -0,0 +1,92 @@ +// +// "$Id: Fl_Cairo_Window.H 8198 2011-01-06 10:24:58Z manolo $" +// +// Main header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Cairo_Window Handling transparently a fltk window incorporte a cairo draw callback. +*/ + +#ifndef FL_CAIRO_WINDOW_H +# define FL_CAIRO_WINDOW_H +# ifdef FLTK_HAVE_CAIRO + +// Cairo is currently supported for the following platforms: +// Win32, Apple Quartz, X11 +# include <FL/Fl.H> +# include <FL/Fl_Double_Window.H> + +/** + \addtogroup group_cairo + @{ +*/ + +/** + This defines a pre-configured cairo fltk window. + This class overloads the virtual draw() method for you, + so that the only thing you have to do is to provide your cairo code. + All cairo context handling is achieved transparently. + \note You can alternatively define your custom cairo fltk window, + and thus at least override the draw() method to provide custom cairo + support. In this case you will probably use Fl::cairo_make_current(Fl_Window*) + to attach a context to your window. You should do it only when your window is + the current window. \see Fl_Window::current() +*/ +class FL_EXPORT Fl_Cairo_Window : public Fl_Double_Window { + +public: + Fl_Cairo_Window(int w, int h) : Fl_Double_Window(w,h),draw_cb_(0) {} + +protected: + /** Overloaded to provide cairo callback support */ + void draw() { + Fl_Double_Window::draw(); + // manual method ? if yes explicitly get a cairo_context here + if (!Fl::cairo_autolink_context()) + Fl::cairo_make_current(this); + if (draw_cb_) draw_cb_(this, Fl::cairo_cc()); + } + +public: + /** This defines the cairo draw callback prototype that you must further */ + typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def); + /** + You must provide a draw callback which will implement your cairo rendering. + This method will permit you to set your cairo callback to \p cb. + */ + void set_draw_cb(cairo_draw_cb cb){draw_cb_=cb;} +private: + cairo_draw_cb draw_cb_; +}; + + +/** @} */ + +# endif // FLTK_HAVE_CAIRO +#endif // FL_CAIRO_WINDOW_H + +// +// End of "$Id: Fl_Cairo_Window.H 8198 2011-01-06 10:24:58Z manolo $" . +// diff --git a/common/fltk/FL/Fl_Chart.H b/common/fltk/FL/Fl_Chart.H new file mode 100644 index 00000000..97bd8eeb --- /dev/null +++ b/common/fltk/FL/Fl_Chart.H @@ -0,0 +1,160 @@ +// +// "$Id: Fl_Chart.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Forms chart header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Chart widget . */ + +#ifndef Fl_Chart_H +#define Fl_Chart_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +// values for type() +#define FL_BAR_CHART 0 /**< type() for Bar Chart variant */ +#define FL_HORBAR_CHART 1 /**< type() for Horizontal Bar Chart variant */ +#define FL_LINE_CHART 2 /**< type() for Line Chart variant */ +#define FL_FILL_CHART 3 /**< type() for Fill Line Chart variant */ +#define FL_SPIKE_CHART 4 /**< type() for Spike Chart variant */ +#define FL_PIE_CHART 5 /**< type() for Pie Chart variant */ +#define FL_SPECIALPIE_CHART 6 /**< type() for Special Pie Chart variant */ + +#define FL_FILLED_CHART FL_FILL_CHART /**< for compatibility */ + +#define FL_CHART_MAX 128 /**< max entries per chart */ +#define FL_CHART_LABEL_MAX 18 /**< max label length for entry */ + +/** For internal use only */ +struct FL_CHART_ENTRY { + float val; /**< For internal use only. */ + unsigned col; /**< For internal use only. */ + char str[FL_CHART_LABEL_MAX+1]; /**< For internal use only. */ +}; + +/** + \class Fl_Chart + \brief Fl_Chart displays simple charts. + It is provided for Forms compatibility. + + \image html charts.png + \image latex charts.png "Fl_Chart" width=10cm + \todo Refactor Fl_Chart::type() information. + + The type of an Fl_Chart object can be set using type(uchar t) to: + \li \c FL_BAR_CHART: Each sample value is drawn as a vertical bar. + \li \c FL_FILLED_CHART: The chart is filled from the bottom of the graph + to the sample values. + \li \c FL_HORBAR_CHART: Each sample value is drawn as a horizontal bar. + \li \c FL_LINE_CHART: The chart is drawn as a polyline with vertices at + each sample value. + \li \c FL_PIE_CHART: A pie chart is drawn with each sample value being + drawn as a proportionate slice in the circle. + \li \c FL_SPECIALPIE_CHART: Like \c FL_PIE_CHART, but the first slice is + separated from the pie. + \li \c FL_SPIKE_CHART: Each sample value is drawn as a vertical line. + */ +class FL_EXPORT Fl_Chart : public Fl_Widget { + int numb; + int maxnumb; + int sizenumb; + FL_CHART_ENTRY *entries; + double min,max; + uchar autosize_; + Fl_Font textfont_; + Fl_Fontsize textsize_; + Fl_Color textcolor_; +protected: + void draw(); +public: + Fl_Chart(int X, int Y, int W, int H, const char *L = 0); + + ~Fl_Chart(); + + void clear(); + + void add(double val, const char *str = 0, unsigned col = 0); + + void insert(int ind, double val, const char *str = 0, unsigned col = 0); + + void replace(int ind, double val, const char *str = 0, unsigned col = 0); + + /** + Gets the lower and upper bounds of the chart values. + \param[out] a, b are set to lower, upper + */ + void bounds(double *a,double *b) const {*a = min; *b = max;} + + void bounds(double a,double b); + + /** + Returns the number of data values in the chart. + */ + int size() const {return numb;} + + void size(int W, int H) { Fl_Widget::size(W, H); } + + /** + Gets the maximum number of data values for a chart. + */ + int maxsize() const {return maxnumb;} + + void maxsize(int m); + + /** Gets the chart's text font */ + Fl_Font textfont() const {return textfont_;} + /** Sets the chart's text font to \p s. */ + void textfont(Fl_Font s) {textfont_ = s;} + + /** Gets the chart's text size */ + Fl_Fontsize textsize() const {return textsize_;} + /** gets the chart's text size to \p s. */ + void textsize(Fl_Fontsize s) {textsize_ = s;} + + /** Gets the chart's text color */ + Fl_Color textcolor() const {return textcolor_;} + /** gets the chart's text color to \p n. */ + void textcolor(Fl_Color n) {textcolor_ = n;} + + /** + Get whether the chart will automatically adjust the bounds of the chart. + \returns non-zero if auto-sizing is enabled and zero if disabled. + */ + uchar autosize() const {return autosize_;} + + /** + Set whether the chart will automatically adjust the bounds of the chart. + \param[in] n non-zero to enable automatic resizing, zero to disable. + */ + void autosize(uchar n) {autosize_ = n;} +}; + +#endif + +// +// End of "$Id: Fl_Chart.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Check_Browser.H b/common/fltk/FL/Fl_Check_Browser.H new file mode 100644 index 00000000..57cd9618 --- /dev/null +++ b/common/fltk/FL/Fl_Check_Browser.H @@ -0,0 +1,122 @@ +// +// "$Id: Fl_Check_Browser.H 7903 2010-11-28 21:06:39Z matt $" +// +// Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Check_Browser widget . */ + +#ifndef Fl_Check_Browser_H +#define Fl_Check_Browser_H + +#include "Fl.H" +#include "Fl_Browser_.H" + +/** + The Fl_Check_Browser widget displays a scrolling list of text + lines that may be selected and/or checked by the user. +*/ +class FL_EXPORT Fl_Check_Browser : public Fl_Browser_ { + /* required routines for Fl_Browser_ subclass: */ + + void *item_first() const; + void *item_next(void *) const; + void *item_prev(void *) const; + int item_height(void *) const; + int item_width(void *) const; + void item_draw(void *, int, int, int, int) const; + void item_select(void *, int); + int item_selected(void *) const; + + /* private data */ + + public: // IRIX 5.3 C++ compiler doesn't support private structures... + +#ifndef FL_DOXYGEN + /** For internal use only. */ + struct cb_item { + cb_item *next; /**< For internal use only. */ + cb_item *prev; /**< For internal use only. */ + char checked; /**< For internal use only. */ + char selected; /**< For internal use only. */ + char *text; /**< For internal use only. */ + }; +#endif // !FL_DOXYGEN + + private: + + cb_item *first; + cb_item *last; + cb_item *cache; + int cached_item; + int nitems_; + int nchecked_; + cb_item *find_item(int) const; + int lineno(cb_item *) const; + + public: + + Fl_Check_Browser(int x, int y, int w, int h, const char *l = 0); + /** The destructor deletes all list items and destroys the browser. */ + ~Fl_Check_Browser() { clear(); } + int add(char *s); // add an (unchecked) item + int add(char *s, int b); // add an item and set checked + // both return the new nitems() + int remove(int item); // delete an item. Returns nitems() + + // inline const char * methods to avoid breaking binary compatibility... + /** See int Fl_Check_Browser::add(char *s) */ + int add(const char *s) { return add((char *)s); } + /** See int Fl_Check_Browser::add(char *s) */ + int add(const char *s, int b) { return add((char *)s, b); } + + void clear(); // delete all items + /** + Returns how many lines are in the browser. The last line number is equal to + this. + */ + int nitems() const { return nitems_; } + /** Returns how many items are currently checked. */ + int nchecked() const { return nchecked_; } + int checked(int item) const; + void checked(int item, int b); + /** Equivalent to Fl_Check_Browser::checked(item, 1). */ + void set_checked(int item) { checked(item, 1); } + void check_all(); + void check_none(); + int value() const; // currently selected item + char *text(int item) const; // returns pointer to internal buffer + + protected: + + int handle(int); +}; + +#endif // Fl_Check_Browser_H + +// +// End of "$Id: Fl_Check_Browser.H 7903 2010-11-28 21:06:39Z matt $". +// + diff --git a/common/fltk/FL/Fl_Check_Button.H b/common/fltk/FL/Fl_Check_Button.H new file mode 100644 index 00000000..67fb0131 --- /dev/null +++ b/common/fltk/FL/Fl_Check_Button.H @@ -0,0 +1,60 @@ +// +// "$Id: Fl_Check_Button.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Check button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Check_Button widget . */ + +#ifndef Fl_Check_Button_H +#define Fl_Check_Button_H + +#include "Fl_Light_Button.H" + +/** + \class Fl_Check_Button + \brief A button with an "checkmark" to show its status. + + \image html Fl_Check_Button.png + \image latex Fl_Check_Button.png "Fl_Check_Button" width=4cm + Buttons generate callbacks when they are clicked by the user. You control + exactly when and how by changing the values for type() and when(). + + The Fl_Check_Button subclass displays its "ON" state by showing a "checkmark" + rather than drawing itself pushed in. + + \todo Refactor Fl_Check_Button doxygen comments (add color() info etc?) + \todo Generate Fl_Check_Button.gif with visible checkmark. + */ +class FL_EXPORT Fl_Check_Button : public Fl_Light_Button { +public: + Fl_Check_Button(int X, int Y, int W, int H, const char *L = 0); +}; + +#endif + +// +// End of "$Id: Fl_Check_Button.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Choice.H b/common/fltk/FL/Fl_Choice.H new file mode 100644 index 00000000..006364f3 --- /dev/null +++ b/common/fltk/FL/Fl_Choice.H @@ -0,0 +1,108 @@ +// +// "$Id: Fl_Choice.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Choice header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Choice widget . */ + +#ifndef Fl_Choice_H +#define Fl_Choice_H + +#include "Fl_Menu_.H" + +/** + \class Fl_Choice + \brief A button that is used to pop up a menu. + + This is a button that, when pushed, pops up a menu (or hierarchy of menus) + defined by an array of Fl_Menu_Item objects. + Motif calls this an OptionButton. + + The only difference between this and a Fl_Menu_Button is that the name of + the most recent chosen menu item is displayed inside the box, while the + label is displayed outside the box. However, since the use of this is most + often to control a single variable rather than do individual callbacks, + some of the Fl_Menu_Button methods are redescribed here in those terms. + + When the user picks an item off the menu the value() is set to that item + and then the item's callback is done with the menu_button as the + \c Fl_Widget* argument. If the item does not have a callback the + menu_button's callback is done instead. + + All three mouse buttons pop up the menu. The Forms behavior of the first + two buttons to increment/decrement the choice is not implemented. This + could be added with a subclass, however. + + The menu will also pop up in response to shortcuts indicated by putting + a '\&' character in the label(). See Fl_Button::shortcut(int s) for a + description of this. + + Typing the shortcut() of any of the items will do exactly the same as when + you pick the item with the mouse. The '\&' character in item names are + only looked at when the menu is popped up, however. + + \image html choice.png + \image latex choice.png "Fl_Choice" width=4cm + \todo Refactor the doxygen comments for Fl_Choice changed() documentation. + + \li <tt>int Fl_Widget::changed() const</tt> + This value is true the user picks a different value. <em>It is turned + off by value() and just before doing a callback (the callback can turn + it back on if desired).</em> + \li <tt>void Fl_Widget::set_changed()</tt> + This method sets the changed() flag. + \li <tt>void Fl_Widget::clear_changed()</tt> + This method clears the changed() flag. + \li <tt>Fl_Boxtype Fl_Choice::down_box() const</tt> + Gets the current down box, which is used when the menu is popped up. + The default down box type is \c FL_DOWN_BOX. + \li <tt>void Fl_Choice::down_box(Fl_Boxtype b)</tt> + Sets the current down box type to \p b. + */ +class FL_EXPORT Fl_Choice : public Fl_Menu_ { +protected: + void draw(); +public: + int handle(int); + + Fl_Choice(int X, int Y, int W, int H, const char *L = 0); + + /** + Gets the index of the last item chosen by the user. + The index is zero initially. + */ + int value() const {return Fl_Menu_::value();} + + int value(int v); + + int value(const Fl_Menu_Item* v); +}; + +#endif + +// +// End of "$Id: Fl_Choice.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Clock.H b/common/fltk/FL/Fl_Clock.H new file mode 100644 index 00000000..0b631a8b --- /dev/null +++ b/common/fltk/FL/Fl_Clock.H @@ -0,0 +1,137 @@ +// +// "$Id: Fl_Clock.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Clock header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Clock, Fl_Clock_Output widgets . */ + +#ifndef Fl_Clock_H +#define Fl_Clock_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +// values for type: +#define FL_SQUARE_CLOCK 0 /**< type() of Square Clock variant */ +#define FL_ROUND_CLOCK 1 /**< type() of Round Clock variant */ +#define FL_ANALOG_CLOCK FL_SQUARE_CLOCK /**< An analog clock is square */ +#define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK /**< Not yet implemented */ + +// fabien: Please keep the horizontal formatting of both images in class desc, +// don't lose vert. space for nothing! + +/** + \class Fl_Clock_Output + \brief This widget can be used to display a program-supplied time. + + The time shown on the clock is not updated. To display the current time, + use Fl_Clock instead. + + \htmlonly <BR> <table align=CENTER border=1 cellpadding=5 > + <caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly + \image html clock.png + \htmlonly </TD> <TD> \endhtmlonly + \image html round_clock.png + \htmlonly </TD> </TR> </table> \endhtmlonly + \image latex clock.png "FL_SQUARE_CLOCK type" width=4cm + \image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm + */ +class FL_EXPORT Fl_Clock_Output : public Fl_Widget { + int hour_, minute_, second_; + ulong value_; + void drawhands(Fl_Color,Fl_Color); // part of draw +protected: + void draw(); + void draw(int X, int Y, int W, int H); +public: + + Fl_Clock_Output(int X, int Y, int W, int H, const char *L = 0); + + void value(ulong v); // set to this Unix time + + void value(int H, int m, int s); + + /** + Returns the displayed time. + Returns the time in seconds since the UNIX epoch (January 1, 1970). + \see value(ulong) + */ + ulong value() const {return value_;} + + /** + Returns the displayed hour (0 to 23). + \see value(), minute(), second() + */ + int hour() const {return hour_;} + + /** + Returns the displayed minute (0 to 59). + \see value(), hour(), second() + */ + int minute() const {return minute_;} + + /** + Returns the displayed second (0 to 60, 60=leap second). + \see value(), hour(), minute() + */ + int second() const {return second_;} +}; + +// a Fl_Clock displays the current time always by using a timeout: + +/** + \class Fl_Clock + \brief This widget provides a round analog clock display. + + Fl_Clock is provided for Forms compatibility. + It installs a 1-second timeout callback using Fl::add_timeout(). + You can choose the rounded or square type of the clock with type(), see below. + \htmlonly <BR> <table align=CENTER border=1 cellpadding=5 > + <caption align=bottom>type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK </caption> <TR><TD> \endhtmlonly + \image html clock.png + \htmlonly </TD> <TD> \endhtmlonly + \image html round_clock.png + \htmlonly </TD> </TR> </table> \endhtmlonly + \image latex clock.png "FL_SQUARE_CLOCK type" width=4cm + \image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm + */ +class FL_EXPORT Fl_Clock : public Fl_Clock_Output { +public: + int handle(int); + + Fl_Clock(int X, int Y, int W, int H, const char *L = 0); + + Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L); + + ~Fl_Clock(); +}; + +#endif + +// +// End of "$Id: Fl_Clock.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Color_Chooser.H b/common/fltk/FL/Fl_Color_Chooser.H new file mode 100644 index 00000000..180ee002 --- /dev/null +++ b/common/fltk/FL/Fl_Color_Chooser.H @@ -0,0 +1,199 @@ +// +// "$Id: Fl_Color_Chooser.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Color chooser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file + Fl_Color_Chooser widget . */ + +// The color chooser object and the color chooser popup. The popup +// is just a window containing a single color chooser and some boxes +// to indicate the current and cancelled color. + +#ifndef Fl_Color_Chooser_H +#define Fl_Color_Chooser_H + +#include <FL/Fl_Group.H> +#include <FL/Fl_Box.H> +#include <FL/Fl_Return_Button.H> +#include <FL/Fl_Choice.H> +#include <FL/Fl_Value_Input.H> + +#ifndef FL_DOXYGEN + +/** For internal use only */ +class FL_EXPORT Flcc_HueBox : public Fl_Widget { + int px, py; +protected: + void draw(); + int handle_key(int); +public: + int handle(int); + Flcc_HueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) { + px = py = 0;} +}; + +/** For internal use only */ +class FL_EXPORT Flcc_ValueBox : public Fl_Widget { + int py; +protected: + void draw(); + int handle_key(int); +public: + int handle(int); + Flcc_ValueBox(int X, int Y, int W, int H) : Fl_Widget(X,Y,W,H) { + py = 0;} +}; + +/** For internal use only */ +class FL_EXPORT Flcc_Value_Input : public Fl_Value_Input { +public: + int format(char*); + Flcc_Value_Input(int X, int Y, int W, int H) : Fl_Value_Input(X,Y,W,H) {} +}; + +#endif // !FL_DOXYGEN + +/** \addtogroup group_comdlg + @{ */ + +/** + \class Fl_Color_Chooser + \brief The Fl_Color_Chooser widget provides a standard RGB color chooser. + + \image html fl_color_chooser.jpg + \image latex fl_color_chooser.jpg "fl_color_chooser()" width=5cm + + You can place any number of the widgets into a panel of your own design. + The diagram shows the widget as part of a color chooser dialog created by + the fl_color_chooser() function. The Fl_Color_Chooser widget contains the + hue box, value slider, and rgb input fields from the above diagram (it + does not have the color chips or the Cancel or OK buttons). + The callback is done every time the user changes the rgb value. It is not + done if they move the hue control in a way that produces the \e same rgb + value, such as when saturation or value is zero. + + The fl_color_chooser() function pops up a window to let the user pick an + arbitrary RGB color. They can pick the hue and saturation in the "hue box" + on the left (hold down CTRL to just change the saturation), and the + brightness using the vertical slider. Or they can type the 8-bit numbers + into the RGB Fl_Value_Input fields, or drag the mouse across them to adjust + them. The pull-down menu lets the user set the input fields to show RGB, + HSV, or 8-bit RGB (0 to 255). + + fl_color_chooser() returns non-zero if the user picks ok, and updates the + RGB values. If the user picks cancel or closes the window this returns + zero and leaves RGB unchanged. + + If you use the color chooser on an 8-bit screen, it will allocate all the + available colors, leaving you no space to exactly represent the color the + user picks! You can however use fl_rectf() to fill a region with a simulated + color using dithering. + */ +/** @} */ +class FL_EXPORT Fl_Color_Chooser : public Fl_Group { + Flcc_HueBox huebox; + Flcc_ValueBox valuebox; + Fl_Choice choice; + Flcc_Value_Input rvalue; + Flcc_Value_Input gvalue; + Flcc_Value_Input bvalue; + Fl_Box resize_box; + double hue_, saturation_, value_; + double r_, g_, b_; + void set_valuators(); + static void rgb_cb(Fl_Widget*, void*); + static void mode_cb(Fl_Widget*, void*); +public: + + /** + Returns which Fl_Color_Chooser variant is currently active + \return color modes are rgb(0), byte(1), hex(2), or hsv(3) + */ + int mode() {return choice.value();} + + /** + Set which Fl_Color_Chooser variant is currently active + \param[in] newMode color modes are rgb(0), byte(1), hex(2), or hsv(3) + */ + void mode(int newMode); + + /** + Returns the current hue. + 0 <= hue < 6. Zero is red, one is yellow, two is green, etc. + <em>This value is convenient for the internal calculations - some other + systems consider hue to run from zero to one, or from 0 to 360.</em> + */ + double hue() const {return hue_;} + + /** + Returns the saturation. + 0 <= saturation <= 1. + */ + double saturation() const {return saturation_;} + + /** + Returns the value/brightness. + 0 <= value <= 1. + */ + double value() const {return value_;} + + /** + Returns the current red value. + 0 <= r <= 1. + */ + double r() const {return r_;} + + /** + Returns the current green value. + 0 <= g <= 1. + */ + double g() const {return g_;} + + /** + Returns the current blue value. + 0 <= b <= 1. + */ + double b() const {return b_;} + + int hsv(double H, double S, double V); + + int rgb(double R, double G, double B); + + static void hsv2rgb(double H, double S, double V, double& R, double& G, double& B); + + static void rgb2hsv(double R, double G, double B, double& H, double& S, double& V); + + Fl_Color_Chooser(int X, int Y, int W, int H, const char *L = 0); +}; + +FL_EXPORT int fl_color_chooser(const char* name, double& r, double& g, double& b, int m=-1); +FL_EXPORT int fl_color_chooser(const char* name, uchar& r, uchar& g, uchar& b, int m=-1); + +#endif + +// +// End of "$Id: Fl_Color_Chooser.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Counter.H b/common/fltk/FL/Fl_Counter.H new file mode 100644 index 00000000..419715be --- /dev/null +++ b/common/fltk/FL/Fl_Counter.H @@ -0,0 +1,124 @@ +// +// "$Id: Fl_Counter.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Counter header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Counter widget . */ + +// A numerical value with up/down step buttons. From Forms. + +#ifndef Fl_Counter_H +#define Fl_Counter_H + +#ifndef Fl_Valuator_H +#include "Fl_Valuator.H" +#endif + +// values for type(): +#define FL_NORMAL_COUNTER 0 /**< type() for counter with fast buttons */ +#define FL_SIMPLE_COUNTER 1 /**< type() for counter without fast buttons */ + +/** + Controls a single floating point value with button (or keyboard) arrows. + Double arrows buttons achieve larger steps than simple arrows. + \see Fl_Spinner for value input with vertical step arrows. + <P align=center>\image html counter.png</P> + \image latex counter.png "Fl_Counter" width=4cm + + \todo Refactor the doxygen comments for Fl_Counter type() documentation. + + The type of an Fl_Counter object can be set using type(uchar t) to: + \li \c FL_NORMAL_COUNTER: Displays a counter with 4 arrow buttons. + \li \c FL_SIMPLE_COUNTER: Displays a counter with only 2 arrow buttons. +*/ +class FL_EXPORT Fl_Counter : public Fl_Valuator { + + Fl_Font textfont_; + Fl_Fontsize textsize_; + Fl_Color textcolor_; + double lstep_; + uchar mouseobj; + static void repeat_callback(void *); + int calc_mouseobj(); + void increment_cb(); + +protected: + + void draw(); + +public: + + int handle(int); + + Fl_Counter(int X, int Y, int W, int H, const char* L = 0); + ~Fl_Counter(); + + /** + Sets the increment for the large step buttons. + The default value is 1.0. + \param[in] a large step increment. + */ + void lstep(double a) {lstep_ = a;} + + /** + Sets the increments for the normal and large step buttons. + \param[in] a, b normal and large step increments. + */ + void step(double a,double b) {Fl_Valuator::step(a); lstep_ = b;} + + /** + Sets the increment for the normal step buttons. + \param[in] a normal step increment. + */ + void step(double a) {Fl_Valuator::step(a);} + + /** + Returns the increment for normal step buttons. + */ + double step() const {return Fl_Valuator::step();} + + /** Gets the text font */ + Fl_Font textfont() const {return textfont_;} + /** Sets the text font to \p s */ + void textfont(Fl_Font s) {textfont_ = s;} + + /** Gets the font size */ + Fl_Fontsize textsize() const {return textsize_;} + /** Sets the font size to \p s */ + void textsize(Fl_Fontsize s) {textsize_ = s;} + + /** Gets the font color */ + Fl_Color textcolor() const {return textcolor_;} + /** Sets the font color to \p s */ + void textcolor(Fl_Color s) {textcolor_ = s;} + +}; + +#endif + +// +// End of "$Id: Fl_Counter.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Device.H b/common/fltk/FL/Fl_Device.H new file mode 100644 index 00000000..5b96dc8b --- /dev/null +++ b/common/fltk/FL/Fl_Device.H @@ -0,0 +1,558 @@ +// +// "$Id: Fl_Device.H 8529 2011-03-23 12:49:30Z AlbrechtS $" +// +// Definition of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device +// for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// +/** \file Fl_Device.H + \brief declaration of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, + Fl_Display_Device, Fl_Device_Plugin. +*/ + +#ifndef Fl_Device_H +#define Fl_Device_H + +#include <FL/x.H> +#include <FL/Fl_Plugin.H> +#include <FL/Fl_Image.H> +#include <FL/Fl_Bitmap.H> +#include <FL/Fl_Pixmap.H> +#include <FL/Fl_RGB_Image.H> + +class Fl_Graphics_Driver; +class Fl_Font_Descriptor; +/** \brief Points to the driver that currently receives all graphics requests */ +FL_EXPORT extern Fl_Graphics_Driver *fl_graphics_driver; + +/** + signature of image generation callback function. + \param[in] data user data passed to function + \param[in] x,y,w position and width of scan line in image + \param[out] buf buffer for generated image data. You must copy \p w + pixels from scanline \p y, starting at pixel \p x + to this buffer. + */ +typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf); + +// typedef what the x,y fields in a point are: +#ifdef WIN32 +typedef int COORD_T; +# define XPOINT XPoint +#elif defined(__APPLE__) +typedef float COORD_T; +typedef struct { float x; float y; } QPoint; +# define XPOINT QPoint +extern float fl_quartz_line_width_; +#else +typedef short COORD_T; +# define XPOINT XPoint +#endif + +/** + \brief All graphical output devices and all graphics systems. + */ +class FL_EXPORT Fl_Device { +public: + /** A string that identifies each subclass of Fl_Device. + Function class_name() applied to a device of this class returns this string. + */ + static const char *class_id; + /** + Returns the name of the class of this object. + The class of an instance of an Fl_Device subclass can be checked with code such as: + \code + if ( instance->class_name() == Fl_Printer::class_id ) { ... } + \endcode + */ + virtual const char *class_name() {return class_id;}; + /** + Virtual destructor. + + The destructor of Fl_Device must be virtual to make the destructors of + derived classes being called correctly on destruction. + */ + virtual ~Fl_Device() {}; +}; + +#define FL_REGION_STACK_SIZE 10 +#define FL_MATRIX_STACK_SIZE 32 +/** + \brief A virtual class subclassed for each graphics driver FLTK uses. + * + The virtual methods of this class are those that a graphics driver should implement to + support all of FLTK drawing functions. + <br> The public API for drawing operations is functionally presented in \ref drawing and as function lists + in the \ref fl_drawings and \ref fl_attributes modules. + */ +class FL_EXPORT Fl_Graphics_Driver : public Fl_Device { +public: + /** A 2D coordinate transformation matrix + */ + struct matrix {double a, b, c, d, x, y;}; +private: + static const matrix m0; + Fl_Font font_; // current font + Fl_Fontsize size_; // current font size + Fl_Color color_; // current color + enum {LINE, LOOP, POLYGON, POINT_}; + int sptr; + static const int matrix_stack_size = FL_MATRIX_STACK_SIZE; + matrix stack[FL_MATRIX_STACK_SIZE]; + matrix m; + int n, p_size, gap_; + XPOINT *p; + int what; + int fl_clip_state_number; + int rstackptr; + static const int region_stack_max = FL_REGION_STACK_SIZE - 1; + Fl_Region rstack[FL_REGION_STACK_SIZE]; +#ifdef WIN32 + int numcount; + int counts[20]; +#endif + Fl_Font_Descriptor *font_descriptor_; + void transformed_vertex0(COORD_T x, COORD_T y); + void fixloop(); + +protected: +/* ** \brief red color for background and/or mixing if device does not support masking or alpha * + uchar bg_r_; + ** \brief green color for background and/or mixing if device does not support masking or alpha * + uchar bg_g_; + ** \brief blue color for background and/or mixing if device does not support masking or alpha * + uchar bg_b_; */ + friend class Fl_Pixmap; + friend class Fl_Bitmap; + friend class Fl_RGB_Image; + friend void fl_rect(int x, int y, int w, int h); + friend void fl_rectf(int x, int y, int w, int h); + friend void fl_line_style(int style, int width, char* dashes); + friend void fl_xyline(int x, int y, int x1); + friend void fl_xyline(int x, int y, int x1, int y2); + friend void fl_xyline(int x, int y, int x1, int y2, int x3); + friend void fl_yxline(int x, int y, int y1); + friend void fl_yxline(int x, int y, int y1, int x2); + friend void fl_yxline(int x, int y, int y1, int x2, int y3); + friend void fl_line(int x, int y, int x1, int y1); + friend void fl_line(int x, int y, int x1, int y1, int x2, int y2); + friend void fl_draw(const char *str, int n, int x, int y); +#ifdef __APPLE__ + friend void fl_draw(const char *str, int n, float x, float y); +#endif + friend void fl_draw(int angle, const char *str, int n, int x, int y); + friend void fl_rtl_draw(const char *str, int n, int x, int y); + friend void fl_font(Fl_Font face, Fl_Fontsize size); + friend void fl_color(Fl_Color c); + friend void fl_color(uchar r, uchar g, uchar b); + friend void fl_point(int x, int y); + friend void fl_loop(int x0, int y0, int x1, int y1, int x2, int y2); + friend void fl_loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + friend void fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2); + friend void fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + friend void fl_begin_points(); + friend void fl_begin_line(); + friend void fl_begin_loop(); + friend void fl_begin_polygon(); + friend void fl_vertex(double x, double y); + friend void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3); + friend void fl_circle(double x, double y, double r); + friend void fl_arc(double x, double y, double r, double start, double end); + friend void fl_arc(int x, int y, int w, int h, double a1, double a2); + friend void fl_pie(int x, int y, int w, int h, double a1, double a2); + friend void fl_end_points(); + friend void fl_end_line(); + friend void fl_end_loop(); + friend void fl_end_polygon(); + friend void fl_transformed_vertex(double xf, double yf); + friend void fl_push_clip(int x, int y, int w, int h); + friend int fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H); + friend int fl_not_clipped(int x, int y, int w, int h); + friend void fl_push_no_clip(); + friend void fl_pop_clip(); + friend void fl_begin_complex_polygon(); + friend void fl_gap(); + friend void fl_end_complex_polygon(); + friend void fl_push_matrix(); + friend void fl_pop_matrix(); + friend void fl_mult_matrix(double a, double b, double c, double d, double x, double y); + friend void fl_scale(double x, double y); + friend void fl_scale(double x); + friend void fl_translate(double x, double y); + friend void fl_rotate(double d); + friend double fl_transform_x(double x, double y); + friend double fl_transform_y(double x, double y); + friend double fl_transform_dx(double x, double y); + friend double fl_transform_dy(double x, double y); + friend Fl_Region fl_clip_region(); + friend void fl_clip_region(Fl_Region r); + friend void fl_restore_clip(); + + friend void fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L); + friend void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L); + friend void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D); + friend FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D); + friend FL_EXPORT void gl_start(); + + matrix *fl_matrix; /**< Points to the current coordinate transformation matrix */ + + /** \brief The constructor. */ + Fl_Graphics_Driver(); + /** \brief see fl_rect(int x, int y, int w, int h). */ + virtual void rect(int x, int y, int w, int h); + /** \brief see fl_rectf(int x, int y, int w, int h). */ + virtual void rectf(int x, int y, int w, int h); + /** \brief see fl_line_style(int style, int width, char* dashes). */ + virtual void line_style(int style, int width=0, char* dashes=0); + /** \brief see fl_xyline(int x, int y, int x1). */ + virtual void xyline(int x, int y, int x1); + /** \brief see fl_xyline(int x, int y, int x1, int y2). */ + virtual void xyline(int x, int y, int x1, int y2); + /** \brief see fl_xyline(int x, int y, int x1, int y2, int x3). */ + virtual void xyline(int x, int y, int x1, int y2, int x3); + /** \brief see fl_yxline(int x, int y, int y1). */ + virtual void yxline(int x, int y, int y1); + /** \brief see fl_yxline(int x, int y, int y1, int x2). */ + virtual void yxline(int x, int y, int y1, int x2); + /** \brief see fl_yxline(int x, int y, int y1, int x2, int y3). */ + virtual void yxline(int x, int y, int y1, int x2, int y3); + /** \brief see fl_line(int x, int y, int x1, int y1). */ + virtual void line(int x, int y, int x1, int y1); + /** \brief see fl_line(int x, int y, int x1, int y1, int x2, int y2). */ + virtual void line(int x, int y, int x1, int y1, int x2, int y2); + /** \brief see fl_draw(const char *str, int n, int x, int y). */ + virtual void draw(const char *str, int n, int x, int y) = 0; +#ifdef __APPLE__ + virtual void draw(const char *str, int n, float x, float y) = 0; +#endif + /** \brief see fl_draw(int angle, const char *str, int n, int x, int y). */ + virtual void draw(int angle, const char *str, int n, int x, int y) = 0; + /** \brief see fl_rtl_draw(const char *str, int n, int x, int y). */ + virtual void rtl_draw(const char *str, int n, int x, int y) = 0; + /** \brief see fl_color(Fl_Color c). */ + virtual void color(Fl_Color c) {color_ = c;} + /** \brief see fl_color(uchar r, uchar g, uchar b). */ + virtual void color(uchar r, uchar g, uchar b) = 0; + /** \brief see fl_point(int x, int y). */ + virtual void point(int x, int y); + /** \brief see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2). */ + virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2); + /** \brief see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3). */ + virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + /** \brief see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2). */ + virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2); + /** \brief see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3). */ + virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + /** \brief see fl_begin_points(). */ + virtual void begin_points(); + /** \brief see fl_begin_line(). */ + virtual void begin_line(); + /** \brief see fl_begin_loop(). */ + virtual void begin_loop(); + /** \brief see fl_begin_polygon(). */ + virtual void begin_polygon(); + /** \brief see fl_vertex(double x, double y). */ + virtual void vertex(double x, double y); + /** \brief see fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3). */ + virtual void curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3); + /** \brief see fl_circle(double x, double y, double r). */ + virtual void circle(double x, double y, double r); + /** \brief see fl_arc(double x, double y, double r, double start, double end). */ + virtual void arc(double x, double y, double r, double start, double end); + /** \brief see fl_arc(int x, int y, int w, int h, double a1, double a2). */ + virtual void arc(int x, int y, int w, int h, double a1, double a2); + /** \brief see fl_pie(int x, int y, int w, int h, double a1, double a2). */ + virtual void pie(int x, int y, int w, int h, double a1, double a2); + /** \brief see fl_end_points(). */ + virtual void end_points(); + /** \brief see fl_end_line(). */ + virtual void end_line(); + /** \brief see fl_end_loop(). */ + virtual void end_loop(); + /** \brief see fl_end_polygon(). */ + virtual void end_polygon(); + /** \brief see fl_begin_complex_polygon(). */ + virtual void begin_complex_polygon(); + /** \brief see fl_gap(). */ + virtual void gap(); + /** \brief see fl_end_complex_polygon(). */ + virtual void end_complex_polygon(); + /** \brief see fl_transformed_vertex(double xf, double yf). */ + virtual void transformed_vertex(double xf, double yf); + /** \brief see fl_push_clip(int x, int y, int w, int h). */ + virtual void push_clip(int x, int y, int w, int h); + /** \brief see fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H). */ + virtual int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H); + /** \brief see fl_not_clipped(int x, int y, int w, int h). */ + virtual int not_clipped(int x, int y, int w, int h); + /** \brief see fl_push_no_clip(). */ + virtual void push_no_clip(); + /** \brief see fl_pop_clip(). */ + virtual void pop_clip(); + + /** \brief see fl_push_matrix(). */ + void push_matrix(); + /** \brief see fl_pop_matrix(). */ + void pop_matrix(); + /** \brief see fl_mult_matrix(double a, double b, double c, double d, double x, double y). */ + void mult_matrix(double a, double b, double c, double d, double x, double y); + /** \brief see fl_scale(double x, double y). */ + inline void scale(double x, double y) { mult_matrix(x,0,0,y,0,0); } + /** \brief see fl_scale(double x). */ + inline void scale(double x) { mult_matrix(x,0,0,x,0,0); } + /** \brief see fl_translate(double x, double y). */ + inline void translate(double x,double y) { mult_matrix(1,0,0,1,x,y); } + /** \brief see fl_rotate(double d). */ + void rotate(double d); + /** \brief see fl_transform_x(double x, double y). */ + double transform_x(double x, double y); + /** \brief see fl_transform_y(double x, double y). */ + double transform_y(double x, double y); + /** \brief see fl_transform_dx(double x, double y). */ + double transform_dx(double x, double y); + /** \brief see fl_transform_dy(double x, double y). */ + double transform_dy(double x, double y); + /** \brief see fl_clip_region(). */ + Fl_Region clip_region(); + /** \brief see fl_clip_region(Fl_Region r). */ + void clip_region(Fl_Region r); + /** \brief see fl_restore_clip(). */ + void restore_clip(); + + // Images + /** \brief see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L). */ + virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) = 0; + /** \brief see fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L). */ + virtual void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) = 0; + /** \brief see fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D). */ + virtual void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) = 0; + /** \brief see fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D). */ + virtual void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1) = 0; + // Image classes + /** \brief Draws an Fl_RGB_Image object to the device. + * + Specifies a bounding box for the image, with the origin (upper left-hand corner) of + the image offset by the cx and cy arguments. + */ + virtual void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy) = 0; + /** \brief Draws an Fl_Pixmap object to the device. + * + Specifies a bounding box for the image, with the origin (upper left-hand corner) of + the image offset by the cx and cy arguments. + */ + virtual void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy) = 0; + /** \brief Draws an Fl_Bitmap object to the device. + * + Specifies a bounding box for the image, with the origin (upper left-hand corner) of + the image offset by the cx and cy arguments. + */ + virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) = 0; + +public: + static const char *class_id; + virtual const char *class_name() {return class_id;}; + /** \brief see fl_font(Fl_Font face, Fl_Fontsize size). */ + virtual void font(Fl_Font face, Fl_Fontsize size) {font_ = face; size_ = size;} + /** \brief see fl_font(void). */ + Fl_Font font() {return font_; } + /** \brief see fl_size(). */ + Fl_Fontsize size() {return size_; } + /** \brief see fl_width(const char *str, int n). */ + virtual double width(const char *str, int n) = 0; + /** \brief see fl_width(unsigned int n). */ + virtual inline double width(unsigned int c) { char ch = (char)c; return width(&ch, 1); } + /** \brief see fl_text_extents(const char*, int n, int& dx, int& dy, int& w, int& h). */ + virtual void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); + /** \brief see fl_height(). */ + virtual int height() = 0; + /** \brief see fl_descent(). */ + virtual int descent() = 0; + /** \brief see fl_color(void). */ + Fl_Color color() {return color_;} + /** Returns a pointer to the current Fl_Font_Descriptor for the graphics driver */ + inline Fl_Font_Descriptor *font_descriptor() { return font_descriptor_;} + /** Sets the current Fl_Font_Descriptor for the graphics driver */ + inline void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;} + /** \brief The destructor */ + virtual ~Fl_Graphics_Driver() {}; +}; + +#if defined(__APPLE__) || defined(FL_DOXYGEN) +/** + \brief The Mac OS X-specific graphics class. + * + This class is implemented only on the Mac OS X platform. + */ +class FL_EXPORT Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver { +public: + static const char *class_id; + const char *class_name() {return class_id;}; + void color(Fl_Color c); + void color(uchar r, uchar g, uchar b); + void draw(const char* str, int n, int x, int y); +#ifdef __APPLE__ + void draw(const char *str, int n, float x, float y); +#endif + void draw(int angle, const char *str, int n, int x, int y); + void rtl_draw(const char* str, int n, int x, int y); + void font(Fl_Font face, Fl_Fontsize size); + void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); + void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); + void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy); + void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); + void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); + void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); + void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); + double width(const char *str, int n); + double width(unsigned int c); + void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); + int height(); + int descent(); +}; +#endif +#if defined(WIN32) || defined(FL_DOXYGEN) +/** + \brief The MSWindows-specific graphics class. + * + This class is implemented only on the MSWindows platform. + */ +class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver { +public: + static const char *class_id; + const char *class_name() {return class_id;}; + void color(Fl_Color c); + void color(uchar r, uchar g, uchar b); + void draw(const char* str, int n, int x, int y); + void draw(int angle, const char *str, int n, int x, int y); + void rtl_draw(const char* str, int n, int x, int y); + void font(Fl_Font face, Fl_Fontsize size); + void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); + void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); + void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy); + void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); + void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); + void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); + void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); + double width(const char *str, int n); + double width(unsigned int c); + void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); + int height(); + int descent(); +}; +#endif +#if !(defined(__APPLE__) || defined(WIN32)) +/** + \brief The Xlib-specific graphics class. + * + This class is implemented only on the Xlib platform. + */ +class Fl_Xlib_Graphics_Driver : public Fl_Graphics_Driver { +public: + static const char *class_id; + const char *class_name() {return class_id;}; + void color(Fl_Color c); + void color(uchar r, uchar g, uchar b); + void draw(const char* str, int n, int x, int y); + void draw(int angle, const char *str, int n, int x, int y); + void rtl_draw(const char* str, int n, int x, int y); + void font(Fl_Font face, Fl_Fontsize size); + void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); + void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); + void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy); + void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); + void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); + void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); + void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); + double width(const char *str, int n); + double width(unsigned int c); + void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); + int height(); + int descent(); +}; +#endif + +/** + \brief A surface that's susceptible to receive graphical output. + */ +class FL_EXPORT Fl_Surface_Device : public Fl_Device { + /** \brief The graphics driver in use by this surface. */ + Fl_Graphics_Driver *_driver; + static Fl_Surface_Device *_surface; // the surface that currently receives graphics output +protected: + /** \brief Constructor that sets the graphics driver to use for the created surface. */ + Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver; }; +public: + static const char *class_id; + const char *class_name() {return class_id;}; + virtual void set_current(void); + /** \brief Sets the graphics driver of this drawing surface. */ + inline void driver(Fl_Graphics_Driver *graphics_driver) {_driver = graphics_driver;}; + /** \brief Returns the graphics driver of this drawing surface. */ + inline Fl_Graphics_Driver *driver() {return _driver; }; + /** \brief the surface that currently receives graphics output */ + static inline Fl_Surface_Device *surface() {return _surface; }; + /** \brief The destructor. */ + virtual ~Fl_Surface_Device() {} +}; + +/** + \brief A display to which the computer can draw. + */ +class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device { + static Fl_Display_Device *_display; // the platform display device +public: + static const char *class_id; + const char *class_name() {return class_id;}; + /** \brief A constructor that sets the graphics driver used by the display */ + Fl_Display_Device(Fl_Graphics_Driver *graphics_driver); + /** Returns the platform display device. */ + static inline Fl_Display_Device *display_device() {return _display;}; +}; + +/** + This plugin socket allows the integration of new device drivers for special + window or screen types. It is currently used to provide an automated printing + service for OpenGL windows, if linked with fltk_gl. + */ +class FL_EXPORT Fl_Device_Plugin : public Fl_Plugin { +public: + /** \brief The constructor */ + Fl_Device_Plugin(const char *name) + : Fl_Plugin(klass(), name) { } + /** \brief Returns the class name */ + virtual const char *klass() { return "fltk:device"; } + /** \brief Returns the plugin name */ + virtual const char *name() = 0; + /** \brief Prints a widget + \param w the widget + \param x,y offsets where to print relatively to coordinates origin + \param height height of the current drawing area + */ + virtual int print(Fl_Widget* w, int x, int y, int height) = 0; +}; + +#endif // Fl_Device_H + +// +// End of "$Id: Fl_Device.H 8529 2011-03-23 12:49:30Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Dial.H b/common/fltk/FL/Fl_Dial.H new file mode 100644 index 00000000..96de59fc --- /dev/null +++ b/common/fltk/FL/Fl_Dial.H @@ -0,0 +1,97 @@ +// +// "$Id: Fl_Dial.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Dial header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Dial widget . */ + +#ifndef Fl_Dial_H +#define Fl_Dial_H + +#ifndef Fl_Valuator_H +#include "Fl_Valuator.H" +#endif + +// values for type(): +#define FL_NORMAL_DIAL 0 /**< type() for dial variant with dot */ +#define FL_LINE_DIAL 1 /**< type() for dial variant with line */ +#define FL_FILL_DIAL 2 /**< type() for dial variant with filled arc */ + +/** + The Fl_Dial widget provides a circular dial to control a + single floating point value. + <P ALIGN=CENTER>\image html dial.png + \image latex dial.png "Fl_Dial" width=4cm + Use type() to set the type of the dial to: + <UL> + <LI>FL_NORMAL_DIAL - Draws a normal dial with a knob. </LI> + <LI>FL_LINE_DIAL - Draws a dial with a line. </LI> + <LI>FL_FILL_DIAL - Draws a dial with a filled arc. </LI> + </UL> + +*/ +class FL_EXPORT Fl_Dial : public Fl_Valuator { + + short a1,a2; + +protected: + + // these allow subclasses to put the dial in a smaller area: + void draw(int X, int Y, int W, int H); + int handle(int event, int X, int Y, int W, int H); + void draw(); + +public: + + int handle(int); + /** + Creates a new Fl_Dial widget using the given position, size, + and label string. The default type is FL_NORMAL_DIAL. + */ + Fl_Dial(int x,int y,int w,int h, const char *l = 0); + /** + Sets Or gets the angles used for the minimum and maximum values. The default + values are 45 and 315 (0 degrees is straight down and the angles + progress clockwise). Normally angle1 is less than angle2, but if you + reverse them the dial moves counter-clockwise. + */ + short angle1() const {return a1;} + /** See short angle1() const */ + void angle1(short a) {a1 = a;} + /** See short angle1() const */ + short angle2() const {return a2;} + /** See short angle1() const */ + void angle2(short a) {a2 = a;} + /** See short angle1() const */ + void angles(short a, short b) {a1 = a; a2 = b;} + +}; + +#endif + +// +// End of "$Id: Fl_Dial.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Double_Window.H b/common/fltk/FL/Fl_Double_Window.H new file mode 100644 index 00000000..20ab25b3 --- /dev/null +++ b/common/fltk/FL/Fl_Double_Window.H @@ -0,0 +1,81 @@ +// +// "$Id: Fl_Double_Window.H 7903 2010-11-28 21:06:39Z matt $" +// +// Double-buffered window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Double_Window widget . */ + +#ifndef Fl_Double_Window_H +#define Fl_Double_Window_H + +#include "Fl_Window.H" + +/** + The Fl_Double_Window provides a double-buffered window. + If possible this will use the X double buffering extension (Xdbe). If + not, it will draw the window data into an off-screen pixmap, and then + copy it to the on-screen window. + <P>It is highly recommended that you put the following code before the + first show() of <I>any</I> window in your program: </P> + \code + Fl::visual(FL_DOUBLE|FL_INDEX) + \endcode + This makes sure you can use Xdbe on servers where double buffering + does not exist for every visual. +*/ +class FL_EXPORT Fl_Double_Window : public Fl_Window { +protected: + void flush(int eraseoverlay); + /** + Force double buffering, even if the OS already buffers windows + (overlays need that on MacOS and Windows2000) + */ + char force_doublebuffering_; +public: + void show(); + void show(int a, char **b) {Fl_Window::show(a,b);} + void flush(); + void resize(int,int,int,int); + void hide(); + ~Fl_Double_Window(); + /** + Creates a new Fl_Double_Window widget using the given + position, size, and label (title) string. + */ + Fl_Double_Window(int W, int H, const char *l = 0) + : Fl_Window(W,H,l), force_doublebuffering_(0) { type(FL_DOUBLE_WINDOW); } + /** + See Fl_Double_Window::Fl_Double_Window(int w, int h, const char *label = 0) + */ + Fl_Double_Window(int X, int Y, int W, int H, const char *l = 0) + : Fl_Window(X,Y,W,H,l), force_doublebuffering_(0) { type(FL_DOUBLE_WINDOW); } +}; + +#endif + +// +// End of "$Id: Fl_Double_Window.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Export.H b/common/fltk/FL/Fl_Export.H new file mode 100644 index 00000000..875a2789 --- /dev/null +++ b/common/fltk/FL/Fl_Export.H @@ -0,0 +1,49 @@ +/* + * "$Id: Fl_Export.H 7903 2010-11-28 21:06:39Z matt $" + * + * WIN32 DLL export . + * + * Copyright 1998-2010 by Bill Spitzak and others. + * + * 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. + * + * Please report all bugs and problems on the following page: + * + * http://www.fltk.org/str.php + */ + +#ifndef Fl_Export_H +# define Fl_Export_H + +/* + * The following is only used when building DLLs under WIN32... + */ + +# if defined(FL_DLL) +# ifdef FL_LIBRARY +# define FL_EXPORT __declspec(dllexport) +# else +# define FL_EXPORT __declspec(dllimport) +# endif /* FL_LIBRARY */ +# else +# define FL_EXPORT +# endif /* FL_DLL */ + +#endif /* !Fl_Export_H */ + +/* + * End of "$Id: Fl_Export.H 7903 2010-11-28 21:06:39Z matt $". + */ diff --git a/common/fltk/FL/Fl_File_Browser.H b/common/fltk/FL/Fl_File_Browser.H new file mode 100644 index 00000000..cc7fc96f --- /dev/null +++ b/common/fltk/FL/Fl_File_Browser.H @@ -0,0 +1,120 @@ +// +// "$Id: Fl_File_Browser.H 8306 2011-01-24 17:04:22Z matt $" +// +// FileBrowser definitions. +// +// Copyright 1999-2010 by Michael Sweet. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_File_Browser widget . */ + +// +// Include necessary header files... +// + +#ifndef _Fl_File_Browser_H_ +# define _Fl_File_Browser_H_ + +# include "Fl_Browser.H" +# include "Fl_File_Icon.H" +# include "filename.H" + + +// +// Fl_File_Browser class... +// + +/** The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons. */ +class FL_EXPORT Fl_File_Browser : public Fl_Browser { + + int filetype_; + const char *directory_; + uchar iconsize_; + const char *pattern_; + + int full_height() const; + int item_height(void *) const; + int item_width(void *) const; + void item_draw(void *, int, int, int, int) const; + int incr_height() const { return (item_height(0)); } + +public: + enum { FILES, DIRECTORIES }; + + /** + The constructor creates the Fl_File_Browser widget at the specified position and size. + The destructor destroys the widget and frees all memory that has been allocated. + */ + Fl_File_Browser(int, int, int, int, const char * = 0); + + /** Sets or gets the size of the icons. The default size is 20 pixels. */ + uchar iconsize() const { return (iconsize_); }; + /** Sets or gets the size of the icons. The default size is 20 pixels. */ + void iconsize(uchar s) { iconsize_ = s; redraw(); }; + + /** + Sets or gets the filename filter. The pattern matching uses + the fl_filename_match() + function in FLTK. + */ + void filter(const char *pattern); + /** + Sets or gets the filename filter. The pattern matching uses + the fl_filename_match() + function in FLTK. + */ + const char *filter() const { return (pattern_); }; + + /** + Loads the specified directory into the browser. If icons have been + loaded then the correct icon is associated with each file in the list. + + <P>The sort argument specifies a sort function to be used with + fl_filename_list(). + */ + int load(const char *directory, Fl_File_Sort_F *sort = fl_numericsort); + + Fl_Fontsize textsize() const { return Fl_Browser::textsize(); }; + void textsize(Fl_Fontsize s) { Fl_Browser::textsize(s); iconsize_ = (uchar)(3 * s / 2); }; + + /** + Sets or gets the file browser type, FILES or + DIRECTORIES. When set to FILES, both + files and directories are shown. Otherwise only directories are + shown. + */ + int filetype() const { return (filetype_); }; + /** + Sets or gets the file browser type, FILES or + DIRECTORIES. When set to FILES, both + files and directories are shown. Otherwise only directories are + shown. + */ + void filetype(int t) { filetype_ = t; }; +}; + +#endif // !_Fl_File_Browser_H_ + +// +// End of "$Id: Fl_File_Browser.H 8306 2011-01-24 17:04:22Z matt $". +// diff --git a/common/fltk/FL/Fl_File_Chooser.H b/common/fltk/FL/Fl_File_Chooser.H new file mode 100644 index 00000000..3816621c --- /dev/null +++ b/common/fltk/FL/Fl_File_Chooser.H @@ -0,0 +1,247 @@ +// +// "$Id: Fl_File_Chooser.H 8786 2011-06-07 11:41:36Z manolo $" +// +// Fl_File_Chooser dialog for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// generated by Fast Light User Interface Designer (fluid) version 1.0300 + +#ifndef Fl_File_Chooser_H +#define Fl_File_Chooser_H +#include <FL/Fl.H> +#include <FL/Fl_Double_Window.H> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <FL/Fl_Group.H> +#include <FL/Fl_Choice.H> +#include <FL/Fl_Menu_Button.H> +#include <FL/Fl_Button.H> +#include <FL/Fl_Preferences.H> +#include <FL/Fl_Tile.H> +#include <FL/Fl_File_Browser.H> +#include <FL/Fl_Box.H> +#include <FL/Fl_Check_Button.H> +#include <FL/Fl_File_Input.H> +#include <FL/Fl_Return_Button.H> +#include <FL/fl_ask.H> + +class FL_EXPORT Fl_File_Chooser { +public: + enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 }; +private: + static Fl_Preferences prefs_; + void (*callback_)(Fl_File_Chooser*, void *); + void *data_; + char directory_[FL_PATH_MAX]; + char pattern_[FL_PATH_MAX]; + char preview_text_[2048]; + int type_; + void favoritesButtonCB(); + void favoritesCB(Fl_Widget *w); + void fileListCB(); + void fileNameCB(); + void newdir(); + static void previewCB(Fl_File_Chooser *fc); + void showChoiceCB(); + void update_favorites(); + void update_preview(); +public: + Fl_File_Chooser(const char *d, const char *p, int t, const char *title); +private: + Fl_Double_Window *window; + void cb_window_i(Fl_Double_Window*, void*); + static void cb_window(Fl_Double_Window*, void*); + Fl_Choice *showChoice; + void cb_showChoice_i(Fl_Choice*, void*); + static void cb_showChoice(Fl_Choice*, void*); + Fl_Menu_Button *favoritesButton; + void cb_favoritesButton_i(Fl_Menu_Button*, void*); + static void cb_favoritesButton(Fl_Menu_Button*, void*); +public: + Fl_Button *newButton; +private: + void cb_newButton_i(Fl_Button*, void*); + static void cb_newButton(Fl_Button*, void*); + void cb__i(Fl_Tile*, void*); + static void cb_(Fl_Tile*, void*); + Fl_File_Browser *fileList; + void cb_fileList_i(Fl_File_Browser*, void*); + static void cb_fileList(Fl_File_Browser*, void*); + Fl_Box *previewBox; +public: + Fl_Check_Button *previewButton; +private: + void cb_previewButton_i(Fl_Check_Button*, void*); + static void cb_previewButton(Fl_Check_Button*, void*); +public: + Fl_Check_Button *showHiddenButton; +private: + void cb_showHiddenButton_i(Fl_Check_Button*, void*); + static void cb_showHiddenButton(Fl_Check_Button*, void*); + Fl_File_Input *fileName; + void cb_fileName_i(Fl_File_Input*, void*); + static void cb_fileName(Fl_File_Input*, void*); + Fl_Return_Button *okButton; + void cb_okButton_i(Fl_Return_Button*, void*); + static void cb_okButton(Fl_Return_Button*, void*); + Fl_Button *cancelButton; + void cb_cancelButton_i(Fl_Button*, void*); + static void cb_cancelButton(Fl_Button*, void*); + Fl_Double_Window *favWindow; + Fl_File_Browser *favList; + void cb_favList_i(Fl_File_Browser*, void*); + static void cb_favList(Fl_File_Browser*, void*); + Fl_Button *favUpButton; + void cb_favUpButton_i(Fl_Button*, void*); + static void cb_favUpButton(Fl_Button*, void*); + Fl_Button *favDeleteButton; + void cb_favDeleteButton_i(Fl_Button*, void*); + static void cb_favDeleteButton(Fl_Button*, void*); + Fl_Button *favDownButton; + void cb_favDownButton_i(Fl_Button*, void*); + static void cb_favDownButton(Fl_Button*, void*); + Fl_Button *favCancelButton; + void cb_favCancelButton_i(Fl_Button*, void*); + static void cb_favCancelButton(Fl_Button*, void*); + Fl_Return_Button *favOkButton; + void cb_favOkButton_i(Fl_Return_Button*, void*); + static void cb_favOkButton(Fl_Return_Button*, void*); +public: + ~Fl_File_Chooser(); + void callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0); + void color(Fl_Color c); + Fl_Color color(); + int count(); + void directory(const char *d); + char * directory(); + void filter(const char *p); + const char * filter(); + int filter_value(); + void filter_value(int f); + void hide(); + void iconsize(uchar s); + uchar iconsize(); + void label(const char *l); + const char * label(); + void ok_label(const char *l); + const char * ok_label(); + void preview(int e); + int preview() const { return previewButton->value(); }; +private: + void showHidden(int e); + void remove_hidden_files(); +public: + void rescan(); + void rescan_keep_filename(); + void show(); + int shown(); + void textcolor(Fl_Color c); + Fl_Color textcolor(); + void textfont(Fl_Font f); + Fl_Font textfont(); + void textsize(Fl_Fontsize s); + Fl_Fontsize textsize(); + void type(int t); + int type(); + void * user_data() const; + void user_data(void *d); + const char *value(int f = 1); + void value(const char *filename); + int visible(); + /** + [standard text may be customized at run-time] + */ + static const char *add_favorites_label; + /** + [standard text may be customized at run-time] + */ + static const char *all_files_label; + /** + [standard text may be customized at run-time] + */ + static const char *custom_filter_label; + /** + [standard text may be customized at run-time] + */ + static const char *existing_file_label; + /** + [standard text may be customized at run-time] + */ + static const char *favorites_label; + /** + [standard text may be customized at run-time] + */ + static const char *filename_label; + /** + [standard text may be customized at run-time] + */ + static const char *filesystems_label; + /** + [standard text may be customized at run-time] + */ + static const char *manage_favorites_label; + /** + [standard text may be customized at run-time] + */ + static const char *new_directory_label; + /** + [standard text may be customized at run-time] + */ + static const char *new_directory_tooltip; + /** + [standard text may be customized at run-time] + */ + static const char *preview_label; + /** + [standard text may be customized at run-time] + */ + static const char *save_label; + /** + [standard text may be customized at run-time] + */ + static const char *show_label; + /** + [standard text may be customized at run-time] + */ + static const char *hidden_label; + /** + the sort function that is used when loading + the contents of a directory. + */ + static Fl_File_Sort_F *sort; +private: + Fl_Widget* ext_group; +public: + Fl_Widget* add_extra(Fl_Widget* gr); +}; +FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0); +FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0); +FL_EXPORT void fl_file_chooser_callback(void (*cb)(const char*)); +FL_EXPORT void fl_file_chooser_ok_label(const char*l); +#endif + +// +// End of "$Id: Fl_File_Chooser.H 8786 2011-06-07 11:41:36Z manolo $". +// diff --git a/common/fltk/FL/Fl_File_Icon.H b/common/fltk/FL/Fl_File_Icon.H new file mode 100644 index 00000000..7e67f027 --- /dev/null +++ b/common/fltk/FL/Fl_File_Icon.H @@ -0,0 +1,168 @@ +// +// "$Id: Fl_File_Icon.H 8306 2011-01-24 17:04:22Z matt $" +// +// Fl_File_Icon definitions. +// +// Copyright 1999-2010 by Michael Sweet. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_File_Icon widget . */ + +// +// Include necessary header files... +// + +#ifndef _Fl_Fl_File_Icon_H_ +# define _Fl_Fl_File_Icon_H_ + +# include "Fl.H" + + +// +// Special color value for the icon color. +// + +# define FL_ICON_COLOR (Fl_Color)0xffffffff /**< icon color [background?]*/ + + +// +// Fl_File_Icon class... +// + +/** + The Fl_File_Icon class manages icon images that can be used + as labels in other widgets and as icons in the FileBrowser widget. +*/ +class FL_EXPORT Fl_File_Icon { //// Icon data + + static Fl_File_Icon *first_; // Pointer to first icon/filetype + Fl_File_Icon *next_; // Pointer to next icon/filetype + const char *pattern_; // Pattern string + int type_; // Match only if directory or file? + int num_data_; // Number of data elements + int alloc_data_; // Number of allocated elements + short *data_; // Icon data + + public: + + enum // File types + { + ANY, // Any kind of file + PLAIN, // Only plain files + FIFO, // Only named pipes + DEVICE, // Only character and block devices + LINK, // Only symbolic links + DIRECTORY // Only directories + }; + + enum // Data opcodes + { + END, // End of primitive/icon + COLOR, // Followed by color value (2 shorts) + LINE, // Start of line + CLOSEDLINE, // Start of closed line + POLYGON, // Start of polygon + OUTLINEPOLYGON, // Followed by outline color (2 shorts) + VERTEX // Followed by scaled X,Y + }; + + Fl_File_Icon(const char *p, int t, int nd = 0, short *d = 0); + ~Fl_File_Icon(); + + short *add(short d); + + /** + Adds a color value to the icon array, returning a pointer to it. + \param[in] c color value + */ + short *add_color(Fl_Color c) + { short *d = add((short)COLOR); add((short)(c >> 16)); add((short)c); return (d); } + + /** + Adds a vertex value to the icon array, returning a pointer to it. + The integer version accepts coordinates from 0 to 10000. + The origin (0.0) is in the lower-lefthand corner of the icon. + \param[in] x, y vertex coordinates + */ + short *add_vertex(int x, int y) + { short *d = add((short)VERTEX); add((short)x); add((short)y); return (d); } + + /** + Adds a vertex value to the icon array, returning a pointer to it. + The floating point version goes from 0.0 to 1.0. + The origin (0.0) is in the lower-lefthand corner of the icon. + \param[in] x, y vertex coordinates + */ + short *add_vertex(float x, float y) + { short *d = add((short)VERTEX); add((short)(x * 10000.0)); + add((short)(y * 10000.0)); return (d); } + + /** Clears all icon data from the icon.*/ + void clear() { num_data_ = 0; } + + void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1); + + void label(Fl_Widget *w); + + static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a); + void load(const char *f); + int load_fti(const char *fti); + int load_image(const char *i); + + /** Returns next file icon object. See Fl_File_Icon::first() */ + Fl_File_Icon *next() { return (next_); } + + /** Returns the filename matching pattern for the icon.*/ + const char *pattern() { return (pattern_); } + + /** Returns the number of words of data used by the icon.*/ + int size() { return (num_data_); } + + /** + Returns the filetype associated with the icon, which can be one of the + following: + + \li Fl_File_Icon::ANY, any kind of file. + \li Fl_File_Icon::PLAIN, plain files. + \li Fl_File_Icon::FIFO, named pipes. + \li Fl_File_Icon::DEVICE, character and block devices. + \li Fl_File_Icon::LINK, symbolic links. + \li Fl_File_Icon::DIRECTORY, directories. + */ + int type() { return (type_); } + + /** Returns the data array for the icon.*/ + short *value() { return (data_); } + + static Fl_File_Icon *find(const char *filename, int filetype = ANY); + + /** Returns a pointer to the first icon in the list.*/ + static Fl_File_Icon *first() { return (first_); } + static void load_system_icons(void); +}; + +#endif // !_Fl_Fl_File_Icon_H_ + +// +// End of "$Id: Fl_File_Icon.H 8306 2011-01-24 17:04:22Z matt $". +// diff --git a/common/fltk/FL/Fl_File_Input.H b/common/fltk/FL/Fl_File_Input.H new file mode 100644 index 00000000..e3d27fab --- /dev/null +++ b/common/fltk/FL/Fl_File_Input.H @@ -0,0 +1,106 @@ +// +// "$Id: Fl_File_Input.H 8712 2011-05-22 09:45:40Z AlbrechtS $" +// +// File_Input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// Original version Copyright 1998 by Curtis Edwards. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_File_Input widget . */ + +#ifndef Fl_File_Input_H +# define Fl_File_Input_H + +# include <FL/Fl_Input.H> + +/** + \class Fl_File_Input + \brief This widget displays a pathname in a text input field. + + A navigation bar located above the input field allows the user to + navigate upward in the directory tree. + You may want to handle FL_WHEN_CHANGED events for tracking text changes + and also FL_WHEN_RELEASE for button release when changing to parent dir. + FL_WHEN_RELEASE callback won't be called if the directory clicked + is the same as the current one. + + <P align=CENTER> \image html Fl_File_Input.png </P> + \image latex Fl_File_Input.png "Fl_File_Input" width=6cm + + \note As all Fl_Input derived objects, Fl_File_Input may call its callback + when losing focus (see FL_UNFOCUS) to update its state like its cursor shape. + One resulting side effect is that you should call clear_changed() early in your callback + to avoid reentrant calls if you plan to show another window or dialog box in the callback. +*/ +class FL_EXPORT Fl_File_Input : public Fl_Input { + + Fl_Color errorcolor_; + char ok_entry_; + uchar down_box_; + short buttons_[200]; + short pressed_; + + void draw_buttons(); + int handle_button(int event); + void update_buttons(); + +public: + + Fl_File_Input(int X, int Y, int W, int H, const char *L=0); + + virtual int handle(int event); + +protected: + virtual void draw(); + +public: + /** Gets the box type used for the navigation bar. */ + Fl_Boxtype down_box() const { return (Fl_Boxtype)down_box_; } + /** Sets the box type to use for the navigation bar. */ + void down_box(Fl_Boxtype b) { down_box_ = b; } + + /** + Gets the current error color. + \todo Better docs for Fl_File_Input::errorcolor() - is it even used? + */ + Fl_Color errorcolor() const { return errorcolor_; } + /** Sets the current error color to \p c */ + void errorcolor(Fl_Color c) { errorcolor_ = c; } + + int value(const char *str); + int value(const char *str, int len); + + /** + Returns the current value, which is a pointer to an internal buffer + and is valid only until the next event is handled. + */ + const char *value() { return Fl_Input_::value(); } +}; + +#endif // !Fl_File_Input_H + + +// +// End of "$Id: Fl_File_Input.H 8712 2011-05-22 09:45:40Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Fill_Dial.H b/common/fltk/FL/Fl_Fill_Dial.H new file mode 100644 index 00000000..e3b8444c --- /dev/null +++ b/common/fltk/FL/Fl_Fill_Dial.H @@ -0,0 +1,48 @@ +// +// "$Id: Fl_Fill_Dial.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Filled dial header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Fill_Dial widget . */ + +#ifndef Fl_Fill_Dial_H +#define Fl_Fill_Dial_H + +#include "Fl_Dial.H" + +/** Draws a dial with a filled arc */ +class FL_EXPORT Fl_Fill_Dial : public Fl_Dial { +public: + /** Creates a filled dial, also setting its type to FL_FILL_DIAL. */ + Fl_Fill_Dial(int x,int y,int w,int h, const char *l = 0) + : Fl_Dial(x,y,w,h,l) {type(FL_FILL_DIAL);} +}; + +#endif + +// +// End of "$Id: Fl_Fill_Dial.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Fill_Slider.H b/common/fltk/FL/Fl_Fill_Slider.H new file mode 100644 index 00000000..05e22b19 --- /dev/null +++ b/common/fltk/FL/Fl_Fill_Slider.H @@ -0,0 +1,47 @@ +// +// "$Id: Fl_Fill_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Filled slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Fill_Slider widget . */ + +#ifndef Fl_Fill_Slider_H +#define Fl_Fill_Slider_H + +#include "Fl_Slider.H" +/** Widget that draws a filled horizontal slider, useful as a progress or value meter*/ +class FL_EXPORT Fl_Fill_Slider : public Fl_Slider { +public: + /** Creates the slider from its position,size and optional title. */ + Fl_Fill_Slider(int x,int y,int w,int h,const char *l=0) + : Fl_Slider(x,y,w,h,l) {type(FL_VERT_FILL_SLIDER);} +}; + +#endif + +// +// End of "$Id: Fl_Fill_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Float_Input.H b/common/fltk/FL/Fl_Float_Input.H new file mode 100644 index 00000000..f774dd37 --- /dev/null +++ b/common/fltk/FL/Fl_Float_Input.H @@ -0,0 +1,62 @@ +// +// "$Id: Fl_Float_Input.H 8726 2011-05-23 18:32:47Z AlbrechtS $" +// +// Floating point input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Float_Input widget . */ + + +#ifndef Fl_Float_Input_H +#define Fl_Float_Input_H + +#include "Fl_Input.H" + +/** + The Fl_Float_Input class is a subclass of Fl_Input + that only allows the user to type floating point numbers (sign, + digits, decimal point, more digits, 'E' or 'e', sign, digits). +*/ +class FL_EXPORT Fl_Float_Input : public Fl_Input { +public: + /** + Creates a new Fl_Float_Input widget using the given position, + size, and label string. The default boxtype is FL_DOWN_BOX. + + Inherited destructor destroys the widget and any value associated with it. + */ +#if defined(FL_DLL) // implementation in src/Fl_Input.cxx + Fl_Float_Input(int X,int Y,int W,int H,const char *l = 0); +#else + Fl_Float_Input(int X,int Y,int W,int H,const char *l = 0) + : Fl_Input(X,Y,W,H,l) {type(FL_FLOAT_INPUT);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Float_Input.H 8726 2011-05-23 18:32:47Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_FormsBitmap.H b/common/fltk/FL/Fl_FormsBitmap.H new file mode 100644 index 00000000..55582629 --- /dev/null +++ b/common/fltk/FL/Fl_FormsBitmap.H @@ -0,0 +1,56 @@ +// +// "$Id: Fl_FormsBitmap.H 7903 2010-11-28 21:06:39Z matt $" +// +// Forms bitmap header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_FormsBitmap widget . */ + +#ifndef Fl_FormsBitmap_H +#define Fl_FormsBitmap_H + +#include "Fl_Bitmap.H" + +/** + Forms compatibility Bitmap Image Widget +*/ +class FL_EXPORT Fl_FormsBitmap : public Fl_Widget { + Fl_Bitmap *b; +protected: + void draw(); +public: + Fl_FormsBitmap(Fl_Boxtype, int, int, int, int, const char * = 0); + void set(int W, int H, const uchar *bits); + /** Sets a new bitmap. */ + void bitmap(Fl_Bitmap *B) {b = B;} + /** Gets a the current associated Fl_Bitmap objects. */ + Fl_Bitmap *bitmap() const {return b;} +}; + +#endif + +// +// End of "$Id: Fl_FormsBitmap.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_FormsPixmap.H b/common/fltk/FL/Fl_FormsPixmap.H new file mode 100644 index 00000000..1eb01dee --- /dev/null +++ b/common/fltk/FL/Fl_FormsPixmap.H @@ -0,0 +1,63 @@ +// +// "$Id: Fl_FormsPixmap.H 7903 2010-11-28 21:06:39Z matt $" +// +// Forms pixmap header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_FormsPixmap widget . */ + +#ifndef Fl_FormsPixmap_H +#define Fl_FormsPixmap_H + +#include "Fl_Pixmap.H" + +/** + \class Fl_FormsPixmap + \brief Forms pixmap drawing routines +*/ +class FL_EXPORT Fl_FormsPixmap : public Fl_Widget { + Fl_Pixmap *b; +protected: + void draw(); +public: + Fl_FormsPixmap(Fl_Boxtype t, int X, int Y, int W, int H, const char *L= 0); + + void set(/*const*/char * const * bits); + + /** + Set the internal pixmap pointer to an existing pixmap. + \param[in] B existing pixmap + */ + void Pixmap(Fl_Pixmap *B) {b = B;} + + /** Get the internal pixmap pointer. */ + Fl_Pixmap *Pixmap() const {return b;} +}; + +#endif + +// +// End of "$Id: Fl_FormsPixmap.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Free.H b/common/fltk/FL/Fl_Free.H new file mode 100644 index 00000000..367443ca --- /dev/null +++ b/common/fltk/FL/Fl_Free.H @@ -0,0 +1,89 @@ +// +// "$Id: Fl_Free.H 7903 2010-11-28 21:06:39Z matt $" +// +// Forms free header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Free widget . */ + +#ifndef Fl_Free_H +#define Fl_Free_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +#define FL_NORMAL_FREE 1 /**< normal event handling */ +#define FL_SLEEPING_FREE 2 /**< deactivate event handling */ +#define FL_INPUT_FREE 3 /**< accepts FL_FOCUS events */ +#define FL_CONTINUOUS_FREE 4 /**< repeated timeout handling */ +#define FL_ALL_FREE 5 /**< FL_INPUT_FREE and FL_CONTINOUS_FREE */ + +/** appropriate signature for handle function */ +typedef int (*FL_HANDLEPTR)(Fl_Widget *, int , float, float, char); + +/** + Emulation of the Forms "free" widget. + + This emulation allows the free demo to run, and appears to be useful for + porting programs written in Forms which use the free widget or make + subclasses of the Forms widgets. + + There are five types of free, which determine when the handle function + is called: + + \li \c FL_NORMAL_FREE normal event handling. + \li \c FL_SLEEPING_FREE deactivates event handling (widget is inactive). + \li \c FL_INPUT_FREE accepts FL_FOCUS events. + \li \c FL_CONTINUOUS_FREE sets a timeout callback 100 times a second and + provides an FL_STEP event. This has obvious + detrimental effects on machine performance. + \li \c FL_ALL_FREE same as FL_INPUT_FREE and FL_CONTINUOUS_FREE. + +*/ +class FL_EXPORT Fl_Free : public Fl_Widget { + FL_HANDLEPTR hfunc; + static void step(void *); +protected: + void draw(); +public: + int handle(int e); + Fl_Free(uchar t,int X,int Y,int W,int H,const char *L,FL_HANDLEPTR hdl); + ~Fl_Free(); +}; + +// old event names for compatibility: +#define FL_MOUSE FL_DRAG /**< for backward compatibility */ +#define FL_DRAW 100 /**< for backward compatibility [UNUSED]*/ +#define FL_STEP 101 /**< for backward compatibility */ +#define FL_FREEMEM 102 /**< for backward compatibility [UNUSED]*/ +#define FL_FREEZE 103 /**< for backward compatibility [UNUSED]*/ +#define FL_THAW 104 /**< for backward compatibility [UNUSED]*/ + +#endif + +// +// End of "$Id: Fl_Free.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_GIF_Image.H b/common/fltk/FL/Fl_GIF_Image.H new file mode 100644 index 00000000..69f055b0 --- /dev/null +++ b/common/fltk/FL/Fl_GIF_Image.H @@ -0,0 +1,51 @@ +// +// "$Id: Fl_GIF_Image.H 7903 2010-11-28 21:06:39Z matt $" +// +// GIF image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_GIF_Image widget . */ + +#ifndef Fl_GIF_Image_H +#define Fl_GIF_Image_H +# include "Fl_Pixmap.H" + +/** + The Fl_GIF_Image class supports loading, caching, + and drawing of Compuserve GIF<SUP>SM</SUP> images. The class + loads the first image and supports transparency. +*/ +class FL_EXPORT Fl_GIF_Image : public Fl_Pixmap { + + public: + + Fl_GIF_Image(const char* filename); +}; + +#endif + +// +// End of "$Id: Fl_GIF_Image.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Gl_Window.H b/common/fltk/FL/Fl_Gl_Window.H new file mode 100644 index 00000000..02c5eb8f --- /dev/null +++ b/common/fltk/FL/Fl_Gl_Window.H @@ -0,0 +1,240 @@ +// +// "$Id: Fl_Gl_Window.H 8157 2011-01-01 14:01:53Z AlbrechtS $" +// +// OpenGL header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Gl_Window widget . */ + +#ifndef Fl_Gl_Window_H +#define Fl_Gl_Window_H + +#include "Fl_Window.H" + +#ifndef GLContext +/** + Opaque pointer type to hide system specific implementation. +*/ +typedef void* GLContext; // actually a GLXContext or HGLDC +#endif + +class Fl_Gl_Choice; // structure to hold result of glXChooseVisual + +/** + The Fl_Gl_Window widget sets things up so OpenGL works. + + It also keeps an OpenGL "context" for that window, so that changes to the + lighting and projection may be reused between redraws. Fl_Gl_Window + also flushes the OpenGL streams and swaps buffers after draw() returns. + + OpenGL hardware typically provides some overlay bit planes, which + are very useful for drawing UI controls atop your 3D graphics. If the + overlay hardware is not provided, FLTK tries to simulate the overlay. + This works pretty well if your graphics are double buffered, but not + very well for single-buffered. + + Please note that the FLTK drawing and clipping functions + will not work inside an Fl_Gl_Window. All drawing + should be done using OpenGL calls exclusively. + Even though Fl_Gl_Window is derived from Fl_Group, + it is not useful to add other FLTK Widgets as children, + unless those widgets are modified to draw using OpenGL calls. +*/ +class FL_EXPORT Fl_Gl_Window : public Fl_Window { + + int mode_; + const int *alist; + Fl_Gl_Choice *g; + GLContext context_; + char valid_f_; + char damage1_; // damage() of back buffer + virtual void draw_overlay(); + void init(); + + void *overlay; + void make_overlay(); + friend class _Fl_Gl_Overlay; + + static int can_do(int, const int *); + int mode(int, const int *); + +public: + + void show(); + void show(int a, char **b) {Fl_Window::show(a,b);} + void flush(); + void hide(); + void resize(int,int,int,int); + int handle(int); + + /** + Is turned off when FLTK creates a new context for this window or + when the window resizes, and is turned on \e after draw() is called. + You can use this inside your draw() method to avoid unnecessarily + initializing the OpenGL context. Just do this: + \code + void mywindow::draw() { + if (!valid()) { + glViewport(0,0,w(),h()); + glFrustum(...); + ...other initialization... + } + if (!context_valid()) { + ...load textures, etc. ... + } + ... draw your geometry here ... + } + \endcode + + You can turn valid() on by calling valid(1). You + should only do this after fixing the transformation inside a draw() + or after make_current(). This is done automatically after + draw() returns. + */ + char valid() const {return valid_f_ & 1;} + /** + See char Fl_Gl_Window::valid() const + */ + void valid(char v) {if (v) valid_f_ |= 1; else valid_f_ &= 0xfe;} + void invalidate(); + + /** + Will only be set if the + OpenGL context is created or recreated. It differs from + Fl_Gl_Window::valid() which is also set whenever the context + changes size. + */ + char context_valid() const {return valid_f_ & 2;} + /** + See char Fl_Gl_Window::context_valid() const + */ + void context_valid(char v) {if (v) valid_f_ |= 2; else valid_f_ &= 0xfd;} + + /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ + static int can_do(int m) {return can_do(m,0);} + /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ + static int can_do(const int *m) {return can_do(0, m);} + /** Returns non-zero if the hardware supports the given or current OpenGL mode. */ + int can_do() {return can_do(mode_,alist);} + /** + Set or change the OpenGL capabilites of the window. The value can be + any of the following OR'd together: + + - \c FL_RGB - RGB color (not indexed) + - \c FL_RGB8 - RGB color with at least 8 bits of each color + - \c FL_INDEX - Indexed mode + - \c FL_SINGLE - not double buffered + - \c FL_DOUBLE - double buffered + - \c FL_ACCUM - accumulation buffer + - \c FL_ALPHA - alpha channel in color + - \c FL_DEPTH - depth buffer + - \c FL_STENCIL - stencil buffer + - \c FL_MULTISAMPLE - multisample antialiasing + + FL_RGB and FL_SINGLE have a value of zero, so they + are "on" unless you give FL_INDEX or FL_DOUBLE. + + If the desired combination cannot be done, FLTK will try turning off + FL_MULTISAMPLE. If this also fails the show() will call + Fl::error() and not show the window. + + You can change the mode while the window is displayed. This is most + useful for turning double-buffering on and off. Under X this will + cause the old X window to be destroyed and a new one to be created. If + this is a top-level window this will unfortunately also cause the + window to blink, raise to the top, and be de-iconized, and the xid() + will change, possibly breaking other code. It is best to make the GL + window a child of another window if you wish to do this! + + mode() must not be called within draw() since it + changes the current context. + */ + Fl_Mode mode() const {return (Fl_Mode)mode_;} + /** See Fl_Mode mode() const */ + int mode(int a) {return mode(a,0);} + /** See Fl_Mode mode() const */ + int mode(const int *a) {return mode(0, a);} + /** void See void context(void* v, int destroy_flag) */ + void* context() const {return context_;} + void context(void*, int destroy_flag = 0); + void make_current(); + void swap_buffers(); + void ortho(); + + /** + Returns true if the hardware overlay is possible. If this is false, + FLTK will try to simulate the overlay, with significant loss of update + speed. Calling this will cause FLTK to open the display. + */ + int can_do_overlay(); + /** + This method causes draw_overlay() to be called at a later time. + Initially the overlay is clear. If you want the window to display + something in the overlay when it first appears, you must call this + immediately after you show() your window. + */ + void redraw_overlay(); + void hide_overlay(); + /** + The make_overlay_current() method selects the OpenGL context + for the widget's overlay. It is called automatically prior to the + draw_overlay() method being called and can also be used to + implement feedback and/or selection within the handle() + method. + */ + void make_overlay_current(); + + // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. + virtual Fl_Gl_Window* as_gl_window() {return this;} + + ~Fl_Gl_Window(); + /** + Creates a new Fl_Gl_Window widget using the given size, and label string. + The default boxtype is FL_NO_BOX. The default mode is FL_RGB|FL_DOUBLE|FL_DEPTH. + */ + Fl_Gl_Window(int W, int H, const char *l=0) : Fl_Window(W,H,l) {init();} + /** + Creates a new Fl_Gl_Window widget using the given position, + size, and label string. The default boxtype is FL_NO_BOX. The + default mode is FL_RGB|FL_DOUBLE|FL_DEPTH. + */ + + Fl_Gl_Window(int X, int Y, int W, int H, const char *l=0) + : Fl_Window(X,Y,W,H,l) {init();} + +protected: + /** + Draws the Fl_Gl_Window. + + You \e \b must override the draw() method. + */ + virtual void draw(); +}; + +#endif + +// +// End of "$Id: Fl_Gl_Window.H 8157 2011-01-01 14:01:53Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Group.H b/common/fltk/FL/Fl_Group.H new file mode 100644 index 00000000..0056e103 --- /dev/null +++ b/common/fltk/FL/Fl_Group.H @@ -0,0 +1,230 @@ +// +// "$Id: Fl_Group.H 8157 2011-01-01 14:01:53Z AlbrechtS $" +// +// Group header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Group, Fl_End classes . */ + +#ifndef Fl_Group_H +#define Fl_Group_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +/** + The Fl_Group class is the FLTK container widget. It maintains + an array of child widgets. These children can themselves be any widget + including Fl_Group. The most important subclass of Fl_Group + is Fl_Window, however groups can also be used to control radio buttons + or to enforce resize behavior. +*/ +class FL_EXPORT Fl_Group : public Fl_Widget { + + Fl_Widget** array_; + Fl_Widget* savedfocus_; + Fl_Widget* resizable_; + int children_; + int *sizes_; // remembered initial sizes of children + + int navigation(int); + static Fl_Group *current_; + + // unimplemented copy ctor and assignment operator + Fl_Group(const Fl_Group&); + Fl_Group& operator=(const Fl_Group&); + +protected: + void draw(); + void draw_child(Fl_Widget& widget) const; + void draw_children(); + void draw_outside_label(const Fl_Widget& widget) const ; + void update_child(Fl_Widget& widget) const; + int *sizes(); + +public: + + int handle(int); + void begin(); + void end(); + static Fl_Group *current(); + static void current(Fl_Group *g); + + /** + Returns how many child widgets the group has. + */ + int children() const {return children_;} + /** + Returns array()[n]. <i>No range checking is done!</i> + */ + Fl_Widget* child(int n) const {return array()[n];} + int find(const Fl_Widget*) const; + /** + See int Fl_Group::find(const Fl_Widget *w) const + */ + int find(const Fl_Widget& o) const {return find(&o);} + Fl_Widget* const* array() const; + + void resize(int,int,int,int); + /** + Creates a new Fl_Group widget using the given position, size, + and label string. The default boxtype is FL_NO_BOX. + */ + Fl_Group(int,int,int,int, const char * = 0); + virtual ~Fl_Group(); + void add(Fl_Widget&); + /** + See void Fl_Group::add(Fl_Widget &w) + */ + void add(Fl_Widget* o) {add(*o);} + void insert(Fl_Widget&, int i); + /** + This does insert(w, find(before)). This will append the + widget if \p before is not in the group. + */ + void insert(Fl_Widget& o, Fl_Widget* before) {insert(o,find(before));} + void remove(int index); + void remove(Fl_Widget&); + /** + Removes the widget \p o from the group. + \sa void remove(Fl_Widget&) + */ + void remove(Fl_Widget* o) {remove(*o);} + void clear(); + + /** + See void Fl_Group::resizable(Fl_Widget *box) + */ + void resizable(Fl_Widget& o) {resizable_ = &o;} + /** + The resizable widget defines the resizing box for the group. When the + group is resized it calculates a new size and position for all of its + children. Widgets that are horizontally or vertically inside the + dimensions of the box are scaled to the new size. Widgets outside the + box are moved. + + In these examples the gray area is the resizable: + + \image html resizebox1.png + + \image html resizebox2.png + + \image latex resizebox1.png "before resize" width=4cm + + \image latex resizebox2.png "after resize" width=4cm + + The resizable may be set to the group itself, in which case all the + contents are resized. This is the default value for Fl_Group, + although NULL is the default for Fl_Window and Fl_Pack. + + If the resizable is NULL then all widgets remain a fixed size + and distance from the top-left corner. + + It is possible to achieve any type of resize behavior by using an + invisible Fl_Box as the resizable and/or by using a hierarchy + of child Fl_Group's. + */ + void resizable(Fl_Widget* o) {resizable_ = o;} + /** + See void Fl_Group::resizable(Fl_Widget *box) + */ + Fl_Widget* resizable() const {return resizable_;} + /** + Adds a widget to the group and makes it the resizable widget. + */ + void add_resizable(Fl_Widget& o) {resizable_ = &o; add(o);} + void init_sizes(); + + /** + Controls whether the group widget clips the drawing of + child widgets to its bounding box. + + Set \p c to 1 if you want to clip the child widgets to the + bounding box. + + The default is to not clip (0) the drawing of child widgets. + */ + void clip_children(int c) { if (c) set_flag(CLIP_CHILDREN); else clear_flag(CLIP_CHILDREN); } + /** + Returns the current clipping mode. + + \return true, if clipping is enabled, false otherwise. + + \see void Fl_Group::clip_children(int c) + */ + unsigned int clip_children() { return (flags() & CLIP_CHILDREN) != 0; } + + // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. + virtual Fl_Group* as_group() { return this; } + + // back compatibility functions: + + /** + \deprecated This is for backwards compatibility only. You should use + \e W->%take_focus() instead. + \sa Fl_Widget::take_focus(); + */ + void focus(Fl_Widget* W) {W->take_focus();} + + /** This is for forms compatibility only */ + Fl_Widget* & _ddfdesign_kludge() {return resizable_;} + + /** This is for forms compatibility only */ + void forms_end(); +}; + +// dummy class used to end child groups in constructors for complex +// subclasses of Fl_Group: +/** + This is a dummy class that allows you to end a Fl_Group in a constructor list of a + class: + \code + class MyClass { + Fl_Group group; + Fl_Button button_in_group; + Fl_End end; + Fl_Button button_outside_group; + MyClass(); + }; + MyClass::MyClass() : + group(10,10,100,100), + button_in_group(20,20,60,30), + end(), + button_outside_group(10,120,60,30) + {} + \endcode +*/ +class FL_EXPORT Fl_End { +public: + /** All it does is calling Fl_Group::current()->end() */ + Fl_End() {Fl_Group::current()->end();} +}; + +#endif + +// +// End of "$Id: Fl_Group.H 8157 2011-01-01 14:01:53Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Help_Dialog.H b/common/fltk/FL/Fl_Help_Dialog.H new file mode 100644 index 00000000..7cb2aef5 --- /dev/null +++ b/common/fltk/FL/Fl_Help_Dialog.H @@ -0,0 +1,95 @@ +// +// "$Id: Fl_Help_Dialog.H 8063 2010-12-19 21:20:10Z matt $" +// +// Fl_Help_Dialog dialog for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Help_Dialog widget . */ + +// generated by Fast Light User Interface Designer (fluid) version 1.0108 + +#ifndef Fl_Help_Dialog_H +#define Fl_Help_Dialog_H +#include <FL/Fl.H> +#include <FL/Fl_Double_Window.H> +#include <FL/Fl_Group.H> +#include <FL/Fl_Button.H> +#include <FL/Fl_Input.H> +#include <FL/Fl_Box.H> +#include <FL/Fl_Help_View.H> + +class FL_EXPORT Fl_Help_Dialog { + int index_; + int max_; + int line_[100]; // FIXME: we must remove those static numbers + char file_[100][FL_PATH_MAX]; // FIXME: we must remove those static numbers + int find_pos_; +public: + Fl_Help_Dialog(); +private: + Fl_Double_Window *window_; + Fl_Button *back_; + void cb_back__i(Fl_Button*, void*); + static void cb_back_(Fl_Button*, void*); + Fl_Button *forward_; + void cb_forward__i(Fl_Button*, void*); + static void cb_forward_(Fl_Button*, void*); + Fl_Button *smaller_; + void cb_smaller__i(Fl_Button*, void*); + static void cb_smaller_(Fl_Button*, void*); + Fl_Button *larger_; + void cb_larger__i(Fl_Button*, void*); + static void cb_larger_(Fl_Button*, void*); + Fl_Input *find_; + void cb_find__i(Fl_Input*, void*); + static void cb_find_(Fl_Input*, void*); + Fl_Help_View *view_; + void cb_view__i(Fl_Help_View*, void*); + static void cb_view_(Fl_Help_View*, void*); +public: + ~Fl_Help_Dialog(); + int h(); + void hide(); + void load(const char *f); + void position(int xx, int yy); + void resize(int xx, int yy, int ww, int hh); + void show(); + void show(int argc, char **argv); + void textsize(Fl_Fontsize s); + Fl_Fontsize textsize(); + void topline(const char *n); + void topline(int n); + void value(const char *f); + const char * value() const; + int visible(); + int w(); + int x(); + int y(); +}; +#endif + +// +// End of "$Id: Fl_Help_Dialog.H 8063 2010-12-19 21:20:10Z matt $". +// diff --git a/common/fltk/FL/Fl_Help_View.H b/common/fltk/FL/Fl_Help_View.H new file mode 100644 index 00000000..c0ee66db --- /dev/null +++ b/common/fltk/FL/Fl_Help_View.H @@ -0,0 +1,396 @@ +// +// "$Id: Fl_Help_View.H 8306 2011-01-24 17:04:22Z matt $" +// +// Help Viewer widget definitions. +// +// Copyright 1997-2010 by Easy Software Products. +// Image support by Matthias Melcher, Copyright 2000-2009. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Help_View widget . */ + +#ifndef Fl_Help_View_H +# define Fl_Help_View_H + +// +// Include necessary header files... +// + +# include <stdio.h> +# include "Fl.H" +# include "Fl_Group.H" +# include "Fl_Scrollbar.H" +# include "fl_draw.H" +# include "Fl_Shared_Image.H" +# include "filename.H" + + +// +// Fl_Help_Func type - link callback function for files... +// + + +typedef const char *(Fl_Help_Func)(Fl_Widget *, const char *); + + +// +// Fl_Help_Block structure... +// + +struct Fl_Help_Block { + const char *start, // Start of text + *end; // End of text + uchar border; // Draw border? + Fl_Color bgcolor; // Background color + int x, // Indentation/starting X coordinate + y, // Starting Y coordinate + w, // Width + h; // Height + int line[32]; // Left starting position for each line +}; + +// +// Fl_Help_Link structure... +// +/** Definition of a link for the html viewer. */ +struct Fl_Help_Link { + char filename[192], ///< Reference filename + name[32]; ///< Link target (blank if none) + int x, ///< X offset of link text + y, ///< Y offset of link text + w, ///< Width of link text + h; ///< Height of link text +}; + +/* + * Fl_Help_View font stack opaque implementation + */ + +/** Fl_Help_View font stack element definition. */ +struct FL_EXPORT Fl_Help_Font_Style { + Fl_Font f; ///< Font + Fl_Fontsize s; ///< Font Size + Fl_Color c; ///< Font Color + void get(Fl_Font &afont, Fl_Fontsize &asize, Fl_Color &acolor) {afont=f; asize=s; acolor=c;} ///< Gets current font attributes + void set(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor) {f=afont; s=asize; c=acolor;} ///< Sets current font attributes + Fl_Help_Font_Style(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor) {set(afont, asize, acolor);} + Fl_Help_Font_Style(){} // For in table use +}; + +/** Fl_Help_View font stack definition. */ +const size_t MAX_FL_HELP_FS_ELTS = 100; + +struct FL_EXPORT Fl_Help_Font_Stack { + /** font stack construction, initialize attributes. */ + Fl_Help_Font_Stack() { + nfonts_ = 0; + } + + void init(Fl_Font f, Fl_Fontsize s, Fl_Color c) { + nfonts_ = 0; + elts_[nfonts_].set(f, s, c); + fl_font(f, s); + fl_color(c); + } + /** Gets the top (current) element on the stack. */ + void top(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { elts_[nfonts_].get(f, s, c); } + /** Pushes the font style triplet on the stack, also calls fl_font() & fl_color() adequately */ + void push(Fl_Font f, Fl_Fontsize s, Fl_Color c) { + if (nfonts_ < MAX_FL_HELP_FS_ELTS-1) nfonts_ ++; + elts_[nfonts_].set(f, s, c); + fl_font(f, s); fl_color(c); + } + /** Pops from the stack the font style triplet and calls fl_font() & fl_color() adequately */ + void pop(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { + if (nfonts_ > 0) nfonts_ --; + top(f, s, c); + fl_font(f, s); fl_color(c); + } + /** Gets the current count of font style elements in the stack. */ + size_t count() const {return nfonts_;} // Gets the current number of fonts in the stack + +protected: + size_t nfonts_; ///< current number of fonts in stack + Fl_Help_Font_Style elts_[100]; ///< font elements +}; + +/** Fl_Help_Target structure */ + +struct Fl_Help_Target { + char name[32]; ///< Target name + int y; ///< Y offset of target +}; + +/** + The Fl_Help_View widget displays HTML text. Most HTML 2.0 + elements are supported, as well as a primitive implementation of tables. + GIF, JPEG, and PNG images are displayed inline. + + Supported HTML tags: + - A: HREF/NAME + - B + - BODY: BGCOLOR/TEXT/LINK + - BR + - CENTER + - CODE + - DD + - DL + - DT + - EM + - FONT: COLOR/SIZE/FACE=(helvetica/arial/sans/times/serif/symbol/courier) + - H1/H2/H3/H4/H5/H6 + - HEAD + - HR + - I + - IMG: SRC/WIDTH/HEIGHT/ALT + - KBD + - LI + - OL + - P + - PRE + - STRONG + - TABLE: TH/TD/TR/BORDER/BGCOLOR/COLSPAN/ALIGN=CENTER|RIGHT|LEFT + - TITLE + - TT + - U + - UL + - VAR + + Supported color names: + - black,red,green,yellow,blue,magenta,fuchsia,cyan,aqua,white,gray,grey,lime,maroon,navy,olive,purple,silver,teal. + + Supported urls: + - Internal: file: + - External: http: ftp: https: ipp: mailto: news: + + Quoted char names: + - Aacute aacute Acirc acirc acute AElig aelig Agrave agrave amp Aring aring Atilde atilde Auml auml + - brvbar bull + - Ccedil ccedil cedil cent copy curren + - deg divide + - Eacute eacute Ecirc ecirc Egrave egrave ETH eth Euml euml euro + - frac12 frac14 frac34 + - gt + - Iacute iacute Icirc icirc iexcl Igrave igrave iquest Iuml iuml + - laquo lt + - macr micro middot + - nbsp not Ntilde ntilde + - Oacute oacute Ocirc ocirc Ograve ograve ordf ordm Oslash oslash Otilde otilde Ouml ouml + - para premil plusmn pound + - quot + - raquo reg + - sect shy sup1 sup2 sup3 szlig + - THORN thorn times trade + - Uacute uacute Ucirc ucirc Ugrave ugrave uml Uuml uuml + - Yacute yacute + - yen Yuml yuml + +*/ +class FL_EXPORT Fl_Help_View : public Fl_Group { // Help viewer widget + + enum { RIGHT = -1, CENTER, LEFT }; ///< Alignments + + char title_[1024]; ///< Title string + Fl_Color defcolor_, ///< Default text color + bgcolor_, ///< Background color + textcolor_, ///< Text color + linkcolor_; ///< Link color + Fl_Font textfont_; ///< Default font for text + Fl_Fontsize textsize_; ///< Default font size + const char *value_; ///< HTML text value + Fl_Help_Font_Stack fstack_; ///< font stack management + int nblocks_, ///< Number of blocks/paragraphs + ablocks_; ///< Allocated blocks + Fl_Help_Block *blocks_; ///< Blocks + + Fl_Help_Func *link_; ///< Link transform function + + int nlinks_, ///< Number of links + alinks_; ///< Allocated links + Fl_Help_Link *links_; ///< Links + + int ntargets_, ///< Number of targets + atargets_; ///< Allocated targets + Fl_Help_Target *targets_; ///< Targets + + char directory_[FL_PATH_MAX];///< Directory for current file + char filename_[FL_PATH_MAX]; ///< Current filename + int topline_, ///< Top line in document + leftline_, ///< Lefthand position + size_, ///< Total document length + hsize_, ///< Maximum document width + scrollbar_size_; ///< Size for both scrollbars + Fl_Scrollbar scrollbar_, ///< Vertical scrollbar for document + hscrollbar_; ///< Horizontal scrollbar + + static int selection_first; + static int selection_last; + static int selection_push_first; + static int selection_push_last; + static int selection_drag_first; + static int selection_drag_last; + static int selected; + static int draw_mode; + static int mouse_x; + static int mouse_y; + static int current_pos; + static Fl_Help_View *current_view; + static Fl_Color hv_selection_color; + static Fl_Color hv_selection_text_color; + + + void initfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { f = textfont_; s = textsize_; c = textcolor_; fstack_.init(f, s, c); } + void pushfont(Fl_Font f, Fl_Fontsize s) {fstack_.push(f, s, textcolor_);} + void pushfont(Fl_Font f, Fl_Fontsize s, Fl_Color c) {fstack_.push(f, s, c);} + void popfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) {fstack_.pop(f, s, c);} + + Fl_Help_Block *add_block(const char *s, int xx, int yy, int ww, int hh, uchar border = 0); + void add_link(const char *n, int xx, int yy, int ww, int hh); + void add_target(const char *n, int yy); + static int compare_targets(const Fl_Help_Target *t0, const Fl_Help_Target *t1); + int do_align(Fl_Help_Block *block, int line, int xx, int a, int &l); + void draw(); + void format(); + void format_table(int *table_width, int *columns, const char *table); + void free_data(); + int get_align(const char *p, int a); + const char *get_attr(const char *p, const char *n, char *buf, int bufsize); + Fl_Color get_color(const char *n, Fl_Color c); + Fl_Shared_Image *get_image(const char *name, int W, int H); + int get_length(const char *l); + int handle(int); + + void hv_draw(const char *t, int x, int y); + char begin_selection(); + char extend_selection(); + void end_selection(int c=0); + void clear_global_selection(); + Fl_Help_Link *find_link(int, int); + void follow_link(Fl_Help_Link*); + +public: + + Fl_Help_View(int xx, int yy, int ww, int hh, const char *l = 0); + ~Fl_Help_View(); + /** Returns the current directory for the text in the buffer. */ + const char *directory() const { if (directory_[0]) return (directory_); + else return ((const char *)0); } + /** Returns the current filename for the text in the buffer. */ + const char *filename() const { if (filename_[0]) return (filename_); + else return ((const char *)0); } + int find(const char *s, int p = 0); + /** + This method assigns a callback function to use when a link is + followed or a file is loaded (via Fl_Help_View::load()) that + requires a different file or path. + + The callback function receives a pointer to the Fl_Help_View + widget and the URI or full pathname for the file in question. + It must return a pathname that can be opened as a local file or NULL: + + \code + const char *fn(Fl_Widget *w, const char *uri); + \endcode + + The link function can be used to retrieve remote or virtual + documents, returning a temporary file that contains the actual + data. If the link function returns NULL, the value of + the Fl_Help_View widget will remain unchanged. + + If the link callback cannot handle the URI scheme, it should + return the uri value unchanged or set the value() of the widget + before returning NULL. + */ + void link(Fl_Help_Func *fn) { link_ = fn; } + int load(const char *f); + void resize(int,int,int,int); + /** Gets the size of the help view. */ + int size() const { return (size_); } + void size(int W, int H) { Fl_Widget::size(W, H); } + /** Sets the default text color. */ + void textcolor(Fl_Color c) { if (textcolor_ == defcolor_) textcolor_ = c; defcolor_ = c; } + /** Returns the current default text color. */ + Fl_Color textcolor() const { return (defcolor_); } + /** Sets the default text font. */ + void textfont(Fl_Font f) { textfont_ = f; format(); } + /** Returns the current default text font. */ + Fl_Font textfont() const { return (textfont_); } + /** Sets the default text size. */ + void textsize(Fl_Fontsize s) { textsize_ = s; format(); } + /** Gets the default text size. */ + Fl_Fontsize textsize() const { return (textsize_); } + /** Returns the current document title, or NULL if there is no title. */ + const char *title() { return (title_); } + void topline(const char *n); + void topline(int); + /** Returns the current top line in pixels. */ + int topline() const { return (topline_); } + void leftline(int); + /** Gets the left position in pixels. */ + int leftline() const { return (leftline_); } + void value(const char *val); + /** Returns the current buffer contents. */ + const char *value() const { return (value_); } + void clear_selection(); + void select_all(); + /** + Gets the current size of the scrollbars' troughs, in pixels. + + If this value is zero (default), this widget will use the + Fl::scrollbar_size() value as the scrollbar's width. + + \returns Scrollbar size in pixels, or 0 if the global Fl::scrollbar_size() is being used. + \see Fl::scrollbar_size(int) + */ + int scrollbar_size() const { + return(scrollbar_size_); + } + /** + Sets the pixel size of the scrollbars' troughs to the \p size, in pixels. + + Normally you should not need this method, and should use + Fl::scrollbar_size(int) instead to manage the size of ALL + your widgets' scrollbars. This ensures your application + has a consistent UI, is the default behavior, and is normally + what you want. + + Only use THIS method if you really need to override the global + scrollbar size. The need for this should be rare. + + Setting \p size to the special value of 0 causes the widget to + track the global Fl::scrollbar_size(), which is the default. + + \param[in] size Sets the scrollbar size in pixels.\n + If 0 (default), scrollbar size tracks the global Fl::scrollbar_size() + \see Fl::scrollbar_size() + */ + void scrollbar_size(int size) { + scrollbar_size_ = size; + } +}; + +#endif // !Fl_Help_View_H + +// +// End of "$Id: Fl_Help_View.H 8306 2011-01-24 17:04:22Z matt $". +// diff --git a/common/fltk/FL/Fl_Hold_Browser.H b/common/fltk/FL/Fl_Hold_Browser.H new file mode 100644 index 00000000..37d05b5a --- /dev/null +++ b/common/fltk/FL/Fl_Hold_Browser.H @@ -0,0 +1,65 @@ +// +// "$Id: Fl_Hold_Browser.H 8736 2011-05-24 20:00:56Z AlbrechtS $" +// +// Hold browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Hold_Browser widget . */ + +#ifndef Fl_Hold_Browser_H +#define Fl_Hold_Browser_H + +#include "Fl_Browser.H" + +/** + The Fl_Hold_Browser is a subclass of Fl_Browser + which lets the user select a single item, or no items by clicking on + the empty space. As long as the mouse button is held down the item + pointed to by it is highlighted, and this highlighting remains on when + the mouse button is released. Normally the callback is done when the + user releases the mouse, but you can change this with when(). + <P>See Fl_Browser for methods to add and remove lines from the browser. +*/ +class FL_EXPORT Fl_Hold_Browser : public Fl_Browser { +public: + /** + Creates a new Fl_Hold_Browser widget using the given + position, size, and label string. The default boxtype is FL_DOWN_BOX. + The constructor specializes Fl_Browser() by setting the type to FL_HOLD_BROWSER. + The destructor destroys the widget and frees all memory that has been allocated. + */ +#if defined(FL_DLL) // implementation in src/Fl_Browser.cxx + Fl_Hold_Browser(int X,int Y,int W,int H,const char *L=0); +#else + Fl_Hold_Browser(int X,int Y,int W,int H,const char *L=0) + : Fl_Browser(X,Y,W,H,L) {type(FL_HOLD_BROWSER);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Hold_Browser.H 8736 2011-05-24 20:00:56Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Hor_Fill_Slider.H b/common/fltk/FL/Fl_Hor_Fill_Slider.H new file mode 100644 index 00000000..3c5a0631 --- /dev/null +++ b/common/fltk/FL/Fl_Hor_Fill_Slider.H @@ -0,0 +1,46 @@ +// +// "$Id: Fl_Hor_Fill_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Horizontal fill slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Hor_Fill_Slider widget . */ + +#ifndef Fl_Hor_Fill_Slider_H +#define Fl_Hor_Fill_Slider_H + +#include "Fl_Slider.H" + +class FL_EXPORT Fl_Hor_Fill_Slider : public Fl_Slider { +public: + Fl_Hor_Fill_Slider(int x,int y,int w,int h,const char *l=0) + : Fl_Slider(x,y,w,h,l) {type(FL_HOR_FILL_SLIDER);} +}; + +#endif + +// +// End of "$Id: Fl_Hor_Fill_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Hor_Nice_Slider.H b/common/fltk/FL/Fl_Hor_Nice_Slider.H new file mode 100644 index 00000000..1305a54e --- /dev/null +++ b/common/fltk/FL/Fl_Hor_Nice_Slider.H @@ -0,0 +1,46 @@ +// +// "$Id: Fl_Hor_Nice_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Horizontal "nice" slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Hor_Nice_Slider widget . */ + +#ifndef Fl_Hor_Nice_Slider_H +#define Fl_Hor_Nice_Slider_H + +#include "Fl_Slider.H" + +class FL_EXPORT Fl_Hor_Nice_Slider : public Fl_Slider { +public: + Fl_Hor_Nice_Slider(int x,int y,int w,int h,const char *l=0) + : Fl_Slider(x,y,w,h,l) {type(FL_HOR_NICE_SLIDER); box(FL_FLAT_BOX);} +}; + +#endif + +// +// End of "$Id: Fl_Hor_Nice_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Hor_Slider.H b/common/fltk/FL/Fl_Hor_Slider.H new file mode 100644 index 00000000..82a88cbc --- /dev/null +++ b/common/fltk/FL/Fl_Hor_Slider.H @@ -0,0 +1,60 @@ +// +// "$Id: Fl_Hor_Slider.H 8726 2011-05-23 18:32:47Z AlbrechtS $" +// +// Horizontal slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Hor_Slider widget . */ + +#ifndef Fl_Hor_Slider_H +#define Fl_Hor_Slider_H + +#include "Fl_Slider.H" + +/** Horizontal Slider class. + + \see class Fl_Slider. +*/ +class FL_EXPORT Fl_Hor_Slider : public Fl_Slider { +public: + + /** + Creates a new Fl_Hor_Slider widget using the given position, + size, and label string. + */ + +#if defined(FL_DLL) // implementation in src/Fl_Slider.cxx + Fl_Hor_Slider(int X,int Y,int W,int H,const char *l=0); +#else + Fl_Hor_Slider(int X,int Y,int W,int H,const char *l=0) + : Fl_Slider(X,Y,W,H,l) { type(FL_HOR_SLIDER); } +#endif +}; + +#endif + +// +// End of "$Id: Fl_Hor_Slider.H 8726 2011-05-23 18:32:47Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Hor_Value_Slider.H b/common/fltk/FL/Fl_Hor_Value_Slider.H new file mode 100644 index 00000000..29994484 --- /dev/null +++ b/common/fltk/FL/Fl_Hor_Value_Slider.H @@ -0,0 +1,46 @@ +// +// "$Id: Fl_Hor_Value_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Horizontal value slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Hor_Value_Slider widget . */ + +#ifndef Fl_Hor_Value_Slider_H +#define Fl_Hor_Value_Slider_H + +#include "Fl_Value_Slider.H" + +class FL_EXPORT Fl_Hor_Value_Slider : public Fl_Value_Slider { +public: + Fl_Hor_Value_Slider(int X,int Y,int W,int H,const char *l=0) + : Fl_Value_Slider(X,Y,W,H,l) {type(FL_HOR_SLIDER);} +}; + +#endif + +// +// End of "$Id: Fl_Hor_Value_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Image.H b/common/fltk/FL/Fl_Image.H new file mode 100644 index 00000000..eb1e7e3f --- /dev/null +++ b/common/fltk/FL/Fl_Image.H @@ -0,0 +1,215 @@ +// +// "$Id: Fl_Image.H 8338 2011-01-30 09:24:40Z manolo $" +// +// Image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Image, Fl_RGB_Image classes . */ + +#ifndef Fl_Image_H +# define Fl_Image_H + +# include "Enumerations.H" + +class Fl_Widget; +struct Fl_Menu_Item; +struct Fl_Label; + +/** + Fl_Image is the base class used for caching and + drawing all kinds of images in FLTK. This class keeps track of + common image data such as the pixels, colormap, width, height, + and depth. Virtual methods are used to provide type-specific + image handling.</P> + + <P>Since the Fl_Image class does not support image + drawing by itself, calling the draw() method results in + a box with an X in it being drawn instead. +*/ +class FL_EXPORT Fl_Image { + int w_, h_, d_, ld_, count_; + const char * const *data_; + + // Forbid use of copy contructor and assign operator + Fl_Image & operator=(const Fl_Image &); + Fl_Image(const Fl_Image &); + + protected: + + /** + Sets the current image width in pixels. + */ + void w(int W) {w_ = W;} + /** + Sets the current image height in pixels. + */ + void h(int H) {h_ = H;} + /** + Sets the current image depth. + */ + void d(int D) {d_ = D;} + /** + Sets the current line data size in bytes. + */ + void ld(int LD) {ld_ = LD;} + /** + Sets the current array pointer and count of pointers in the array. + */ + void data(const char * const *p, int c) {data_ = p; count_ = c;} + void draw_empty(int X, int Y); + + static void labeltype(const Fl_Label *lo, int lx, int ly, int lw, int lh, Fl_Align la); + static void measure(const Fl_Label *lo, int &lw, int &lh); + + public: + + /** + Returns the current image width in pixels. + */ + int w() const {return w_;} + /** Returns the current image height in pixels. + */ + int h() const {return h_;} + /** + Returns the current image depth. + The return value will be 0 for bitmaps, 1 for + pixmaps, and 1 to 4 for color images.</P> + */ + int d() const {return d_;} + /** + Returns the current line data size in bytes. + Line data is extra data that is included + after each line of color image data and is normally not present. + */ + int ld() const {return ld_;} + /** + The count() method returns the number of data values + associated with the image. The value will be 0 for images with + no associated data, 1 for bitmap and color images, and greater + than 2 for pixmap images. + */ + int count() const {return count_;} + /** + Returns a pointer to the current image data array. + Use the count() method to find the size of the data array. + */ + const char * const *data() const {return data_;} + + /** + The constructor creates an empty image with the specified + width, height, and depth. The width and height are in pixels. + The depth is 0 for bitmaps, 1 for pixmap (colormap) images, and + 1 to 4 for color images. + */ + Fl_Image(int W, int H, int D) {w_ = W; h_ = H; d_ = D; ld_ = 0; count_ = 0; data_ = 0;} + virtual ~Fl_Image(); + virtual Fl_Image *copy(int W, int H); + /** + The copy() method creates a copy of the specified + image. If the width and height are provided, the image is + resized to the specified size. The image should be deleted (or in + the case of Fl_Shared_Image, released) when you are done + with it. + */ + Fl_Image *copy() { return copy(w(), h()); } + virtual void color_average(Fl_Color c, float i); + /** + The inactive() method calls + color_average(FL_BACKGROUND_COLOR, 0.33f) to produce + an image that appears grayed out. <I>This method does not + alter the original image data.</I> + */ + void inactive() { color_average(FL_GRAY, .33f); } + virtual void desaturate(); + virtual void label(Fl_Widget*w); + virtual void label(Fl_Menu_Item*m); + /** + Draws the image with a bounding box. + This form specifies + a bounding box for the image, with the origin + (upper-lefthand corner) of the image offset by the cx + and cy arguments. + */ + virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent + /** + Draws the image. + This form specifies the upper-lefthand corner of the image. + */ + void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} // platform dependent + virtual void uncache(); +}; + +/** + The Fl_RGB_Image class supports caching and drawing + of full-color images with 1 to 4 channels of color information. + Images with an even number of channels are assumed to contain + alpha information, which is used to blend the image with the + contents of the screen.</P> + + <P>Fl_RGB_Image is defined in + <FL/Fl_Image.H>, however for compatibility reasons + <FL/Fl_RGB_Image.H> should be included. +*/ +class FL_EXPORT Fl_RGB_Image : public Fl_Image { + friend class Fl_Quartz_Graphics_Driver; + friend class Fl_GDI_Graphics_Driver; + friend class Fl_Xlib_Graphics_Driver; +public: + + const uchar *array; + int alloc_array; // Non-zero if array was allocated + + private: + +#if defined(__APPLE__) || defined(WIN32) + void *id_; // for internal use + void *mask_; // for internal use (mask bitmap) +#else + unsigned id_; // for internal use + unsigned mask_; // for internal use (mask bitmap) +#endif // __APPLE__ || WIN32 + + public: + +/** The constructor creates a new image from the specified data. */ + Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0) : + Fl_Image(W,H,D), array(bits), alloc_array(0), id_(0), mask_(0) {data((const char **)&array, 1); ld(LD);} + virtual ~Fl_RGB_Image(); + virtual Fl_Image *copy(int W, int H); + Fl_Image *copy() { return copy(w(), h()); } + virtual void color_average(Fl_Color c, float i); + virtual void desaturate(); + virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); + void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} + virtual void label(Fl_Widget*w); + virtual void label(Fl_Menu_Item*m); + virtual void uncache(); +}; + +#endif // !Fl_Image_H + +// +// End of "$Id: Fl_Image.H 8338 2011-01-30 09:24:40Z manolo $". +// diff --git a/common/fltk/FL/Fl_Input.H b/common/fltk/FL/Fl_Input.H new file mode 100644 index 00000000..3f6c49e9 --- /dev/null +++ b/common/fltk/FL/Fl_Input.H @@ -0,0 +1,277 @@ +// +// "$Id: Fl_Input.H 8111 2010-12-23 08:13:18Z manolo $" +// +// Input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Input widget . */ + +#ifndef Fl_Input_H +#define Fl_Input_H + +#include "Fl_Input_.H" + +/** + This is the FLTK text input widget. It displays a single line + of text and lets the user edit it. Normally it is drawn with an + inset box and a white background. The text may contain any + characters, and will correctly display any UTF text, using + ^X notation for unprintable control characters. It assumes the + font can draw any characters of the used scripts, which is true + for standard fonts under MSWindows and Mac OS X. + Characters can be input using the keyboard or the character palette/map. + Character composition is done using dead keys and/or a compose + key as defined by the operating system. + <P> + <TABLE WIDTH=90% BORDER=1 SUMMARY="Fl_Input keyboard and mouse bindings."> + <CAPTION ALIGN=TOP>Fl_Input keyboard and mouse bindings.</CAPTION> + <TR><TD NOWRAP="NOWRAP" WIDTH="1%"> + <B>Mouse button 1</B> + </TD><TD> + Moves the cursor to this point. + Drag selects characters. + Double click selects words. + Triple click selects all line. + Shift+click extends the selection. + When you select text it is automatically copied to the selection buffer. + </TD></TR><TR><TD NOWRAP="NOWRAP"> + <B>Mouse button 2</B> + </TD><TD> + Insert the selection buffer at the point clicked. + You can also select a region and replace it with the selection buffer + by selecting the region with mouse button 2. + </TD></TR><TR><TD NOWRAP="NOWRAP"> + <B>Mouse button 3</B> + </TD><TD> + Currently acts like button 1. + </TD></TR><TR><TD NOWRAP="NOWRAP"> + <B>Backspace</B> + </TD><TD> + Deletes one character to the left, or deletes the selected region. + </TD></TR><TR><TD NOWRAP="NOWRAP"> + <B>Delete</B> + </TD><TD> + Deletes one character to the right, or deletes the selected region. + Combine with Shift for equivalent of ^X (copy+cut). + </TD></TR><TR><TD NOWRAP="NOWRAP"> + <B>Enter</b> + </TD><TD> + May cause the callback, see when(). + </TD></TR></TABLE> + + <P> + + <TABLE WIDTH="90%" BORDER="1" SUMMARY="Fl_Input platform specific keyboard bindings."> + <CAPTION ALIGN=TOP>Fl_Input platform specific keyboard bindings.</CAPTION> + <TR> + <TD NOWRAP="NOWRAP" WIDTH="1%"><B> Windows/Linux </B></TD> + <TD NOWRAP="NOWRAP" WIDTH="1%"><B> Mac </B></TD> + <TD NOWRAP="NOWRAP" ><B> Function </B></TD> + + </TR><TR> + <TD NOWRAP="NOWRAP"><B> ^A </B></TD> + <TD NOWRAP="NOWRAP"><B> Command-A </B></TD> + <TD> + <B>Selects all text in the widget.</B> + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> ^C </B></TD> + <TD NOWRAP="NOWRAP"><B> Command-C </B></TD> + <TD> + <B>Copy the current selection to the clipboard.</B> + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> ^I </B></TD> + <TD NOWRAP="NOWRAP"><B> ^I </B></TD> + <TD> + <B>Insert a tab.</B> + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> ^J </B></TD> + <TD NOWRAP="NOWRAP"><B> ^J </B></TD> + <TD> + <B>Insert a Line Feed.</B> <BR> + (Similar to literal 'Enter' character) + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> ^L </B></TD> + <TD NOWRAP="NOWRAP"><B> ^L </B></TD> + <TD> + <B>Insert a Form Feed.</B> + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> ^M </B></TD> + <TD NOWRAP="NOWRAP"><B> ^M </B></TD> + <TD> + <B>Insert a Carriage Return.</B> + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> ^V,<BR>Shift-Insert </B></TD> + <TD NOWRAP="NOWRAP"><B> Command-V </B></TD> + <TD> + <B>Paste the clipboard.</B> <BR> + (Macs keyboards don't have "Insert" keys, + but if they did, Shift-Insert would work) + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> ^X,<BR>Shift-Delete </B></TD> + <TD NOWRAP="NOWRAP"><B> Command-X,<BR>Shift-Delete </B></TD> + <TD> + <B>Cut.</B> <BR> + Copy the selection to the clipboard and delete it. + (If there's no selection, Shift-Delete acts like Delete) + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> ^Z </B></TD> + <TD NOWRAP="NOWRAP"><B> Command-Z </B></TD> + <TD> + <B>Undo.</B> <BR> + This is a single-level undo mechanism, but all adjacent + deletions and insertions are concatenated into a single "undo". + Often this will undo a lot more than you expected. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> Shift-^Z </B></TD> + <TD NOWRAP="NOWRAP"><B> Shift-Command-Z </B></TD> + <TD> + <B>Redo.</B> <BR> + Currently same behavior as ^Z. + Reserved for future multilevel undo/redo. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> Arrow Keys </B></TD> + <TD NOWRAP="NOWRAP"><B> Arrow Keys </B></TD> + <TD> + <B>Standard cursor movement.</B> <BR> + Can be combined with Shift to extend selection. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> Home </B></TD> + <TD NOWRAP="NOWRAP"><B> Command-Up,<BR>Command-Left </B></TD> + <TD> + <B>Move to start of line.</B> <BR> + Can be combined with Shift to extend selection. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> End </B></TD> + <TD NOWRAP="NOWRAP"><B> Command-Down,<BR>Command-Right </B></TD> + <TD> + <B>Move to end of line.</B> <BR> + Can be combined with Shift to extend selection. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B>Ctrl-Home</B></TD> + <TD NOWRAP="NOWRAP"><B>Command-Up,<BR>Command-PgUp,<BR>Ctrl-Left</B></TD> + <TD> + <B>Move to top of document/field.</B> <BR> + In single line input, moves to start of line. + In multiline input, moves to start of top line. + Can be combined with Shift to extend selection. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> Ctrl-End </B></TD> + <TD NOWRAP="NOWRAP"><B> Command-End,<BR>Command-PgDn,<BR>Ctrl-Right</B></TD> + <TD> + <B>Move to bottom of document/field.</B> <BR> + In single line input, moves to end of line. + In multiline input, moves to end of last line. + Can be combined with Shift to extend selection. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> Ctrl-Left </B></TD> + <TD NOWRAP="NOWRAP"><B> Alt-Left </B></TD> + <TD> + <B>Word left.</B> <BR> + Can be combined with Shift to extend selection. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> Ctrl-Right </B></TD> + <TD NOWRAP="NOWRAP"><B> Alt-Right </B></TD> + <TD> + <B>Word right.</B> <BR> + Can be combined with Shift to extend selection. + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> Ctrl-Backspace </B></TD> + <TD NOWRAP="NOWRAP"><B> Alt-Backspace </B></TD> + <TD> + <B>Delete word left.</B> + + </TD></TR><TR> + <TD NOWRAP="NOWRAP"><B> Ctrl-Delete </B></TD> + <TD NOWRAP="NOWRAP"><B> Alt-Delete </B></TD> + <TD> + <B>Delete word right.</B> + + </TD></TR></TABLE> + */ +class FL_EXPORT Fl_Input : public Fl_Input_ { + int handle_key(); + int shift_position(int p); + int shift_up_down_position(int p); + void handle_mouse(int keepmark=0); + + // Private keyboard functions + int kf_lines_up(int repeat_num); + int kf_lines_down(int repeat_num); + int kf_page_up(); + int kf_page_down(); + int kf_insert_toggle(); + int kf_delete_word_right(); + int kf_delete_word_left(); + int kf_delete_sol(); + int kf_delete_eol(); + int kf_delete_char_right(); + int kf_delete_char_left(); + int kf_move_sol(); + int kf_move_eol(); + int kf_clear_eol(); + int kf_move_char_left(); + int kf_move_char_right(); + int kf_move_word_left(); + int kf_move_word_right(); + int kf_move_up_and_sol(); + int kf_move_down_and_eol(); + int kf_top(); + int kf_bottom(); + int kf_select_all(); + int kf_undo(); + int kf_redo(); + int kf_copy(); + int kf_paste(); + int kf_copy_cut(); + +protected: + void draw(); +public: + int handle(int); + Fl_Input(int,int,int,int,const char * = 0); +}; + +#endif + +// +// End of "$Id: Fl_Input.H 8111 2010-12-23 08:13:18Z manolo $". +// diff --git a/common/fltk/FL/Fl_Input_.H b/common/fltk/FL/Fl_Input_.H new file mode 100644 index 00000000..1638436a --- /dev/null +++ b/common/fltk/FL/Fl_Input_.H @@ -0,0 +1,497 @@ +// +// "$Id: Fl_Input_.H 8068 2010-12-20 07:48:59Z greg.ercolano $" +// +// Input base class header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Input_ widget . */ + +#ifndef Fl_Input__H +#define Fl_Input__H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +#define FL_NORMAL_INPUT 0 +#define FL_FLOAT_INPUT 1 +#define FL_INT_INPUT 2 +#define FL_HIDDEN_INPUT 3 +#define FL_MULTILINE_INPUT 4 +#define FL_SECRET_INPUT 5 +#define FL_INPUT_TYPE 7 +#define FL_INPUT_READONLY 8 +#define FL_NORMAL_OUTPUT (FL_NORMAL_INPUT | FL_INPUT_READONLY) +#define FL_MULTILINE_OUTPUT (FL_MULTILINE_INPUT | FL_INPUT_READONLY) +#define FL_INPUT_WRAP 16 +#define FL_MULTILINE_INPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_WRAP) +#define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP) + +/** + This class provides a low-overhead text input field. + + This is a virtual base class below Fl_Input. It has all + the same interfaces, but lacks the handle() and + draw() method. You may want to subclass it if you are + one of those people who likes to change how the editing keys + work. It may also be useful for adding scrollbars + to the input field. + + This can act like any of the subclasses of Fl_Input, by + setting type() to one of the following values: + + \code + #define FL_NORMAL_INPUT 0 + #define FL_FLOAT_INPUT 1 + #define FL_INT_INPUT 2 + #define FL_MULTILINE_INPUT 4 + #define FL_SECRET_INPUT 5 + #define FL_INPUT_TYPE 7 + #define FL_INPUT_READONLY 8 + #define FL_NORMAL_OUTPUT (FL_NORMAL_INPUT | FL_INPUT_READONLY) + #define FL_MULTILINE_OUTPUT (FL_MULTILINE_INPUT | FL_INPUT_READONLY) + #define FL_INPUT_WRAP 16 + #define FL_MULTILINE_INPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_WRAP) + #define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP) + \endcode + + All variables that represent an index into a text buffer are byte-oriented, + not character oriented. Since UTF-8 characters can be up to six bytes long, + simply incrementing such an index will not reliably advance to the next character + in the text buffer. + + Indices and pointers into the text buffer should always point at a 7 bit ASCII + character or the beginning of a UTF-8 character sequence. Behavior for false + UTF-8 sequences and pointers into the middle of a sequence are undefined. + + \see Fl_Text_Display, Fl_Text_Editor for more powerful text handling widgets + + \internal + When porting this widget from ASCII to UTF-8, previously legal pointers into + the text of this widget can become illegal by pointing into the middle of + a UTF-8 sequence. This is not a big problem for Fl_Input_ because all code + in this module is quite tolerant. It could be problematic though when deriving + from this class because no feedback for illegal pointers is given. Additionally, + a careless "copy" call can put partial UTF-8 sequences into the clipboard. + + None of these issues should be disastrous. Nevertheless, we should + discuss how FLTK should handle false UTF-8 sequences and pointers. +*/ +class FL_EXPORT Fl_Input_ : public Fl_Widget { + + /** \internal Storage for the text field. */ + const char* value_; + + /** \internal Buffer memory for expanded text. \see expand() */ + char* buffer; + + /** \internal Size of text in bytes in the \p value_ field. */ + int size_; + + /** \internal \todo Please document me! */ + int bufsize; + + /** \internal Position of the cursor in the document. */ + int position_; + + /** \internal Position of the other end of the selected text. If \p position_ equals + \p mark_, no text is selected */ + int mark_; + + /** \internal Behavior of Tab key in multiline input widget. + If enabled (default) Tab causes focus nav, otherwise Tab is inserted + as a character. */ + int tab_nav_; + + /** \internal Offset to text origin within widget bounds */ + int xscroll_, yscroll_; + + /** \internal Minimal update pointer. Display requires redraw from here to the end + of the buffer. */ + int mu_p; + + /** \internal Maximum size of buffer. \todo Is this really needed? */ + int maximum_size_; + + /** \internal Shortcut key that will fetch focus for this widget. */ + int shortcut_; + + /** \internal This is set if no text but only the cursor needs updating. */ + uchar erase_cursor_only; + + /** \internal The font used for the entire text. */ + Fl_Font textfont_; + + /** \internal Height of the font used for the entire text. */ + Fl_Fontsize textsize_; + + /** \internal color of the entire text */ + Fl_Color textcolor_; + + /** \internal color of the text cursor */ + Fl_Color cursor_color_; + + /** \internal Horizontal cursor position in pixels while moving up or down. */ + static double up_down_pos; + + /** \internal Flag to remember last cursor move. */ + static int was_up_down; + + /* Convert a given text segment into the text that will be rendered on screen. */ + const char* expand(const char*, char*) const; + + /* Calculates the width in pixels of part of a text buffer. */ + double expandpos(const char*, const char*, const char*, int*) const; + + /* Mark a range of characters for update. */ + void minimal_update(int, int); + + /* Mark a range of characters for update. */ + void minimal_update(int p); + + /* Copy the value from a possibly static entry into the internal buffer. */ + void put_in_buffer(int newsize); + + /* Set the current font and font size. */ + void setfont() const; + +protected: + + /* Find the start of a word. */ + int word_start(int i) const; + + /* Find the end of a word. */ + int word_end(int i) const; + + /* Find the start of a line. */ + int line_start(int i) const; + + /* Find the end of a line. */ + int line_end(int i) const; + + /* Draw the text in the passed bounding box. */ + void drawtext(int, int, int, int); + + /* Move the cursor to the column given by up_down_pos. */ + int up_down_position(int, int keepmark=0); + + /* Handle mouse clicks and mouse moves. */ + void handle_mouse(int, int, int, int, int keepmark=0); + + /* Handle all kinds of text field related events. */ + int handletext(int e, int, int, int, int); + + /* Check the when() field and do a callback if indicated. */ + void maybe_do_callback(); + + /** \internal Horizontal offset of text to left edge of widget. */ + int xscroll() const {return xscroll_;} + + /** \internal Vertical offset of text to top edge of widget. */ + int yscroll() const {return yscroll_;} + void yscroll(int y) { yscroll_ = y; damage(FL_DAMAGE_EXPOSE);} + + /* Return the number of lines displayed on a single page. */ + int linesPerPage(); + +public: + + /* Change the size of the widget. */ + void resize(int, int, int, int); + + /* Constructor */ + Fl_Input_(int, int, int, int, const char* = 0); + + /* Destructor */ + ~Fl_Input_(); + + /* Changes the widget text. */ + int value(const char*); + + /* Changes the widget text. */ + int value(const char*, int); + + /* Changes the widget text. */ + int static_value(const char*); + + /* Changes the widget text. */ + int static_value(const char*, int); + + /** + Returns the text displayed in the widget. + + This function returns the current value, which is a pointer + to the internal buffer and is valid only until the next event is + handled. + + \return pointer to an internal buffer - do not free() this + \see Fl_Input_::value(const char*) + */ + const char* value() const {return value_;} + + /* Returns the character at index \p i. */ + Fl_Char index(int i) const; + + /** + Returns the number of bytes in value(). + + This may be greater than <tt>strlen(value())</tt> if there are + \c nul characters in the text. + + \return number of bytes in the text + */ + int size() const {return size_;} + + /** Sets the width and height of this widget. + \param [in] W, H new width and height + \see Fl_Widget::size(int, int) */ + void size(int W, int H) { Fl_Widget::size(W, H); } + + /** Gets the maximum length of the input field. + \todo It is not clear if this function is actually required */ + int maximum_size() const {return maximum_size_;} + + /** Sets the maximum length of the input field. + \todo It is not clear if this function is actually required */ + void maximum_size(int m) {maximum_size_ = m;} + + /** Gets the position of the text cursor. + \return the cursor position as an index + \see position(int, int) + */ + int position() const {return position_;} + + /** Gets the current selection mark. + \return index into the text */ + int mark() const {return mark_;} + + /* Sets the index for the cursor and mark. */ + int position(int p, int m); + + /** Set the cursor position and mark. + position(n) is the same as <tt>position(n, n)</tt>. + \param p new index for cursor and mark + \return 0 if no positions changed + \see position(int, int), position(), mark(int) + */ + int position(int p) {return position(p, p);} + + /** Sets the current selection mark. + mark(n) is the same as <tt>position(position(),n)</tt>. + \param m new index of the mark + \return 0 if the mark did not change + \see position(), position(int, int) */ + int mark(int m) {return position(position(), m);} + + /* Deletes text from b to e and inserts the new string text. */ + int replace(int, int, const char*, int=0); + + /** + Deletes the current selection. + + This function deletes the currently selected text + \e without storing it in the clipboard. To use the clipboard, + you may call copy() first or copy_cuts() after + this call. + + \return 0 if no data was copied + */ + int cut() {return replace(position(), mark(), 0);} + + /** + Deletes the next \p n bytes rounded to characters before or after the cursor. + + This function deletes the currently selected text + \e without storing it in the clipboard. To use the clipboard, + you may call copy() first or copy_cuts() after + this call. + + \param n number of bytes rounded to full characters and clamped to the buffer. + A negative number will cut characters to the left of the cursor. + \return 0 if no data was copied + */ + int cut(int n) {return replace(position(), position()+n, 0);} + + /** + Deletes all characters between index \p a and \p b. + + This function deletes the currently selected text + \e without storing it in the clipboard. To use the clipboard, + you may call copy() first or copy_cuts() after + this call. + + \param a, b range of bytes rounded to full characters and clamped to the buffer + \return 0 if no data was copied + */ + int cut(int a, int b) {return replace(a, b, 0);} + + /** + Inserts text at the cursor position. + + This function inserts the string in \p t at the cursor + position() and moves the new position and mark to + the end of the inserted text. + + \param [in] t text that will be inserted + \param [in] l length of text, or 0 if the string is terminated by \c nul. + \return 0 if no text was inserted + */ + int insert(const char* t, int l=0){return replace(position_, mark_, t, l);} + + /* Put the current selection into the clipboard. */ + int copy(int clipboard); + + /* Undo previous changes to the text buffer. */ + int undo(); + + /* Copy the yank buffer to the clipboard. */ + int copy_cuts(); + + /** Return the shortcut key associated with this widget. + \return shortcut keystroke + \see Fl_Button::shortcut() */ + int shortcut() const {return shortcut_;} + + /** + Sets the shortcut key associated with this widget. + Pressing the shortcut key gives text editing focus to this widget. + \param [in] s new shortcut keystroke + \see Fl_Button::shortcut() + */ + void shortcut(int s) {shortcut_ = s;} + + /** Gets the font of the text in the input field. + \return the current Fl_Font index */ + Fl_Font textfont() const {return textfont_;} + + /** Sets the font of the text in the input field. + The text font defaults to \c FL_HELVETICA. + \param [in] s the new text font */ + void textfont(Fl_Font s) {textfont_ = s;} + + /** Gets the size of the text in the input field. + \return the text height in pixels */ + Fl_Fontsize textsize() const {return textsize_;} + + /** Sets the size of the text in the input field. + The text height defaults to \c FL_NORMAL_SIZE. + \param [in] s the new font height in pixel units */ + void textsize(Fl_Fontsize s) {textsize_ = s;} + + /** Gets the color of the text in the input field. + \return the text color + \see textcolor(Fl_Color) */ + Fl_Color textcolor() const {return textcolor_;} + + /** Sets the color of the text in the input field. + The text color defaults to \c FL_FOREGROUND_COLOR. + \param [in] n new text color + \see textcolor() */ + void textcolor(Fl_Color n) {textcolor_ = n;} + + /** Gets the color of the cursor. + \return the current cursor color */ + Fl_Color cursor_color() const {return cursor_color_;} + + /** Sets the color of the cursor. + The default color for the cursor is \c FL_BLACK. + \param [in] n the new cursor color */ + void cursor_color(Fl_Color n) {cursor_color_ = n;} + + /** Gets the input field type. + \return the current input type */ + int input_type() const {return type() & FL_INPUT_TYPE; } + + /** Sets the input field type. + A redraw() is required to reformat the input field. + \param [in] t new input type */ + void input_type(int t) { type((uchar)(t | readonly())); } + + /** Gets the read-only state of the input field. + \return non-zero if this widget is read-only */ + int readonly() const { return type() & FL_INPUT_READONLY; } + + /** Sets the read-only state of the input field. + \param [in] b if \p b is 0, the text in this widget can be edited by the user */ + void readonly(int b) { if (b) type((uchar)(type() | FL_INPUT_READONLY)); + else type((uchar)(type() & ~FL_INPUT_READONLY)); } + + /** + Gets the word wrapping state of the input field. + Word wrap is only functional with multi-line input fields. + */ + int wrap() const { return type() & FL_INPUT_WRAP; } + + /** + Sets the word wrapping state of the input field. + Word wrap is only functional with multi-line input fields. + */ + void wrap(int b) { if (b) type((uchar)(type() | FL_INPUT_WRAP)); + else type((uchar)(type() & ~FL_INPUT_WRAP)); } + + /** + Sets whether the Tab key does focus navigation, + or inserts tab characters into Fl_Multiline_Input. + + By default this flag is enabled to provide the 'normal' behavior + most users expect; Tab navigates focus to the next widget. + To inserting an actual Tab character, users can use Ctrl-I + or copy/paste. + + Disabling this flag gives the old FLTK behavior where Tab + inserts a tab character into the text field, in which case + only the mouse can be used to navigate to the next field. + + History: This flag was provided for backwards support of FLTK's old 1.1.x + behavior where Tab inserts a tab character instead of navigating + focus to the next widget. This behavior was unique to Fl_Multiline_Input. + With the advent of Fl_Text_Editor, this old behavior has been deprecated. + + \param [in] val If \p val is 1, Tab advances focus (default).<BR> + If \p val is 0, Tab inserts a tab character (old FLTK behavior). + */ + void tab_nav(int val) { + tab_nav_ = val; + } + + /** + Gets whether the Tab key causes focus navigation in multiline input fields or not. + + If enabled (default), hitting Tab causes focus navigation to the next widget. + + If disabled, hitting Tab inserts a tab character into the text field. + \returns 1 if Tab advances focus (default), 0 if Tab inserts tab characters. + \see tab_nav(int) + */ + int tab_nav() const { + return tab_nav_; + } +}; + +#endif + +// +// End of "$Id: Fl_Input_.H 8068 2010-12-20 07:48:59Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Input_Choice.H b/common/fltk/FL/Fl_Input_Choice.H new file mode 100644 index 00000000..843e7495 --- /dev/null +++ b/common/fltk/FL/Fl_Input_Choice.H @@ -0,0 +1,222 @@ +// +// "$Id: Fl_Input_Choice.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// An input/chooser widget. +// ______________ ____ +// | || __ | +// | input area || \/ | +// |______________||____| +// +// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 2004 by Greg Ercolano. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Input_Choice widget . */ + + + +#ifndef Fl_Input_Choice_H +#define Fl_Input_Choice_H + +#include <FL/Fl.H> +#include <FL/Fl_Group.H> +#include <FL/Fl_Input.H> +#include <FL/Fl_Menu_Button.H> +#include <FL/fl_draw.H> +#include <string.h> + +/** + A combination of the input widget and a menu button. + The user can either type into the input area, or use the + menu button chooser on the right, which loads the input area + with predefined text. Normally it is drawn with an inset box + and a white background. + <P> + The application can directly access both the input and menu + widgets directly, using the menubutton() + and input() accessor methods. +*/ +class FL_EXPORT Fl_Input_Choice : public Fl_Group { + // Private class to handle slightly 'special' behavior of menu button + class InputMenuButton : public Fl_Menu_Button { + void draw() { + draw_box(FL_UP_BOX, color()); + fl_color(active_r() ? labelcolor() : fl_inactive(labelcolor())); + int xc = x()+w()/2, yc=y()+h()/2; + fl_polygon(xc-5,yc-3,xc+5,yc-3,xc,yc+3); + if (Fl::focus() == this) draw_focus(); + } + public: + InputMenuButton(int x,int y,int w,int h,const char*l=0) : + Fl_Menu_Button(x,y,w,h,l) { box(FL_UP_BOX); } + }; + + Fl_Input *inp_; + InputMenuButton *menu_; + + static void menu_cb(Fl_Widget*, void *data) { + Fl_Input_Choice *o=(Fl_Input_Choice *)data; + Fl_Widget_Tracker wp(o); + const Fl_Menu_Item *item = o->menubutton()->mvalue(); + if (item && item->flags & (FL_SUBMENU|FL_SUBMENU_POINTER)) return; // ignore submenus + if (!strcmp(o->inp_->value(), o->menu_->text())) + { + o->Fl_Widget::clear_changed(); + if (o->when() & FL_WHEN_NOT_CHANGED) + o->do_callback(); + } + else + { + o->inp_->value(o->menu_->text()); + o->inp_->set_changed(); + o->Fl_Widget::set_changed(); + if (o->when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE)) + o->do_callback(); + } + + if (wp.deleted()) return; + + if (o->callback() != default_callback) + { + o->Fl_Widget::clear_changed(); + o->inp_->clear_changed(); + } + } + + static void inp_cb(Fl_Widget*, void *data) { + Fl_Input_Choice *o=(Fl_Input_Choice *)data; + Fl_Widget_Tracker wp(o); + if (o->inp_->changed()) { + o->Fl_Widget::set_changed(); + if (o->when() & (FL_WHEN_CHANGED|FL_WHEN_RELEASE)) + o->do_callback(); + } else { + o->Fl_Widget::clear_changed(); + if (o->when() & FL_WHEN_NOT_CHANGED) + o->do_callback(); + } + + if (wp.deleted()) return; + + if (o->callback() != default_callback) + o->Fl_Widget::clear_changed(); + } + + // Custom resize behavior -- input stretches, menu button doesn't + inline int inp_x() { return(x() + Fl::box_dx(box())); } + inline int inp_y() { return(y() + Fl::box_dy(box())); } + inline int inp_w() { return(w() - Fl::box_dw(box()) - 20); } + inline int inp_h() { return(h() - Fl::box_dh(box())); } + + inline int menu_x() { return(x() + w() - 20 - Fl::box_dx(box())); } + inline int menu_y() { return(y() + Fl::box_dy(box())); } + inline int menu_w() { return(20); } + inline int menu_h() { return(h() - Fl::box_dh(box())); } + +public: + /** + Creates a new Fl_Input_Choice widget using the given position, size, + and label string. + <P> Inherited destructor Destroys the widget and any value associated with it. + */ + Fl_Input_Choice (int x,int y,int w,int h,const char*l=0) : Fl_Group(x,y,w,h,l) { + Fl_Group::box(FL_DOWN_BOX); + align(FL_ALIGN_LEFT); // default like Fl_Input + inp_ = new Fl_Input(inp_x(), inp_y(), + inp_w(), inp_h()); + inp_->callback(inp_cb, (void*)this); + inp_->box(FL_FLAT_BOX); // cosmetic + inp_->when(FL_WHEN_CHANGED|FL_WHEN_NOT_CHANGED); + menu_ = new InputMenuButton(menu_x(), menu_y(), + menu_w(), menu_h()); + menu_->callback(menu_cb, (void*)this); + menu_->box(FL_FLAT_BOX); // cosmetic + end(); + } + + /** Adds an item to the menu.*/ + void add(const char *s) { menu_->add(s); } + int changed() const { return inp_->changed() | Fl_Widget::changed();} + void clear_changed() { + inp_->clear_changed(); + Fl_Widget::clear_changed(); + } + void set_changed() { + inp_->set_changed(); + // no need to call Fl_Widget::set_changed() + } + /** Removes all items from the menu. */ + void clear() { menu_->clear(); } + /** Gets the box type of the menu button */ + Fl_Boxtype down_box() const { return (menu_->down_box()); } + /** Sets the box type of the menu button */ + void down_box(Fl_Boxtype b) { menu_->down_box(b); } + /** Gets the Fl_Menu_Item array used for the menu. */ + const Fl_Menu_Item *menu() { return (menu_->menu()); } + /** Sets the Fl_Menu_Item array used for the menu. */ + void menu(const Fl_Menu_Item *m) { menu_->menu(m); } + void resize(int X, int Y, int W, int H) { + Fl_Group::resize(X,Y,W,H); + inp_->resize(inp_x(), inp_y(), inp_w(), inp_h()); + menu_->resize(menu_x(), menu_y(), menu_w(), menu_h()); + } + /** Gets the encapsulated input text color attributes */ + Fl_Color textcolor() const { return (inp_->textcolor());} + /** Sets the encapsulated input text color attributes */ + void textcolor(Fl_Color c) { inp_->textcolor(c);} + /** Gets the encapsulated input text font attributes */ + Fl_Font textfont() const { return (inp_->textfont());} + /** Sets the encapsulated input text font attributes */ + void textfont(Fl_Font f) { inp_->textfont(f);} + /** Gets the encapsulated input size attributes */ + Fl_Fontsize textsize() const { return (inp_->textsize()); } + /** Sets the encapsulated input size attributes */ + void textsize(Fl_Fontsize s) { inp_->textsize(s); } + /** See void Fl_Input_Choice::value(const char *s) */ + const char* value() const { return (inp_->value()); } + /** + Sets or returns the input widget's current contents. The + second form sets the contents using the index into the menu + which you can set as an integer. Setting the value effectively + 'chooses' this menu item, and sets it as the new input text, + deleting the previous text. + */ + void value(const char *val) { inp_->value(val); } + /** See void Fl_Input_Choice::value(const char *s) */ + void value(int val) { + menu_->value(val); + inp_->value(menu_->text(val)); + } + /** Returns a reference to the internal Fl_Menu_Button widget. */ + Fl_Menu_Button *menubutton() { return menu_; } + /** + Returns a reference to the internal Fl_Input widget.</p> + */ + Fl_Input *input() { return inp_; } +}; + +#endif // !Fl_Input_Choice_H + +// +// End of "$Id: Fl_Input_Choice.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Int_Input.H b/common/fltk/FL/Fl_Int_Input.H new file mode 100644 index 00000000..9bc94778 --- /dev/null +++ b/common/fltk/FL/Fl_Int_Input.H @@ -0,0 +1,61 @@ +// +// "$Id: Fl_Int_Input.H 8726 2011-05-23 18:32:47Z AlbrechtS $" +// +// Integer input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Int_Input widget . */ + +#ifndef Fl_Int_Input_H +#define Fl_Int_Input_H + +#include "Fl_Input.H" + +/** + The Fl_Int_Input class is a subclass of Fl_Input that only allows + the user to type decimal digits (or hex numbers of the form 0xaef). +*/ +class FL_EXPORT Fl_Int_Input : public Fl_Input { +public: + /** + Creates a new Fl_Int_Input widget using the given position, + size, and label string. The default boxtype is FL_DOWN_BOX. + + Inherited destructor destroys the widget and any value associated with it. + */ + +#if defined(FL_DLL) // implementation in src/Fl_Input.cxx + Fl_Int_Input(int X,int Y,int W,int H,const char *l = 0); +#else + Fl_Int_Input(int X,int Y,int W,int H,const char *l = 0) + : Fl_Input(X,Y,W,H,l) {type(FL_INT_INPUT);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Int_Input.H 8726 2011-05-23 18:32:47Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_JPEG_Image.H b/common/fltk/FL/Fl_JPEG_Image.H new file mode 100644 index 00000000..06f3a4c0 --- /dev/null +++ b/common/fltk/FL/Fl_JPEG_Image.H @@ -0,0 +1,53 @@ +// +// "$Id: Fl_JPEG_Image.H 7903 2010-11-28 21:06:39Z matt $" +// +// JPEG image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_JPEG_Image class . */ + +#ifndef Fl_JPEG_Image_H +#define Fl_JPEG_Image_H +# include "Fl_Image.H" + +/** + The Fl_JPEG_Image class supports loading, caching, + and drawing of Joint Photographic Experts Group (JPEG) File + Interchange Format (JFIF) images. The class supports grayscale + and color (RGB) JPEG image files. +*/ +class FL_EXPORT Fl_JPEG_Image : public Fl_RGB_Image { + +public: + + Fl_JPEG_Image(const char *filename); + Fl_JPEG_Image(const char *name, const unsigned char *data); +}; + +#endif + +// +// End of "$Id: Fl_JPEG_Image.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Light_Button.H b/common/fltk/FL/Fl_Light_Button.H new file mode 100644 index 00000000..a5786c27 --- /dev/null +++ b/common/fltk/FL/Fl_Light_Button.H @@ -0,0 +1,59 @@ +// +// "$Id: Fl_Light_Button.H 8178 2011-01-04 14:09:37Z manolo $" +// +// Lighted button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Light_Button widget . */ + +#ifndef Fl_Light_Button_H +#define Fl_Light_Button_H + +#include "Fl_Button.H" + +/** + This subclass displays the "on" state by turning on a light, + rather than drawing pushed in. The shape of the "light" + is initially set to FL_DOWN_BOX. The color of the light when + on is controlled with selection_color(), which defaults to FL_YELLOW. + + Buttons generate callbacks when they are clicked by the user. You + control exactly when and how by changing the values for type() and when(). + <P ALIGN=CENTER>\image html Fl_Light_Button.png</P> + \image latex Fl_Light_Button.png "Fl_Light_Button" width=4cm +*/ +class FL_EXPORT Fl_Light_Button : public Fl_Button { +protected: + virtual void draw(); +public: + virtual int handle(int); + Fl_Light_Button(int x,int y,int w,int h,const char *l = 0); +}; + +#endif + +// +// End of "$Id: Fl_Light_Button.H 8178 2011-01-04 14:09:37Z manolo $". +// diff --git a/common/fltk/FL/Fl_Line_Dial.H b/common/fltk/FL/Fl_Line_Dial.H new file mode 100644 index 00000000..ade856c1 --- /dev/null +++ b/common/fltk/FL/Fl_Line_Dial.H @@ -0,0 +1,46 @@ +// +// "$Id: Fl_Line_Dial.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Line dial header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Line_Dial widget . */ + +#ifndef Fl_Line_Dial_H +#define Fl_Line_Dial_H + +#include "Fl_Dial.H" + +class FL_EXPORT Fl_Line_Dial : public Fl_Dial { +public: + Fl_Line_Dial(int x,int y,int w,int h, const char *l = 0) + : Fl_Dial(x,y,w,h,l) {type(FL_LINE_DIAL);} +}; + +#endif + +// +// End of "$Id: Fl_Line_Dial.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Menu.H b/common/fltk/FL/Fl_Menu.H new file mode 100644 index 00000000..a35dd4a8 --- /dev/null +++ b/common/fltk/FL/Fl_Menu.H @@ -0,0 +1,33 @@ +// +// "$Id: Fl_Menu.H 7903 2010-11-28 21:06:39Z matt $" +// +// Old menu header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// this include file is for back compatibility only +#include "Fl_Menu_Item.H" + +// +// End of "$Id: Fl_Menu.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Menu_.H b/common/fltk/FL/Fl_Menu_.H new file mode 100644 index 00000000..278ad8ca --- /dev/null +++ b/common/fltk/FL/Fl_Menu_.H @@ -0,0 +1,168 @@ +// +// "$Id: Fl_Menu_.H 7903 2010-11-28 21:06:39Z matt $" +// +// Menu base class header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Menu_ widget . */ + +#ifndef Fl_Menu__H +#define Fl_Menu__H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif +#include "Fl_Menu_Item.H" + +/** + Base class of all widgets that have a menu in FLTK. + Currently FLTK provides you with + Fl_Menu_Button, Fl_Menu_Bar, and Fl_Choice. + + <P>The class contains a pointer to an array of structures of type Fl_Menu_Item. The + array may either be supplied directly by the user program, or it may + be "private": a dynamically allocated array managed by the Fl_Menu_. +*/ +class FL_EXPORT Fl_Menu_ : public Fl_Widget { + + Fl_Menu_Item *menu_; + const Fl_Menu_Item *value_; + +protected: + + uchar alloc; // flag indicates if menu_ is a dynamic copy (=1) or not (=0) + uchar down_box_; + Fl_Font textfont_; + Fl_Fontsize textsize_; + Fl_Color textcolor_; + +public: + Fl_Menu_(int,int,int,int,const char * =0); + ~Fl_Menu_(); + + int item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem=0) const; + const Fl_Menu_Item* picked(const Fl_Menu_Item*); + const Fl_Menu_Item* find_item(const char *name); + const Fl_Menu_Item* find_item(Fl_Callback*); + int find_index(const char *name) const; + int find_index(const Fl_Menu_Item *item) const; + int find_index(Fl_Callback *cb) const; + + /** + Returns the menu item with the entered shortcut (key value). + + This searches the complete menu() for a shortcut that matches the + entered key value. It must be called for a FL_KEYBOARD or FL_SHORTCUT + event. + + If a match is found, the menu's callback will be called. + + \return matched Fl_Menu_Item or NULL. + */ + const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());} + void global(); + + /** + Returns a pointer to the array of Fl_Menu_Items. This will either be + the value passed to menu(value) or the private copy. + */ + const Fl_Menu_Item *menu() const {return menu_;} + void menu(const Fl_Menu_Item *m); + void copy(const Fl_Menu_Item *m, void* user_data = 0); + int insert(int index, const char*, int shortcut, Fl_Callback*, void* = 0, int = 0); + int add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0); + /** See int Fl_Menu_::add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0) */ + int add(const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) { + return add(a,fl_old_shortcut(b),c,d,e); + } + /** See int Fl_Menu_::insert(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0) */ + int insert(int index, const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) { + return insert(index,a,fl_old_shortcut(b),c,d,e); + } + int add(const char *); + int size() const ; + void size(int W, int H) { Fl_Widget::size(W, H); } + void clear(); + int clear_submenu(int index); + void replace(int,const char *); + void remove(int); + /** Changes the shortcut of item i to n. */ + void shortcut(int i, int s) {menu_[i].shortcut(s);} + /** Sets the flags of item i. For a list of the flags, see Fl_Menu_Item. */ + void mode(int i,int fl) {menu_[i].flags = fl;} + /** Gets the flags of item i. For a list of the flags, see Fl_Menu_Item. */ + int mode(int i) const {return menu_[i].flags;} + + /** Returns a pointer to the last menu item that was picked. */ + const Fl_Menu_Item *mvalue() const {return value_;} + /** Returns the index into menu() of the last item chosen by the user. It is zero initially. */ + int value() const {return value_ ? (int)(value_-menu_) : -1;} + int value(const Fl_Menu_Item*); + /** + The value is the index into menu() of the last item chosen by + the user. It is zero initially. You can set it as an integer, or set + it with a pointer to a menu item. The set routines return non-zero if + the new value is different than the old one. + */ + int value(int i) {return value(menu_+i);} + /** Returns the title of the last item chosen. */ + const char *text() const {return value_ ? value_->text : 0;} + /** Returns the title of item i. */ + const char *text(int i) const {return menu_[i].text;} + + /** Gets the current font of menu item labels. */ + Fl_Font textfont() const {return textfont_;} + /** Sets the current font of menu item labels. */ + void textfont(Fl_Font c) {textfont_=c;} + /** Gets the font size of menu item labels. */ + Fl_Fontsize textsize() const {return textsize_;} + /** Sets the font size of menu item labels. */ + void textsize(Fl_Fontsize c) {textsize_=c;} + /** Get the current color of menu item labels. */ + Fl_Color textcolor() const {return textcolor_;} + /** Sets the current color of menu item labels. */ + void textcolor(Fl_Color c) {textcolor_=c;} + + /** + This box type is used to surround the currently-selected items in the + menus. If this is FL_NO_BOX then it acts like + FL_THIN_UP_BOX and selection_color() acts like + FL_WHITE, for back compatibility. + */ + Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;} + /** See Fl_Boxtype Fl_Menu_::down_box() const */ + void down_box(Fl_Boxtype b) {down_box_ = b;} + + /** For back compatibility, same as selection_color() */ + Fl_Color down_color() const {return selection_color();} + /** For back compatibility, same as selection_color() */ + void down_color(unsigned c) {selection_color(c);} +}; + +#endif + +// +// End of "$Id: Fl_Menu_.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Menu_Bar.H b/common/fltk/FL/Fl_Menu_Bar.H new file mode 100644 index 00000000..5e522f6a --- /dev/null +++ b/common/fltk/FL/Fl_Menu_Bar.H @@ -0,0 +1,89 @@ +// +// "$Id: Fl_Menu_Bar.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Menu bar header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Menu_Bar widget . */ + +#ifndef Fl_Menu_Bar_H +#define Fl_Menu_Bar_H + +#include "Fl_Menu_.H" + +/** + This widget provides a standard menubar interface. Usually you will + put this widget along the top edge of your window. The height of the + widget should be 30 for the menu titles to draw correctly with the + default font. + <P>The items on the bar and the menus they bring up are defined by a + single Fl_Menu_Item + array. Because a Fl_Menu_Item array defines a hierarchy, the + top level menu defines the items in the menubar, while the submenus + define the pull-down menus. Sub-sub menus and lower pop up to the right + of the submenus. </P> + <P ALIGN=CENTER>\image html menubar.png</P> + \image latex menubar.png " menubar" width=12cm + <P>If there is an item in the top menu that is not a title of a + submenu, then it acts like a "button" in the menubar. Clicking on it + will pick it. </P> + <P>When the user picks an item off the menu, the item's callback is + done with the menubar as the Fl_Widget* argument. If the item + does not have a callback the menubar's callback is done instead. </P> + <P>Submenus will also pop up in response to shortcuts indicated by + putting a '&' character in the name field of the menu item. If you put a + '&' character in a top-level "button" then the shortcut picks it. The + '&' character in submenus is ignored until the menu is popped up. </P> + <P>Typing the shortcut() of any of the menu items will cause + callbacks exactly the same as when you pick the item with the mouse. +*/ +class FL_EXPORT Fl_Menu_Bar : public Fl_Menu_ { +protected: + void draw(); +public: + int handle(int); + /** + Creates a new Fl_Menu_Bar widget using the given position, + size, and label string. The default boxtype is FL_UP_BOX. + <P>The constructor sets menu() to NULL. See + Fl_Menu_ for the methods to set or change the menu. </P> + <P>labelsize(), labelfont(), and labelcolor() + are used to control how the menubar items are drawn. They are + initialized from the Fl_Menu static variables, but you can + change them if desired. </P> + <P>label() is ignored unless you change align() to + put it outside the menubar. + <P>The destructor removes the Fl_Menu_Bar widget and all of its + menu items. + */ + Fl_Menu_Bar(int X, int Y, int W, int H,const char *l=0) + : Fl_Menu_(X,Y,W,H,l) {} +}; + +#endif + +// +// End of "$Id: Fl_Menu_Bar.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Menu_Button.H b/common/fltk/FL/Fl_Menu_Button.H new file mode 100644 index 00000000..a5ff5d89 --- /dev/null +++ b/common/fltk/FL/Fl_Menu_Button.H @@ -0,0 +1,86 @@ +// +// "$Id: Fl_Menu_Button.H 8016 2010-12-12 11:19:12Z manolo $" +// +// Menu button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Menu_Button widget . */ + +#ifndef Fl_Menu_Button_H +#define Fl_Menu_Button_H + +#include "Fl_Menu_.H" + +/** + This is a button that when pushed pops up a menu (or hierarchy of + menus) defined by an array of + Fl_Menu_Item objects. + <P ALIGN=CENTER>\image html menu_button.png</P> + \image latex menu_button.png " menu_button" width=5cm + <P>Normally any mouse button will pop up a menu and it is lined up + below the button as shown in the picture. However an Fl_Menu_Button + may also control a pop-up menu. This is done by setting the type(). + If type() is zero a normal menu button is produced. + If it is nonzero then this is a pop-up menu. The bits in type() indicate + what mouse buttons pop up the menu (see Fl_Menu_Button::popup_buttons). </P> + <P>The menu will also pop up in response to shortcuts indicated by + putting a '&' character in the label(). </P> + <P>Typing the shortcut() of any of the menu items will cause + callbacks exactly the same as when you pick the item with the mouse. + The '&' character in menu item names are only looked at when the menu is + popped up, however. </P> + <P>When the user picks an item off the menu, the item's callback is + done with the menu_button as the Fl_Widget* argument. If the + item does not have a callback the menu_button's callback is done + instead. +*/ +class FL_EXPORT Fl_Menu_Button : public Fl_Menu_ { +protected: + void draw(); +public: + /** + \brief indicate what mouse buttons pop up the menu. + + Values for type() used to indicate what mouse buttons pop up the menu. + Fl_Menu_Button::POPUP3 is usually what you want. + */ + enum popup_buttons {POPUP1 = 1, /**< pops up with the mouse 1st button. */ + POPUP2, /**< pops up with the mouse 2nd button. */ + POPUP12, /**< pops up with the mouse 1st or 2nd buttons. */ + POPUP3, /**< pops up with the mouse 3rd button. */ + POPUP13, /**< pops up with the mouse 1st or 3rd buttons. */ + POPUP23, /**< pops up with the mouse 2nd or 3rd buttons. */ + POPUP123 /**< pops up with any mouse button. */ + }; + int handle(int); + const Fl_Menu_Item* popup(); + Fl_Menu_Button(int,int,int,int,const char * =0); +}; + +#endif + +// +// End of "$Id: Fl_Menu_Button.H 8016 2010-12-12 11:19:12Z manolo $". +// diff --git a/common/fltk/FL/Fl_Menu_Item.H b/common/fltk/FL/Fl_Menu_Item.H new file mode 100644 index 00000000..4d586993 --- /dev/null +++ b/common/fltk/FL/Fl_Menu_Item.H @@ -0,0 +1,443 @@ +// +// "$Id: Fl_Menu_Item.H 7983 2010-12-09 00:04:06Z AlbrechtS $" +// +// Menu item header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef Fl_Menu_Item_H +#define Fl_Menu_Item_H + +# include "Fl_Widget.H" +# include "Fl_Image.H" + +# if defined(__APPLE__) && defined(check) +# undef check +# endif + +enum { // values for flags: + FL_MENU_INACTIVE = 1, ///< Deactivate menu item (gray out) + FL_MENU_TOGGLE= 2, ///< Item is a checkbox toggle (shows checkbox for on/off state) + FL_MENU_VALUE = 4, ///< The on/off state for checkbox/radio buttons (if set, state is 'on') + FL_MENU_RADIO = 8, ///< Item is a radio button (one checkbox of many can be on) + FL_MENU_INVISIBLE = 0x10, ///< Item will not show up (shortcut will work) + FL_SUBMENU_POINTER = 0x20, ///< Indicates user_data() is a pointer to another menu array + FL_SUBMENU = 0x40, ///< This item is a submenu to other items + FL_MENU_DIVIDER = 0x80, ///< Creates divider line below this item. Also ends a group of radio buttons. + FL_MENU_HORIZONTAL = 0x100 ///< ??? -- reserved +}; + +extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*); + +class Fl_Menu_; + +/** + The Fl_Menu_Item structure defines a single menu item that + is used by the Fl_Menu_ class. + \code + struct Fl_Menu_Item { + const char* text; // label() + ulong shortcut_; + Fl_Callback* callback_; + void* user_data_; + int flags; + uchar labeltype_; + uchar labelfont_; + uchar labelsize_; + uchar labelcolor_; + }; + + enum { // values for flags: + FL_MENU_INACTIVE = 1, // Deactivate menu item (gray out) + FL_MENU_TOGGLE = 2, // Item is a checkbox toggle (shows checkbox for on/off state) + FL_MENU_VALUE = 4, // The on/off state for checkbox/radio buttons (if set, state is 'on') + FL_MENU_RADIO = 8, // Item is a radio button (one checkbox of many can be on) + FL_MENU_INVISIBLE = 0x10, // Item will not show up (shortcut will work) + FL_SUBMENU_POINTER = 0x20, // Indicates user_data() is a pointer to another menu array + FL_SUBMENU = 0x40, // This item is a submenu to other items + FL_MENU_DIVIDER = 0x80, // Creates divider line below this item. Also ends a group of radio buttons. + FL_MENU_HORIZONTAL = 0x100 // ??? -- reserved + }; + \endcode + Typically menu items are statically defined; for example: + \code + Fl_Menu_Item popup[] = { + {"&alpha", FL_ALT+'a', the_cb, (void*)1}, + {"&beta", FL_ALT+'b', the_cb, (void*)2}, + {"gamma", FL_ALT+'c', the_cb, (void*)3, FL_MENU_DIVIDER}, + {"&strange", 0, strange_cb}, + {"&charm", 0, charm_cb}, + {"&truth", 0, truth_cb}, + {"b&eauty", 0, beauty_cb}, + {"sub&menu", 0, 0, 0, FL_SUBMENU}, + {"one"}, + {"two"}, + {"three"}, + {0}, + {"inactive", FL_ALT+'i', 0, 0, FL_MENU_INACTIVE|FL_MENU_DIVIDER}, + {"invisible",FL_ALT+'i', 0, 0, FL_MENU_INVISIBLE}, + {"check", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE|FL_MENU_VALUE}, + {"box", FL_ALT+'i', 0, 0, FL_MENU_TOGGLE}, + {0}}; + \endcode + produces: + + \image html menu.png + \image latex menu.png "menu" width=10cm + + A submenu title is identified by the bit FL_SUBMENU in the + flags field, and ends with a label() that is NULL. + You can nest menus to any depth. A pointer to the first item in the + submenu can be treated as an Fl_Menu array itself. It is also + possible to make separate submenu arrays with FL_SUBMENU_POINTER flags. + + You should use the method functions to access structure members and + not access them directly to avoid compatibility problems with future + releases of FLTK. +*/ +struct FL_EXPORT Fl_Menu_Item { + const char *text; ///< menu item text, returned by label() + int shortcut_; ///< menu item shortcut + Fl_Callback *callback_; ///< menu item callback + void *user_data_; ///< menu item user_data for the menu's callback + int flags; ///< menu item flags like FL_MENU_TOGGLE, FL_MENU_RADIO + uchar labeltype_; ///< how the menu item text looks like + Fl_Font labelfont_; ///< which font for this menu item text + Fl_Fontsize labelsize_; ///< size of menu item text + Fl_Color labelcolor_; ///< menu item text color + + // advance N items, skipping submenus: + const Fl_Menu_Item *next(int=1) const; + + /** + Advances a pointer by n items through a menu array, skipping + the contents of submenus and invisible items. There are two calls so + that you can advance through const and non-const data. + */ + Fl_Menu_Item *next(int i=1) { + return (Fl_Menu_Item*)(((const Fl_Menu_Item*)this)->next(i));} + + /** Returns the first menu item, same as next(0). */ + const Fl_Menu_Item *first() const { return next(0); } + + /** Returns the first menu item, same as next(0). */ + Fl_Menu_Item *first() { return next(0); } + + // methods on menu items: + /** + Returns the title of the item. + A NULL here indicates the end of the menu (or of a submenu). + A '&' in the item will print an underscore under the next letter, + and if the menu is popped up that letter will be a "shortcut" to pick + that item. To get a real '&' put two in a row. + */ + const char* label() const {return text;} + + /** See const char* Fl_Menu_Item::label() const */ + void label(const char* a) {text=a;} + + /** See const char* Fl_Menu_Item::label() const */ + void label(Fl_Labeltype a,const char* b) {labeltype_ = a; text = b;} + + /** + Returns the menu item's labeltype. + A labeltype identifies a routine that draws the label of the + widget. This can be used for special effects such as emboss, or to use + the label() pointer as another form of data such as a bitmap. + The value FL_NORMAL_LABEL prints the label as text. + */ + Fl_Labeltype labeltype() const {return (Fl_Labeltype)labeltype_;} + + /** + Sets the menu item's labeltype. + A labeltype identifies a routine that draws the label of the + widget. This can be used for special effects such as emboss, or to use + the label() pointer as another form of data such as a bitmap. + The value FL_NORMAL_LABEL prints the label as text. + */ + void labeltype(Fl_Labeltype a) {labeltype_ = a;} + + /** + Gets the menu item's label color. + This color is passed to the labeltype routine, and is typically the + color of the label text. This defaults to FL_BLACK. If this + color is not black fltk will \b not use overlay bitplanes to draw + the menu - this is so that images put in the menu draw correctly. + */ + Fl_Color labelcolor() const {return labelcolor_;} + + /** + Sets the menu item's label color. + \see Fl_Color Fl_Menu_Item::labelcolor() const + */ + void labelcolor(Fl_Color a) {labelcolor_ = a;} + /** + Gets the menu item's label font. + Fonts are identified by small 8-bit indexes into a table. See the + enumeration list for predefined fonts. The default value is a + Helvetica font. The function Fl::set_font() can define new fonts. + */ + Fl_Font labelfont() const {return labelfont_;} + + /** + Sets the menu item's label font. + Fonts are identified by small 8-bit indexes into a table. See the + enumeration list for predefined fonts. The default value is a + Helvetica font. The function Fl::set_font() can define new fonts. + */ + void labelfont(Fl_Font a) {labelfont_ = a;} + + /** Gets the label font pixel size/height. */ + Fl_Fontsize labelsize() const {return labelsize_;} + + /** Sets the label font pixel size/height.*/ + void labelsize(Fl_Fontsize a) {labelsize_ = a;} + + /** + Returns the callback function that is set for the menu item. + Each item has space for a callback function and an argument for that + function. Due to back compatibility, the Fl_Menu_Item itself + is not passed to the callback, instead you have to get it by calling + ((Fl_Menu_*)w)->mvalue() where w is the widget argument. + */ + Fl_Callback_p callback() const {return callback_;} + + /** + Sets the menu item's callback function and userdata() argument. + \see Fl_Callback_p Fl_MenuItem::callback() const + */ + void callback(Fl_Callback* c, void* p) {callback_=c; user_data_=p;} + + /** + Sets the menu item's callback function. + This method does not set the userdata() argument. + \see Fl_Callback_p Fl_MenuItem::callback() const + */ + void callback(Fl_Callback* c) {callback_=c;} + + /** + Sets the menu item's callback function. + This method does not set the userdata() argument. + \see Fl_Callback_p Fl_MenuItem::callback() const + */ + void callback(Fl_Callback0*c) {callback_=(Fl_Callback*)c;} + + /** + Sets the menu item's callback function and userdata() argument. + This method does not set the userdata() argument. + The argument \p is cast to void* and stored as the userdata() + for the menu item's callback function. + \see Fl_Callback_p Fl_MenuItem::callback() const + */ + void callback(Fl_Callback1*c, long p=0) {callback_=(Fl_Callback*)c; user_data_=(void*)p;} + + /** + Gets the user_data() argument that is sent to the callback function. + */ + void* user_data() const {return user_data_;} + /** + Sets the user_data() argument that is sent to the callback function. + */ + void user_data(void* v) {user_data_ = v;} + /** + Gets the user_data() argument that is sent to the callback function. + For convenience you can also define the callback as taking a long + argument. This method casts the stored userdata() argument to long + and returns it as a \e long value. + */ + long argument() const {return (long)(fl_intptr_t)user_data_;} + /** + Sets the user_data() argument that is sent to the callback function. + For convenience you can also define the callback as taking a long + argument. This method casts the given argument \p v to void* + and stores it in the menu item's userdata() member. + This may not be portable to some machines. + */ + void argument(long v) {user_data_ = (void*)v;} + + /** Gets what key combination shortcut will trigger the menu item. */ + int shortcut() const {return shortcut_;} + + /** + Sets exactly what key combination will trigger the menu item. The + value is a logical 'or' of a key and a set of shift flags, for instance + FL_ALT+'a' or FL_ALT+FL_F+10 or just 'a'. A value of + zero disables the shortcut. + + The key can be any value returned by Fl::event_key(), but will usually + be an ASCII letter. Use a lower-case letter unless you require the shift + key to be held down. + + The shift flags can be any set of values accepted by Fl::event_state(). + If the bit is on that shift key must be pushed. Meta, Alt, Ctrl, + and Shift must be off if they are not in the shift flags (zero for the + other bits indicates a "don't care" setting). + */ + void shortcut(int s) {shortcut_ = s;} + /** + Returns true if either FL_SUBMENU or FL_SUBMENU_POINTER + is on in the flags. FL_SUBMENU indicates an embedded submenu + that goes from the next item through the next one with a NULL + label(). FL_SUBMENU_POINTER indicates that user_data() + is a pointer to another menu array. + */ + int submenu() const {return flags&(FL_SUBMENU|FL_SUBMENU_POINTER);} + /** + Returns true if a checkbox will be drawn next to this item. + This is true if FL_MENU_TOGGLE or FL_MENU_RADIO is set in the flags. + */ + int checkbox() const {return flags&FL_MENU_TOGGLE;} + /** + Returns true if this item is a radio item. + When a radio button is selected all "adjacent" radio buttons are + turned off. A set of radio items is delimited by an item that has + radio() false, or by an item with FL_MENU_DIVIDER turned on. + */ + int radio() const {return flags&FL_MENU_RADIO;} + /** Returns the current value of the check or radio item. */ + int value() const {return flags&FL_MENU_VALUE;} + /** + Turns the check or radio item "on" for the menu item. Note that this + does not turn off any adjacent radio items like set_only() does. + */ + void set() {flags |= FL_MENU_VALUE;} + + /** Turns the check or radio item "off" for the menu item. */ + void clear() {flags &= ~FL_MENU_VALUE;} + + void setonly(); + + /** Gets the visibility of an item. */ + int visible() const {return !(flags&FL_MENU_INVISIBLE);} + + /** Makes an item visible in the menu. */ + void show() {flags &= ~FL_MENU_INVISIBLE;} + + /** Hides an item in the menu. */ + void hide() {flags |= FL_MENU_INVISIBLE;} + + /** Gets whether or not the item can be picked. */ + int active() const {return !(flags&FL_MENU_INACTIVE);} + + /** Allows a menu item to be picked. */ + void activate() {flags &= ~FL_MENU_INACTIVE;} + /** + Prevents a menu item from being picked. Note that this will also cause + the menu item to appear grayed-out. + */ + void deactivate() {flags |= FL_MENU_INACTIVE;} + /** Returns non 0 if FL_INACTIVE and FL_INVISIBLE are cleared, 0 otherwise. */ + int activevisible() const {return !(flags & (FL_MENU_INACTIVE|FL_MENU_INVISIBLE));} + + // compatibility for FLUID so it can set the image of a menu item... + + /** compatibility api for FLUID, same as a->label(this) */ + void image(Fl_Image* a) {a->label(this);} + + /** compatibility api for FLUID, same as a.label(this) */ + void image(Fl_Image& a) {a.label(this);} + + // used by menubar: + int measure(int* h, const Fl_Menu_*) const; + void draw(int x, int y, int w, int h, const Fl_Menu_*, int t=0) const; + + // popup menus without using an Fl_Menu_ widget: + const Fl_Menu_Item* popup( + int X, int Y, + const char *title = 0, + const Fl_Menu_Item* picked=0, + const Fl_Menu_* = 0) const; + const Fl_Menu_Item* pulldown( + int X, int Y, int W, int H, + const Fl_Menu_Item* picked = 0, + const Fl_Menu_* = 0, + const Fl_Menu_Item* title = 0, + int menubar=0) const; + const Fl_Menu_Item* test_shortcut() const; + const Fl_Menu_Item* find_shortcut(int *ip=0, const bool require_alt = false) const; + + /** + Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument. + The callback is called with the stored user_data() as its second argument. + You must first check that callback() is non-zero before calling this. + */ + void do_callback(Fl_Widget* o) const {callback_(o, user_data_);} + + /** + Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument. + This call overrides the callback's second argument with the given value \p arg. + You must first check that callback() is non-zero before calling this. + */ + void do_callback(Fl_Widget* o,void* arg) const {callback_(o, arg);} + + /** + Calls the Fl_Menu_Item item's callback, and provides the Fl_Widget argument. + This call overrides the callback's second argument with the + given value \p arg. long \p arg is cast to void* when calling + the callback. + You must first check that callback() is non-zero before calling this. + */ + void do_callback(Fl_Widget* o,long arg) const {callback_(o, (void*)arg);} + + // back-compatibility, do not use: + + /** back compatibility only \deprecated. */ + int checked() const {return flags&FL_MENU_VALUE;} + + /** back compatibility only \deprecated. */ + void check() {flags |= FL_MENU_VALUE;} + + /** back compatibility only \deprecated. */ + void uncheck() {flags &= ~FL_MENU_VALUE;} + + int insert(int,const char*,int,Fl_Callback*,void* =0, int =0); + int add(const char*, int shortcut, Fl_Callback*, void* =0, int = 0); + + /** See int add(const char*, int shortcut, Fl_Callback*, void*, int) */ + int add(const char*a, const char* b, Fl_Callback* c, + void* d = 0, int e = 0) { + return add(a,fl_old_shortcut(b),c,d,e);} + + int size() const ; +}; + +typedef Fl_Menu_Item Fl_Menu; // back compatibility + +enum { // back-compatibility enum: + FL_PUP_NONE = 0, + FL_PUP_GREY = FL_MENU_INACTIVE, + FL_PUP_GRAY = FL_MENU_INACTIVE, + FL_MENU_BOX = FL_MENU_TOGGLE, + FL_PUP_BOX = FL_MENU_TOGGLE, + FL_MENU_CHECK = FL_MENU_VALUE, + FL_PUP_CHECK = FL_MENU_VALUE, + FL_PUP_RADIO = FL_MENU_RADIO, + FL_PUP_INVISIBLE = FL_MENU_INVISIBLE, + FL_PUP_SUBMENU = FL_SUBMENU_POINTER +}; + +#endif + +// +// End of "$Id: Fl_Menu_Item.H 7983 2010-12-09 00:04:06Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Menu_Window.H b/common/fltk/FL/Fl_Menu_Window.H new file mode 100644 index 00000000..cca5a97d --- /dev/null +++ b/common/fltk/FL/Fl_Menu_Window.H @@ -0,0 +1,68 @@ +// +// "$Id: Fl_Menu_Window.H 7903 2010-11-28 21:06:39Z matt $" +// +// Menu window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Menu_Window widget . */ + +#ifndef Fl_Menu_Window_H +#define Fl_Menu_Window_H + +#include "Fl_Single_Window.H" + +/** + The Fl_Menu_Window widget is a window type used for menus. By + default the window is drawn in the hardware overlay planes if they are + available so that the menu don't force the rest of the window to + redraw. +*/ +class FL_EXPORT Fl_Menu_Window : public Fl_Single_Window { +public: + void show(); + void erase(); + void flush(); + void hide(); + /** Tells if hardware overlay mode is set */ + unsigned int overlay() {return !(flags()&NO_OVERLAY);} + /** Tells FLTK to use hardware overlay planes if they are available. */ + void set_overlay() {clear_flag(NO_OVERLAY);} + /** Tells FLTK to use normal drawing planes instead of overlay planes. + This is usually necessary if your menu contains multi-color pixmaps. */ + void clear_overlay() {set_flag(NO_OVERLAY);} + ~Fl_Menu_Window(); + /** Creates a new Fl_Menu_Window widget using the given size, and label string. */ + Fl_Menu_Window(int W, int H, const char *l = 0) + : Fl_Single_Window(W,H,l) { image(0); } + /** Creates a new Fl_Menu_Window widget using the given position, size, and label string. */ + Fl_Menu_Window(int X, int Y, int W, int H, const char *l = 0) + : Fl_Single_Window(X,Y,W,H,l) { image(0); } +}; + +#endif + +// +// End of "$Id: Fl_Menu_Window.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Multi_Browser.H b/common/fltk/FL/Fl_Multi_Browser.H new file mode 100644 index 00000000..6a866111 --- /dev/null +++ b/common/fltk/FL/Fl_Multi_Browser.H @@ -0,0 +1,66 @@ +// +// "$Id: Fl_Multi_Browser.H 8736 2011-05-24 20:00:56Z AlbrechtS $" +// +// Multi browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Multi_Browser widget . */ + +#ifndef Fl_Multi_Browser_H +#define Fl_Multi_Browser_H + +#include "Fl_Browser.H" + +/** + The Fl_Multi_Browser class is a subclass of Fl_Browser + which lets the user select any set of the lines. The user interface + is Macintosh style: clicking an item turns off all the others and + selects that one, dragging selects all the items the mouse moves over, + and shift + click toggles the items. This is different then how forms + did it. Normally the callback is done when the user releases the + mouse, but you can change this with when(). + <P>See Fl_Browser for methods to add and remove lines from the browser. +*/ +class FL_EXPORT Fl_Multi_Browser : public Fl_Browser { +public: + /** + Creates a new Fl_Multi_Browser widget using the given + position, size, and label string. The default boxtype is FL_DOWN_BOX. + The constructor specializes Fl_Browser() by setting the type to FL_MULTI_BROWSER. + The destructor destroys the widget and frees all memory that has been allocated. + */ +#if defined(FL_DLL) // implementation in src/Fl_Browser.cxx + Fl_Multi_Browser(int X,int Y,int W,int H,const char *L=0); +#else + Fl_Multi_Browser(int X,int Y,int W,int H,const char *L=0) + : Fl_Browser(X,Y,W,H,L) {type(FL_MULTI_BROWSER);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Multi_Browser.H 8736 2011-05-24 20:00:56Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Multi_Label.H b/common/fltk/FL/Fl_Multi_Label.H new file mode 100644 index 00000000..0b160d13 --- /dev/null +++ b/common/fltk/FL/Fl_Multi_Label.H @@ -0,0 +1,47 @@ +// +// "$Id: Fl_Multi_Label.H 7903 2010-11-28 21:06:39Z matt $" +// +// Multi-label header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef Fl_Multi_Label_H +#define Fl_Multi_Label_H + +class Fl_Widget; +struct Fl_Menu_Item; + +struct FL_EXPORT Fl_Multi_Label { + const char* labela; + const char* labelb; + uchar typea; + uchar typeb; + void label(Fl_Widget*); + void label(Fl_Menu_Item*); +}; + +#endif + +// +// End of "$Id: Fl_Multi_Label.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Multiline_Input.H b/common/fltk/FL/Fl_Multiline_Input.H new file mode 100644 index 00000000..a22bfaa3 --- /dev/null +++ b/common/fltk/FL/Fl_Multiline_Input.H @@ -0,0 +1,75 @@ +// +// "$Id: Fl_Multiline_Input.H 8726 2011-05-23 18:32:47Z AlbrechtS $" +// +// Multiline input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Multiline_Input widget . */ + + +#ifndef Fl_Multiline_Input_H +#define Fl_Multiline_Input_H + +#include "Fl_Input.H" + +/** + This input field displays '\n' characters as new lines rather than ^J, + and accepts the Return, Tab, and up and down arrow keys. This is for + editing multiline text. + + This is far from the nirvana of text editors, and is probably only + good for small bits of text, 10 lines at most. Note that this widget + does not support scrollbars or per-character color control. + + If you are presenting large amounts of text and need scrollbars + or full color control of characters, you probably want Fl_Text_Editor + instead. + + In FLTK 1.3.x, the default behavior of the 'Tab' key was changed + to support consistent focus navigation. To get the older FLTK 1.1.x + behavior, set Fl_Input_::tab_nav() to 0. Newer programs should consider using + Fl_Text_Editor. +*/ +class FL_EXPORT Fl_Multiline_Input : public Fl_Input { +public: + /** + Creates a new Fl_Multiline_Input widget using the given + position, size, and label string. The default boxtype is FL_DOWN_BOX. + + Inherited destructor destroys the widget and any value associated with it. + */ +#if defined(FL_DLL) // implementation in src/Fl_Input.cxx + Fl_Multiline_Input(int X,int Y,int W,int H,const char *l = 0); +#else + Fl_Multiline_Input(int X,int Y,int W,int H,const char *l = 0) + : Fl_Input(X,Y,W,H,l) {type(FL_MULTILINE_INPUT);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Multiline_Input.H 8726 2011-05-23 18:32:47Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Multiline_Output.H b/common/fltk/FL/Fl_Multiline_Output.H new file mode 100644 index 00000000..087d6ed6 --- /dev/null +++ b/common/fltk/FL/Fl_Multiline_Output.H @@ -0,0 +1,70 @@ +// +// "$Id: Fl_Multiline_Output.H 8726 2011-05-23 18:32:47Z AlbrechtS $" +// +// Multi line output header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Multiline_Output widget . */ + +#ifndef Fl_Multiline_Output_H +#define Fl_Multiline_Output_H + +#include "Fl_Output.H" + +/** + This widget is a subclass of Fl_Output that displays multiple + lines of text. It also displays tab characters as whitespace to the + next column. + + Note that this widget does not support scrollbars, or per-character + color control. + + If you are presenting large amounts of read-only text + and need scrollbars, or full color control of characters, + then use Fl_Text_Display. If you want to display HTML text, + use Fl_Help_View. +*/ +class FL_EXPORT Fl_Multiline_Output : public Fl_Output { +public: + + /** + Creates a new Fl_Multiline_Output widget using the given position, + size, and label string. The default boxtype is FL_DOWN_BOX. + + Inherited destructor destroys the widget and any value associated with it. + */ +#if defined(FL_DLL) // implementation in src/Fl_Input.cxx + Fl_Multiline_Output(int X,int Y,int W,int H,const char *l = 0); +#else + Fl_Multiline_Output(int X,int Y,int W,int H,const char *l = 0) + : Fl_Output(X,Y,W,H,l) {type(FL_MULTILINE_OUTPUT);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Multiline_Output.H 8726 2011-05-23 18:32:47Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Native_File_Chooser.H b/common/fltk/FL/Fl_Native_File_Chooser.H new file mode 100644 index 00000000..ad76c68d --- /dev/null +++ b/common/fltk/FL/Fl_Native_File_Chooser.H @@ -0,0 +1,305 @@ +// +// "$Id: Fl_Native_File_Chooser.H 8380 2011-02-06 10:07:28Z manolo $" +// +// FLTK native OS file chooser widget +// +// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 2004 Greg Ercolano. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file + Fl_Native_File_Chooser widget. */ + +/** + \class Fl_Native_File_Chooser + + This class lets an FLTK application easily and consistently access + the operating system's native file chooser. Some operating systems + have very complex and specific file choosers that many users want + access to specifically, instead of FLTK's default file chooser(s). + + In cases where there is no native file browser, FLTK's own file browser + is used instead. + + To use this widget correctly, use the following include in your code: + \code + #include <FL/Fl_Native_File_Chooser.H> + \endcode + Do not include the other Fl_Native_File_Choser_XXX.H files in your code; + those are platform specific files that will be included automatically + depending on your build platform. + + The following example shows how to pick a single file: + \code + // Create and post the local native file chooser + #include <FL/Fl_Native_File_Chooser.H> + [..] + Fl_Native_File_Chooser fnfc; + fnfc.title("Pick a file"); + fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE); + fnfc.filter("Text\t*.txt\n" + "C Files\t*.{cxx,h,c}"); + fnfc.directory("/var/tmp"); // default directory to use + // Show native chooser + switch ( fnfc.show() ) { + case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR + case 1: printf("CANCEL\n"); break; // CANCEL + default: printf("PICKED: %s\n", fnfc.filename()); break; // FILE CHOSEN + } + \endcode + + <B>Platform Specific Caveats</B> + + - Under X windows, it's best if you call Fl_File_Icon::load_system_icons() + at the start of main(), to enable the nicer looking file browser widgets. + Use the static public attributes of class Fl_File_Chooser to localize + the browser. + - Some operating systems support certain OS specific options; see + Fl_Native_File_Chooser::options() for a list. + + \image html Fl_Native_File_Chooser.png "The Fl_Native_File_Chooser on different platforms." + \image latex Fl_Native_File_Chooser.png "The Fl_Native_File_Chooser on different platforms" width=14cm + +*/ +#ifndef FL_NATIVE_FILE_CHOOSER_H +#define FL_NATIVE_FILE_CHOOSER_H + +/* \file + Fl_Native_File_Chooser widget. */ + +// Use Windows' chooser +#ifdef WIN32 +// #define _WIN32_WINNT 0x0501 // needed for OPENFILENAME's 'FlagsEx' +#include <stdio.h> +#include <stdlib.h> // malloc +#include <windows.h> +#include <commdlg.h> // OPENFILENAME, GetOpenFileName() +#include <shlobj.h> // BROWSEINFO, SHBrowseForFolder() +#endif + +// Use Apple's chooser +#ifdef __APPLE__ +#include <FL/filename.H> +#define MAXFILTERS 80 +#endif + +// All else falls back to FLTK's own chooser +#if ! defined(__APPLE__) && !defined(WIN32) +#include <FL/Fl_File_Chooser.H> +#include <unistd.h> // _POSIX_NAME_MAX +#endif + + +/** + This class lets an FLTK application easily and consistently access + the operating system's native file chooser. Some operating systems + have very complex and specific file choosers that many users want + access to specifically, instead of FLTK's default file chooser(s). + + In cases where there is no native file browser, FLTK's own file browser + is used instead. + + To use this widget, use the following include in your code: + \code + #include <FL/Fl_Native_File_Chooser.H> + \endcode + + The following example shows how to pick a single file: + \code + // Create and post the local native file chooser + #include <FL/Fl_Native_File_Chooser.H> + [..] + Fl_Native_File_Chooser fnfc; + fnfc.title("Pick a file"); + fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE); + fnfc.filter("Text\t*.txt\n" + "C Files\t*.{cxx,h,c}"); + fnfc.directory("/var/tmp"); // default directory to use + // Show native chooser + switch ( fnfc.show() ) { + case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR + case 1: printf("CANCEL\n"); break; // CANCEL + default: printf("PICKED: %s\n", fnfc.filename()); break; // FILE CHOSEN + } + \endcode + + <B>Platform Specific Caveats</B> + + - Under X windows, it's best if you call Fl_File_Icon::load_system_icons() + at the start of main(), to enable the nicer looking file browser widgets. + Use the static public attributes of class Fl_File_Chooser to localize + the browser. + - Some operating systems support certain OS specific options; see + Fl_Native_File_Chooser::options() for a list. + + \image html Fl_Native_File_Chooser.png "The Fl_Native_File_Chooser on different platforms." + \image latex Fl_Native_File_Chooser.png "The Fl_Native_File_Chooser on different platforms" width=14cm + + */ +class FL_EXPORT Fl_Native_File_Chooser { +public: + enum Type { + BROWSE_FILE = 0, ///< browse files (lets user choose one file) + BROWSE_DIRECTORY, ///< browse directories (lets user choose one directory) + BROWSE_MULTI_FILE, ///< browse files (lets user choose multiple files) + BROWSE_MULTI_DIRECTORY, ///< browse directories (lets user choose multiple directories) + BROWSE_SAVE_FILE, ///< browse to save a file + BROWSE_SAVE_DIRECTORY ///< browse to save a directory + }; + enum Option { + NO_OPTIONS = 0x0000, ///< no options enabled + SAVEAS_CONFIRM = 0x0001, ///< Show native 'Save As' overwrite confirm dialog (if supported) + NEW_FOLDER = 0x0002, ///< Show 'New Folder' icon (if supported) + PREVIEW = 0x0004 ///< enable preview mode + }; + /** Localizable message */ + static const char *file_exists_message; + +public: + Fl_Native_File_Chooser(int val=BROWSE_FILE); + ~Fl_Native_File_Chooser(); + + // Public methods + void type(int); + int type() const; + void options(int); + int options() const; + int count() const; + const char *filename() const; + const char *filename(int i) const; + void directory(const char *val); + const char *directory() const; + void title(const char *); + const char* title() const; + const char *filter() const; + void filter(const char *); + int filters() const; + void filter_value(int i); + int filter_value() const; + void preset_file(const char*); + const char* preset_file() const; + const char *errmsg() const; + int show(); + +#ifdef WIN32 +private: + int _btype; // kind-of browser to show() + int _options; // general options + OPENFILENAMEW _ofn; // GetOpenFileName() & GetSaveFileName() struct + BROWSEINFO _binf; // SHBrowseForFolder() struct + char **_pathnames; // array of pathnames + int _tpathnames; // total pathnames + char *_directory; // default pathname to use + char *_title; // title for window + char *_filter; // user-side search filter + char *_parsedfilt; // filter parsed for Windows dialog + int _nfilters; // number of filters parse_filter counted + char *_preset_file; // the file to preselect + char *_errmsg; // error message + + // Private methods + void errmsg(const char *msg); + + void clear_pathnames(); + void set_single_pathname(const char *s); + void add_pathname(const char *s); + + void FreePIDL(ITEMIDLIST *pidl); + void ClearOFN(); + void ClearBINF(); + void Win2Unix(char *s); + void Unix2Win(char *s); + int showfile(); + static int CALLBACK Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data); + int showdir(); + + void parse_filter(const char *); + void clear_filters(); + void add_filter(const char *, const char *); +#endif + +#ifdef __APPLE__ +private: + int _btype; // kind-of browser to show() + int _options; // general options + void *_panel; + char **_pathnames; // array of pathnames + int _tpathnames; // total pathnames + char *_directory; // default pathname to use + char *_title; // title for window + char *_preset_file; // the 'save as' filename + + char *_filter; // user-side search filter, eg: + // C Files\t*.[ch]\nText Files\t*.txt" + + char *_filt_names; // filter names (tab delimited) + // eg. "C Files\tText Files" + + char *_filt_patt[MAXFILTERS]; + // array of filter patterns, eg: + // _filt_patt[0]="*.{cxx,h}" + // _filt_patt[1]="*.txt" + + int _filt_total; // parse_filter() # of filters loaded + int _filt_value; // index of the selected filter + char *_errmsg; // error message + + // Private methods + void errmsg(const char *msg); + void clear_pathnames(); + void set_single_pathname(const char *s); + int get_saveas_basename(void); + void clear_filters(); + void add_filter(const char *, const char *); + void parse_filter(const char *from); + int post(); +#endif + +#if ! defined(__APPLE__) && !defined(WIN32) +private: + int _btype; // kind-of browser to show() + int _options; // general options + int _nfilters; + char *_filter; // user supplied filter + char *_parsedfilt; // parsed filter + int _filtvalue; // selected filter + char *_preset_file; + char *_prevvalue; // Returned filename + char *_directory; + char *_errmsg; // error message + Fl_File_Chooser *_file_chooser; + + // Private methods + void errmsg(const char *msg); + int type_fl_file(int); + void parse_filter(); + void keeplocation(); + int exist_dialog(); +#endif +}; + + +#endif /*FL_NATIVE_FILE_CHOOSER_H*/ + +// +// End of "$Id: Fl_Native_File_Chooser.H 8380 2011-02-06 10:07:28Z manolo $". +// diff --git a/common/fltk/FL/Fl_Nice_Slider.H b/common/fltk/FL/Fl_Nice_Slider.H new file mode 100644 index 00000000..591a8333 --- /dev/null +++ b/common/fltk/FL/Fl_Nice_Slider.H @@ -0,0 +1,46 @@ +// +// "$Id: Fl_Nice_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// "Nice" slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Nice_Slider widget . */ + +#ifndef Fl_Nice_Slider_H +#define Fl_Nice_Slider_H + +#include "Fl_Slider.H" + +class FL_EXPORT Fl_Nice_Slider : public Fl_Slider { +public: + Fl_Nice_Slider(int x,int y,int w,int h,const char *l=0) + : Fl_Slider(x,y,w,h,l) {type(FL_VERT_NICE_SLIDER); box(FL_FLAT_BOX);} +}; + +#endif + +// +// End of "$Id: Fl_Nice_Slider.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Object.H b/common/fltk/FL/Fl_Object.H new file mode 100644 index 00000000..c743999f --- /dev/null +++ b/common/fltk/FL/Fl_Object.H @@ -0,0 +1,36 @@ +// +// "$Id: Fl_Object.H 7903 2010-11-28 21:06:39Z matt $" +// +// Old Fl_Object header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// This file is provided for back compatibility only. Please use Fl_Widget +#ifndef Fl_Object +#define Fl_Object Fl_Widget +#endif +#include "Fl_Widget.H" + +// +// End of "$Id: Fl_Object.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Output.H b/common/fltk/FL/Fl_Output.H new file mode 100644 index 00000000..51cc0348 --- /dev/null +++ b/common/fltk/FL/Fl_Output.H @@ -0,0 +1,77 @@ +// +// "$Id: Fl_Output.H 8726 2011-05-23 18:32:47Z AlbrechtS $" +// +// Output header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Output widget . */ + +#ifndef Fl_Output_H +#define Fl_Output_H + +#include "Fl_Input.H" +/** + This widget displays a piece of text. + + When you set the value() , Fl_Output does a strcpy() to its own storage, + which is useful for program-generated values. The user may select + portions of the text using the mouse and paste the contents into other + fields or programs. + + <P align=CENTER>\image html text.png</P> + \image latex text.png "Fl_Output" width=8cm + + There is a single subclass, Fl_Multiline_Output, which allows you to + display multiple lines of text. Fl_Multiline_Output does not provide + scroll bars. If a more complete text editing widget is needed, use + Fl_Text_Display instead. + + The text may contain any characters except \\0, and will correctly + display anything, using ^X notation for unprintable control characters + and \\nnn notation for unprintable characters with the high bit set. It + assumes the font can draw any characters in the ISO-Latin1 character set. +*/ +class FL_EXPORT Fl_Output : public Fl_Input { +public: + /** + Creates a new Fl_Output widget using the given position, + size, and label string. The default boxtype is FL_DOWN_BOX. + + Inherited destructor destroys the widget and any value associated with it. + */ + +#if defined(FL_DLL) // implementation in src/Fl_Input.cxx + Fl_Output(int X,int Y,int W,int H, const char *l = 0); +#else + Fl_Output(int X,int Y,int W,int H, const char *l = 0) + : Fl_Input(X, Y, W, H, l) {type(FL_NORMAL_OUTPUT);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Output.H 8726 2011-05-23 18:32:47Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Overlay_Window.H b/common/fltk/FL/Fl_Overlay_Window.H new file mode 100644 index 00000000..918b6710 --- /dev/null +++ b/common/fltk/FL/Fl_Overlay_Window.H @@ -0,0 +1,79 @@ +// +// "$Id: Fl_Overlay_Window.H 7903 2010-11-28 21:06:39Z matt $" +// +// Overlay window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Overlay_Window class . */ + +#ifndef Fl_Overlay_Window_H +#define Fl_Overlay_Window_H + +#include "Fl_Double_Window.H" + +/** + This window provides double buffering and also the ability to draw the + "overlay" which is another picture placed on top of the main image. The + overlay is designed to be a rapidly-changing but simple graphic such as + a mouse selection box. Fl_Overlay_Window uses the overlay + planes provided by your graphics hardware if they are available. + <P>If no hardware support is found the overlay is simulated by drawing + directly into the on-screen copy of the double-buffered window, and + "erased" by copying the backbuffer over it again. This means the + overlay will blink if you change the image in the window. +*/ +class FL_EXPORT Fl_Overlay_Window : public Fl_Double_Window { + friend class _Fl_Overlay; + virtual void draw_overlay() = 0; + Fl_Window *overlay_; +public: + void show(); + void flush(); + void hide(); + void resize(int,int,int,int); + ~Fl_Overlay_Window(); + int can_do_overlay(); + void redraw_overlay(); + /** + Creates a new Fl_Overlay_Window widget using the given + position, size, and label (title) string. If the + positions (x,y) are not given, then the window manager + will choose them. + */ + Fl_Overlay_Window(int W, int H, const char *l=0) + : Fl_Double_Window(W,H,l) {overlay_ = 0; force_doublebuffering_=1; image(0); } + /** + See Fl_Overlay_Window::Fl_Overlay_Window(int W, int H, const char *l=0) + */ + Fl_Overlay_Window(int X, int Y, int W, int H, const char *l=0) + : Fl_Double_Window(X,Y,W,H,l) {overlay_ = 0; force_doublebuffering_=1; image(0); } + void show(int a, char **b) {Fl_Double_Window::show(a,b);} +}; + +#endif + +// +// End of "$Id: Fl_Overlay_Window.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_PNG_Image.H b/common/fltk/FL/Fl_PNG_Image.H new file mode 100644 index 00000000..995b8017 --- /dev/null +++ b/common/fltk/FL/Fl_PNG_Image.H @@ -0,0 +1,55 @@ +// +// "$Id: Fl_PNG_Image.H 8287 2011-01-17 20:51:12Z manolo $" +// +// PNG image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_PNG_Image class . */ + +#ifndef Fl_PNG_Image_H +#define Fl_PNG_Image_H +# include "Fl_Image.H" + +/** + The Fl_PNG_Image class supports loading, caching, + and drawing of Portable Network Graphics (PNG) image files. The + class loads colormapped and full-color images and handles color- + and alpha-based transparency. +*/ +class FL_EXPORT Fl_PNG_Image : public Fl_RGB_Image { + +public: + + Fl_PNG_Image(const char* filename); + Fl_PNG_Image (const char *name_png, const unsigned char *buffer, int datasize); +private: + void load_png_(const char *name_png, const unsigned char *buffer_png, int datasize); +}; + +#endif + +// +// End of "$Id: Fl_PNG_Image.H 8287 2011-01-17 20:51:12Z manolo $". +// diff --git a/common/fltk/FL/Fl_PNM_Image.H b/common/fltk/FL/Fl_PNM_Image.H new file mode 100644 index 00000000..739fc07e --- /dev/null +++ b/common/fltk/FL/Fl_PNM_Image.H @@ -0,0 +1,52 @@ +// +// "$Id: Fl_PNM_Image.H 7903 2010-11-28 21:06:39Z matt $" +// +// PNM image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_PNM_Image class . */ + +#ifndef Fl_PNM_Image_H +#define Fl_PNM_Image_H +# include "Fl_Image.H" + +/** + The Fl_PNM_Image class supports loading, caching, + and drawing of Portable Anymap (PNM, PBM, PGM, PPM) image files. The class + loads bitmap, grayscale, and full-color images in both ASCII and + binary formats. +*/ +class FL_EXPORT Fl_PNM_Image : public Fl_RGB_Image { + + public: + + Fl_PNM_Image(const char* filename); +}; + +#endif + +// +// End of "$Id: Fl_PNM_Image.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Pack.H b/common/fltk/FL/Fl_Pack.H new file mode 100644 index 00000000..4ff3ae44 --- /dev/null +++ b/common/fltk/FL/Fl_Pack.H @@ -0,0 +1,84 @@ +// +// "$Id: Fl_Pack.H 7903 2010-11-28 21:06:39Z matt $" +// +// Pack header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Pack widget . */ + +#ifndef Fl_Pack_H +#define Fl_Pack_H + +#include <FL/Fl_Group.H> + +/** + This widget was designed to add the functionality of compressing and + aligning widgets. + <P>If type() is Fl_Pack::HORIZONTAL all the children are + resized to the height of the Fl_Pack, and are moved next to + each other horizontally. If type() is not Fl_Pack::HORIZONTAL + then the children are resized to the width and are stacked below each + other. Then the Fl_Pack resizes itself to surround the child + widgets. + <P>This widget is needed for the Fl_Tabs. + In addition you may want to put the Fl_Pack inside an + Fl_Scroll. + + <P>The resizable for Fl_Pack is set to NULL by default.</p> + <P>See also: Fl_Group::resizable() +*/ +class FL_EXPORT Fl_Pack : public Fl_Group { + int spacing_; + +public: + enum { // values for type(int) + VERTICAL = 0, + HORIZONTAL = 1 + }; + +protected: + void draw(); + +public: + Fl_Pack(int x,int y,int w ,int h,const char *l = 0); + /** + Gets the number of extra pixels of blank space that are added + between the children. + */ + int spacing() const {return spacing_;} + /** + Sets the number of extra pixels of blank space that are added + between the children. + */ + void spacing(int i) {spacing_ = i;} + /** Same as Fl_Group::type() */ + uchar horizontal() const {return type();} +}; + +#endif + +// +// End of "$Id: Fl_Pack.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Paged_Device.H b/common/fltk/FL/Fl_Paged_Device.H new file mode 100644 index 00000000..f65da3a9 --- /dev/null +++ b/common/fltk/FL/Fl_Paged_Device.H @@ -0,0 +1,153 @@ +// +// "$Id: Fl_Paged_Device.H 8699 2011-05-20 16:39:06Z manolo $" +// +// Printing support for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file Fl_Paged_Device.H + \brief declaration of class Fl_Paged_Device. + */ + +#ifndef Fl_Paged_Device_H +#define Fl_Paged_Device_H + +#include <FL/Fl_Device.H> +#include <FL/Fl_Window.H> + +/** \brief Number of elements in enum Page_Format */ +#define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */ + +/** + \brief Represents page-structured drawing surfaces. + * + This class has no public constructor: don't instantiate it; use Fl_Printer + or Fl_PostScript_File_Device instead. + */ +class FL_EXPORT Fl_Paged_Device : public Fl_Surface_Device { +public: + /** + \brief Possible page formats. + + All paper formats with pre-defined width and height. + */ + enum Page_Format { + A0 = 0, /**< A0 format */ + A1, + A2, + A3, + A4, /**< A4 format */ + A5, + A6, + A7, + A8, + A9, + B0, + B1, + B2, + B3, + B4, + B5, + B6, + B7, + B8, + B9, + B10, + C5E, + DLE, + EXECUTIVE, + FOLIO, + LEDGER, + LEGAL, + LETTER, /**< Letter format */ + TABLOID, + ENVELOPE, + MEDIA = 0x1000 + }; + /** + \brief Possible page layouts. + */ + enum Page_Layout { + PORTRAIT = 0, /**< Portrait orientation */ + LANDSCAPE = 0x100, /**< Landscape orientation */ + REVERSED = 0x200, /**< Reversed orientation */ + ORIENTATION = 0x300 /**< orientation */ + }; + + /** \brief width, height and name of a page format + */ + typedef struct { + /** \brief width in points */ + int width; + /** \brief height in points */ + int height; + /** \brief format name */ + const char *name; + } page_format; + /** \brief width, height and name of all elements of the enum \ref Page_Format. + */ + static const page_format page_formats[NO_PAGE_FORMATS]; +private: + void traverse(Fl_Widget *widget); // finds subwindows of widget and prints them +protected: + /** \brief horizontal offset to the origin of graphics coordinates */ + int x_offset; + /** \brief vertical offset to the origin of graphics coordinates */ + int y_offset; + /** \brief The constructor */ + Fl_Paged_Device() : Fl_Surface_Device(NULL) {}; + /** \brief The destructor */ + virtual ~Fl_Paged_Device() {}; +public: + static const char *class_id; + const char *class_name() {return class_id;}; + virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); + virtual int start_page(void); + virtual int printable_rect(int *w, int *h); + virtual void margins(int *left, int *top, int *right, int *bottom); + virtual void origin(int x, int y); + virtual void origin(int *x, int *y); + virtual void scale(float scale_x, float scale_y = 0.); + virtual void rotate(float angle); + virtual void translate(int x, int y); + virtual void untranslate(void); + virtual void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0); + /** Prints a window with its title bar and frame if any. + + \p x_offset and \p y_offset are optional coordinates of where to position the window top left. + Equivalent to print_widget() if \p win is a subwindow or has no border. + Use Fl_Window::decorated_w() and Fl_Window::decorated_h() to get the size of the + printed window. + */ + void print_window(Fl_Window *win, int x_offset = 0, int y_offset = 0); + virtual void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x = 0, int delta_y = 0); + virtual int end_page (void); + virtual void end_job (void); +}; + +#endif // Fl_Paged_Device_H + +// +// End of "$Id: Fl_Paged_Device.H 8699 2011-05-20 16:39:06Z manolo $" +// + diff --git a/common/fltk/FL/Fl_Pixmap.H b/common/fltk/FL/Fl_Pixmap.H new file mode 100644 index 00000000..bc6438b7 --- /dev/null +++ b/common/fltk/FL/Fl_Pixmap.H @@ -0,0 +1,99 @@ +// +// "$Id: Fl_Pixmap.H 7903 2010-11-28 21:06:39Z matt $" +// +// Pixmap header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Pixmap widget . */ + +#ifndef Fl_Pixmap_H +#define Fl_Pixmap_H +# include "Fl_Image.H" + +class Fl_Widget; +struct Fl_Menu_Item; + +// Older C++ compilers don't support the explicit keyword... :( +# if defined(__sgi) && !defined(_COMPILER_VERSION) +# define explicit +# endif // __sgi && !_COMPILER_VERSION + +/** + The Fl_Pixmap class supports caching and drawing of colormap + (pixmap) images, including transparency. +*/ +class FL_EXPORT Fl_Pixmap : public Fl_Image { + friend class Fl_Quartz_Graphics_Driver; + friend class Fl_GDI_Graphics_Driver; + friend class Fl_Xlib_Graphics_Driver; + void copy_data(); + void delete_data(); + void set_data(const char * const *p); + + protected: + + void measure(); + + public: + + int alloc_data; // Non-zero if data was allocated + + private: + +#if defined(__APPLE__) || defined(WIN32) + void *id_; // for internal use + void *mask_; // for internal use (mask bitmap) +#else + unsigned id_; // for internal use + unsigned mask_; // for internal use (mask bitmap) +#endif // __APPLE__ || WIN32 + + public: + + /** The constructors create a new pixmap from the specified XPM data. */ + explicit Fl_Pixmap(char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();} + /** The constructors create a new pixmap from the specified XPM data. */ + explicit Fl_Pixmap(uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();} + /** The constructors create a new pixmap from the specified XPM data. */ + explicit Fl_Pixmap(const char * const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();} + /** The constructors create a new pixmap from the specified XPM data. */ + explicit Fl_Pixmap(const uchar* const * D) : Fl_Image(-1,0,1), alloc_data(0), id_(0), mask_(0) {set_data((const char*const*)D); measure();} + virtual ~Fl_Pixmap(); + virtual Fl_Image *copy(int W, int H); + Fl_Image *copy() { return copy(w(), h()); } + virtual void color_average(Fl_Color c, float i); + virtual void desaturate(); + virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); + void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} + virtual void label(Fl_Widget*w); + virtual void label(Fl_Menu_Item*m); + virtual void uncache(); +}; + +#endif + +// +// End of "$Id: Fl_Pixmap.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Plugin.H b/common/fltk/FL/Fl_Plugin.H new file mode 100644 index 00000000..62da3a23 --- /dev/null +++ b/common/fltk/FL/Fl_Plugin.H @@ -0,0 +1,104 @@ +// +// "$Id: Fl_Plugin.H 6995 2010-01-12 08:48:55Z matt $" +// +// A Plugin system for FLTK, implemented in Fl_Preferences.cxx. +// +// Copyright 2002-2010 by Matthias Melcher. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Plugin class . */ + +#ifndef Fl_Plugin_H +# define Fl_Plugin_H + +# include "Fl_Preferences.H" + + +/** + \brief Fl_Plugin allows link-time and run-time integration of binary modules. + + Fl_Plugin and Fl_Plugin_Manager provide a small and simple solution for + linking C++ classes at run-time, or optionally linking modules at compile + time without the need to change the main application. + + Fl_Plugin_Manager uses static initialisation to create the plugin interface + early during startup. Plugins are stored in a temporary database, organized + in classes. + + Plugins should derive a new class from Fl_Plugin as a base: + \code + class My_Plugin : public Fl_Plugin { + public: + My_Plugin() : Fl_Plugin("effects", "blur") { } + void do_something(...); + }; + My_Plugin blur_plugin(); + \endcode + + Plugins can be put into modules and either linked before distribution, or loaded + from dynamically linkable files. An Fl_Plugin_Manager is used to list and + access all currently loaded plugins. + \code + Fl_Plugin_Manager mgr("effects"); + int i, n = mgr.plugins(); + for (i=0; i<n; i++) { + My_Plugin *pin = (My_Plugin*)mgr.plugin(i); + pin->do_something(); + } + \endcode + */ +class FL_EXPORT Fl_Plugin { + Fl_Preferences::ID id; +public: + Fl_Plugin(const char *klass, const char *name); + virtual ~Fl_Plugin(); +}; + + +/** + \brief Fl_Plugin_Manager manages link-time and run-time plugin binaries. + \see Fl_Plugin + */ +class FL_EXPORT Fl_Plugin_Manager : public Fl_Preferences { +public: + Fl_Plugin_Manager(const char *klass); + ~Fl_Plugin_Manager(); + + /** \brief Return the number of plugins in the klass. + */ + int plugins() { return groups(); } + Fl_Plugin *plugin(int index); + Fl_Plugin *plugin(const char *name); + Fl_Preferences::ID addPlugin(const char *name, Fl_Plugin *plugin); + + static void removePlugin(Fl_Preferences::ID id); + static int load(const char *filename); + static int loadAll(const char *filepath, const char *pattern=0); +}; + + +#endif // !Fl_Preferences_H + +// +// End of "$Id: Fl_Preferences.H 6995 2010-01-12 08:48:55Z matt $". +// diff --git a/common/fltk/FL/Fl_Positioner.H b/common/fltk/FL/Fl_Positioner.H new file mode 100644 index 00000000..c8b31a62 --- /dev/null +++ b/common/fltk/FL/Fl_Positioner.H @@ -0,0 +1,103 @@ +// +// "$Id: Fl_Positioner.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Positioner header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Positioner widget . */ + +#ifndef Fl_Positioner_H +#define Fl_Positioner_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +/** + This class is provided for Forms compatibility. It provides 2D input. + It would be useful if this could be put atop another widget so that the + crosshairs are on top, but this is not implemented. The color of the + crosshairs is selection_color(). + <P ALIGN=CENTER>\image html positioner.png </P> + \image latex positioner.png " Fl_Positioner" width=4cm +*/ +class FL_EXPORT Fl_Positioner : public Fl_Widget { + + double xmin, ymin; + double xmax, ymax; + double xvalue_, yvalue_; + double xstep_, ystep_; + +protected: + + // these allow subclasses to put the dial in a smaller area: + void draw(int, int, int, int); + int handle(int, int, int, int, int); + void draw(); + +public: + + int handle(int); + /** + Creates a new Fl_Positioner widget using the given position, + size, and label string. The default boxtype is FL_NO_BOX. + */ + Fl_Positioner(int x,int y,int w,int h, const char *l=0); + /** Gets the X axis coordinate.*/ + double xvalue() const {return xvalue_;} + /** Gets the Y axis coordinate.*/ + double yvalue() const {return yvalue_;} + int xvalue(double); + int yvalue(double); + int value(double,double); + void xbounds(double, double); + /** Gets the X axis minimum */ + double xminimum() const {return xmin;} + /** Same as xbounds(a, xmaximum()) */ + void xminimum(double a) {xbounds(a,xmax);} + /** Gets the X axis maximum */ + double xmaximum() const {return xmax;} + /** Same as xbounds(xminimum(), a) */ + void xmaximum(double a) {xbounds(xmin,a);} + void ybounds(double, double); + /** Gets the Y axis minimum */ + double yminimum() const {return ymin;} + /** Same as ybounds(a, ymaximum()) */ + void yminimum(double a) {ybounds(a, ymax);} + /** Gets the Y axis maximum */ + double ymaximum() const {return ymax;} + /** Same as ybounds(ymininimum(), a) */ + void ymaximum(double a) {ybounds(ymin, a);} + /** Sets the stepping value for the X axis.*/ + void xstep(double a) {xstep_ = a;} + /** Sets the stepping value for the Y axis.*/ + void ystep(double a) {ystep_ = a;} +}; + +#endif + +// +// End of "$Id: Fl_Positioner.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_PostScript.H b/common/fltk/FL/Fl_PostScript.H new file mode 100644 index 00000000..fe1ee01b --- /dev/null +++ b/common/fltk/FL/Fl_PostScript.H @@ -0,0 +1,253 @@ +// +// "$Id: Fl_PostScript.H 8699 2011-05-20 16:39:06Z manolo $" +// +// Support for graphics output to PostScript file for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// +/** \file Fl_PostScript.H + \brief declaration of classes Fl_PostScript_Graphics_Driver, Fl_PostScript_File_Device. + */ + + +#ifndef Fl_PostScript_H +#define Fl_PostScript_H + +#include <FL/Fl_Paged_Device.H> +#include <FL/fl_draw.H> + +/** + \brief PostScript graphical backend. + * + PostScript text uses vectorial fonts for the latin alphabet (exactly: all unicode + characters between U+0020 and U+017F, that is, ASCII, Latin-1 Supplement and Latin Extended-A charts) + plus a few other characters: + <table> + <tr> <th>Char</th><th>Codepoint</th><th>Name</th> <th>Char</th><th>Codepoint</th><th>Name</th> <th>Char</th><th>Codepoint</th><th>Name</th></tr> + <tr><td>Æ</td><td>U+0192</td><td>florin</td><td>â</td><td>U+201A</td><td>quotesinglbase</td><td>âą</td><td>U+2122</td><td>trademark</td></tr> + <tr><td>Ë</td><td>U+02C6</td><td>circumflex</td><td>â</td><td>U+201C</td><td>quotedblleft</td><td>â</td><td>U+2202</td><td>partialdiff</td></tr> + <tr><td>Ë</td><td>U+02C7</td><td>caron</td><td>â</td><td>U+201D</td><td>quotedblright</td><td>Î</td><td>U+2206</td><td>Delta</td></tr> + <tr><td>Ë</td><td>U+02D8</td><td>breve</td><td>â</td><td>U+201E</td><td>quotedblbase</td><td>â</td><td>U+2211</td><td>summation</td></tr> + <tr><td>Ë</td><td>U+02D9</td><td>dotaccent</td><td>â </td><td>U+2020</td><td>dagger</td><td>â</td><td>U+221A</td><td>radical</td></tr> + <tr><td>Ë</td><td>U+02DA</td><td>ring</td><td>âĄ</td><td>U+2021</td><td>daggerdbl</td><td>â</td><td>U+221E</td><td>infinity</td></tr> + <tr><td>Ë</td><td>U+02DB</td><td>ogonek</td><td>âą</td><td>U+2022</td><td>bullet</td><td>â </td><td>U+2260</td><td>notequal</td></tr> + <tr><td>Ë</td><td>U+02DC</td><td>tilde</td><td>âŠ</td><td>U+2026</td><td>ellipsis</td><td>â€</td><td>U+2264</td><td>lessequal</td></tr> + <tr><td>Ë</td><td>U+02DD</td><td>hungarumlaut</td><td>â°</td><td>U+2030</td><td>perthousand</td><td>â„</td><td>U+2265</td><td>greaterequal</td></tr> + <tr><td>â</td><td>U+2013</td><td>endash</td><td>âč</td><td>U+2039</td><td>guilsinglleft</td><td>â</td><td>U+25CA</td><td>lozenge</td></tr> + <tr><td>â</td><td>U+2014</td><td>emdash</td><td>âș</td><td>U+203A</td><td>guilsinglright</td><td>ïŹ</td><td>U+FB01</td><td>fi</td></tr> + <tr><td>â</td><td>U+2018</td><td>quoteleft</td><td>/</td><td>U+2044</td><td>fraction</td><td>ïŹ</td><td>U+FB02</td><td>fl</td></tr> + <tr><td>â</td><td>U+2019</td><td>quoteright</td><td>âŹ</td><td>U+20AC</td><td>Euro</td><td>ïŁż</td><td>U+F8FF</td><td>apple (Mac OS only)</td></tr> + </table> + <br> All other unicode characters are output as a bitmap. + <br> FLTK standard fonts are output using PostScript standard fonts: Helvetica, Courier, + Times (and their bold, oblique, italic variants). + */ +class FL_EXPORT Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver { +public: + static const char *class_id; + const char *class_name() {return class_id;}; + Fl_PostScript_Graphics_Driver(); +#ifndef FL_DOXYGEN + enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS}; + +class Clip { + public: + int x, y, w, h; + Clip *prev; + }; + Clip * clip_; + + int lang_level_; + int gap_; + int pages_; + + double width_; + double height_; + + int shape_; + int linewidth_;// need for clipping, lang level 1-2 + int linestyle_;// + int interpolate_; //interpolation of images + unsigned char cr_,cg_,cb_; + char linedash_[256];//should be enough + void concat(); // transform ror scalable dradings... + void reconcat(); //invert + void recover(); //recovers the state after grestore (such as line styles...) + void reset(); + + uchar * mask; + int mx; // width of mask; + int my; // mask lines + //Fl_Color bg_; + int (*close_cmd_)(FILE *); + int page_policy_; + int nPages; + int orientation_; + + float scale_x; + float scale_y; + float angle; + int left_margin; + int top_margin; + + FILE *output; + double pw_, ph_; + + uchar bg_r, bg_g, bg_b; + int start_postscript (int pagecount, enum Fl_Paged_Device::Page_Format format, enum Fl_Paged_Device::Page_Layout layout); + /* int alpha_mask(const uchar * data, int w, int h, int D, int LD=0); + */ + void transformed_draw(const char* s, int n, double x, double y); //precise text placing + void transformed_draw(const char* s, double x, double y); + int alpha_mask(const uchar * data, int w, int h, int D, int LD=0); + + enum Fl_Paged_Device::Page_Format page_format_; + char *ps_filename_; + + void page_policy(int p); + int page_policy(){return page_policy_;}; + void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;}; + FILE * file() {return output;}; + //void orientation (int o); + //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor + //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor + void interpolate(int i){interpolate_=i;}; + int interpolate(){return interpolate_;} + + void page(double pw, double ph, int media = 0); + void page(int format); +#endif // FL_DOXYGEN + + // implementation of drawing methods + void color(Fl_Color c); + void color(uchar r, uchar g, uchar b); + + void push_clip(int x, int y, int w, int h); + int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H); + int not_clipped(int x, int y, int w, int h); + void push_no_clip(); + void pop_clip(); + + void line_style(int style, int width=0, char* dashes=0); + + void rect(int x, int y, int w, int h); + void rectf(int x, int y, int w, int h); + + void xyline(int x, int y, int x1); + void xyline(int x, int y, int x1, int y2); + void xyline(int x, int y, int x1, int y2, int x3); + + void yxline(int x, int y, int y1); + void yxline(int x, int y, int y1, int x2); + void yxline(int x, int y, int y1, int x2, int y3); + + void line(int x1, int y1, int x2, int y2); + void line(int x1, int y1, int x2, int y2, int x3, int y3); + + void loop(int x0, int y0, int x1, int y1, int x2, int y2); + void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + void polygon(int x0, int y0, int x1, int y1, int x2, int y2); + void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + void point(int x, int y); + + void begin_points(); + void begin_line(); + void begin_loop(); + void begin_polygon(); + void vertex(double x, double y); + void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3); + void circle(double x, double y, double r); + void arc(double x, double y, double r, double start, double a); + void arc(int x, int y, int w, int h, double a1, double a2); + void pie(int x, int y, int w, int h, double a1, double a2); + void end_points(); + void end_line(); + void end_loop(); + void end_polygon(); + void begin_complex_polygon(){begin_polygon();}; + void gap(){gap_=1;}; + void end_complex_polygon(){end_polygon();}; + void transformed_vertex(double x, double y); + + void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0); + void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0); + void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3); + void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1); + + void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); }; +#ifdef __APPLE__ + void draw(const char* s, int n, float x, float y) {transformed_draw(s,n,x,y); }; +#endif + void draw(int angle, const char *str, int n, int x, int y); + void rtl_draw(const char* s, int n, int x, int y); + void font(int face, int size); + double width(const char *, int); + void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h); + int height(); + int descent(); + void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy); + void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy); + void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy); + ~Fl_PostScript_Graphics_Driver(); +}; + +/** + \brief To send graphical output to a PostScript file. + */ +class FL_EXPORT Fl_PostScript_File_Device : public Fl_Paged_Device { +#ifdef __APPLE__ + Fl_CGContextRef gc; +#endif +protected: + Fl_PostScript_Graphics_Driver *driver(); +public: + static const char *class_id; + const char *class_name() {return class_id;}; + Fl_PostScript_File_Device(); + ~Fl_PostScript_File_Device(); + int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, + enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT); + int start_job(FILE *ps_output, int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, + enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT); + int start_page (void); + int printable_rect(int *w, int *h); + void margins(int *left, int *top, int *right, int *bottom); + void origin(int *x, int *y); + void origin(int x, int y); + void scale (float scale_x, float scale_y = 0.); + void rotate(float angle); + void translate(int x, int y); + void untranslate(void); + int end_page (void); + void end_job(void); +#ifdef __APPLE__ + void set_current() { fl_gc = gc; Fl_Paged_Device::set_current(); } +#endif + + static const char *file_chooser_title; +}; + +#endif // Fl_PostScript_H + +// +// End of "$Id: Fl_PostScript.H 8699 2011-05-20 16:39:06Z manolo $" +// diff --git a/common/fltk/FL/Fl_Preferences.H b/common/fltk/FL/Fl_Preferences.H new file mode 100644 index 00000000..8fa3f04c --- /dev/null +++ b/common/fltk/FL/Fl_Preferences.H @@ -0,0 +1,276 @@ +// +// "$Id: Fl_Preferences.H 7949 2010-12-05 00:38:16Z greg.ercolano $" +// +// Preferences . +// +// Copyright 2002-2010 by Matthias Melcher. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Preferences class . */ + +#ifndef Fl_Preferences_H +# define Fl_Preferences_H + +# include <stdio.h> +# include "Fl_Export.H" + +/** + \brief Fl_Preferences provides methods to store user + settings between application starts. + + It is similar to the + Registry on WIN32 and Preferences on MacOS, and provides a + simple configuration mechanism for UNIX. + + Fl_Preferences uses a hierarchy to store data. It + bundles similar data into groups and manages entries into those + groups as name/value pairs. + + Preferences are stored in text files that can be edited + manually. The file format is easy to read and relatively + forgiving. Preferences files are the same on all platforms. User + comments in preference files are preserved. Filenames are unique + for each application by using a vendor/application naming + scheme. The user must provide default values for all entries to + ensure proper operation should preferences be corrupted or not + yet exist. + + Entries can be of any length. However, the size of each + preferences file should be kept small for performance + reasons. One application can have multiple preferences files. + Extensive binary data however should be stored in separate + files: see getUserdataPath(). + + \note Starting with FLTK 1.3, preference databases are expected to + be in utf8 encoding. Previous databases were stored in the + current chracter set or code page which renders them incompatible + for text entries using international characters. + */ +class FL_EXPORT Fl_Preferences { + +public: + /** + Define the scope of the preferences. + */ + enum Root { + SYSTEM=0, ///< Preferences are used system-wide + USER ///< Preferences apply only to the current user + }; + + /** + Every Fl_Preferences-Group has a uniqe ID. + + ID's can be retrieved from an Fl_Preferences-Group and can then be used + to create more Fl_Preference references to the same data set, as long as the + database remains open. + */ + typedef void *ID; + + static const char *newUUID(); + + Fl_Preferences( Root root, const char *vendor, const char *application ); + Fl_Preferences( const char *path, const char *vendor, const char *application ); + Fl_Preferences( Fl_Preferences &parent, const char *group ); + Fl_Preferences( Fl_Preferences *parent, const char *group ); + Fl_Preferences( Fl_Preferences &parent, int groupIndex ); + Fl_Preferences( Fl_Preferences *parent, int groupIndex ); + Fl_Preferences(const Fl_Preferences&); + Fl_Preferences( ID id ); + virtual ~Fl_Preferences(); + + /** Return an ID that can later be reused to open more references to this dataset. + */ + ID id() { return (ID)node; } + + /** Remove the group with this ID from a database. + */ + static char remove(ID id_) { return ((Node*)id_)->remove(); } + + /** Return the name of this entry. + */ + const char *name() { return node->name(); } + + /** Return the the full path to this entry. + */ + const char *path() { return node->path(); } + + int groups(); + const char *group( int num_group ); + char groupExists( const char *key ); + char deleteGroup( const char *group ); + char deleteAllGroups(); + + int entries(); + const char *entry( int index ); + char entryExists( const char *key ); + char deleteEntry( const char *entry ); + char deleteAllEntries(); + + char clear(); + + char set( const char *entry, int value ); + char set( const char *entry, float value ); + char set( const char *entry, float value, int precision ); + char set( const char *entry, double value ); + char set( const char *entry, double value, int precision ); + char set( const char *entry, const char *value ); + char set( const char *entry, const void *value, int size ); + + char get( const char *entry, int &value, int defaultValue ); + char get( const char *entry, float &value, float defaultValue ); + char get( const char *entry, double &value, double defaultValue ); + char get( const char *entry, char *&value, const char *defaultValue ); + char get( const char *entry, char *value, const char *defaultValue, int maxSize ); + char get( const char *entry, void *&value, const void *defaultValue, int defaultSize ); + char get( const char *entry, void *value, const void *defaultValue, int defaultSize, int maxSize ); + + int size( const char *entry ); + + char getUserdataPath( char *path, int pathlen ); + + void flush(); + + // char export( const char *filename, Type fileFormat ); + // char import( const char *filename ); + + /** + 'Name' provides a simple method to create numerical or more complex + procedural names for entries and groups on the fly. + + Example: prefs.set(Fl_Preferences::Name("File%d",i),file[i]);. + + See test/preferences.cxx as a sample for writing arrays into preferences.<p> + 'Name' is actually implemented as a class inside Fl_Preferences. It casts + into const char* and gets automatically destroyed after the enclosing call + ends. + */ + class FL_EXPORT Name { + + char *data_; + + public: + Name( unsigned int n ); + Name( const char *format, ... ); + + /** + Return the Name as a "C" string. + \internal + */ + operator const char *() { return data_; } + ~Name(); + }; + + /** \internal An entry associates a preference name to its corresponding value */ + struct Entry { + char *name, *value; + }; + +private: + Fl_Preferences() : node(0), rootNode(0) { } + Fl_Preferences &operator=(const Fl_Preferences&); + + static char nameBuffer[128]; + static char uuidBuffer[40]; + static Fl_Preferences *runtimePrefs; + + class RootNode; + + class FL_EXPORT Node { // a node contains a list to all its entries + // and all means to manage the tree structure + Node *child_, *next_; + union { // these two are mutually exclusive + Node *parent_; // top_ bit clear + RootNode *root_; // top_ bit set + }; + char *path_; + Entry *entry_; + int nEntry_, NEntry_; + unsigned char dirty_:1; + unsigned char top_:1; + unsigned char indexed_:1; + // indexing routines + Node **index_; + int nIndex_, NIndex_; + void createIndex(); + void updateIndex(); + void deleteIndex(); + public: + static int lastEntrySet; + public: + Node( const char *path ); + ~Node(); + // node methods + int write( FILE *f ); + const char *name(); + const char *path() { return path_; } + Node *find( const char *path ); + Node *search( const char *path, int offset=0 ); + Node *childNode( int ix ); + Node *addChild( const char *path ); + void setParent( Node *parent ); + Node *parent() { return top_?0L:parent_; } + void setRoot(RootNode *r) { root_ = r; top_ = 1; } + RootNode *findRoot(); + char remove(); + char dirty(); + void deleteAllChildren(); + // entry methods + int nChildren(); + const char *child( int ix ); + void set( const char *name, const char *value ); + void set( const char *line ); + void add( const char *line ); + const char *get( const char *name ); + int getEntry( const char *name ); + char deleteEntry( const char *name ); + void deleteAllEntries(); + int nEntry() { return nEntry_; } + Entry &entry(int i) { return entry_[i]; } + }; + friend class Node; + + class FL_EXPORT RootNode { // the root node manages file paths and basic reading and writing + Fl_Preferences *prefs_; + char *filename_; + char *vendor_, *application_; + public: + RootNode( Fl_Preferences *, Root root, const char *vendor, const char *application ); + RootNode( Fl_Preferences *, const char *path, const char *vendor, const char *application ); + RootNode( Fl_Preferences * ); + ~RootNode(); + int read(); + int write(); + char getPath( char *path, int pathlen ); + }; + friend class RootNode; + +protected: + Node *node; + RootNode *rootNode; +}; + +#endif // !Fl_Preferences_H + +// +// End of "$Id: Fl_Preferences.H 7949 2010-12-05 00:38:16Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Printer.H b/common/fltk/FL/Fl_Printer.H new file mode 100644 index 00000000..6e8d0efc --- /dev/null +++ b/common/fltk/FL/Fl_Printer.H @@ -0,0 +1,214 @@ +// +// "$Id: Fl_Printer.H 8699 2011-05-20 16:39:06Z manolo $" +// +// Printing support for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// +/** \file Fl_Printer.H + \brief declaration of classes Fl_Printer, Fl_System_Printer and Fl_PostScript_Printer. + */ + +#ifndef Fl_Printer_H +#define Fl_Printer_H + +#include <FL/x.H> +#include <FL/Fl_Paged_Device.H> +#include <FL/fl_draw.H> +#include <FL/Fl_Pixmap.H> +#include <FL/Fl_RGB_Image.H> +#include <FL/Fl_Bitmap.H> +#include <stdio.h> +#if !(defined(__APPLE__) || defined(WIN32)) +#include <FL/Fl_PostScript.H> +#elif defined(WIN32) +#include <commdlg.h> +#endif + +#if defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN) +/** + Print support under MSWindows and Mac OS. + + Class Fl_System_Printer is implemented only on the MSWindows and Mac OS platforms. + It has no public constructor. + Use Fl_Printer instead that is cross-platform and has the same API. + */ +class Fl_System_Printer : public Fl_Paged_Device { + friend class Fl_Printer; +private: + /** \brief the printer's graphics context, if there's one, NULL otherwise */ + void *gc; + void set_current(void); +#ifdef __APPLE__ + float scale_x; + float scale_y; + float angle; // rotation angle in radians + Fl_PMPrintSession printSession; + Fl_PMPageFormat pageFormat; + Fl_PMPrintSettings printSettings; +#elif defined(WIN32) + int abortPrint; + PRINTDLG pd; + HDC hPr; + int prerr; + int left_margin; + int top_margin; + void absolute_printable_rect(int *x, int *y, int *w, int *h); +#endif +protected: + /** \brief The constructor */ + Fl_System_Printer(void); +public: + static const char *class_id; + const char *class_name() {return class_id;}; + int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); + int start_page (void); + int printable_rect(int *w, int *h); + void margins(int *left, int *top, int *right, int *bottom); + void origin(int *x, int *y); + void origin(int x, int y); + void scale (float scale_x, float scale_y = 0.); + void rotate(float angle); + void translate(int x, int y); + void untranslate(void); + int end_page (void); + void end_job (void); + /** \brief The destructor */ + ~Fl_System_Printer(void); +}; // class Fl_System_Printer + +#endif + +#if !(defined(__APPLE__) || defined(WIN32) ) +/** + Print support under Unix/Linux. + + Class Fl_PostScript_Printer is implemented only on the Unix/Linux platform. + It has no public constructor. + Use Fl_Printer instead that is cross-platform and has the same API. + */ +class Fl_PostScript_Printer : public Fl_PostScript_File_Device { + friend class Fl_Printer; +protected: + /** The constructor */ + Fl_PostScript_Printer(void) {}; +public: + static const char *class_id; + const char *class_name() {return class_id;}; + int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL); +}; + +#endif + +/** + * \brief OS-independent print support. + * + Fl_Printer allows to use all FLTK drawing, color, text, and clip functions, and to have them operate + on printed page(s). There are two main, non exclusive, ways to use it. + <ul><li>Print any widget (standard, custom, Fl_Window, Fl_Gl_Window) as it appears + on screen, with optional translation, scaling and rotation. This is done by calling print_widget() + or print_window_part(). + <li>Use a series of FLTK graphics commands (e.g., font, text, lines, colors, clip, image) to + compose a page appropriately shaped for printing. + </ul> + In both cases, begin by start_job(), start_page(), printable_rect() and origin() calls + and finish by end_page() and end_job() calls. + <p><b>Platform specifics</b> + <ul> + <li>Unix/Linux platforms: + Class Fl_RGB_Image prints but loses its transparency if it has one. + See class Fl_PostScript_Graphics_Driver for a description of how UTF-8 strings appear in print. + Use the static public attributes of this class to set the print dialog to other languages + than English. For example, the "Printer:" dialog item Fl_Printer::dialog_printer can be set to French with: + \code + Fl_Printer::dialog_printer = "Imprimante:"; + \endcode + before creation of the Fl_Printer object. + Use Fl_PostScript_File_Device::file_chooser_title to customize the title of the file chooser dialog that opens + when using the "Print To File" option of the print dialog. + <li>MSWindows platform: Transparent Fl_RGB_Image 's don't print with exact transparency on most printers. + Fl_RGB_Image 's don't rotate() well. + A workaround is to use the print_window_part() call. + <li>Mac OS X platform: all graphics requests print as on display. + </ul> + */ +class FL_EXPORT Fl_Printer : public Fl_Paged_Device { +public: + static const char *class_id; + const char *class_name() {return class_id;}; + /** \brief The constructor */ + Fl_Printer(void); + int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); + int start_page(void); + int printable_rect(int *w, int *h); + void margins(int *left, int *top, int *right, int *bottom); + void origin(int *x, int *y); + void origin(int x, int y); + void scale(float scale_x, float scale_y = 0.); + void rotate(float angle); + void translate(int x, int y); + void untranslate(void); + int end_page (void); + void end_job (void); + void print_widget(Fl_Widget* widget, int delta_x=0, int delta_y=0); + void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x=0, int delta_y=0); + void set_current(void); + Fl_Graphics_Driver* driver(void); + /** \brief The destructor */ + ~Fl_Printer(void); + + /** \name These attributes are effective under the Xlib platform only. + \{ + */ + static const char *dialog_title; + static const char *dialog_printer; + static const char *dialog_range; + static const char *dialog_copies; + static const char *dialog_all; + static const char *dialog_pages; + static const char *dialog_from; + static const char *dialog_to; + static const char *dialog_properties; + static const char *dialog_copyNo; + static const char *dialog_print_button; + static const char *dialog_cancel_button; + static const char *dialog_print_to_file; + static const char *property_title; + static const char *property_pagesize; + static const char *property_mode; + static const char *property_use; + static const char *property_save; + static const char *property_cancel; + /** \} */ +private: +#if defined(WIN32) || defined(__APPLE__) + Fl_System_Printer *printer; +#else + Fl_PostScript_Printer *printer; +#endif +}; + +#endif // Fl_Printer_H + +// +// End of "$Id: Fl_Printer.H 8699 2011-05-20 16:39:06Z manolo $" +// diff --git a/common/fltk/FL/Fl_Progress.H b/common/fltk/FL/Fl_Progress.H new file mode 100644 index 00000000..ce506d5a --- /dev/null +++ b/common/fltk/FL/Fl_Progress.H @@ -0,0 +1,81 @@ +// +// "$Id: Fl_Progress.H 8306 2011-01-24 17:04:22Z matt $" +// +// Progress bar widget definitions. +// +// Copyright 2000-2010 by Michael Sweet. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Progress widget . */ + +#ifndef _Fl_Progress_H_ +# define _Fl_Progress_H_ + +// +// Include necessary headers. +// + +#include "Fl_Widget.H" + + +// +// Progress class... +// +/** + Displays a progress bar for the user. +*/ +class FL_EXPORT Fl_Progress : public Fl_Widget { + + float value_, + minimum_, + maximum_; + + protected: + + virtual void draw(); + + public: + + Fl_Progress(int x, int y, int w, int h, const char *l = 0); + + /** Sets the maximum value in the progress widget. */ + void maximum(float v) { maximum_ = v; redraw(); } + /** Gets the maximum value in the progress widget. */ + float maximum() const { return (maximum_); } + + /** Sets the minimum value in the progress widget. */ + void minimum(float v) { minimum_ = v; redraw(); } + /** Gets the minimum value in the progress widget. */ + float minimum() const { return (minimum_); } + + /** Sets the current value in the progress widget. */ + void value(float v) { value_ = v; redraw(); } + /** Gets the current value in the progress widget. */ + float value() const { return (value_); } +}; + +#endif // !_Fl_Progress_H_ + +// +// End of "$Id: Fl_Progress.H 8306 2011-01-24 17:04:22Z matt $". +// diff --git a/common/fltk/FL/Fl_RGB_Image.H b/common/fltk/FL/Fl_RGB_Image.H new file mode 100644 index 00000000..bf1285eb --- /dev/null +++ b/common/fltk/FL/Fl_RGB_Image.H @@ -0,0 +1,35 @@ +// +// "$Id: Fl_RGB_Image.H 7903 2010-11-28 21:06:39Z matt $" +// +// RGB Image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef Fl_RGB_Image_H +# define Fl_RGB_Image_H +# include "Fl_Image.H" +#endif // !Fl_RGB_Image_H + +// +// End of "$Id: Fl_RGB_Image.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Radio_Button.H b/common/fltk/FL/Fl_Radio_Button.H new file mode 100644 index 00000000..979e3301 --- /dev/null +++ b/common/fltk/FL/Fl_Radio_Button.H @@ -0,0 +1,46 @@ +// +// "$Id: Fl_Radio_Button.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Radio button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Radio_Button widget . */ + +#ifndef Fl_Radio_Button_H +#define Fl_Radio_Button_H + +#include "Fl_Button.H" + +class FL_EXPORT Fl_Radio_Button : public Fl_Button { +public: + Fl_Radio_Button(int x,int y,int w,int h,const char *l=0) + : Fl_Button(x,y,w,h,l) {type(FL_RADIO_BUTTON);} +}; + +#endif + +// +// End of "$Id: Fl_Radio_Button.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Radio_Light_Button.H b/common/fltk/FL/Fl_Radio_Light_Button.H new file mode 100644 index 00000000..6286dbd7 --- /dev/null +++ b/common/fltk/FL/Fl_Radio_Light_Button.H @@ -0,0 +1,46 @@ +// +// "$Id: Fl_Radio_Light_Button.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Radio light button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Radio_Light_Button widget . */ + +#ifndef Fl_Radio_Light_Button_H +#define Fl_Radio_Light_Button_H + +#include "Fl_Light_Button.H" + +class FL_EXPORT Fl_Radio_Light_Button : public Fl_Light_Button { +public: + Fl_Radio_Light_Button(int X,int Y,int W,int H,const char *l=0) + : Fl_Light_Button(X,Y,W,H,l) {type(FL_RADIO_BUTTON);} +}; + +#endif + +// +// End of "$Id: Fl_Radio_Light_Button.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Radio_Round_Button.H b/common/fltk/FL/Fl_Radio_Round_Button.H new file mode 100644 index 00000000..b1505afd --- /dev/null +++ b/common/fltk/FL/Fl_Radio_Round_Button.H @@ -0,0 +1,46 @@ +// +// "$Id: Fl_Radio_Round_Button.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Radio round button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Radio_Round_Button widget . */ + +#ifndef Fl_Radio_Round_Button_H +#define Fl_Radio_Round_Button_H + +#include "Fl_Round_Button.H" + +class FL_EXPORT Fl_Radio_Round_Button : public Fl_Round_Button { +public: + Fl_Radio_Round_Button(int x,int y,int w,int h,const char *l=0) + : Fl_Round_Button(x,y,w,h,l) {type(FL_RADIO_BUTTON);} +}; + +#endif + +// +// End of "$Id: Fl_Radio_Round_Button.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Repeat_Button.H b/common/fltk/FL/Fl_Repeat_Button.H new file mode 100644 index 00000000..dc6d42eb --- /dev/null +++ b/common/fltk/FL/Fl_Repeat_Button.H @@ -0,0 +1,63 @@ +// +// "$Id: Fl_Repeat_Button.H 7903 2010-11-28 21:06:39Z matt $" +// +// Repeat button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Repeat_Button widget . */ + +#ifndef Fl_Repeat_Button_H +#define Fl_Repeat_Button_H +#include "Fl.H" +#include "Fl_Button.H" + +/** + The Fl_Repeat_Button is a subclass of Fl_Button that + generates a callback when it is pressed and then repeatedly generates + callbacks as long as it is held down. The speed of the repeat is fixed + and depends on the implementation. +*/ +class FL_EXPORT Fl_Repeat_Button : public Fl_Button { + static void repeat_callback(void *); +public: + int handle(int); + /** + Creates a new Fl_Repeat_Button widget using the given + position, size, and label string. The default boxtype is FL_UP_BOX. + Deletes the button. + */ + Fl_Repeat_Button(int X,int Y,int W,int H,const char *l=0) + : Fl_Button(X,Y,W,H,l) {} + void deactivate() { + Fl::remove_timeout(repeat_callback,this); + Fl_Button::deactivate(); + } +}; + +#endif + +// +// End of "$Id: Fl_Repeat_Button.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Return_Button.H b/common/fltk/FL/Fl_Return_Button.H new file mode 100644 index 00000000..eb8d6c4e --- /dev/null +++ b/common/fltk/FL/Fl_Return_Button.H @@ -0,0 +1,60 @@ +// +// "$Id: Fl_Return_Button.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Return button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Return_Button widget . */ + +#ifndef Fl_Return_Button_H +#define Fl_Return_Button_H +#include "Fl_Button.H" + +/** + The Fl_Return_Button is a subclass of Fl_Button that + generates a callback when it is pressed or when the user presses the + Enter key. A carriage-return symbol is drawn next to the button label. + <P ALIGN=CENTER>\image html Fl_Return_Button.png + \image latex Fl_Return_Button.png "Fl_Return_Button" width=4cm +*/ +class FL_EXPORT Fl_Return_Button : public Fl_Button { +protected: + void draw(); +public: + int handle(int); + /** + Creates a new Fl_Return_Button widget using the given + position, size, and label string. The default boxtype is FL_UP_BOX. + <P> The inherited destructor deletes the button. + */ + Fl_Return_Button(int X, int Y, int W, int H,const char *l=0) + : Fl_Button(X,Y,W,H,l) {} +}; + +#endif + +// +// End of "$Id: Fl_Return_Button.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Roller.H b/common/fltk/FL/Fl_Roller.H new file mode 100644 index 00000000..a22d6433 --- /dev/null +++ b/common/fltk/FL/Fl_Roller.H @@ -0,0 +1,56 @@ +// +// "$Id: Fl_Roller.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Roller header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Roller widget . */ + +#ifndef Fl_Roller_H +#define Fl_Roller_H + +#ifndef Fl_Valuator_H +#include "Fl_Valuator.H" +#endif + +/** + The Fl_Roller widget is a "dolly" control commonly used to + move 3D objects. + <P ALIGN=CENTER>\image html Fl_Roller.png + \image latex Fl_Roller.png "Fl_Roller" width=4cm +*/ +class FL_EXPORT Fl_Roller : public Fl_Valuator { +protected: + void draw(); +public: + int handle(int); + Fl_Roller(int X,int Y,int W,int H,const char* L=0); +}; + +#endif + +// +// End of "$Id: Fl_Roller.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Round_Button.H b/common/fltk/FL/Fl_Round_Button.H new file mode 100644 index 00000000..f11123ec --- /dev/null +++ b/common/fltk/FL/Fl_Round_Button.H @@ -0,0 +1,57 @@ +// +// "$Id: Fl_Round_Button.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Round button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Round_Button widget . */ + +#ifndef Fl_Round_Button_H +#define Fl_Round_Button_H + +#include "Fl_Light_Button.H" + +/** + Buttons generate callbacks when they are clicked by the user. You + control exactly when and how by changing the values for type() + and when(). + <P ALIGN=CENTER>\image html Fl_Round_Button.png</P> + \image latex Fl_Round_Button.png " Fl_Round_Button" width=4cm + <P>The Fl_Round_Button subclass display the "on" state by + turning on a light, rather than drawing pushed in. The shape of the + "light" is initially set to FL_ROUND_DOWN_BOX. The color of the light + when on is controlled with selection_color(), which defaults to + FL_RED. +*/ +class FL_EXPORT Fl_Round_Button : public Fl_Light_Button { +public: + Fl_Round_Button(int x,int y,int w,int h,const char *l = 0); +}; + +#endif + +// +// End of "$Id: Fl_Round_Button.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Round_Clock.H b/common/fltk/FL/Fl_Round_Clock.H new file mode 100644 index 00000000..2d420bae --- /dev/null +++ b/common/fltk/FL/Fl_Round_Clock.H @@ -0,0 +1,48 @@ +// +// "$Id: Fl_Round_Clock.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Round clock header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Round_Clock widget . */ + +#ifndef Fl_Round_Clock_H +#define Fl_Round_Clock_H + +#include "Fl_Clock.H" + +/** A clock widget of type FL_ROUND_CLOCK. Has no box. */ +class FL_EXPORT Fl_Round_Clock : public Fl_Clock { +public: + /** Creates the clock widget, setting his type and box. */ + Fl_Round_Clock(int x,int y,int w,int h, const char *l = 0) + : Fl_Clock(x,y,w,h,l) {type(FL_ROUND_CLOCK); box(FL_NO_BOX);} +}; + +#endif + +// +// End of "$Id: Fl_Round_Clock.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Scroll.H b/common/fltk/FL/Fl_Scroll.H new file mode 100644 index 00000000..c649497e --- /dev/null +++ b/common/fltk/FL/Fl_Scroll.H @@ -0,0 +1,199 @@ +// +// "$Id: Fl_Scroll.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Scroll header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Scroll widget . */ + +#ifndef Fl_Scroll_H +#define Fl_Scroll_H + +#include "Fl_Group.H" +#include "Fl_Scrollbar.H" + +/** + This container widget lets you maneuver around a set of widgets much + larger than your window. If the child widgets are larger than the size + of this object then scrollbars will appear so that you can scroll over + to them: + \image html Fl_Scroll.png + \image latex Fl_Scroll.png "Fl_Scroll" width=4cm + + If all of the child widgets are packed together into a solid + rectangle then you want to set box() to FL_NO_BOX or + one of the _FRAME types. This will result in the best output. + However, if the child widgets are a sparse arrangement you must + set box() to a real _BOX type. This can result in some + blinking during redrawing, but that can be solved by using a + Fl_Double_Window. + + By default you can scroll in both directions, and the scrollbars + disappear if the data will fit in the area of the scroll. + + Use Fl_Scroll::type() to change this as follows : + <UL> + <LI>0 - No scrollbars </LI> + <LI>Fl_Scroll::HORIZONTAL - Only a horizontal scrollbar. </LI> + <LI>Fl_Scroll::VERTICAL - Only a vertical scrollbar. </LI> + <LI>Fl_Scroll::BOTH - The default is both scrollbars. </LI> + <LI>Fl_Scroll::HORIZONTAL_ALWAYS - Horizontal scrollbar always on, vertical always off. </LI> + <LI>Fl_Scroll::VERTICAL_ALWAYS - Vertical scrollbar always on, horizontal always off. </LI> + <LI>Fl_Scroll::BOTH_ALWAYS - Both always on. </LI> + </UL> + + Use <B> scrollbar.align(int) ( see void Fl_Widget::align(Fl_Align) ) :</B> + to change what side the scrollbars are drawn on. + + If the FL_ALIGN_LEFT bit is on, the vertical scrollbar is on the left. + If the FL_ALIGN_TOP bit is on, the horizontal scrollbar is on + the top. Note that only the alignment flags in scrollbar are + considered. The flags in hscrollbar however are ignored. + + This widget can also be used to pan around a single child widget + "canvas". This child widget should be of your own class, with a + draw() method that draws the contents. The scrolling is done by + changing the x() and y() of the widget, so this child + must use the x() and y() to position its drawing. + To speed up drawing it should test fl_push_clip(). + + Another very useful child is a single Fl_Pack, which is itself a group + that packs its children together and changes size to surround them. + Filling the Fl_Pack with Fl_Tabs groups (and then putting + normal widgets inside those) gives you a very powerful scrolling list + of individually-openable panels. + + Fluid lets you create these, but you can only lay out objects that + fit inside the Fl_Scroll without scrolling. Be sure to leave + space for the scrollbars, as Fluid won't show these either. + + <I>You cannot use Fl_Window as a child of this since the + clipping is not conveyed to it when drawn, and it will draw over the + scrollbars and neighboring objects.</I> +*/ +class FL_EXPORT Fl_Scroll : public Fl_Group { + + int xposition_, yposition_; + int oldx, oldy; + int scrollbar_size_; + static void hscrollbar_cb(Fl_Widget*, void*); + static void scrollbar_cb(Fl_Widget*, void*); + void fix_scrollbar_order(); + static void draw_clip(void*,int,int,int,int); + +private: + + // + // Structure to manage scrollbar and widget interior sizes. + // + // Private for now -- we'd like to expose some of this at + // some point to solve STR#1895.) + // + typedef struct { + int scrollsize; // the scrollsize (global|local) + int innerbox_x, innerbox_y, innerbox_w, innerbox_h; // widget's inner box (excludes scrollbars) + int innerchild_x, innerchild_y, innerchild_w, innerchild_h; // widget's inner box including scrollbars + int child_l, child_r, child_b, child_t; // child bounding box: left/right/bottom/top + int hneeded, vneeded; // hor + ver scrollbar visibility + int hscroll_x, hscroll_y, hscroll_w, hscroll_h; // hor scrollbar size/position + int vscroll_x, vscroll_y, vscroll_w, vscroll_h; // ver scrollbar size/position + int hpos, hsize, hfirst, htotal; // hor scrollbar values (pos/size/first/total) + int vpos, vsize, vfirst, vtotal; // ver scrollbar values (pos/size/first/total) + } ScrollInfo; + void recalc_scrollbars(ScrollInfo &si); + +protected: + + void bbox(int&,int&,int&,int&); + void draw(); + +public: + + Fl_Scrollbar scrollbar; + Fl_Scrollbar hscrollbar; + + void resize(int,int,int,int); + int handle(int); + + Fl_Scroll(int X,int Y,int W,int H,const char*l=0); + + enum { // values for type() + HORIZONTAL = 1, + VERTICAL = 2, + BOTH = 3, + ALWAYS_ON = 4, + HORIZONTAL_ALWAYS = 5, + VERTICAL_ALWAYS = 6, + BOTH_ALWAYS = 7 + }; + + /** Gets the current horizontal scrolling position. */ + int xposition() const {return xposition_;} + /** Gets the current vertical scrolling position. */ + int yposition() const {return yposition_;} + void scroll_to(int, int); + void clear(); + /** + Gets the current size of the scrollbars' troughs, in pixels. + + If this value is zero (default), this widget will use the + Fl::scrollbar_size() value as the scrollbar's width. + + \returns Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used. + \see Fl::scrollbar_size(int) + */ + int scrollbar_size() const { + return(scrollbar_size_); + } + /** + Sets the pixel size of the scrollbars' troughs to the \p size, in pixels. + + Normally you should not need this method, and should use + Fl::scrollbar_size(int) instead to manage the size of ALL + your widgets' scrollbars. This ensures your application + has a consistent UI, is the default behavior, and is normally + what you want. + + Only use THIS method if you really need to override the global + scrollbar size. The need for this should be rare. + + Setting \p size to the special value of 0 causes the widget to + track the global Fl::scrollbar_size(), which is the default. + + \param[in] size Sets the scrollbar size in pixels.\n + If 0 (default), scrollbar size tracks the global Fl::scrollbar_size() + \see Fl::scrollbar_size() + */ + void scrollbar_size(int size) { + if ( size != scrollbar_size_ ) redraw(); + scrollbar_size_ = size; + } +}; + +#endif + +// +// End of "$Id: Fl_Scroll.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Scrollbar.H b/common/fltk/FL/Fl_Scrollbar.H new file mode 100644 index 00000000..96aa4330 --- /dev/null +++ b/common/fltk/FL/Fl_Scrollbar.H @@ -0,0 +1,120 @@ +// +// "$Id: Fl_Scrollbar.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Scroll bar header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Scrollbar widget . */ + +#ifndef Fl_Scrollbar_H +#define Fl_Scrollbar_H + +#include "Fl_Slider.H" + +/** + The Fl_Scrollbar widget displays a slider with arrow buttons at + the ends of the scrollbar. Clicking on the arrows move up/left and + down/right by linesize(). Scrollbars also accept FL_SHORTCUT events: + the arrows move by linesize(), and vertical scrollbars take Page + Up/Down (they move by the page size minus linesize()) and Home/End + (they jump to the top or bottom). + + Scrollbars have step(1) preset (they always return integers). If + desired you can set the step() to non-integer values. You will then + have to use casts to get at the floating-point versions of value() + from Fl_Slider. + + \image html scrollbar.png + \image latex scrollbar.png "Fl_Scrollbar" width=4cm +*/ +class FL_EXPORT Fl_Scrollbar : public Fl_Slider { + + int linesize_; + int pushed_; + static void timeout_cb(void*); + void increment_cb(); +protected: + void draw(); + +public: + + Fl_Scrollbar(int X,int Y,int W,int H, const char *L = 0); + ~Fl_Scrollbar(); + int handle(int); + + /** + Gets the integer value (position) of the slider in the scrollbar. + You can get the floating point value with Fl_Slider::value(). + + \see Fl_Scrollbar::value(int p) + \see Fl_Scrollbar::value(int pos, int size, int first, int total) + */ + int value() const {return int(Fl_Slider::value());} + + /** + Sets the value (position) of the slider in the scrollbar. + + \see Fl_Scrollbar::value() + \see Fl_Scrollbar::value(int pos, int size, int first, int total) + */ + int value(int p) {return int(Fl_Slider::value((double)p));} + + /** + Sets the position, size and range of the slider in the scrollbar. + \param[in] pos position, first line displayed + \param[in] size window size, number of lines displayed + \param[in] first number of first line + \param[in] total total number of lines + + You should call this every time your window changes size, your data + changes size, or your scroll position changes (even if in response + to a callback from this scrollbar). + All necessary calls to redraw() are done. + + Calls Fl_Slider::scrollvalue(int pos, int size, int first, int total). + */ + int value(int pos, int size, int first, int total) { + return scrollvalue(pos, size, first, total); + } + + /** + Get the size of step, in lines, that the arror keys move. + */ + int linesize() const {return linesize_;} + + /** + This number controls how big the steps are that the arrow keys do. + In addition page up/down move by the size last sent to value() + minus one linesize(). The default is 16. + */ + void linesize(int i) {linesize_ = i;} + +}; + +#endif + +// +// End of "$Id: Fl_Scrollbar.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Secret_Input.H b/common/fltk/FL/Fl_Secret_Input.H new file mode 100644 index 00000000..2c100362 --- /dev/null +++ b/common/fltk/FL/Fl_Secret_Input.H @@ -0,0 +1,64 @@ +// +// "$Id: Fl_Secret_Input.H 8726 2011-05-23 18:32:47Z AlbrechtS $" +// +// Secret input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Secret_Input widget . */ + +#ifndef Fl_Secret_Input_H +#define Fl_Secret_Input_H + +#include "Fl_Input.H" + +/** + The Fl_Secret_Input class is a subclass of Fl_Input that displays its + input as a string of placeholders. Depending on the platform this + placeholder is either the asterisk ('*') or the Unicode bullet + character (U+2022). + + This subclass is usually used to receive passwords and other "secret" information. +*/ +class FL_EXPORT Fl_Secret_Input : public Fl_Input { +public: + /** + Creates a new Fl_Secret_Input widget using the given + position, size, and label string. The default boxtype is FL_DOWN_BOX. + + Inherited destructor destroys the widget and any value associated with it. + */ +#if defined(FL_DLL) // implementation in src/Fl_Input.cxx + Fl_Secret_Input(int X,int Y,int W,int H,const char *l = 0); +#else + Fl_Secret_Input(int X,int Y,int W,int H,const char *l = 0) + : Fl_Input(X,Y,W,H,l) {type(FL_SECRET_INPUT);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Secret_Input.H 8726 2011-05-23 18:32:47Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Select_Browser.H b/common/fltk/FL/Fl_Select_Browser.H new file mode 100644 index 00000000..82e68da2 --- /dev/null +++ b/common/fltk/FL/Fl_Select_Browser.H @@ -0,0 +1,64 @@ +// +// "$Id: Fl_Select_Browser.H 8736 2011-05-24 20:00:56Z AlbrechtS $" +// +// Select browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Select_Browser widget . */ + +#ifndef Fl_Select_Browser_H +#define Fl_Select_Browser_H + +#include "Fl_Browser.H" + +/** + The class is a subclass of Fl_Browser + which lets the user select a single item, or no items by clicking on + the empty space. As long as the mouse button is held down on an + unselected item it is highlighted. Normally the callback is done when the + user presses the mouse, but you can change this with when(). + <P>See Fl_Browser for methods to add and remove lines from the browser. +*/ +class FL_EXPORT Fl_Select_Browser : public Fl_Browser { +public: + /** + Creates a new Fl_Select_Browser widget using the given + position, size, and label string. The default boxtype is FL_DOWN_BOX. + The constructor specializes Fl_Browser() by setting the type to FL_SELECT_BROWSER. + The destructor destroys the widget and frees all memory that has been allocated. + */ +#if defined(FL_DLL) // implementation in src/Fl_Browser.cxx + Fl_Select_Browser(int X,int Y,int W,int H,const char *L=0); +#else + Fl_Select_Browser(int X,int Y,int W,int H,const char *L=0) + : Fl_Browser(X,Y,W,H,L) {type(FL_SELECT_BROWSER);} +#endif +}; + +#endif + +// +// End of "$Id: Fl_Select_Browser.H 8736 2011-05-24 20:00:56Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Shared_Image.H b/common/fltk/FL/Fl_Shared_Image.H new file mode 100644 index 00000000..a6beb0dd --- /dev/null +++ b/common/fltk/FL/Fl_Shared_Image.H @@ -0,0 +1,114 @@ +// +// "$Id: Fl_Shared_Image.H 8306 2011-01-24 17:04:22Z matt $" +// +// Shared image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file + Fl_Shared_Image class. */ + +#ifndef Fl_Shared_Image_H +# define Fl_Shared_Image_H + +# include "Fl_Image.H" + + +// Test function for adding new formats +typedef Fl_Image *(*Fl_Shared_Handler)(const char *name, uchar *header, + int headerlen); + +// Shared images class. +/** + This class supports caching, loading, + and drawing of image files. Most applications will also want to + link against the fltk_images library and call the + fl_register_images() + function to support standard image formats such as BMP, GIF, JPEG, and PNG. +*/ +class FL_EXPORT Fl_Shared_Image : public Fl_Image { + + friend class Fl_JPEG_Image; + friend class Fl_PNG_Image; + +protected: + + static Fl_Shared_Image **images_; // Shared images + static int num_images_; // Number of shared images + static int alloc_images_; // Allocated shared images + static Fl_Shared_Handler *handlers_; // Additional format handlers + static int num_handlers_; // Number of format handlers + static int alloc_handlers_; // Allocated format handlers + + const char *name_; // Name of image file + int original_; // Original image? + int refcount_; // Number of times this image has been used + Fl_Image *image_; // The image that is shared + int alloc_image_; // Was the image allocated? + + static int compare(Fl_Shared_Image **i0, Fl_Shared_Image **i1); + + // Use get() and release() to load/delete images in memory... + Fl_Shared_Image(); + Fl_Shared_Image(const char *n, Fl_Image *img = 0); + virtual ~Fl_Shared_Image(); + void add(); + void update(); + + public: + /** Returns the filename of the shared image */ + const char *name() { return name_; } + /** Returns the number of references of this shared image. When reference is below 1, the image is deleted. */ + int refcount() { return refcount_; } + void release(); + void reload(); + + virtual Fl_Image *copy(int W, int H); + Fl_Image *copy() { return copy(w(), h()); } + virtual void color_average(Fl_Color c, float i); + virtual void desaturate(); + virtual void draw(int X, int Y, int W, int H, int cx, int cy); + void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); } + virtual void uncache(); + + static Fl_Shared_Image *find(const char *n, int W = 0, int H = 0); + static Fl_Shared_Image *get(const char *n, int W = 0, int H = 0); + static Fl_Shared_Image **images(); + static int num_images(); + static void add_handler(Fl_Shared_Handler f); + static void remove_handler(Fl_Shared_Handler f); +}; + +// +// The following function is provided in the fltk_images library and +// registers all of the "extra" image file formats that are not part +// of the core FLTK library... +// + +FL_EXPORT extern void fl_register_images(); + +#endif // !Fl_Shared_Image_H + +// +// End of "$Id: Fl_Shared_Image.H 8306 2011-01-24 17:04:22Z matt $" +// diff --git a/common/fltk/FL/Fl_Simple_Counter.H b/common/fltk/FL/Fl_Simple_Counter.H new file mode 100644 index 00000000..dbcebdba --- /dev/null +++ b/common/fltk/FL/Fl_Simple_Counter.H @@ -0,0 +1,50 @@ +// +// "$Id: Fl_Simple_Counter.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Simple counter header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Simple_Counter widget . */ + +#ifndef Fl_Simple_Counter_H +#define Fl_Simple_Counter_H + +#include "Fl_Counter.H" +/** + This widget creates a counter with only 2 arrow buttons + <P align=center>\image html counter.png</P> + \image latex counter.png "Fl_Simple_Counter" width=4cm +*/ +class FL_EXPORT Fl_Simple_Counter : public Fl_Counter { +public: + Fl_Simple_Counter(int x,int y,int w,int h, const char *l = 0) + : Fl_Counter(x,y,w,h,l) {type(FL_SIMPLE_COUNTER);} +}; + +#endif + +// +// End of "$Id: Fl_Simple_Counter.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Single_Window.H b/common/fltk/FL/Fl_Single_Window.H new file mode 100644 index 00000000..9bebc4ea --- /dev/null +++ b/common/fltk/FL/Fl_Single_Window.H @@ -0,0 +1,67 @@ +// +// "$Id: Fl_Single_Window.H 7903 2010-11-28 21:06:39Z matt $" +// +// Single-buffered window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Single_Window class . */ + +#ifndef Fl_Single_Window_H +#define Fl_Single_Window_H + +#include "Fl_Window.H" + +/** + This is the same as Fl_Window. However, it is possible that + some implementations will provide double-buffered windows by default. + This subcan be used to force single-buffering. This may be + useful for modifying existing programs that use incremental update, or + for some types of image data, such as a movie flipbook. +*/ +class FL_EXPORT Fl_Single_Window : public Fl_Window { +public: + void show(); + void show(int a, char **b) {Fl_Window::show(a,b);} + void flush(); + /** + Creates a new Fl_Single_Window widget using the given + size, and label (title) string. + */ + Fl_Single_Window(int W, int H, const char *l=0) + : Fl_Window(W,H,l) {} + /** + Creates a new Fl_Single_Window widget using the given + position, size, and label (title) string. + */ + Fl_Single_Window(int X, int Y, int W, int H, const char *l=0) + : Fl_Window(X,Y,W,H,l) {} + int make_current(); +}; + +#endif + +// +// End of "$Id: Fl_Single_Window.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Slider.H b/common/fltk/FL/Fl_Slider.H new file mode 100644 index 00000000..e16e2d6d --- /dev/null +++ b/common/fltk/FL/Fl_Slider.H @@ -0,0 +1,120 @@ +// +// "$Id: Fl_Slider.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Slider widget . */ + +#ifndef Fl_Slider_H +#define Fl_Slider_H + +#ifndef Fl_Valuator_H +#include "Fl_Valuator.H" +#endif + +// values for type(), lowest bit indicate horizontal: +#define FL_VERT_SLIDER 0 +#define FL_HOR_SLIDER 1 +#define FL_VERT_FILL_SLIDER 2 +#define FL_HOR_FILL_SLIDER 3 +#define FL_VERT_NICE_SLIDER 4 +#define FL_HOR_NICE_SLIDER 5 + +/** + The Fl_Slider widget contains a sliding knob inside a box. It if + often used as a scrollbar. Moving the box all the way to the + top/left sets it to the minimum(), and to the bottom/right to the + maximum(). The minimum() may be greater than the maximum() to + reverse the slider direction. + + Use void Fl_Widget::type(int) to set how the slider is drawn, + which can be one of the following: + + \li FL_VERTICAL - Draws a vertical slider (this is the default). + \li FL_HORIZONTAL - Draws a horizontal slider. + \li FL_VERT_FILL_SLIDER - Draws a filled vertical slider, + useful as a progress or value meter. + \li FL_HOR_FILL_SLIDER - Draws a filled horizontal slider, + useful as a progress or value meter. + \li FL_VERT_NICE_SLIDER - Draws a vertical slider with a nice + looking control knob. + \li FL_HOR_NICE_SLIDER - Draws a horizontal slider with a + nice looking control knob. + + \image html slider.png + \image latex slider.png "Fl_Slider" width=4cm +*/ +class FL_EXPORT Fl_Slider : public Fl_Valuator { + + float slider_size_; + uchar slider_; + void _Fl_Slider(); + void draw_bg(int, int, int, int); + +protected: + + // these allow subclasses to put the slider in a smaller area: + void draw(int, int, int, int); + int handle(int, int, int, int, int); + void draw(); + +public: + + int handle(int); + Fl_Slider(int X,int Y,int W,int H, const char *L = 0); + Fl_Slider(uchar t,int X,int Y,int W,int H, const char *L); + + int scrollvalue(int pos,int size,int first,int total); + void bounds(double a, double b); + + /** + Get the dimensions of the moving piece of slider. + */ + float slider_size() const {return slider_size_;} + + /** + Set the dimensions of the moving piece of slider. This is + the fraction of the size of the entire widget. If you set this + to 1 then the slider cannot move. The default value is .08. + + For the "fill" sliders this is the size of the area around the + end that causes a drag effect rather than causing the slider to + jump to the mouse. + */ + void slider_size(double v); + + /** Gets the slider box type. */ + Fl_Boxtype slider() const {return (Fl_Boxtype)slider_;} + + /** Sets the slider box type. */ + void slider(Fl_Boxtype c) {slider_ = c;} +}; + +#endif + +// +// End of "$Id: Fl_Slider.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Spinner.H b/common/fltk/FL/Fl_Spinner.H new file mode 100644 index 00000000..5d141bd3 --- /dev/null +++ b/common/fltk/FL/Fl_Spinner.H @@ -0,0 +1,268 @@ +// +// "$Id: Fl_Spinner.H 8339 2011-01-30 12:50:19Z ianmacarthur $" +// +// Spinner widget for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Spinner widget . */ + +#ifndef Fl_Spinner_H +# define Fl_Spinner_H + +// +// Include necessary headers... +// + +# include <FL/Enumerations.H> +# include <FL/Fl_Group.H> +# include <FL/Fl_Input.H> +# include <FL/Fl_Repeat_Button.H> +# include <stdio.h> +# include <stdlib.h> + + +/** + This widget is a combination of the input + widget and repeat buttons. The user can either type into the + input area or use the buttons to change the value. +*/ +class FL_EXPORT Fl_Spinner : public Fl_Group { + + double value_; // Current value + double minimum_; // Minimum value + double maximum_; // Maximum value + double step_; // Amount to add/subtract for up/down + const char *format_; // Format string + + Fl_Input input_; // Input field for the value + Fl_Repeat_Button + up_button_, // Up button + down_button_; // Down button + + + static void sb_cb(Fl_Widget *w, Fl_Spinner *sb) { + double v; // New value + + if (w == &(sb->input_)) { + // Something changed in the input field... + v = atof(sb->input_.value()); + + if (v < sb->minimum_) { + sb->value_ = sb->minimum_; + sb->update(); + } else if (v > sb->maximum_) { + sb->value_ = sb->maximum_; + sb->update(); + } else sb->value_ = v; + } else if (w == &(sb->up_button_)) { + // Up button pressed... + v = sb->value_ + sb->step_; + + if (v > sb->maximum_) sb->value_ = sb->minimum_; + else sb->value_ = v; + + sb->update(); + } else if (w == &(sb->down_button_)) { + // Down button pressed... + v = sb->value_ - sb->step_; + + if (v < sb->minimum_) sb->value_ = sb->maximum_; + else sb->value_ = v; + + sb->update(); + } + + sb->do_callback(); + } + void update() { + char s[255]; // Value string + + if (format_[0]=='%'&&format_[1]=='.'&&format_[2]=='*') { // precision argument + // this code block is a simplified version of + // Fl_Valuator::format() and works well (but looks ugly) + int c = 0; + char temp[64], *sp = temp; + sprintf(temp, "%.12f", step_); + while (*sp) sp++; + sp--; + while (sp>temp && *sp=='0') sp--; + while (sp>temp && (*sp>='0' && *sp<='9')) { sp--; c++; } + sprintf(s, format_, c, value_); + } else { + sprintf(s, format_, value_); + } + input_.value(s); + } + + public: + + /** + Creates a new Fl_Spinner widget using the given position, size, + and label string. + <P>Inherited destructor Destroys the widget and any value associated with it. + */ + Fl_Spinner(int X, int Y, int W, int H, const char *L = 0) + : Fl_Group(X, Y, W, H, L), + input_(X, Y, W - H / 2 - 2, H), + up_button_(X + W - H / 2 - 2, Y, H / 2 + 2, H / 2, "@-42<"), + down_button_(X + W - H / 2 - 2, Y + H - H / 2, + H / 2 + 2, H / 2, "@-42>") { + end(); + + value_ = 1.0; + minimum_ = 1.0; + maximum_ = 100.0; + step_ = 1.0; + format_ = "%g"; + + align(FL_ALIGN_LEFT); + + input_.value("1"); + input_.type(FL_INT_INPUT); + input_.when(FL_WHEN_ENTER_KEY | FL_WHEN_RELEASE); + input_.callback((Fl_Callback *)sb_cb, this); + + up_button_.callback((Fl_Callback *)sb_cb, this); + + down_button_.callback((Fl_Callback *)sb_cb, this); + } + + /** Sets or returns the format string for the value. */ + const char *format() { return (format_); } + /** Sets or returns the format string for the value. */ + void format(const char *f) { format_ = f; update(); } + + int handle(int event) { + switch (event) { + case FL_KEYDOWN : + case FL_SHORTCUT : + if (Fl::event_key() == FL_Up) { + up_button_.do_callback(); + return 1; + } else if (Fl::event_key() == FL_Down) { + down_button_.do_callback(); + return 1; + } else return 0; + + case FL_FOCUS : + if (input_.take_focus()) return 1; + else return 0; + } + + return Fl_Group::handle(event); + } + + /** Speling mistakes retained for source compatibility \deprecated */ + double maxinum() const { return (maximum_); } + /** Gets the maximum value of the widget. */ + double maximum() const { return (maximum_); } + /** Sets the maximum value of the widget. */ + void maximum(double m) { maximum_ = m; } + /** Speling mistakes retained for source compatibility \deprecated */ + double mininum() const { return (minimum_); } + /** Gets the minimum value of the widget. */ + double minimum() const { return (minimum_); } + /** Sets the minimum value of the widget. */ + void minimum(double m) { minimum_ = m; } + /** Sets the minimum and maximum values for the widget. */ + void range(double a, double b) { minimum_ = a; maximum_ = b; } + void resize(int X, int Y, int W, int H) { + Fl_Group::resize(X,Y,W,H); + + input_.resize(X, Y, W - H / 2 - 2, H); + up_button_.resize(X + W - H / 2 - 2, Y, H / 2 + 2, H / 2); + down_button_.resize(X + W - H / 2 - 2, Y + H - H / 2, + H / 2 + 2, H / 2); + } + /** + Sets or returns the amount to change the value when the user clicks a button. + Before setting step to a non-integer value, the spinner + type() should be changed to floating point. + */ + double step() const { return (step_); } + /** See double Fl_Spinner::step() const */ + void step(double s) { + step_ = s; + if (step_ != (int)step_) input_.type(FL_FLOAT_INPUT); + else input_.type(FL_INT_INPUT); + update(); + } + /** Gets the color of the text in the input field. */ + Fl_Color textcolor() const { + return (input_.textcolor()); + } + /** Sets the color of the text in the input field. */ + void textcolor(Fl_Color c) { + input_.textcolor(c); + } + /** Gets the font of the text in the input field. */ + Fl_Font textfont() const { + return (input_.textfont()); + } + /** Sets the font of the text in the input field. */ + void textfont(Fl_Font f) { + input_.textfont(f); + } + /** Gets the size of the text in the input field. */ + Fl_Fontsize textsize() const { + return (input_.textsize()); + } + /** Sets the size of the text in the input field. */ + void textsize(Fl_Fontsize s) { + input_.textsize(s); + } + /** Gets the numeric representation in the input field. + \see Fl_Spinner::type(uchar) + */ + uchar type() const { return (input_.type()); } + /** Sets the numeric representation in the input field. + Valid values are FL_INT_INPUT and FL_FLOAT_INPUT. + Also changes the format() template. + Setting a new spinner type via a superclass pointer will not work. + \note type is not a virtual function. + */ + void type(uchar v) { + if (v==FL_FLOAT_INPUT) { + format("%.*f"); + } else { + format("%.0f"); + } + input_.type(v); + } + /** Gets the current value of the widget. */ + double value() const { return (value_); } + /** + Sets the current value of the widget. + Before setting value to a non-integer value, the spinner + type() should be changed to floating point. + */ + void value(double v) { value_ = v; update(); } +}; + +#endif // !Fl_Spinner_H + +// +// End of "$Id: Fl_Spinner.H 8339 2011-01-30 12:50:19Z ianmacarthur $". +// diff --git a/common/fltk/FL/Fl_Sys_Menu_Bar.H b/common/fltk/FL/Fl_Sys_Menu_Bar.H new file mode 100644 index 00000000..da70c92c --- /dev/null +++ b/common/fltk/FL/Fl_Sys_Menu_Bar.H @@ -0,0 +1,80 @@ +// +// "$Id: Fl_Sys_Menu_Bar.H 7903 2010-11-28 21:06:39Z matt $" +// +// MacOS system menu bar header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef Fl_Sys_Menu_Bar_H +#define Fl_Sys_Menu_Bar_H + +#include "Fl_Menu_Bar.H" +#include "x.H" + +#if defined(__APPLE__) || defined(FL_DOXYGEN) + +/** + @brief A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the screen. + * + * On other than Mac OS X platforms, Fl_Sys_Menu_Bar is a synonym of class Fl_Menu_Bar. + */ +class FL_EXPORT Fl_Sys_Menu_Bar : public Fl_Menu_Bar { +protected: + void draw(); +public: + /** + @brief The constructor. + * + * On Mac OS X, all arguments are unused. On other platforms they are used as by Fl_Menu_Bar::Fl_Menu_Bar(). + */ + Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l=0) + : Fl_Menu_Bar(x,y,w,h,l) { + deactivate(); // don't let the old area take events + fl_sys_menu_bar = this; + } + void menu(const Fl_Menu_Item *m); + int add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0); + int insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data=0, int flags=0); + void remove(int n); + void replace(int rank, const char *name); + void clear(); + int clear_submenu(int index); +#if ! defined(FL_DOXYGEN) + enum menuOrItemOperation { itemAtIndex, setKeyEquivalent, setKeyEquivalentModifierMask, setState, initWithTitle, + numberOfItems, setSubmenu, setEnabled, addSeparatorItem, setTitle, removeItem, addNewItem, renameItem }; + // function doMenuOrItemOperation is in file Fl_cocoa.mm because it contains objective-c code + static void *doMenuOrItemOperation( menuOrItemOperation operation, ...); +#endif +}; + +#else + +typedef Fl_Menu_Bar Fl_Sys_Menu_Bar; + +#endif // defined(__APPLE__) || defined(FL_DOXYGEN) + +#endif // Fl_Sys_Menu_Bar_H + +// +// End of "$Id: Fl_Sys_Menu_Bar.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Table.H b/common/fltk/FL/Fl_Table.H new file mode 100644 index 00000000..55c06fdd --- /dev/null +++ b/common/fltk/FL/Fl_Table.H @@ -0,0 +1,1081 @@ +// +// "$Id: Fl_Table.H 8301 2011-01-22 22:40:11Z AlbrechtS $" +// +// Fl_Table -- A table widget +// +// Copyright 2002 by Greg Ercolano. +// Copyright (c) 2004 O'ksi'D +// +// 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. +// +// Please report all bugs and problems to "erco at seriss dot com". +// +// TODO: +// o Auto scroll during dragged selection +// o Keyboard navigation (up/down/left/right arrow) +// + +#ifndef _FL_TABLE_H +#define _FL_TABLE_H + +#include <sys/types.h> +#include <string.h> // memcpy +#ifdef WIN32 +#include <malloc.h> // WINDOWS: malloc/realloc +#else /*WIN32*/ +#include <stdlib.h> // UNIX: malloc/realloc +#endif /*WIN32*/ + +#include <FL/Fl.H> +#include <FL/Fl_Group.H> +#include <FL/Fl_Scroll.H> +#include <FL/Fl_Box.H> +#include <FL/Fl_Scrollbar.H> + +/** + A table of widgets or other content. + + This is the base class for table widgets. + + To be useful it must be subclassed and several virtual functions defined. + Normally applications use widgets derived from this widget, and do not use this + widget directly; this widget is usually too low level to be used directly by + applications. + + This widget does \em not handle the data in the table. The draw_cell() + method must be overridden by a subclass to manage drawing the contents of + the cells. + + This widget can be used in several ways: + + - As a custom widget; see examples/table-simple.cxx and test/table.cxx. + Very optimal for even extremely large tables. + - As a table made up of a single FLTK widget instanced all over the table, + simulating a numeric spreadsheet. See examples/table-spreadsheet.cxx and + examples/table-spreadsheet-with-keyboard-nav.cxx. Optimal for large tables. + - As a regular container of FLTK widgets, one widget per cell. + See examples/table-as-container.cxx. \em Not recommended for large tables. + + \image html table-simple.png + \image latex table-simple.png "table-simple example" width=6cm + + \image html table-as-container.png + \image latex table-as-container.png "table-as-container example" width=6cm + + When acting as part of a custom widget, events on the cells and/or headings + generate callbacks when they are clicked by the user. You control when events + are generated based on the setting for Fl_Table::when(). + + When acting as a container for FLTK widgets, the FLTK widgets maintain + themselves. Although the draw_cell() method must be overridden, its contents + can be very simple. See the draw_cell() code in examples/table-simple.cxx. + + The following variables are available to classes deriving from Fl_Table: + + \image html table-dimensions.png + \image latex table-dimensions.png "Fl_Table Dimensions" width=6cm + + <table border=0> + <tr><td>x()/y()/w()/h()</td> + <td>Fl_Table widget's outer dimension. The outer edge of the border of the + Fl_Table. (Red in the diagram above)</td></tr> + + <tr><td>wix/wiy/wiw/wih</td> + <td>Fl_Table widget's inner dimension. The inner edge of the border of the + Fl_Table. eg. if the Fl_Table's box() is FL_NO_BOX, these values are the same + as x()/y()/w()/h(). (Yellow in the diagram above)</td></tr> + + <tr><td>tox/toy/tow/toh</td> + <td>The table's outer dimension. The outer edge of the border around the cells, + but inside the row/col headings and scrollbars. (Green in the diagram above) + </td></tr> + + <tr><td>tix/tiy/tiw/tih</td> + <td>The table's inner dimension. The inner edge of the border around the cells, + but inside the row/col headings and scrollbars. AKA the table's clip region. + eg. if the table_box() is FL_NO_BOX, these values are the same as + tox/toyy/tow/toh. (Blue in the diagram above) + </td></tr></table> + + CORE DEVELOPERS + + - Greg Ercolano : 12/16/2002 - initial implementation 12/16/02. Fl_Table, Fl_Table_Row, docs. + - Jean-Marc Lienher : 02/22/2004 - added keyboard nav + mouse selection, and ported Fl_Table into fltk-utf8-1.1.4 + + OTHER CONTRIBUTORS + + - Inspired by the Feb 2000 version of FLVW's Flvw_Table widget. Mucho thanks to those folks. + - Mister Satan : 04/07/2003 - MinGW porting mods, and singleinput.cxx; a cool Fl_Input oriented spreadsheet example + - Marek Paliwoda : 01/08/2003 - Porting mods for Borland + - Ori Berger : 03/16/2006 - Optimizations for >500k rows/cols + + LICENSE + + Greg added the following license to the original distribution of Fl_Table. He + kindly gave his permission to integrate Fl_Table and Fl_Table_Row into FLTK, + allowing FLTK license to apply while his widgets are part of the library. + + If used on its own, this is the license that applies: + + \verbatim + Fl_Table License + December 16, 2002 + + The Fl_Table library and included programs are provided under the terms + of the GNU Library General Public License (LGPL) with the following + exceptions: + + 1. Modifications to the Fl_Table configure script, config + header file, and makefiles by themselves to support + a specific platform do not constitute a modified or + derivative work. + + The authors do request that such modifications be + contributed to the Fl_Table project - send all + contributions to "erco at seriss dot com". + + 2. Widgets that are subclassed from Fl_Table widgets do not + constitute a derivative work. + + 3. Static linking of applications and widgets to the + Fl_Table library does not constitute a derivative work + and does not require the author to provide source + code for the application or widget, use the shared + Fl_Table libraries, or link their applications or + widgets against a user-supplied version of Fl_Table. + + If you link the application or widget to a modified + version of Fl_Table, then the changes to Fl_Table must be + provided under the terms of the LGPL in sections + 1, 2, and 4. + + 4. You do not have to provide a copy of the Fl_Table license + with programs that are linked to the Fl_Table library, nor + do you have to identify the Fl_Table license in your + program or documentation as required by section 6 + of the LGPL. + + However, programs must still identify their use of Fl_Table. + The following example statement can be included in user + documentation to satisfy this requirement: + + [program/widget] is based in part on the work of + the Fl_Table project http://seriss.com/people/erco/fltk/Fl_Table/ + \endverbatim + + + */ +class FL_EXPORT Fl_Table : public Fl_Group { +public: + /** + The context bit flags for Fl_Table related callbacks (eg. draw_cell(), callback(), etc) + */ + enum TableContext { + CONTEXT_NONE = 0, ///< no known context + CONTEXT_STARTPAGE = 0x01, ///< before a page is redrawn + CONTEXT_ENDPAGE = 0x02, ///< after a page is redrawn + CONTEXT_ROW_HEADER = 0x04, ///< in the row header + CONTEXT_COL_HEADER = 0x08, ///< in the col header + CONTEXT_CELL = 0x10, ///< in one of the cells + CONTEXT_TABLE = 0x20, ///< in a dead zone of table + CONTEXT_RC_RESIZE = 0x40 ///< column or row being resized + }; + +private: + int _rows, _cols; // total rows/cols + int _row_header_w; // width of row header + int _col_header_h; // height of column header + int _row_position; // last row_position set (not necessarily == toprow!) + int _col_position; // last col_position set (not necessarily == leftcol!) + + char _row_header; // row header enabled? + char _col_header; // col header enabled? + char _row_resize; // row resizing enabled? + char _col_resize; // col resizing enabled? + int _row_resize_min; // row minimum resizing height (default=1) + int _col_resize_min; // col minimum resizing width (default=1) + + // OPTIMIZATION: partial row/column redraw variables + int _redraw_toprow; + int _redraw_botrow; + int _redraw_leftcol; + int _redraw_rightcol; + Fl_Color _row_header_color; + Fl_Color _col_header_color; + + int _auto_drag; + int _selecting; + + // An STL-ish vector without templates + class FL_EXPORT IntVector { + int *arr; + unsigned int _size; + void init() { + arr = NULL; + _size = 0; + } + void copy(int *newarr, unsigned int newsize) { + size(newsize); + memcpy(arr, newarr, newsize * sizeof(int)); + } + public: + IntVector() { init(); } // CTOR + ~IntVector() { if ( arr ) free(arr); arr = NULL; } // DTOR + IntVector(IntVector&o) { init(); copy(o.arr, o._size); } // COPY CTOR + IntVector& operator=(IntVector&o) { // ASSIGN + init(); + copy(o.arr, o._size); + return(*this); + } + int operator[](int x) const { return(arr[x]); } + int& operator[](int x) { return(arr[x]); } + unsigned int size() { return(_size); } + void size(unsigned int count) { + if ( count != _size ) { + arr = (int*)realloc(arr, count * sizeof(int)); + _size = count; + } + } + int pop_back() { int tmp = arr[_size-1]; _size--; return(tmp); } + void push_back(int val) { unsigned int x = _size; size(_size+1); arr[x] = val; } + int back() { return(arr[_size-1]); } + }; + + IntVector _colwidths; // column widths in pixels + IntVector _rowheights; // row heights in pixels + + Fl_Cursor _last_cursor; // last mouse cursor before changed to 'resize' cursor + + // EVENT CALLBACK DATA + TableContext _callback_context; // event context + int _callback_row, _callback_col; // event row/col + + // handle() state variables. + // Put here instead of local statics in handle(), so more + // than one Fl_Table can exist without crosstalk between them. + // + int _resizing_col; // column being dragged + int _resizing_row; // row being dragged + int _dragging_x; // starting x position for horiz drag + int _dragging_y; // starting y position for vert drag + int _last_row; // last row we FL_PUSH'ed + + // Redraw single cell + void _redraw_cell(TableContext context, int R, int C); + + void _start_auto_drag(); + void _stop_auto_drag(); + void _auto_drag_cb(); + static void _auto_drag_cb2(void *d); + +protected: + enum ResizeFlag { + RESIZE_NONE = 0, + RESIZE_COL_LEFT = 1, + RESIZE_COL_RIGHT = 2, + RESIZE_ROW_ABOVE = 3, + RESIZE_ROW_BELOW = 4 + }; + + int table_w, table_h; // table's virtual size (in pixels) + int toprow, botrow, leftcol, rightcol; // four corners of viewable table + + // selection + int current_row, current_col; + int select_row, select_col; + + // OPTIMIZATION: Precomputed scroll positions for the toprow/leftcol + int toprow_scrollpos; + int leftcol_scrollpos; + + // Dimensions + int tix, tiy, tiw, tih; // data table inner dimension xywh + int tox, toy, tow, toh; // data table outer dimension xywh + int wix, wiy, wiw, wih; // widget inner dimension xywh + + Fl_Scroll *table; // container for child fltk widgets (if any) + Fl_Scrollbar *vscrollbar; // vertical scrollbar + Fl_Scrollbar *hscrollbar; // horizontal scrollbar + + // Fltk + int handle(int e); // fltk handle() override + + // Class maintenance + void recalc_dimensions(); + void table_resized(); // table resized; recalc + void table_scrolled(); // table scrolled; recalc + void get_bounds(TableContext context, // return x/y/w/h bounds for context + int &X, int &Y, int &W, int &H); + void change_cursor(Fl_Cursor newcursor); // change mouse cursor to some other shape + TableContext cursor2rowcol(int &R, int &C, ResizeFlag &resizeflag); + // find r/c given current x/y event + int find_cell(TableContext context, // find cell's x/y/w/h given r/c + int R, int C, int &X, int &Y, int &W, int &H); + int row_col_clamp(TableContext context, int &R, int &C); + // clamp r/c to known universe + + /** + Subclass should override this method to handle drawing the cells. + + This method will be called whenever the table is redrawn, once per cell. + + Only cells that are completely (or partially) visible will be told to draw. + + \p context will be one of the following: + + <table border=1> + <tr> + <td>\p Fl_Table::CONTEXT_STARTPAGE</td> + <td>When table, or parts of the table, are about to be redrawn.<br> + Use to initialize static data, such as font selections.<p> + R/C will be zero,<br> + X/Y/W/H will be the dimensions of the table's entire data area.<br> + (Useful for locking a database before accessing; see + also visible_cells())</td> + </tr><tr> + <td>\p Fl_Table::CONTEXT_ENDPAGE</td> + <td>When table has completed being redrawn.<br> + R/C will be zero, X/Y/W/H dimensions of table's data area.<br> + (Useful for unlocking a database after accessing)</td> + </tr><tr> + <td>\p Fl_Table::CONTEXT_ROW_HEADER</td> + <td>Whenever a row header cell needs to be drawn.<br> + R will be the row number of the header being redrawn,<br> + C will be zero,<br> + X/Y/W/H will be the fltk drawing area of the row header in the window </td> + </tr><tr> + <td>\p Fl_Table::CONTEXT_COL_HEADER</td> + <td>Whenever a column header cell needs to be drawn.<br> + R will be zero, <br> + C will be the column number of the header being redrawn,<br> + X/Y/W/H will be the fltk drawing area of the column header in the window </td> + </tr><tr> + <td>\p Fl_Table::CONTEXT_CELL</td> + <td>Whenever a data cell in the table needs to be drawn.<br> + R/C will be the row/column of the cell to be drawn,<br> + X/Y/W/H will be the fltk drawing area of the cell in the window </td> + </tr><tr> + <td>\p Fl_Table::CONTEXT_RC_RESIZE</td> + <td>Whenever table or row/column is resized or scrolled, + either interactively or via col_width() or row_height().<br> + R/C/X/Y/W/H will all be zero. + <p> + Useful for fltk containers that need to resize or move + the child fltk widgets.</td> + </tr> + </table> + + \p row and \p col will be set to the row and column number + of the cell being drawn. In the case of row headers, \p col will be \a 0. + In the case of column headers, \p row will be \a 0. + + <tt>x/y/w/h</tt> will be the position and dimensions of where the cell + should be drawn. + + In the case of custom widgets, a minimal draw_cell() override might + look like the following. With custom widgets it is up to the caller to handle + drawing everything within the dimensions of the cell, including handling the + selection color. Note all clipping must be handled as well; this allows drawing + outside the dimensions of the cell if so desired for 'custom effects'. + + \code + // This is called whenever Fl_Table wants you to draw a cell + void MyTable::draw_cell(TableContext context, int R=0, int C=0, int X=0, int Y=0, int W=0, int H=0) { + static char s[40]; + sprintf(s, "%d/%d", R, C); // text for each cell + switch ( context ) { + case CONTEXT_STARTPAGE: // Fl_Table telling us its starting to draw page + fl_font(FL_HELVETICA, 16); + return; + + case CONTEXT_ROW_HEADER: // Fl_Table telling us it's draw row/col headers + case CONTEXT_COL_HEADER: + fl_push_clip(X, Y, W, H); + { + fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, color()); + fl_color(FL_BLACK); + fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER); + } + fl_pop_clip(); + return; + + case CONTEXT_CELL: // Fl_Table telling us to draw cells + fl_push_clip(X, Y, W, H); + { + // BG COLOR + fl_color( row_selected(R) ? selection_color() : FL_WHITE); + fl_rectf(X, Y, W, H); + + // TEXT + fl_color(FL_BLACK); + fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER); + + // BORDER + fl_color(FL_LIGHT2); + fl_rect(X, Y, W, H); + } + fl_pop_clip(); + return; + + default: + return; + } + //NOTREACHED + } + \endcode + */ + virtual void draw_cell(TableContext context, int R=0, int C=0, + int X=0, int Y=0, int W=0, int H=0) + { } // overridden by deriving class + + long row_scroll_position(int row); // find scroll position of row (in pixels) + long col_scroll_position(int col); // find scroll position of col (in pixels) + + int is_fltk_container() { // does table contain fltk widgets? + return( Fl_Group::children() > 3 ); // (ie. more than box and 2 scrollbars?) + } + + static void scroll_cb(Fl_Widget*,void*); // h/v scrollbar callback + + void damage_zone(int r1, int c1, int r2, int c2, int r3 = 0, int c3 = 0); + + void redraw_range(int toprow, int botrow, int leftcol, int rightcol) { + if ( _redraw_toprow == -1 ) { + // Initialize redraw range + _redraw_toprow = toprow; + _redraw_botrow = botrow; + _redraw_leftcol = leftcol; + _redraw_rightcol = rightcol; + } else { + // Extend redraw range + if ( toprow < _redraw_toprow ) _redraw_toprow = toprow; + if ( botrow > _redraw_botrow ) _redraw_botrow = botrow; + if ( leftcol < _redraw_leftcol ) _redraw_leftcol = leftcol; + if ( rightcol > _redraw_rightcol ) _redraw_rightcol = rightcol; + } + + // Indicate partial redraw needed of some cells + damage(FL_DAMAGE_CHILD); + } + +public: + /** + The constructor for the Fl_Table. + This creates an empty table with no rows or columns, + with headers and row/column resize behavior disabled. + */ + Fl_Table(int X, int Y, int W, int H, const char *l=0); + + /** + The destructor for the Fl_Table. + Destroys the table and its associated widgets. + */ + ~Fl_Table(); + + /** + Clears the table to zero rows, zero columns. + Same as rows(0); cols(0); + \see rows(int), cols(int) + */ + virtual void clear() { rows(0); cols(0); } + + // \todo: add topline(), middleline(), bottomline() + + /** + Sets the kind of box drawn around the data table, + the default being FL_NO_BOX. Changing this value will cause the table + to redraw. + */ + inline void table_box(Fl_Boxtype val) { + table->box(val); + table_resized(); + } + + /** + Returns the current box type used for the data table. + */ + inline Fl_Boxtype table_box( void ) { + return(table->box()); + } + + /** + Sets the number of rows in the table, and the table is redrawn. + */ + virtual void rows(int val); // set/get number of rows + + /** + Returns the number of rows in the table. + */ + inline int rows() { + return(_rows); + } + + /** + Set the number of columns in the table and redraw. + */ + virtual void cols(int val); // set/get number of columns + + /** + Get the number of columns in the table. + */ + inline int cols() { + return(_cols); + } + + /** + Returns the range of row and column numbers for all visible + and partially visible cells in the table. + + These values can be used e.g. by your draw_cell() routine during + CONTEXT_STARTPAGE to figure out what cells are about to be redrawn + for the purposes of locking the data from a database before it's drawn. + + \code + leftcol rightcol + : : + toprow .. .-------------------. + | | + | V I S I B L E | + | | + | T A B L E | + | | + botrow .. '-------------------` + \endcode + + e.g. in a table where the visible rows are 5-20, and the + visible columns are 100-120, then those variables would be: + + - toprow = 5 + - botrow = 20 + - leftcol = 100 + - rightcol = 120 + */ + inline void visible_cells(int& r1, int& r2, int& c1, int& c2) { + r1 = toprow; + r2 = botrow; + c1 = leftcol; + c2 = rightcol; + } + + /** + Returns 1 if someone is interactively resizing a row or column. + You can currently call this only from within your callback(). + */ + int is_interactive_resize() { + return(_resizing_row != -1 || _resizing_col != -1); + } + + /** + Returns the current value of this flag. + */ + inline int row_resize() { + return(_row_resize); + } + + /** + Allows/disallows row resizing by the user. + 1=allow interactive resizing, 0=disallow interactive resizing. + Since interactive resizing is done via the row headers, + row_header() must also be enabled to allow resizing. + */ + void row_resize(int flag) { // enable row resizing + _row_resize = flag; + } + + /** + Returns the current value of this flag. + */ + inline int col_resize() { + return(_col_resize); + } + /** + Allows/disallows column resizing by the user. + 1=allow interactive resizing, 0=disallow interactive resizing. + Since interactive resizing is done via the column headers, + \p col_header() must also be enabled to allow resizing. + */ + void col_resize(int flag) { // enable col resizing + _col_resize = flag; + } + + /** + Sets the current column minimum resize value. + This is used to prevent the user from interactively resizing + any column to be smaller than 'pixels'. Must be a value >=1. + */ + inline int col_resize_min() { // column minimum resizing width + return(_col_resize_min); + } + + /** + Returns the current column minimum resize value. + */ + void col_resize_min(int val) { + _col_resize_min = ( val < 1 ) ? 1 : val; + } + + /** + Returns the current row minimum resize value. + */ + inline int row_resize_min() { // column minimum resizing width + return(_row_resize_min); + } + + /** + Sets the current row minimum resize value. + This is used to prevent the user from interactively resizing + any row to be smaller than 'pixels'. Must be a value >=1. + */ + void row_resize_min(int val) { + _row_resize_min = ( val < 1 ) ? 1 : val; + } + + /** + Returns the value of this flag. + */ + inline int row_header() { // set/get row header enable flag + return(_row_header); + } + + /** + Enables/disables showing the row headers. 1=enabled, 0=disabled. + If changed, the table is redrawn. + */ + void row_header(int flag) { + _row_header = flag; + table_resized(); + redraw(); + } + + /** + Returns if column headers are enabled or not. + */ + inline int col_header() { // set/get col header enable flag + return(_col_header); + } + + /** + Enable or disable column headers. + If changed, the table is redrawn. + */ + void col_header(int flag) { + _col_header = flag; + table_resized(); + redraw(); + } + + /** + Sets the height in pixels for column headers and redraws the table. + */ + inline void col_header_height(int height) { // set/get col header height + _col_header_h = height; + table_resized(); + redraw(); + } + + /** + Gets the column header height. + */ + inline int col_header_height() { + return(_col_header_h); + } + + /** + Sets the row header width to n and causes the screen to redraw. + */ + inline void row_header_width(int width) { // set/get row header width + _row_header_w = width; + table_resized(); + redraw(); + } + + /** + Returns the current row header width (in pixels). + */ + inline int row_header_width() { + return(_row_header_w); + } + + /** + Sets the row header color and causes the screen to redraw. + */ + inline void row_header_color(Fl_Color val) { // set/get row header color + _row_header_color = val; + redraw(); + } + + /** + Returns the current row header color. + */ + inline Fl_Color row_header_color() { + return(_row_header_color); + } + + /** + Sets the color for column headers and redraws the table. + */ + inline void col_header_color(Fl_Color val) { // set/get col header color + _col_header_color = val; + redraw(); + } + + /** + Gets the color for column headers. + */ + inline Fl_Color col_header_color() { + return(_col_header_color); + } + + /** + Sets the height of the specified row in pixels, + and the table is redrawn. + callback() will be invoked with CONTEXT_RC_RESIZE + if the row's height was actually changed, and when() is FL_WHEN_CHANGED. + */ + void row_height(int row, int height); // set/get row height + + /** + Returns the current height of the specified row as a value in pixels. + */ + inline int row_height(int row) { + return((row<0 || row>=(int)_rowheights.size()) ? 0 : _rowheights[row]); + } + + /** + Sets the width of the specified column in pixels, and the table is redrawn. + callback() will be invoked with CONTEXT_RC_RESIZE + if the column's width was actually changed, and when() is FL_WHEN_CHANGED. + */ + void col_width(int col, int width); // set/get a column's width + + /** + Returns the current width of the specified column in pixels. + */ + inline int col_width(int col) { + return((col<0 || col>=(int)_colwidths.size()) ? 0 : _colwidths[col]); + } + + /** + Convenience method to set the height of all rows to the + same value, in pixels. The screen is redrawn. + */ + void row_height_all(int height) { // set all row/col heights + for ( int r=0; r<rows(); r++ ) { + row_height(r, height); + } + } + + /** + Convenience method to set the width of all columns to the + same value, in pixels. The screen is redrawn. + */ + void col_width_all(int width) { + for ( int c=0; c<cols(); c++ ) { + col_width(c, width); + } + } + + /** + Sets the row scroll position to 'row', and causes the screen to redraw. + */ + void row_position(int row); // set/get table's current scroll position + + /** + Sets the column scroll position to column 'col', and causes the screen to redraw. + */ + void col_position(int col); + + /** + Returns the current row scroll position as a row number. + */ + int row_position() { // current row position + return(_row_position); + } + + /** + Returns the current column scroll position as a column number. + */ + int col_position() { // current col position + return(_col_position); + } + + /** + Sets which row should be at the top of the table, + scrolling as necessary, and the table is redrawn. If the table + cannot be scrolled that far, it is scrolled as far as possible. + */ + inline void top_row(int row) { // set/get top row (deprecated) + row_position(row); + } + + /** + Returns the current top row shown in the table. + This row may be partially obscured. + */ + inline int top_row() { + return(row_position()); + } + int is_selected(int r, int c); // selected cell + void get_selection(int &row_top, int &col_left, int &row_bot, int &col_right); + void set_selection(int row_top, int col_left, int row_bot, int col_right); + int move_cursor(int R, int C); + + /** + Changes the size of the Fl_Table, causing it to redraw. + */ + void resize(int X, int Y, int W, int H); // fltk resize() override + void draw(void); // fltk draw() override + + // This crashes sortapp() during init. + // void box(Fl_Boxtype val) { + // Fl_Group::box(val); + // if ( table ) { + // resize(x(), y(), w(), h()); + // } + // } + // Fl_Boxtype box(void) const { + // return(Fl_Group::box()); + // } + + // Child group + void init_sizes() { + table->init_sizes(); + table->redraw(); + } + void add(Fl_Widget& w) { + table->add(w); + } + void add(Fl_Widget* w) { + table->add(w); + } + void insert(Fl_Widget& w, int n) { + table->insert(w,n); + } + void insert(Fl_Widget& w, Fl_Widget* w2) { + table->insert(w,w2); + } + void remove(Fl_Widget& w) { + table->remove(w); + } + void begin() { + table->begin(); + } + void end() { + table->end(); + // HACK: Avoid showing Fl_Scroll; seems to erase screen + // causing unnecessary flicker, even if its box() is FL_NO_BOX. + // + if ( table->children() > 2 ) { + table->show(); + } else { + table->hide(); + } + Fl_Group::current(Fl_Group::parent()); + } + Fl_Widget * const *array() { + return(table->array()); + } + + /** + Returns the child widget by an index. + + When using the Fl_Table as a container for FLTK widgets, this method returns + the widget pointer from the internal array of widgets in the container. + + Typically used in loops, eg: + \code + for ( int i=0; i<children(); i++ ) { + Fl_Widget *w = child(i); + [..] + } + \endcode + */ + Fl_Widget *child(int n) const { + return(table->child(n)); + } + + /** + Returns the number of children in the table. + + When using the Fl_Table as a container for FLTK widgets, this method returns + how many child widgets the table has. + + \see child(int) + */ + int children() const { + return(table->children()-2); // -2: skip Fl_Scroll's h/v scrollbar widgets + } + int find(const Fl_Widget *w) const { + return(table->find(w)); + } + int find(const Fl_Widget &w) const { + return(table->find(w)); + } + // CALLBACKS + + /** + * Returns the current row the event occurred on. + * + * This function should only be used from within the user's callback function + */ + int callback_row() { + return(_callback_row); + } + + /** + * Returns the current column the event occurred on. + * + * This function should only be used from within the user's callback function + */ + int callback_col() { + return(_callback_col); + } + + /** + * Returns the current 'table context'. + * + * This function should only be used from within the user's callback function + */ + TableContext callback_context() { + return(_callback_context); + } + + void do_callback(TableContext context, int row, int col) { + _callback_context = context; + _callback_row = row; + _callback_col = col; + Fl_Widget::do_callback(); + } + +#if FL_DOXYGEN + /** + The Fl_Widget::when() function is used to set a group of flags, determining + when the widget callback is called: + + <table border=1> + <tr> + <td>\p FL_WHEN_CHANGED</td> + <td> + callback() will be called when rows or columns are resized (interactively or + via col_width() or row_height()), passing CONTEXT_RC_RESIZE via + callback_context(). + </td> + </tr><tr> + <td>\p FL_WHEN_RELEASE</td> + <td> + callback() will be called during FL_RELEASE events, such as when someone + releases a mouse button somewhere on the table. + </td> + </tr> + </table> + + The callback() routine is sent a TableContext that indicates the context the + event occurred in, such as in a cell, in a header, or elsewhere on the table. + When an event occurs in a cell or header, callback_row() and + callback_col() can be used to determine the row and column. The callback can + also look at the regular fltk event values (ie. Fl::event() and Fl::button()) + to determine what kind of event is occurring. + */ + void when(Fl_When flags); +#endif + +#if FL_DOXYGEN + /** + Callbacks will be called depending on the setting of Fl_Widget::when(). + + Callback functions should use the following functions to determine the + context/row/column: + + * Fl_Table::callback_row() returns current row + * Fl_Table::callback_col() returns current column + * Fl_Table::callback_context() returns current table context + + callback_row() and callback_col() will be set to the row and column number the + event occurred on. If someone clicked on a row header, \p col will be \a 0. + If someone clicked on a column header, \p row will be \a 0. + + callback_context() will return one of the following: + + <table border=1> + <tr><td><tt>Fl_Table::CONTEXT_ROW_HEADER</tt></td> + <td>Someone clicked on a row header. Excludes resizing.</td> + </tr><tr> + <td><tt>Fl_Table::CONTEXT_COL_HEADER</tt></td> + <td>Someone clicked on a column header. Excludes resizing.</td> + </tr><tr> + <td><tt>Fl_Table::CONTEXT_CELL</tt></td> + <td> + Someone clicked on a cell. + + To receive callbacks for FL_RELEASE events, you must set + when(FL_WHEN_RELEASE). + </td> + </tr><tr> + <td><tt>Fl_Table::CONTEXT_RC_RESIZE</tt></td> + <td> + Someone is resizing rows/columns either interactively, + or via the col_width() or row_height() API. + + Use is_interactive_resize() + to determine interactive resizing. + + If resizing a column, R=0 and C=column being resized. + + If resizing a row, C=0 and R=row being resized. + + NOTE: To receive resize events, you must set when(FL_WHEN_CHANGED). + </td> + </tr> + </table> + + \code + class MyTable : public Fl_Table { + [..] + private: + // Handle events that happen on the table + void event_callback2() { + int R = callback_row(), // row where event occurred + C = callback_col(); // column where event occurred + TableContext context = callback_context(); // which part of table + fprintf(stderr, "callback: Row=%d Col=%d Context=%d Event=%d\n", + R, C, (int)context, (int)Fl::event()); + } + + // Actual static callback + static void event_callback(Fl_Widget*, void* data) { + MyTable *o = (MyTable*)data; + o->event_callback2(); + } + + public: + // Constructor + MyTable() { + [..] + table.callback(&event_callback, (void*)this); // setup callback + table.when(FL_WHEN_CHANGED|FL_WHEN_RELEASE); // when to call it + } + }; + \endcode + */ + void callback(Fl_Widget*, void*); +#endif +}; + +#endif /*_FL_TABLE_H*/ + +// +// End of "$Id: Fl_Table.H 8301 2011-01-22 22:40:11Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Table_Row.H b/common/fltk/FL/Fl_Table_Row.H new file mode 100644 index 00000000..f2c3f25c --- /dev/null +++ b/common/fltk/FL/Fl_Table_Row.H @@ -0,0 +1,211 @@ +// +// "$Id: Fl_Table_Row.H 8301 2011-01-22 22:40:11Z AlbrechtS $" +// + +#ifndef _FL_TABLE_ROW_H +#define _FL_TABLE_ROW_H + +// +// Fl_Table_Row -- A row oriented table widget +// +// A class specializing in a table of rows. +// Handles row-specific selection behavior. +// +// Copyright 2002 by Greg Ercolano. +// +// 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. +// +// Please report all bugs and problems to "erco at seriss dot com". +// +// + +#include "Fl_Table.H" + +/** + A table with row selection capabilities. + + This class implements a simple table with the ability to select + rows. This widget is similar to an Fl_Browser with columns. Most + methods of importance will be found in the Fl_Table widget, such + as Fl_Table::rows() and Fl_Table::cols(). + + To be useful it must be subclassed and at minimum the draw_cell() + method must be overridden to provide the content of the cells. This widget + does \em not manage the cell's data content; it is up to the parent + class's draw_cell() method override to provide this. + + Events on the cells and/or headings generate callbacks when they are + clicked by the user. You control when events are generated based on + the values you supply for Fl_Table::when(). + */ +class FL_EXPORT Fl_Table_Row : public Fl_Table { +public: + enum TableRowSelectMode { + SELECT_NONE, // no selection allowed + SELECT_SINGLE, // single row selection + SELECT_MULTI // multiple row selection (default) + }; +private: + // An STL-ish vector without templates + class FL_EXPORT CharVector { + char *arr; + int _size; + void init() { + arr = NULL; + _size = 0; + } + void copy(char *newarr, int newsize) { + size(newsize); + memcpy(arr, newarr, newsize * sizeof(char)); + } + public: + CharVector() { // CTOR + init(); + } + ~CharVector() { // DTOR + if ( arr ) free(arr); + arr = NULL; + } + CharVector(CharVector&o) { // COPY CTOR + init(); + copy(o.arr, o._size); + } + CharVector& operator=(CharVector&o) { // ASSIGN + init(); + copy(o.arr, o._size); + return(*this); + } + char operator[](int x) const { + return(arr[x]); + } + char& operator[](int x) { + return(arr[x]); + } + int size() { + return(_size); + } + void size(int count) { + if ( count != _size ) { + arr = (char*)realloc(arr, count * sizeof(char)); + _size = count; + } + } + char pop_back() { + char tmp = arr[_size-1]; + _size--; + return(tmp); + } + void push_back(char val) { + int x = _size; + size(_size+1); + arr[x] = val; + } + char back() { + return(arr[_size-1]); + } + }; + CharVector _rowselect; // selection flag for each row + + // handle() state variables. + // Put here instead of local statics in handle(), so more + // than one instance can exist without crosstalk between. + // + int _dragging_select; // dragging out a selection? + int _last_row; + int _last_y; // last event's Y position + int _last_push_x; // last PUSH event's X position + int _last_push_y; // last PUSH event's Y position + + TableRowSelectMode _selectmode; + +protected: + int handle(int event); + int find_cell(TableContext context, // find cell's x/y/w/h given r/c + int R, int C, int &X, int &Y, int &W, int &H) { + return(Fl_Table::find_cell(context, R, C, X, Y, W, H)); + } + +public: + /** + The constructor for the Fl_Table_Row. + This creates an empty table with no rows or columns, + with headers and row/column resize behavior disabled. + */ + Fl_Table_Row(int X, int Y, int W, int H, const char *l=0) : Fl_Table(X,Y,W,H,l) { + _dragging_select = 0; + _last_row = -1; + _last_y = -1; + _last_push_x = -1; + _last_push_y = -1; + _selectmode = SELECT_MULTI; + } + + /** + The destructor for the Fl_Table_Row. + Destroys the table and its associated widgets. + */ + ~Fl_Table_Row() { } + + void rows(int val); // set number of rows + int rows() { // get number of rows + return(Fl_Table::rows()); + } + + /** + Sets the table selection mode. + + - \p Fl_Table_Row::SELECT_NONE - No selection allowed + - \p Fl_Table_Row::SELECT_SINGLE - Only single rows can be selected + - \p Fl_Table_Row::SELECT_MULTI - Multiple rows can be selected + */ + void type(TableRowSelectMode val); // set selection mode + + TableRowSelectMode type() const { // get selection mode + return(_selectmode); + } + + /** + Checks to see if 'row' is selected. Returns 1 if selected, 0 if not. You can + change the selection of a row by clicking on it, or by using + select_row(row, flag) + */ + int row_selected(int row); // is row selected? (0=no, 1=yes, -1=range err) + + /** + Changes the selection state for 'row', depending on the value + of 'flag'. 0=deselected, 1=select, 2=toggle existing state. + */ + int select_row(int row, int flag=1); // select state for row: flag:0=off, 1=on, 2=toggle + // returns: 0=no change, 1=changed, -1=range err + + /** + This convenience function changes the selection state + for \em all rows based on 'flag'. 0=deselect, 1=select, 2=toggle existing state. + */ + void select_all_rows(int flag=1); // all rows to a known state + + void clear() { + rows(0); // implies clearing selection + cols(0); + Fl_Table::clear(); // clear the table + } +}; + +#endif /*_FL_TABLE_ROW_H*/ + +// +// End of "$Id: Fl_Table_Row.H 8301 2011-01-22 22:40:11Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Tabs.H b/common/fltk/FL/Fl_Tabs.H new file mode 100644 index 00000000..66b4d3be --- /dev/null +++ b/common/fltk/FL/Fl_Tabs.H @@ -0,0 +1,92 @@ +// +// "$Id: Fl_Tabs.H 8101 2010-12-22 13:06:03Z AlbrechtS $" +// +// Tab header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Tabs widget . */ + +#ifndef Fl_Tabs_H +#define Fl_Tabs_H + +#include "Fl_Group.H" + +/** + The Fl_Tabs widget is the "file card tabs" + interface that allows you to put lots and lots of buttons and + switches in a panel, as popularized by many toolkits. + + \image html tabs.png + \image latex tabs.png "Fl_Tabs" width=8cm + + Clicking the tab makes a child visible() by calling + show() on it, and all other children are made invisible + by calling hide() on them. Usually the children are Fl_Group widgets + containing several widgets themselves. + + Each child makes a card, and its label() is printed + on the card tab, including the label font and style. The + selection color of that child is used to color the tab, while + the color of the child determines the background color of the pane. + + The size of the tabs is controlled by the bounding box of the + children (there should be some space between the children and + the edge of the Fl_Tabs), and the tabs may be placed + "inverted" on the bottom - this is determined by which + gap is larger. It is easiest to lay this out in fluid, using the + fluid browser to select each child group and resize them until + the tabs look the way you want them to. +*/ +class FL_EXPORT Fl_Tabs : public Fl_Group { + Fl_Widget *value_; + Fl_Widget *push_; + int *tab_pos; // array of x-offsets of tabs per child + 1 + int *tab_width; // array of widths of tabs per child + 1 + int tab_count; // array size + int tab_positions(); // allocate and calculate tab positions + void clear_tab_positions(); + int tab_height(); + void draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int sel=0); +protected: + void redraw_tabs(); + void draw(); + +public: + int handle(int); + Fl_Widget *value(); + int value(Fl_Widget *); + Fl_Widget *push() const {return push_;} + int push(Fl_Widget *); + Fl_Tabs(int,int,int,int,const char * = 0); + Fl_Widget *which(int event_x, int event_y); + ~Fl_Tabs(); + void client_area(int &rx, int &ry, int &rw, int &rh, int tabh=0); +}; + +#endif + +// +// End of "$Id: Fl_Tabs.H 8101 2010-12-22 13:06:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Text_Buffer.H b/common/fltk/FL/Fl_Text_Buffer.H new file mode 100644 index 00000000..630fccbb --- /dev/null +++ b/common/fltk/FL/Fl_Text_Buffer.H @@ -0,0 +1,781 @@ +// +// "$Id: Fl_Text_Buffer.H 8148 2010-12-31 22:38:03Z matt $" +// +// Header file for Fl_Text_Buffer class. +// +// Copyright 2001-2010 by Bill Spitzak and others. +// Original code Copyright Mark Edel. Permission to distribute under +// the LGPL for the FLTK library granted by Mark Edel. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Text_Buffer, Fl_Text_Selection widget . */ + +#ifndef FL_TEXT_BUFFER_H +#define FL_TEXT_BUFFER_H + + +#undef ASSERT_UTF8 + +#ifdef ASSERT_UTF8 +# include <assert.h> +# define IS_UTF8_ALIGNED(a) if (a && *a) assert(fl_utf8len(*(a))>0); +# define IS_UTF8_ALIGNED2(a, b) if (b>=0 && b<a->length()) assert(fl_utf8len(a->byte_at(b))>0); +#else +# define IS_UTF8_ALIGNED(a) +# define IS_UTF8_ALIGNED2(a, b) +#endif + + +/* + "character size" is the size of a UTF-8 character in bytes + "character width" is the width of a Unicode character in pixels + "column" was orginally defined as a character offset from the left margin. + It was identical to the byte offset. In UTF-8, we have neither a byte offset + nor truly fixed width fonts (*). Column could be a pixel value multiplied with + an average character width (which is a bearable approximation). + + * in Unicode, there are no fixed width fonts! Even if the ASCII characters may + happen to be all the same width in pixels, chinese charcaters surely are not. + There are plenty of exceptions, like ligatures, that make special handling of + "fixed" character widths a nightmare. I decided to remove all references to + fixed fonts and see "columns" as a multiple of the average width of a + character in the main font. + - Matthias + */ + + +/* Maximum length in characters of a tab or control character expansion + of a single buffer character */ +#define FL_TEXT_MAX_EXP_CHAR_LEN 20 + +#include "Fl_Export.H" + + +/** + \class Fl_Text_Selection + \brief This is an internal class for Fl_Text_Buffer to manage text selections. + This class works correctly with utf-8 strings assuming that the parameters + for all calls are on character boundaries. + */ +class FL_EXPORT Fl_Text_Selection { + friend class Fl_Text_Buffer; + +public: + + /** + \brief Set the selection range. + \param start byte offset to first selected character + \param end byte offset pointing after last selected character + */ + void set(int start, int end); + + /** + \brief Updates a selection afer text was modified. + Updates an individual selection for changes in the corresponding text + \param pos byte offset into text buffer at which the change occured + \param nDeleted number of bytes deleted from the buffer + \param nInserted number of bytes inserted into the buffer + */ + void update(int pos, int nDeleted, int nInserted); + + /** + \brief Return the byte offset to the first selected character. + \return byte offset + */ + int start() const { return mStart; } + + /** + \brief Return the byte ofsset to the character after the last selected character. + \return byte offset + */ + int end() const { return mEnd; } + + /** + \brief Returns true if any text is selected. + \return a non-zero number if any text has been selected, or 0 + if no text is selected. + */ + bool selected() const { return mSelected; } + + /** + \brief Modify the 'selected' flag. + \param b new flag + */ + void selected(bool b) { mSelected = b; } + + /** + Return true if position \p pos with indentation \p dispIndex is in + the Fl_Text_Selection. + */ + int includes(int pos) const; + + /** + \brief Return the positions of this selection. + \param start retrun byte offset to first selected character + \param end retrun byte offset pointing after last selected character + \return true if selected + */ + int position(int* start, int* end) const; + +protected: + + int mStart; ///< byte offset to the first selected character + int mEnd; ///< byte offset to the character after the last selected character + bool mSelected; ///< this flag is set if any text is selected +}; + + +typedef void (*Fl_Text_Modify_Cb)(int pos, int nInserted, int nDeleted, + int nRestyled, const char* deletedText, + void* cbArg); + + +typedef void (*Fl_Text_Predelete_Cb)(int pos, int nDeleted, void* cbArg); + + +/** + \brief This class manages unicode displayed in one or more Fl_Text_Display widgets. + + All text in Fl_Text_Buffermust be encoded in UTF-8. All indices used in the + function calls must be aligned to the start of a UTF-8 sequence. All indices + and pointers returned will be aligned. All functions that return a single + character will return that in an unsiged int in UCS-4 encoding. + + The Fl_Text_Buffer class is used by the Fl_Text_Display + and Fl_Text_Editor to manage complex text data and is based upon the + excellent NEdit text editor engine - see http://www.nedit.org/. + */ +class FL_EXPORT Fl_Text_Buffer { +public: + + /** + Create an empty text buffer of a pre-determined size. + \param requestedSize use this to avoid unnecessary re-allocation + if you know exactly how much the buffer will need to hold + \param preferredGapSize Initial size for the buffer gap (empty space + in the buffer where text might be inserted + if the user is typing sequential chars) + */ + Fl_Text_Buffer(int requestedSize = 0, int preferredGapSize = 1024); + + /** + Frees a text buffer + */ + ~Fl_Text_Buffer(); + + /** + \brief Returns the number of bytes in the buffer. + \return size of text in bytes + */ + int length() const { return mLength; } + + /** + \brief Get a copy of the entire contents of the text buffer. + Memory is allocated to contain the returned string, which the caller + must free. + \return newly allocated text buffer - must be free'd, text is utf8 + */ + char* text() const; + + /** + Replaces the entire contents of the text buffer. + \param text Text must be valid utf8. + */ + void text(const char* text); + + /** + \brief Get a copy of a part of the text buffer. + Return a copy of the text between \p start and \p end character positions + from text buffer \p buf. Positions start at 0, and the range does not + include the character pointed to by \p end. + When you are done with the text, free it using the free() function. + \param start byte offset to first character + \param end byte offset after last character in range + \return newly allocated text buffer - must be free'd, text is utf8 + */ + char* text_range(int start, int end) const; + + /** + Returns the character at the specified position pos in the buffer. + Positions start at 0 + \param pos byte offset into buffer, pos must be at acharacter boundary + \return Unicode UCS-4 encoded character + */ + unsigned int char_at(int pos) const; + + /** + Returns the raw byte at the specified position pos in the buffer. + Positions start at 0 + \param pos byte offset into buffer + \return unencoded raw byte + */ + char byte_at(int pos) const; + + /** + Convert a byte offset in buffer into a memory address. + \param pos byte offset into buffer + \return byte offset converted to a memory address + */ + const char *address(int pos) const + { return (pos < mGapStart) ? mBuf+pos : mBuf+pos+mGapEnd-mGapStart; } + + /** + Convert a byte offset in buffer into a memory address. + \param pos byte offset into buffer + \return byte offset converted to a memory address + */ + char *address(int pos) + { return (pos < mGapStart) ? mBuf+pos : mBuf+pos+mGapEnd-mGapStart; } + + /** + Inserts null-terminated string \p text at position \p pos. + \param pos insertion position as byte offset (must be utf-8 character aligned) + \param text utf-8 encoded and nul terminated text + */ + void insert(int pos, const char* text); + + /** + Appends the text string to the end of the buffer. + \param t utf-8 encoded and nul terminated text + */ + void append(const char* t) { insert(length(), t); } + + /** + Deletes a range of characters in the buffer. + \param start byte offset to first character to be removed + \param end byte offset to charcatre after last character to be removed + */ + void remove(int start, int end); + + /** + Deletes the characters between \p start and \p end, and inserts the null-terminated string \p text in their place in the buffer. + \param start byte offset to first character to be removed and new insert position + \param end byte offset to charcatre after last character to be removed + \param text utf-8 encoded and nul terminated text + */ + void replace(int start, int end, const char *text); + + /** + Copies text from one buffer to this one. + \param fromBuf source text buffer may be the same as this + \param fromStart byte offset into buffer + \param fromEnd byte offset into buffer + \param toPos destination byte offset into buffer + */ + void copy(Fl_Text_Buffer* fromBuf, int fromStart, int fromEnd, int toPos); + + /** + Undo text modification according to the undo variables or insert text + from the undo buffer + */ + int undo(int *cp=0); + + /** + Lets the undo system know if we can undo changes + */ + void canUndo(char flag=1); + + /** + Inserts a file at the specified position. Returns 0 on success, + non-zero on error (strerror() contains reason). 1 indicates open + for read failed (no data loaded). 2 indicates error occurred + while reading data (data was partially loaded). + File can be UTF-8 or CP1252-encoded. + If the input file is not UTF-8-encoded, the Fl_Text_Buffer widget will contain + UTF-8-transcoded data. By default, the message Fl_Text_Buffer::file_encoding_warning_message + will warn the user about this. + \see input_file_was_transcoded and transcoding_warning_action. + */ + int insertfile(const char *file, int pos, int buflen = 128*1024); + + /** + Appends the named file to the end of the buffer. See also insertfile(). + */ + int appendfile(const char *file, int buflen = 128*1024) + { return insertfile(file, length(), buflen); } + + /** + Loads a text file into the buffer. See also insertfile(). + */ + int loadfile(const char *file, int buflen = 128*1024) + { select(0, length()); remove_selection(); return appendfile(file, buflen); } + + /** + Writes the specified portions of the file to a file. Returns 0 on success, non-zero + on error (strerror() contains reason). 1 indicates open for write failed + (no data saved). 2 indicates error occurred while writing data + (data was partially saved). + */ + int outputfile(const char *file, int start, int end, int buflen = 128*1024); + + /** + Saves a text file from the current buffer + */ + int savefile(const char *file, int buflen = 128*1024) + { return outputfile(file, 0, length(), buflen); } + + /** + Gets the tab width. + */ + int tab_distance() const { return mTabDist; } + + /** + Set the hardware tab distance (width) used by all displays for this buffer, + and used in computing offsets for rectangular selection operations. + */ + void tab_distance(int tabDist); + + /** + Selects a range of characters in the buffer. + */ + void select(int start, int end); + + /** + Returns a non 0 value if text has been selected, 0 otherwise + */ + int selected() const { return mPrimary.selected(); } + + /** + Cancels any previous selection on the primary text selection object + */ + void unselect(); + + /** + Gets the selection position + */ + int selection_position(int* start, int* end); + + /** + Returns the currently selected text. When you are done with + the text, free it using the free() function. + */ + char* selection_text(); + + /** + Removes the text in the primary selection. + */ + void remove_selection(); + + /** + Replaces the text in the primary selection. + */ + void replace_selection(const char* text); + + /** + Selects a range of characters in the secondary selection. + */ + void secondary_select(int start, int end); + + /** + Returns a non 0 value if text has been selected in the secondary + text selection, 0 otherwise + */ + int secondary_selected() { return mSecondary.selected(); } + + /** + Clears any selection in the secondary text selection object. + */ + void secondary_unselect(); + + /** + Returns the current selection in the secondary text selection object. + */ + int secondary_selection_position(int* start, int* end); + + /** + Returns the text in the secondary selection. When you are + done with the text, free it using the free() function. + */ + char* secondary_selection_text(); + + /** + Removes the text from the buffer corresponding to the secondary text selection object. + */ + void remove_secondary_selection(); + + /** + Replaces the text from the buffer corresponding to the secondary + text selection object with the new string \p text. + */ + void replace_secondary_selection(const char* text); + + /** + Highlights the specified text within the buffer. + */ + void highlight(int start, int end); + + /** + Returns the highlighted text. When you are done with the + text, free it using the free() function. + */ + int highlight() { return mHighlight.selected(); } + + /** + Unhighlights text in the buffer. + */ + void unhighlight(); + + /** + Highlights the specified text between \p start and \p end within the buffer. + */ + int highlight_position(int* start, int* end); + + /** + Returns the highlighted text. When you are done with the + text, free it using the free() function. + */ + char* highlight_text(); + + /** + Adds a callback function that is called whenever the text buffer is + modified. The callback function is declared as follows: + + \code + typedef void (*Fl_Text_Modify_Cb)(int pos, int nInserted, int nDeleted, + int nRestyled, const char* deletedText, + void* cbArg); + \endcode + */ + void add_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void* cbArg); + + /** + Removes a modify callback. + */ + void remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void* cbArg); + + /** + Calls all modify callbacks that have been registered using + the add_modify_callback() + method. + */ + void call_modify_callbacks() { call_modify_callbacks(0, 0, 0, 0, 0); } + + /** + Adds a callback routine to be called before text is deleted from the buffer. + */ + void add_predelete_callback(Fl_Text_Predelete_Cb bufPredelCB, void* cbArg); + + /** + Removes a callback routine \p bufPreDeleteCB associated with argument \p cbArg + to be called before text is deleted from the buffer. + */ + void remove_predelete_callback(Fl_Text_Predelete_Cb predelCB, void* cbArg); + + /** + Calls the stored pre-delete callback procedure(s) for this buffer to update + the changed area(s) on the screen and any other listeners. + */ + void call_predelete_callbacks() { call_predelete_callbacks(0, 0); } + + /** + Returns the text from the entire line containing the specified + character position. When you are done with the text, free it + using the free() function. + \param pos byte index into buffer + \return copy of utf8 text, must be free'd + */ + char* line_text(int pos) const; + + /** + Returns the position of the start of the line containing position \p pos. + \param pos byte index into buffer + \return byte offset to line start + */ + int line_start(int pos) const; + + /** + Finds and returns the position of the end of the line containing position \p pos + (which is either a pointer to the newline character ending the line, + or a pointer to one character beyond the end of the buffer) + \param pos byte index into buffer + \return byte offset to line end + */ + int line_end(int pos) const; + + /** + Returns the position corresponding to the start of the word + \param pos byte index into buffer + \return byte offset to word start + */ + int word_start(int pos) const; + + /** + Returns the position corresponding to the end of the word. + \param pos byte index into buffer + \return byte offset to word end + */ + int word_end(int pos) const; + + /** + Count the number of displayed characters between buffer position + \p lineStartPos and \p targetPos. (displayed characters are the characters + shown on the screen to represent characters in the buffer, where tabs and + control characters are expanded) + */ + int count_displayed_characters(int lineStartPos, int targetPos) const; + + /** + Count forward from buffer position \p startPos in displayed characters + (displayed characters are the characters shown on the screen to represent + characters in the buffer, where tabs and control characters are expanded) + \param lineStartPos byte offset into buffer + \param nChars number of bytes that are sent to the display + \return byte offset in input after all output bytes are sent + */ + int skip_displayed_characters(int lineStartPos, int nChars); + + /** + Counts the number of newlines between \p startPos and \p endPos in buffer. + The character at position \p endPos is not counted. + */ + int count_lines(int startPos, int endPos) const; + + /** + Finds the first character of the line \p nLines forward from \p startPos + in the buffer and returns its position + */ + int skip_lines(int startPos, int nLines); + + /** + Finds and returns the position of the first character of the line \p nLines backwards + from \p startPos (not counting the character pointed to by \p startpos if + that is a newline) in the buffer. \p nLines == 0 means find the beginning of the line + */ + int rewind_lines(int startPos, int nLines); + + /** + Finds the next occurrence of the specified character. + Search forwards in buffer for character \p searchChar, starting + with the character \p startPos, and returning the result in \p foundPos + returns 1 if found, 0 if not. (The difference between this and + BufSearchForward is that it's optimized for single characters. The + overall performance of the text widget is dependent on its ability to + count lines quickly, hence searching for a single character: newline) + \param startPos byte offset to start position + \param searchChar UCS-4 character that we want to find + \param foundPos byte offset where the character was found + \return 1 if found, 0 if not + */ + int findchar_forward(int startPos, unsigned searchChar, int* foundPos) const; + + /** + Search backwards in buffer \p buf for character \p searchChar, starting + with the character BEFORE \p startPos, returning the result in \p foundPos + returns 1 if found, 0 if not. (The difference between this and + BufSearchBackward is that it's optimized for single characters. The + overall performance of the text widget is dependent on its ability to + count lines quickly, hence searching for a single character: newline) + \param startPos byte offset to start position + \param searchChar UCS-4 character that we want to find + \param foundPos byte offset where the character was found + \return 1 if found, 0 if not + */ + int findchar_backward(int startPos, unsigned int searchChar, int* foundPos) const; + + /** + Search forwards in buffer for string \p searchString, starting with the + character \p startPos, and returning the result in \p foundPos + returns 1 if found, 0 if not. + \param startPos byte offset to start position + \param searchString utf8 string that we want to find + \param foundPos byte offset where the string was found + \param matchCase if set, match character case + \return 1 if found, 0 if not + */ + int search_forward(int startPos, const char* searchString, int* foundPos, + int matchCase = 0) const; + + /** + Search backwards in buffer for string <i>searchCharssearchString</i>, starting with the + character BEFORE \p startPos, returning the result in \p foundPos + returns 1 if found, 0 if not. + \param startPos byte offset to start position + \param searchString utf8 string that we want to find + \param foundPos byte offset where the string was found + \param matchCase if set, match character case + \return 1 if found, 0 if not + */ + int search_backward(int startPos, const char* searchString, int* foundPos, + int matchCase = 0) const; + + /** + Returns the primary selection. + */ + const Fl_Text_Selection* primary_selection() const { return &mPrimary; } + + /** + Returns the primary selection. + */ + Fl_Text_Selection* primary_selection() { return &mPrimary; } + + /** + Returns the secondary selection. + */ + const Fl_Text_Selection* secondary_selection() const { return &mSecondary; } + + /** + Returns the current highlight selection. + */ + const Fl_Text_Selection* highlight_selection() const { return &mHighlight; } + + /** + Returns the index of the previous character. + \param ix index to the current char + */ + int prev_char(int ix) const; + int prev_char_clipped(int ix) const; + + /** + Returns the index of the next character. + \param ix index to the current char + */ + int next_char(int ix) const; + int next_char_clipped(int ix) const; + + /** + Align an index into the buffer to the current or previous utf8 boundary. + */ + int utf8_align(int) const; + + /** + \brief true iff the loaded file has been transcoded to UTF-8 + */ + int input_file_was_transcoded; + + /** This message may be displayed using the fl_alert() function when a file + which was not UTF-8 encoded is input. + */ + static const char* file_encoding_warning_message; + + /** + \brief Pointer to a function called after reading a non UTF-8 encoded file. + + This function is called after reading a file if the file content + was transcoded to UTF-8. Its default implementation calls fl_alert() + with the text of \ref file_encoding_warning_message. No warning message is + displayed if this pointer is set to NULL. Use \ref input_file_was_transcoded + to be informed if file input required transcoding to UTF-8. + */ + void (*transcoding_warning_action)(Fl_Text_Buffer*); + +protected: + + /** + Calls the stored modify callback procedure(s) for this buffer to update the + changed area(s) on the screen and any other listeners. + */ + void call_modify_callbacks(int pos, int nDeleted, int nInserted, + int nRestyled, const char* deletedText) const; + + /** + Calls the stored pre-delete callback procedure(s) for this buffer to update + the changed area(s) on the screen and any other listeners. + */ + void call_predelete_callbacks(int pos, int nDeleted) const; + + /** + Internal (non-redisplaying) version of BufInsert. Returns the length of + text inserted (this is just strlen(\p text), however this calculation can be + expensive and the length will be required by any caller who will continue + on to call redisplay). \p pos must be contiguous with the existing text in + the buffer (i.e. not past the end). + \return the number of bytes inserted + */ + int insert_(int pos, const char* text); + + /** + Internal (non-redisplaying) version of BufRemove. Removes the contents + of the buffer between start and end (and moves the gap to the site of + the delete). + */ + void remove_(int start, int end); + + /** + Calls the stored redisplay procedure(s) for this buffer to update the + screen for a change in a selection. + */ + void redisplay_selection(Fl_Text_Selection* oldSelection, + Fl_Text_Selection* newSelection) const; + + /** + Move the gap to start at a new position. + */ + void move_gap(int pos); + + /** + Reallocates the text storage in the buffer to have a gap starting at \p newGapStart + and a gap size of \p newGapLen, preserving the buffer's current contents. + */ + void reallocate_with_gap(int newGapStart, int newGapLen); + + char* selection_text_(Fl_Text_Selection* sel) const; + + /** + Removes the text from the buffer corresponding to \p sel. + */ + void remove_selection_(Fl_Text_Selection* sel); + + /** + Replaces the \p text in selection \p sel. + */ + void replace_selection_(Fl_Text_Selection* sel, const char* text); + + /** + Updates all of the selections in the buffer for changes in the buffer's text + */ + void update_selections(int pos, int nDeleted, int nInserted); + + Fl_Text_Selection mPrimary; /**< highlighted areas */ + Fl_Text_Selection mSecondary; /**< highlighted areas */ + Fl_Text_Selection mHighlight; /**< highlighted areas */ + int mLength; /**< length of the text in the buffer (the length + of the buffer itself must be calculated: + gapEnd - gapStart + length) */ + char* mBuf; /**< allocated memory where the text is stored */ + int mGapStart; /**< points to the first character of the gap */ + int mGapEnd; /**< points to the first char after the gap */ + // The hardware tab distance used by all displays for this buffer, + // and used in computing offsets for rectangular selection operations. + int mTabDist; /**< equiv. number of characters in a tab */ + int mNModifyProcs; /**< number of modify-redisplay procs attached */ + Fl_Text_Modify_Cb *mModifyProcs;/**< procedures to call when buffer is + modified to redisplay contents */ + void** mCbArgs; /**< caller arguments for modifyProcs above */ + int mNPredeleteProcs; /**< number of pre-delete procs attached */ + Fl_Text_Predelete_Cb *mPredeleteProcs; /**< procedure to call before text is deleted + from the buffer; at most one is supported. */ + void **mPredeleteCbArgs; /**< caller argument for pre-delete proc above */ + int mCursorPosHint; /**< hint for reasonable cursor position after + a buffer modification operation */ + char mCanUndo; /**< if this buffer is used for attributes, it must + not do any undo calls */ + int mPreferredGapSize; /**< the default allocation for the text gap is 1024 + bytes and should only be increased if frequent + and large changes in buffer size are expected */ +}; + +#endif + +// +// End of "$Id: Fl_Text_Buffer.H 8148 2010-12-31 22:38:03Z matt $". +// diff --git a/common/fltk/FL/Fl_Text_Display.H b/common/fltk/FL/Fl_Text_Display.H new file mode 100644 index 00000000..c9b91f1f --- /dev/null +++ b/common/fltk/FL/Fl_Text_Display.H @@ -0,0 +1,480 @@ +// +// "$Id: Fl_Text_Display.H 8306 2011-01-24 17:04:22Z matt $" +// +// Header file for Fl_Text_Display class. +// +// Copyright 2001-2010 by Bill Spitzak and others. +// Original code Copyright Mark Edel. Permission to distribute under +// the LGPL for the FLTK library granted by Mark Edel. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Text_Display widget . */ + +#ifndef FL_TEXT_DISPLAY_H +#define FL_TEXT_DISPLAY_H + +#include "fl_draw.H" +#include "Fl_Group.H" +#include "Fl_Widget.H" +#include "Fl_Scrollbar.H" +#include "Fl_Text_Buffer.H" + +/** + \brief Rich text display widget. + + This is the FLTK text display widget. It allows the user to view multiple lines + of text and supports highlighting and scrolling. The buffer that is displayed + in the widget is managed by the Fl_Text_Buffer class. A single Text Buffer + can be displayed by multiple Text Displays. + */ +class FL_EXPORT Fl_Text_Display: public Fl_Group { + +public: + + /** + text display cursor shapes enumeration + */ + enum { + NORMAL_CURSOR, /**< I-beam */ + CARET_CURSOR, /**< caret under the text */ + DIM_CURSOR, /**< dim I-beam */ + BLOCK_CURSOR, /**< unfille box under the current character */ + HEAVY_CURSOR /**< thick I-beam */ + }; + + /** + the character position is the left edge of a character, whereas + the cursor is thought to be between the centers of two consecutive + characters. + */ + enum { + CURSOR_POS, + CHARACTER_POS + }; + + /** + drag types - they match Fl::event_clicks() so that single clicking to + start a collection selects by character, double clicking selects by + word and triple clicking selects by line. + */ + enum { + DRAG_NONE = -2, + DRAG_START_DND = -1, + DRAG_CHAR = 0, + DRAG_WORD = 1, + DRAG_LINE = 2 + }; + + /** + wrap types - used in wrap_mode() + */ + enum { + WRAP_NONE, /**< don't wrap text at all */ + WRAP_AT_COLUMN, /**< wrap text at the given text column */ + WRAP_AT_PIXEL, /**< wrap text at a pixel position */ + WRAP_AT_BOUNDS /**< wrap text so that it fits into the widget width */ + }; + + friend void fl_text_drag_me(int pos, Fl_Text_Display* d); + + typedef void (*Unfinished_Style_Cb)(int, void *); + + /** + This structure associates the color, font, andsize of a string to draw + with an attribute mask matching attr + */ + struct Style_Table_Entry { + Fl_Color color; + Fl_Font font; + Fl_Fontsize size; + unsigned attr; + }; + + Fl_Text_Display(int X, int Y, int W, int H, const char *l = 0); + ~Fl_Text_Display(); + + virtual int handle(int e); + + void buffer(Fl_Text_Buffer* buf); + + /** + Sets the current text buffer associated with the text widget. + Multiple text widgets can be associated with the same text buffer. + \param buf new text buffer + */ + void buffer(Fl_Text_Buffer& buf) { buffer(&buf); } + + /** + Gets the current text buffer associated with the text widget. + Multiple text widgets can be associated with the same text buffer. + \return current text buffer + */ + Fl_Text_Buffer* buffer() const { return mBuffer; } + + void redisplay_range(int start, int end); + void scroll(int topLineNum, int horizOffset); + void insert(const char* text); + void overstrike(const char* text); + void insert_position(int newPos); + + /** + Gets the position of the text insertion cursor for text display. + \return insert position index into text buffer + */ + int insert_position() const { return mCursorPos; } + int position_to_xy(int pos, int* x, int* y) const; + + int in_selection(int x, int y) const; + void show_insert_position(); + + int move_right(); + int move_left(); + int move_up(); + int move_down(); + int count_lines(int start, int end, bool start_pos_is_line_start) const; + int line_start(int pos) const; + int line_end(int startPos, bool startPosIsLineStart) const; + int skip_lines(int startPos, int nLines, bool startPosIsLineStart); + int rewind_lines(int startPos, int nLines); + void next_word(void); + void previous_word(void); + + void show_cursor(int b = 1); + + /** + Hides the text cursor. + */ + void hide_cursor() { show_cursor(0); } + + void cursor_style(int style); + + /** + Gets the text cursor color. + \return cursor color + */ + Fl_Color cursor_color() const {return mCursor_color;} + + /** + Sets the text cursor color. + \param n new cursor color + */ + void cursor_color(Fl_Color n) {mCursor_color = n;} + + /** + Gets the width/height of the scrollbars. + /return width of scrollbars + */ + int scrollbar_width() const { return scrollbar_width_; } + + /** + Sets the width/height of the scrollbars. + \param W width of scrollbars + */ + void scrollbar_width(int W) { scrollbar_width_ = W; } + + /** + Gets the scrollbar alignment type. + \return scrollbar alignment + */ + Fl_Align scrollbar_align() const { return scrollbar_align_; } + + /** + Sets the scrollbar alignment type. + \param a new scrollbar alignment + */ + void scrollbar_align(Fl_Align a) { scrollbar_align_ = a; } + + /** + Moves the insert position to the beginning of the current word. + \param pos start calculation at this index + \return beginning of the words + */ + int word_start(int pos) const { return buffer()->word_start(pos); } + + /** + Moves the insert position to the end of the current word. + \param pos start calculation at this index + \return index of first character after the end of the word + */ + int word_end(int pos) const { return buffer()->word_end(pos); } + + + void highlight_data(Fl_Text_Buffer *styleBuffer, + const Style_Table_Entry *styleTable, + int nStyles, char unfinishedStyle, + Unfinished_Style_Cb unfinishedHighlightCB, + void *cbArg); + + int position_style(int lineStartPos, int lineLen, int lineIndex) const; + + /** + \todo FIXME : get set methods pointing on shortcut_ + have no effects as shortcut_ is unused in this class and derived! + \return the current shortcut key + */ + int shortcut() const {return shortcut_;} + + /** + \todo FIXME : get set methods pointing on shortcut_ + have no effects as shortcut_ is unused in this class and derived! + \param s the new shortcut key + */ + void shortcut(int s) {shortcut_ = s;} + + /** + Gets the default font used when drawing text in the widget. + \return current text font face unless overridden by a style + */ + Fl_Font textfont() const {return textfont_;} + + /** + Sets the default font used when drawing text in the widget. + \param s default text font face + */ + void textfont(Fl_Font s) {textfont_ = s; mColumnScale = 0;} + + /** + Gets the default size of text in the widget. + \return current text height unless overridden by a style + */ + Fl_Fontsize textsize() const {return textsize_;} + + /** + Sets the default size of text in the widget. + \param s new text size + */ + void textsize(Fl_Fontsize s) {textsize_ = s; mColumnScale = 0;} + + /** + Gets the default color of text in the widget. + \return text color unless overridden by a style + */ + Fl_Color textcolor() const {return textcolor_;} + + /** + Sets the default color of text in the widget. + \param n new text color + */ + void textcolor(Fl_Color n) {textcolor_ = n;} + + int wrapped_column(int row, int column) const; + int wrapped_row(int row) const; + void wrap_mode(int wrap, int wrap_margin); + + virtual void resize(int X, int Y, int W, int H); + + /** + Convert an x pixel position into a column number. + \param x number of pixels from the left margin + \return an approximate column number based on the main font + */ + double x_to_col(double x) const; + + /** + Convert a column number into an x pixel position. + \param col an approximate column number based on the main font + \return number of pixels from the left margin to the left of an + average sized character + */ + double col_to_x(double col) const; + +protected: + // Most (all?) of this stuff should only be called from resize() or + // draw(). + // Anything with "vline" indicates thats it deals with currently + // visible lines. + + virtual void draw(); + void draw_text(int X, int Y, int W, int H); + void draw_range(int start, int end); + void draw_cursor(int, int); + + void draw_string(int style, int x, int y, int toX, const char *string, + int nChars) const; + + void draw_vline(int visLineNum, int leftClip, int rightClip, + int leftCharIndex, int rightCharIndex); + + int find_x(const char *s, int len, int style, int x) const; + + enum { + DRAW_LINE, + FIND_INDEX, + FIND_INDEX_FROM_ZERO, + GET_WIDTH + }; + + int handle_vline(int mode, + int lineStart, int lineLen, int leftChar, int rightChar, + int topClip, int bottomClip, + int leftClip, int rightClip) const; + + void draw_line_numbers(bool clearAll); + + void clear_rect(int style, int x, int y, int width, int height) const; + void display_insert(); + + void offset_line_starts(int newTopLineNum); + + void calc_line_starts(int startLine, int endLine); + + void update_line_starts(int pos, int charsInserted, int charsDeleted, + int linesInserted, int linesDeleted, int *scrolled); + + void calc_last_char(); + + int position_to_line( int pos, int* lineNum ) const; + double string_width(const char* string, int length, int style) const; + + static void scroll_timer_cb(void*); + + static void buffer_predelete_cb(int pos, int nDeleted, void* cbArg); + static void buffer_modified_cb(int pos, int nInserted, int nDeleted, + int nRestyled, const char* deletedText, + void* cbArg); + + static void h_scrollbar_cb(Fl_Scrollbar* w, Fl_Text_Display* d); + static void v_scrollbar_cb( Fl_Scrollbar* w, Fl_Text_Display* d); + void update_v_scrollbar(); + void update_h_scrollbar(); + int measure_vline(int visLineNum) const; + int longest_vline() const; + int empty_vlines() const; + int vline_length(int visLineNum) const; + int xy_to_position(int x, int y, int PosType = CHARACTER_POS) const; + + void xy_to_rowcol(int x, int y, int* row, int* column, + int PosType = CHARACTER_POS) const; + void maintain_absolute_top_line_number(int state); + int get_absolute_top_line_number() const; + void absolute_top_line_number(int oldFirstChar); + int maintaining_absolute_top_line_number() const; + void reset_absolute_top_line_number(); + int position_to_linecol(int pos, int* lineNum, int* column) const; + int scroll_(int topLineNum, int horizOffset); + + void extend_range_for_styles(int* start, int* end); + + void find_wrap_range(const char *deletedText, int pos, int nInserted, + int nDeleted, int *modRangeStart, int *modRangeEnd, + int *linesInserted, int *linesDeleted); + void measure_deleted_lines(int pos, int nDeleted); + void wrapped_line_counter(Fl_Text_Buffer *buf, int startPos, int maxPos, + int maxLines, bool startPosIsLineStart, + int styleBufOffset, int *retPos, int *retLines, + int *retLineStart, int *retLineEnd, + bool countLastLineMissingNewLine = true) const; + void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd, + int *nextLineStart) const; + double measure_proportional_character(const char *s, int colNum, int pos) const; + int wrap_uses_character(int lineEndPos) const; + + int damage_range1_start, damage_range1_end; + int damage_range2_start, damage_range2_end; + int mCursorPos; + int mCursorOn; + int mCursorOldY; /* Y pos. of cursor for blanking */ + int mCursorToHint; /* Tells the buffer modified callback + where to move the cursor, to reduce + the number of redraw calls */ + int mCursorStyle; /* One of enum cursorStyles above */ + int mCursorPreferredXPos; /* Pixel position for vert. cursor movement */ + int mNVisibleLines; /* # of visible (displayed) lines */ + int mNBufferLines; /* # of newlines in the buffer */ + Fl_Text_Buffer* mBuffer; /* Contains text to be displayed */ + Fl_Text_Buffer* mStyleBuffer; /* Optional parallel buffer containing + color and font information */ + int mFirstChar, mLastChar; /* Buffer positions of first and last + displayed character (lastChar points + either to a newline or one character + beyond the end of the buffer) */ + int mContinuousWrap; /* Wrap long lines when displaying */ + int mWrapMarginPix; /* Margin in # of pixels for + wrapping in continuousWrap mode */ + int* mLineStarts; + int mTopLineNum; /* Line number of top displayed line + of file (first line of file is 1) */ + int mAbsTopLineNum; /* In continuous wrap mode, the line + number of the top line if the text + were not wrapped (note that this is + only maintained as needed). */ + int mNeedAbsTopLineNum; /* Externally settable flag to continue + maintaining absTopLineNum even if + it isn't needed for line # display */ + int mHorizOffset; /* Horizontal scroll pos. in pixels */ + int mTopLineNumHint; /* Line number of top displayed line + of file (first line of file is 1) */ + int mHorizOffsetHint; /* Horizontal scroll pos. in pixels */ + int mNStyles; /* Number of entries in styleTable */ + const Style_Table_Entry *mStyleTable; /* Table of fonts and colors for + coloring/syntax-highlighting */ + char mUnfinishedStyle; /* Style buffer entry which triggers + on-the-fly reparsing of region */ + Unfinished_Style_Cb mUnfinishedHighlightCB; /* Callback to parse "unfinished" */ + /* regions */ + void* mHighlightCBArg; /* Arg to unfinishedHighlightCB */ + + int mMaxsize; + + int mSuppressResync; /* Suppress resynchronization of line + starts during buffer updates */ + int mNLinesDeleted; /* Number of lines deleted during + buffer modification (only used + when resynchronization is suppressed) */ + int mModifyingTabDistance; /* Whether tab distance is being + modified */ + + mutable double mColumnScale; /* Width in pixels of an average character. This + value is calculated as needed (lazy eval); it + needs to be mutable so that it can be calculated + within a method marked as "const" */ + + Fl_Color mCursor_color; + + Fl_Scrollbar* mHScrollBar; + Fl_Scrollbar* mVScrollBar; + int scrollbar_width_; + Fl_Align scrollbar_align_; + int dragPos, dragType, dragging; + int display_insert_position_hint; + struct { int x, y, w, h; } text_area; + + int shortcut_; + + Fl_Font textfont_; + Fl_Fontsize textsize_; + Fl_Color textcolor_; + + // The following are not presently used from the original NEdit code, + // but are being put here so that future versions of Fl_Text_Display + // can implement line numbers without breaking binary compatibility. + + /* Line number margin and width */ + int mLineNumLeft, mLineNumWidth; +}; + +#endif + +// +// End of "$Id: Fl_Text_Display.H 8306 2011-01-24 17:04:22Z matt $". +// diff --git a/common/fltk/FL/Fl_Text_Editor.H b/common/fltk/FL/Fl_Text_Editor.H new file mode 100644 index 00000000..40f9e6be --- /dev/null +++ b/common/fltk/FL/Fl_Text_Editor.H @@ -0,0 +1,141 @@ +// +// "$Id: Fl_Text_Editor.H 7903 2010-11-28 21:06:39Z matt $" +// +// Header file for Fl_Text_Editor class. +// +// Copyright 2001-2010 by Bill Spitzak and others. +// Original code Copyright Mark Edel. Permission to distribute under +// the LGPL for the FLTK library granted by Mark Edel. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Text_Editor widget . */ + + +#ifndef FL_TEXT_EDITOR_H +#define FL_TEXT_EDITOR_H + +#include "Fl_Text_Display.H" + +// key will match in any state +#define FL_TEXT_EDITOR_ANY_STATE (-1L) + +/** + This is the FLTK text editor widget. It allows the user to + edit multiple lines of text and supports highlighting and + scrolling. The buffer that is displayed in the widget is managed + by the Fl_Text_Buffer + class. +*/ +class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display { + public: + /** Key function binding callback type */ + typedef int (*Key_Func)(int key, Fl_Text_Editor* editor); + + /** Simple linked list associating a key/state to a function */ + struct Key_Binding { + int key; ///< the key pressed + int state; ///< the state of key modifiers + Key_Func function; ///< associated function + Key_Binding* next; ///< next key binding in the list + }; + + Fl_Text_Editor(int X, int Y, int W, int H, const char* l = 0); + ~Fl_Text_Editor() { remove_all_key_bindings(); } + virtual int handle(int e); + /** + Sets the current insert mode; if non-zero, new text + is inserted before the current cursor position. Otherwise, new + text replaces text at the current cursor position. + */ + void insert_mode(int b) { insert_mode_ = b; } + /** + Gets the current insert mode; if non-zero, new text + is inserted before the current cursor position. Otherwise, new + text replaces text at the current cursor position. + */ + int insert_mode() { return insert_mode_; } + + void add_key_binding(int key, int state, Key_Func f, Key_Binding** list); + /** Adds a key of state "state" with the function "function" */ + void add_key_binding(int key, int state, Key_Func f) + { add_key_binding(key, state, f, &key_bindings); } + void remove_key_binding(int key, int state, Key_Binding** list); + /** Removes the key binding associated with the key "key" of state "state". */ + void remove_key_binding(int key, int state) + { remove_key_binding(key, state, &key_bindings); } + void remove_all_key_bindings(Key_Binding** list); + /** Removes all of the key bindings associated with the text editor or list. */ + void remove_all_key_bindings() { remove_all_key_bindings(&key_bindings); } + void add_default_key_bindings(Key_Binding** list); + Key_Func bound_key_function(int key, int state, Key_Binding* list); + /** Returns the function associated with a key binding. */ + Key_Func bound_key_function(int key, int state) + { return bound_key_function(key, state, key_bindings); } + /** Sets the default key function for unassigned keys. */ + void default_key_function(Key_Func f) { default_key_function_ = f; } + + // functions for the built in default bindings + static int kf_default(int c, Fl_Text_Editor* e); + static int kf_ignore(int c, Fl_Text_Editor* e); + static int kf_backspace(int c, Fl_Text_Editor* e); + static int kf_enter(int c, Fl_Text_Editor* e); + static int kf_move(int c, Fl_Text_Editor* e); + static int kf_shift_move(int c, Fl_Text_Editor* e); + static int kf_ctrl_move(int c, Fl_Text_Editor* e); + static int kf_c_s_move(int c, Fl_Text_Editor* e); + static int kf_meta_move(int c, Fl_Text_Editor* e); + static int kf_m_s_move(int c, Fl_Text_Editor* e); + static int kf_home(int, Fl_Text_Editor* e); + static int kf_end(int c, Fl_Text_Editor* e); + static int kf_left(int c, Fl_Text_Editor* e); + static int kf_up(int c, Fl_Text_Editor* e); + static int kf_right(int c, Fl_Text_Editor* e); + static int kf_down(int c, Fl_Text_Editor* e); + static int kf_page_up(int c, Fl_Text_Editor* e); + static int kf_page_down(int c, Fl_Text_Editor* e); + static int kf_insert(int c, Fl_Text_Editor* e); + static int kf_delete(int c, Fl_Text_Editor* e); + static int kf_copy(int c, Fl_Text_Editor* e); + static int kf_cut(int c, Fl_Text_Editor* e); + static int kf_paste(int c, Fl_Text_Editor* e); + static int kf_select_all(int c, Fl_Text_Editor* e); + static int kf_undo(int c, Fl_Text_Editor* e); + + protected: + int handle_key(); + void maybe_do_callback(); + +#ifndef FL_DOXYGEN + int insert_mode_; + Key_Binding* key_bindings; + static Key_Binding* global_key_bindings; + Key_Func default_key_function_; +#endif +}; + +#endif + +// +// End of "$Id: Fl_Text_Editor.H 7903 2010-11-28 21:06:39Z matt $". +// + diff --git a/common/fltk/FL/Fl_Tile.H b/common/fltk/FL/Fl_Tile.H new file mode 100644 index 00000000..c83d2ec1 --- /dev/null +++ b/common/fltk/FL/Fl_Tile.H @@ -0,0 +1,102 @@ +// +// "$Id: Fl_Tile.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Tile header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Tile widget . */ + +#ifndef Fl_Tile_H +#define Fl_Tile_H + +#include "Fl_Group.H" + +/** + The Fl_Tile class lets you resize the children by dragging + the border between them: + + <P ALIGN=CENTER>\image html Fl_Tile.png </P> + \image latex Fl_Tile.png "Fl_Tile" width=4cm + + <P>For the tiling to work correctly, the children of an + Fl_Tile must cover the entire area of the widget, but not + overlap. This means that all children must touch each + other at their edges, and no gaps can't be left inside the + Fl_Tile. + + <P>Fl_Tile does not normailly draw any graphics of its own. + The "borders" which can be seen in the snapshot above + are actually part of the children. Their boxtypes have been set + to FL_DOWN_BOX creating the impression of + "ridges" where the boxes touch. What you see are + actually two adjacent FL_DOWN_BOX's drawn next to each + other. All neighboring widgets share the same edge - the widget's + thick borders make it appear as though the widgets aren't actually + touching, but they are. If the edges of adjacent widgets do not + touch, then it will be impossible to drag the corresponding + edges.</P> + + <P>Fl_Tile allows objects to be resized to zero dimensions. + To prevent this you can use the resizable() to limit where + corners can be dragged to.</P> + + <P>Even though objects can be resized to zero sizes, they must + initially have non-zero sizes so the Fl_Tile can figure out + their layout. If desired, call position() after creating the + children but before displaying the window to set the borders where you + want. + + <P>Note on resizable(Fl_Widget &w) : + The "resizable" child widget (which should be invisible) limits where the + border can be dragged to. If you don't set it, it will be possible to + drag the borders right to the edge, and thus resize objects on the edge + to zero width or height. The resizable() widget is not + resized by dragging any borders. See also void Fl_Group::resizable(Fl_Widget &w) + +*/ +class FL_EXPORT Fl_Tile : public Fl_Group { +public: + int handle(int); + /** + Creates a new Fl_Tile widget using the given position, size, + and label string. The default boxtype is FL_NO_BOX. + + <P>The destructor <I>also deletes all the children</I>. This allows a + whole tree to be deleted at once, without having to keep a pointer to + all the children in the user code. A kludge has been done so the + Fl_Tile and all of it's children can be automatic (local) + variables, but you must declare the Fl_Tile <I>first</I>, so + that it is destroyed last. + */ + Fl_Tile(int X,int Y,int W,int H,const char*l=0) : Fl_Group(X,Y,W,H,l) {} + void resize(int, int, int, int); + void position(int, int, int, int); +}; + +#endif + +// +// End of "$Id: Fl_Tile.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Tiled_Image.H b/common/fltk/FL/Fl_Tiled_Image.H new file mode 100644 index 00000000..d1693798 --- /dev/null +++ b/common/fltk/FL/Fl_Tiled_Image.H @@ -0,0 +1,70 @@ +// +// "$Id: Fl_Tiled_Image.H 7903 2010-11-28 21:06:39Z matt $" +// +// Tiled image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Tiled_Image widget . */ + +#ifndef Fl_Tiled_Image_H +# define Fl_Tiled_Image_H + +# include "Fl_Image.H" + + +/** + This class supports tiling of images + over a specified area. The source (tile) image is <B>not</B> + copied unless you call the color_average(), + desaturate(), + or inactive() + methods. +*/ +class FL_EXPORT Fl_Tiled_Image : public Fl_Image { + protected: + + Fl_Image *image_; // The image that is shared + int alloc_image_; // Did we allocate this image? + + public: + + Fl_Tiled_Image(Fl_Image *i, int W = 0, int H = 0); + virtual ~Fl_Tiled_Image(); + + virtual Fl_Image *copy(int W, int H); + Fl_Image *copy() { return copy(w(), h()); } + virtual void color_average(Fl_Color c, float i); + virtual void desaturate(); + virtual void draw(int X, int Y, int W, int H, int cx, int cy); + void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); } + /** Gets The image that is shared */ + Fl_Image *image() { return image_; } +}; + +#endif // !Fl_Tiled_Image_H + +// +// End of "$Id: Fl_Tiled_Image.H 7903 2010-11-28 21:06:39Z matt $" +// diff --git a/common/fltk/FL/Fl_Timer.H b/common/fltk/FL/Fl_Timer.H new file mode 100644 index 00000000..952273ff --- /dev/null +++ b/common/fltk/FL/Fl_Timer.H @@ -0,0 +1,87 @@ +// +// "$Id: Fl_Timer.H 7903 2010-11-28 21:06:39Z matt $" +// +// Timer header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Timer widget . */ + +#ifndef Fl_Timer_H +#define Fl_Timer_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +// values for type(): +#define FL_NORMAL_TIMER 0 +#define FL_VALUE_TIMER 1 +#define FL_HIDDEN_TIMER 2 + +/** + This is provided only to emulate the Forms Timer widget. It works by + making a timeout callback every 1/5 second. This is wasteful and + inaccurate if you just want something to happen a fixed time in the + future. You should directly call + Fl::add_timeout() instead. +*/ +class FL_EXPORT Fl_Timer : public Fl_Widget { + static void stepcb(void *); + void step(); + char on, direction_; + double delay, total; + long lastsec,lastusec; +protected: + void draw(); +public: + int handle(int); + Fl_Timer(uchar t,int x,int y,int w,int h, const char *l); + ~Fl_Timer(); + void value(double); + /** See void Fl_Timer::value(double) */ + double value() const {return delay>0.0?delay:0.0;} + /** + Gets or sets the direction of the timer. If the direction is zero + then the timer will count up, otherwise it will count down from the + initial value(). + */ + char direction() const {return direction_;} + /** + Gets or sets the direction of the timer. If the direction is zero + then the timer will count up, otherwise it will count down from the + initial value(). + */ + void direction(char d) {direction_ = d;} + /** Gets or sets whether the timer is suspended. */ + char suspended() const {return !on;} + void suspended(char d); +}; + +#endif + +// +// End of "$Id: Fl_Timer.H 7903 2010-11-28 21:06:39Z matt $". +// + diff --git a/common/fltk/FL/Fl_Toggle_Button.H b/common/fltk/FL/Fl_Toggle_Button.H new file mode 100644 index 00000000..eaf821b4 --- /dev/null +++ b/common/fltk/FL/Fl_Toggle_Button.H @@ -0,0 +1,60 @@ +// +// "$Id: Fl_Toggle_Button.H 8022 2010-12-12 23:21:03Z AlbrechtS $" +// +// Toggle button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Toggle_Button widget . */ + +#ifndef Fl_Toggle_Button_H +#define Fl_Toggle_Button_H + +#include "Fl_Button.H" + +/** + The toggle button is a push button that needs to be clicked once + to toggle on, and one more time to toggle off. + The Fl_Toggle_Button subclass displays the "on" state by + drawing a pushed-in button.</P> + <P>Buttons generate callbacks when they are clicked by the user. You + control exactly when and how by changing the values for type() + and when(). +*/ +class FL_EXPORT Fl_Toggle_Button : public Fl_Button { +public: + /** + Creates a new Fl_Toggle_Button widget using the given + position, size, and label string. + <P>The inherited destructor deletes the toggle button. + */ + Fl_Toggle_Button(int X,int Y,int W,int H,const char *l=0) + : Fl_Button(X,Y,W,H,l) {type(FL_TOGGLE_BUTTON);} +}; + +#endif + +// +// End of "$Id: Fl_Toggle_Button.H 8022 2010-12-12 23:21:03Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Toggle_Light_Button.H b/common/fltk/FL/Fl_Toggle_Light_Button.H new file mode 100644 index 00000000..8d446d8e --- /dev/null +++ b/common/fltk/FL/Fl_Toggle_Light_Button.H @@ -0,0 +1,37 @@ +// +// "$Id: Fl_Toggle_Light_Button.H 7903 2010-11-28 21:06:39Z matt $" +// +// Toggle light button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// provided for back-compatibility only + +#ifndef Fl_Toggle_Light_Button +#include "Fl_Light_Button.H" +#define Fl_Toggle_Light_Button Fl_Light_Button +#endif + +// +// End of "$Id: Fl_Toggle_Light_Button.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Toggle_Round_Button.H b/common/fltk/FL/Fl_Toggle_Round_Button.H new file mode 100644 index 00000000..3fd892bc --- /dev/null +++ b/common/fltk/FL/Fl_Toggle_Round_Button.H @@ -0,0 +1,37 @@ +// +// "$Id: Fl_Toggle_Round_Button.H 7903 2010-11-28 21:06:39Z matt $" +// +// Toggle round button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// provided for back-compatibility only + +#ifndef Fl_Toggle_Round_Button +#include "Fl_Round_Button.H" +#define Fl_Toggle_Round_Button Fl_Round_Button +#endif + +// +// End of "$Id: Fl_Toggle_Round_Button.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Tooltip.H b/common/fltk/FL/Fl_Tooltip.H new file mode 100644 index 00000000..71153791 --- /dev/null +++ b/common/fltk/FL/Fl_Tooltip.H @@ -0,0 +1,114 @@ +// +// "$Id: Fl_Tooltip.H 8405 2011-02-08 20:59:46Z manolo $" +// +// Tooltip header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Tooltip widget . */ + +#ifndef Fl_Tooltip_H +#define Fl_Tooltip_H + +#include <FL/Fl.H> +#include <FL/Fl_Widget.H> + +/** + The Fl_Tooltip class provides tooltip support for + all FLTK widgets. It contains only static methods. +*/ +class FL_EXPORT Fl_Tooltip { +public: + /** Gets the tooltip delay. The default delay is 1.0 seconds. */ + static float delay() { return delay_; } + /** Sets the tooltip delay. The default delay is 1.0 seconds. */ + static void delay(float f) { delay_ = f; } + /** + Gets the tooltip hover delay, the delay between tooltips. + The default delay is 0.2 seconds. + */ + static float hoverdelay() { return hoverdelay_; } + /** + Sets the tooltip hover delay, the delay between tooltips. + The default delay is 0.2 seconds. + */ + static void hoverdelay(float f) { hoverdelay_ = f; } + /** Returns non-zero if tooltips are enabled. */ + static int enabled() { return Fl::option(Fl::OPTION_SHOW_TOOLTIPS); } + /** Enables tooltips on all widgets (or disables if <i>b</i> is false). */ + static void enable(int b = 1) { Fl::option(Fl::OPTION_SHOW_TOOLTIPS, (b!=0));} + /** Same as enable(0), disables tooltips on all widgets. */ + static void disable() { enable(0); } + static void (*enter)(Fl_Widget* w); + static void enter_area(Fl_Widget* w, int X, int Y, int W, int H, const char* tip); + static void (*exit)(Fl_Widget *w); + /** Gets the current widget target */ + static Fl_Widget* current() {return widget_;} + static void current(Fl_Widget*); + + /** Gets the typeface for the tooltip text. */ + static Fl_Font font() { return font_; } + /** Sets the typeface for the tooltip text. */ + static void font(Fl_Font i) { font_ = i; } + /** Gets the size of the tooltip text. */ + static Fl_Fontsize size() { return (size_ == -1 ? FL_NORMAL_SIZE : size_); } + /** Sets the size of the tooltip text. */ + static void size(Fl_Fontsize s) { size_ = s; } + /** Gets the background color for tooltips. The default background color is a pale yellow. */ + static Fl_Color color() { return color_; } + /** Sets the background color for tooltips. The default background color is a pale yellow. */ + static void color(Fl_Color c) { color_ = c; } + /** Gets the color of the text in the tooltip. The default is black. */ + static Fl_Color textcolor() { return textcolor_; } + /** Sets the color of the text in the tooltip. The default is black. */ + static void textcolor(Fl_Color c) { textcolor_ = c; } +#ifdef __APPLE__ + // the unique tooltip window + static Fl_Window* current_window(void); +#endif + + // These should not be public, but Fl_Widget::tooltip() needs them... + // fabien: made it private with only a friend function access +private: + friend void Fl_Widget::tooltip(const char *); + friend void Fl_Widget::copy_tooltip(const char *); + static void enter_(Fl_Widget* w); + static void exit_(Fl_Widget *w); + static void set_enter_exit_once_(); + +private: + static float delay_; //!< delay before a tooltip is shown + static float hoverdelay_; //!< delay between tooltips + static Fl_Color color_; + static Fl_Color textcolor_; + static Fl_Font font_; + static Fl_Fontsize size_; + static Fl_Widget* widget_; //!< Keeps track of the current target widget +}; + +#endif + +// +// End of "$Id: Fl_Tooltip.H 8405 2011-02-08 20:59:46Z manolo $". +// diff --git a/common/fltk/FL/Fl_Tree.H b/common/fltk/FL/Fl_Tree.H new file mode 100644 index 00000000..cce11e72 --- /dev/null +++ b/common/fltk/FL/Fl_Tree.H @@ -0,0 +1,1016 @@ +// +// "$Id: Fl_Tree.H 8632 2011-05-04 02:59:50Z greg.ercolano $" +// + +#ifndef FL_TREE_H +#define FL_TREE_H + +#include <FL/Fl.H> +#include <FL/Fl_Group.H> +#include <FL/Fl_Scrollbar.H> +#include <FL/fl_draw.H> + +#include <FL/Fl_Tree_Item.H> +#include <FL/Fl_Tree_Prefs.H> + +////////////////////// +// FL/Fl_Tree.H +////////////////////// +// +// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK +// Copyright (C) 2009-2010 by Greg Ercolano. +// +// 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. +// + +/// +/// \file +/// \brief This file contains the definitions of the Fl_Tree class +/// + +/// \class Fl_Tree +/// +/// \brief Tree widget. +/// +/// \image html tree-simple.png "Fl_Tree example program" +/// \image latex tree-simple.png "Fl_Tree example program" width=4cm +/// +/// \code +/// Fl_Tree // Top level widget +/// |--- Fl_Tree_Item // Items in the tree +/// |--- Fl_Tree_Prefs // Preferences for the tree +/// |--- Fl_Tree_Connector (enum) // Connection modes +/// |--- Fl_Tree_Select (enum) // Selection modes +/// |--- Fl_Tree_Sort (enum) // Sort behavior +/// \endcode +/// +/// Similar to Fl_Browser, Fl_Tree is a browser of Fl_Tree_Item's, which is arranged +/// in a parented hierarchy, or 'tree'. Subtrees can be expanded or closed. Items can be +/// added, deleted, inserted, sorted and re-ordered. +/// +/// The tree items may also contain other FLTK widgets, like buttons, input fields, +/// or even "custom" widgets. +/// +/// The callback() is invoked depending on the value of when(): +/// +/// - FL_WHEN_RELEASE -- callback invoked when left mouse button is released on an item +/// - FL_WHEN_CHANGED -- callback invoked when left mouse changes selection state +/// +/// The simple way to define a tree: +/// \code +/// #include <FL/Fl_Tree.H> +/// [..] +/// Fl_Tree tree(X,Y,W,H); +/// tree.begin(); +/// tree.add("Flintstones/Fred"); +/// tree.add("Flintstones/Wilma"); +/// tree.add("Flintstones/Pebbles"); +/// tree.add("Simpsons/Homer"); +/// tree.add("Simpsons/Marge"); +/// tree.add("Simpsons/Bart"); +/// tree.add("Simpsons/Lisa"); +/// tree.end(); +/// \endcode +/// +/// Items can be added with add(), +/// removed with remove(), +/// completely cleared with clear(), +/// inserted with insert() and insert_above(), +/// selected/deselected with select() and deselect(), +/// open/closed with open() and closed(). +/// Children of an item can be swapped around with Fl_Tree_Item::swap_children(), +/// sorting can be controlled when items are add()ed via sortorder(). +/// You can walk the entire tree with first() and next(). +/// You can walk selected items with first_selected_item() and +/// next_selected_item(). +/// Items can be found by their pathname using find_item(const char*), +/// and an item's pathname can be found with item_pathname(). +/// The selected items' colors are controlled by selection_color() (inherited from Fl_Widget). +/// +/// The tree can have different selection behaviors controlled by selectmode(). +/// +/// FLTK widgets (including custom widgets) can be assigned to tree items via +/// Fl_Tree_Item::widget(). +/// +/// Icons for individual items can be changed with +/// Fl_Tree_Item::openicon(), +/// Fl_Tree_Item::closeicon(), +/// Fl_Tree_Item::usericon(). +/// +/// Various default preferences can be globally manipulated via Fl_Tree_Prefs, +/// including colors, margins, icons, connection lines. +/// +/// The tree's callback() will be invoked when items change state or are open/closed. +/// when() controls when mouse/keyboard events invoke the callback. +/// callback_item() and callback_reason() can be used to determine the cause of the callback. eg: +/// +/// \code +/// void MyTreeCallback(Fl_Widget *w, void *data) { +/// Fl_Tree *tree = (Fl_Tree*)w; +/// Fl_Tree_Item *item = (Fl_Tree_Item*)tree->callback_item(); // get selected item +/// switch ( tree->callback_reason() ) { +/// case FL_TREE_REASON_SELECTED: [..] +/// case FL_TREE_REASON_DESELECTED: [..] +/// case FL_TREE_REASON_OPENED: [..] +/// case FL_TREE_REASON_CLOSED: [..] +/// } +/// \endcode +/// +/// To get the item's full menu pathname, you can use Fl_Tree_Item::item_pathname(), eg: +/// +/// \code +/// char pathname[256] = "???"; +/// tree->item_pathname(pathname, sizeof(pathname), item); // eg. "Parent/Child/Item" +/// \endcode +/// +/// To walk all the items of the tree from top to bottom: +/// \code +/// // Walk all the items in the tree, and print their labels +/// for ( Fl_Tree_Item *item = tree->first(); item; item = tree->next(item) ) { +/// printf("Item: %s\n", item->label()); +/// } +/// \endcode +/// +/// To recursively walk all the children of a particular item, +/// define a function that uses recursion: +/// \code +/// // Find all of the item's children and print an indented report of their labels +/// void my_print_all_children(Fl_Tree_Item *item, int indent=0) { +/// for ( int t=0; t<item->children(); t++ ) { +/// printf("%*s Item: %s\n", indent, "", item->child(t)->label()); +/// my_print_all_children(item->child(t), indent+4); // recurse +/// } +/// } +/// \endcode +/// +/// To change the default label font and color for creating new items: +/// \code +/// tree = new Fl_Tree(..); +/// tree->item_labelfont(FL_COURIER); // Use Courier font for all new items +/// tree->item_labelfgcolor(FL_RED); // Use red color for labels of all new items +/// [..] +/// // Now create the items in the tree using the above defaults. +/// tree->add("Aaa"); +/// tree->add("Bbb"); +/// [..] +/// \endcode +/// +/// To change the font and color of all items in the tree: +/// \code +/// // Change the font and color of all items currently in the tree +/// for ( Fl_Tree_Item *item = tree->first(); item; item = tree->next(item) ) { +/// item->labelfont(FL_COURIER); +/// item->labelcolor(FL_RED); +/// } +/// \endcode +/// +/// The following image shows the tree's various visual elements +/// and the methods that control them: +/// +/// \image html tree-elements.png +/// \image latex tree-elements.png "Fl_Tree dimensions" width=6cm +/// + +/// \enum Fl_Tree_Reason +/// The reason the callback was invoked. +/// +enum Fl_Tree_Reason { + FL_TREE_REASON_NONE=0, ///< unknown reason + FL_TREE_REASON_SELECTED, ///< an item was selected + FL_TREE_REASON_DESELECTED, ///< an item was de-selected + FL_TREE_REASON_OPENED, ///< an item was opened + FL_TREE_REASON_CLOSED ///< an item was closed +}; + + +class FL_EXPORT Fl_Tree : public Fl_Group { + Fl_Tree_Item *_root; // can be null! + Fl_Tree_Item *_item_focus; // item that has focus box + Fl_Tree_Item *_callback_item; // item invoked during callback (can be NULL) + Fl_Tree_Reason _callback_reason; // reason for the callback + Fl_Tree_Prefs _prefs; // all the tree's settings + int _scrollbar_size; // size of scrollbar trough + +protected: + /// Vertical scrollbar + Fl_Scrollbar *_vscroll; + +protected: + void item_clicked(Fl_Tree_Item* val); + /// Do the callback for the item, setting the item and reason + void do_callback_for_item(Fl_Tree_Item* item, Fl_Tree_Reason reason) { + callback_reason(reason); + callback_item(item); + do_callback((Fl_Widget*)this, user_data()); + } + Fl_Tree_Item *next_visible_item(Fl_Tree_Item *start, int dir); + +public: + Fl_Tree(int X, int Y, int W, int H, const char *L=0); + ~Fl_Tree(); + int handle(int e); + void draw(); + + /////////////////////// + // root methods + /////////////////////// + + /// Set the label for the root item. + /// + /// Makes an internally managed copy of 'new_label'. + /// + void root_label(const char *new_label) { + if ( ! _root ) return; + _root->label(new_label); + } + /// Returns the root item. + Fl_Tree_Item* root() { + return(_root); + } + + //////////////////////////////// + // Item creation/removal methods + //////////////////////////////// + Fl_Tree_Item *add(const char *path); + Fl_Tree_Item* add(Fl_Tree_Item *item, const char *name); + Fl_Tree_Item *insert_above(Fl_Tree_Item *above, const char *name); + Fl_Tree_Item* insert(Fl_Tree_Item *item, const char *name, int pos); + + /// Remove the specified \p item from the tree. + /// \p item may not be NULL. + /// If it has children, all those are removed too. + /// \returns 0 if done, -1 if 'item' not found. + /// + int remove(Fl_Tree_Item *item) { + if ( item == _root ) { + clear(); + } else { + Fl_Tree_Item *parent = item->parent(); // find item's parent + if ( ! parent ) return(-1); + parent->remove_child(item); // remove child + children + } + return(0); + } + /// Clear all children from the tree. + /// The tree will be left completely empty. + /// + void clear() { + if ( ! _root ) return; + _root->clear_children(); + delete _root; _root = 0; + } + /// Clear all the children of a particular node in the tree specified by \p item. + /// Item may not be NULL. + /// + void clear_children(Fl_Tree_Item *item) { + if ( item->has_children() ) { + item->clear_children(); + redraw(); // redraw only if there were children to clear + } + } + + //////////////////////// + // Item lookup methods + //////////////////////// + Fl_Tree_Item *find_item(const char *path); + const Fl_Tree_Item *find_item(const char *path) const; + int item_pathname(char *pathname, int pathnamelen, const Fl_Tree_Item *item) const; + + const Fl_Tree_Item *find_clicked() const; + + /// Return the item that was last clicked. + /// + /// Valid only from within the callback(). + /// + /// Deprecated: use callback_item() instead. + /// + /// \returns the item clicked, or 0 if none. + /// 0 may also be used to indicate several items were clicked/changed. + /// + Fl_Tree_Item *item_clicked() { + return(_callback_item); + } + Fl_Tree_Item *first(); + Fl_Tree_Item *next(Fl_Tree_Item *item=0); + Fl_Tree_Item *prev(Fl_Tree_Item *item=0); + Fl_Tree_Item *last(); + Fl_Tree_Item *first_selected_item(); + Fl_Tree_Item *next_selected_item(Fl_Tree_Item *item=0); + + ////////////////////////// + // Item open/close methods + ////////////////////////// + + /// Open the specified 'item'. + /// This causes the item's children (if any) to be shown. + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] item -- the item to be opened. Must not be NULL. + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - callback() is not invoked + /// - 1 - callback() is invoked if item changed, + /// callback_reason() will be FL_TREE_REASON_OPENED + /// \returns + /// - 1 -- item was opened + /// - 0 -- item was already open, no change + /// + /// \see open(), close(), is_open(), is_close(), callback_item(), callback_reason() + /// + int open(Fl_Tree_Item *item, int docallback=1) { + if ( item->is_open() ) return(0); + item->open(); + redraw(); + if ( docallback ) { + do_callback_for_item(item, FL_TREE_REASON_OPENED); + } + return(1); + } + /// Opens the item specified by \p path (eg: "Parent/child/item"). + /// This causes the item's children (if any) to be shown. + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// Items or submenus that themselves contain slashes ('/' or '\') + /// should be escaped, e.g. open("Holidays/12\\/25\//2010"). + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] path -- the tree item's pathname (e.g. "Flintstones/Fred") + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - callback() is not invoked + /// - 1 - callback() is invoked if item changed, + /// callback_reason() will be FL_TREE_REASON_OPENED + /// \returns + /// - 1 -- OK: item opened + /// - 0 -- OK: item was already open, no change + /// - -1 -- ERROR: item was not found + /// + /// \see open(), close(), is_open(), is_close(), callback_item(), callback_reason() + /// + int open(const char *path, int docallback=1) { + Fl_Tree_Item *item = find_item(path); + if ( ! item ) return(-1); + return(open(item, docallback)); + } + /// Toggle the open state of \p item. + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] item -- the item whose open state is to be toggled. Must not be NULL. + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - callback() is not invoked + /// - 1 - callback() is invoked, callback_reason() will be either + /// FL_TREE_REASON_OPENED or FL_TREE_REASON_CLOSED + /// + /// \see open(), close(), is_open(), is_close(), callback_item(), callback_reason() + /// + void open_toggle(Fl_Tree_Item *item, int docallback=1) { + if ( item->is_open() ) { + close(item, docallback); + } else { + open(item, docallback); + } + } + /// Closes the specified \p item. + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] item -- the item to be closed. Must not be NULL. + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - callback() is not invoked + /// - 1 - callback() is invoked if item changed, + /// callback_reason() will be FL_TREE_REASON_CLOSED + /// \returns + /// - 1 -- item was closed + /// - 0 -- item was already closed, no change + /// + /// \see open(), close(), is_open(), is_close(), callback_item(), callback_reason() + /// + int close(Fl_Tree_Item *item, int docallback=1) { + if ( item->is_close() ) return(0); + item->close(); + redraw(); + if ( docallback ) { + do_callback_for_item(item, FL_TREE_REASON_CLOSED); + } + return(1); + } + /// Closes the item specified by \p path, eg: "Parent/child/item". + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// Items or submenus that themselves contain slashes ('/' or '\') + /// should be escaped, e.g. close("Holidays/12\\/25\//2010"). + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] path -- the tree item's pathname (e.g. "Flintstones/Fred") + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - callback() is not invoked + /// - 1 - callback() is invoked if item changed, + /// callback_reason() will be FL_TREE_REASON_CLOSED + /// \returns + /// - 1 -- OK: item closed + /// - 0 -- OK: item was already closed, no change + /// - -1 -- ERROR: item was not found + /// + /// \see open(), close(), is_open(), is_close(), callback_item(), callback_reason() + /// + int close(const char *path, int docallback=1) { + Fl_Tree_Item *item = find_item(path); + if ( ! item ) return(-1); + return(close(item, docallback)); + } + /// See if \p item is open. + /// + /// Items that are 'open' are themselves not necessarily visible; + /// one of the item's parents might be closed. + /// + /// \param[in] item -- the item to be tested. Must not be NULL. + /// \returns + /// - 1 : item is open + /// - 0 : item is closed + /// + int is_open(Fl_Tree_Item *item) const { + return(item->is_open()?1:0); + } + /// See if item specified by \p path (eg: "Parent/child/item") is open. + /// + /// Items or submenus that themselves contain slashes ('/' or '\') + /// should be escaped, e.g. is_open("Holidays/12\\/25\//2010"). + /// + /// Items that are 'open' are themselves not necessarily visible; + /// one of the item's parents might be closed. + /// + /// \param[in] path -- the tree item's pathname (e.g. "Flintstones/Fred") + /// \returns + /// - 1 - OK: item is open + /// - 0 - OK: item is closed + /// - -1 - ERROR: item was not found + /// + int is_open(const char *path) const { + const Fl_Tree_Item *item = find_item(path); + if ( ! item ) return(-1); + return(item->is_open()?1:0); + } + /// See if the specified \p item is closed. + /// + /// \param[in] item -- the item to be tested. Must not be NULL. + /// \returns + /// - 1 : item is open + /// - 0 : item is closed + /// + int is_close(Fl_Tree_Item *item) const { + return(item->is_close()); + } + /// See if item specified by \p path (eg: "Parent/child/item") is closed. + /// + /// Items or submenus that themselves contain slashes ('/' or '\') + /// should be escaped, e.g. is_close("Holidays/12\\/25\//2010"). + /// + /// \param[in] path -- the tree item's pathname (e.g. "Flintstones/Fred") + /// \returns + /// - 1 - OK: item is closed + /// - 0 - OK: item is open + /// - -1 - ERROR: item was not found + /// + int is_close(const char *path) const { + const Fl_Tree_Item *item = find_item(path); + if ( ! item ) return(-1); + return(item->is_close()?1:0); + } + + /// Select the specified \p item. Use 'deselect()' to de-select it. + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] item -- the item to be selected. Must not be NULL. + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - the callback() is not invoked + /// - 1 - the callback() is invoked if item changed state, + /// callback_reason() will be FL_TREE_REASON_SELECTED + /// \returns + /// - 1 - item's state was changed + /// - 0 - item was already selected, no change was made + /// + int select(Fl_Tree_Item *item, int docallback=1) { + if ( ! item->is_selected() ) { + item->select(); + set_changed(); + if ( docallback ) { + do_callback_for_item(item, FL_TREE_REASON_SELECTED); + } + redraw(); + return(1); + } + return(0); + } + /// Select the item specified by \p path (eg: "Parent/child/item"). + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// Items or submenus that themselves contain slashes ('/' or '\') + /// should be escaped, e.g. select("Holidays/12\\/25\//2010"). + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] path -- the tree item's pathname (e.g. "Flintstones/Fred") + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - the callback() is not invoked + /// - 1 - the callback() is invoked if item changed state, + /// callback_reason() will be FL_TREE_REASON_SELECTED + /// \returns + /// - 1 : OK: item's state was changed + /// - 0 : OK: item was already selected, no change was made + /// - -1 : ERROR: item was not found + /// + int select(const char *path, int docallback=1) { + Fl_Tree_Item *item = find_item(path); + if ( ! item ) return(-1); + return(select(item, docallback)); + } + /// Toggle the select state of the specified \p item. + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] item -- the item to be selected. Must not be NULL. + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - the callback() is not invoked + /// - 1 - the callback() is invoked, callback_reason() will be + /// either FL_TREE_REASON_SELECTED or FL_TREE_REASON_DESELECTED + /// + void select_toggle(Fl_Tree_Item *item, int docallback=1) { + item->select_toggle(); + set_changed(); + if ( docallback ) { + do_callback_for_item(item, item->is_selected() ? FL_TREE_REASON_SELECTED + : FL_TREE_REASON_DESELECTED); + } + redraw(); + } + /// De-select the specified \p item. + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] item -- the item to be selected. Must not be NULL. + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - the callback() is not invoked + /// - 1 - the callback() is invoked if item changed state, + /// callback_reason() will be FL_TREE_REASON_DESELECTED + /// \returns + /// - 0 - item was already deselected, no change was made + /// - 1 - item's state was changed + /// + int deselect(Fl_Tree_Item *item, int docallback=1) { + if ( item->is_selected() ) { + item->deselect(); + set_changed(); + if ( docallback ) { + do_callback_for_item(item, FL_TREE_REASON_DESELECTED); + } + redraw(); + return(1); + } + return(0); + } + /// Deselect an item specified by \p path (eg: "Parent/child/item"). + /// Handles redrawing if anything was actually changed. + /// Invokes the callback depending on the value of optional parameter \p docallback. + /// + /// Items or submenus that themselves contain slashes ('/' or '\') + /// should be escaped, e.g. deselect("Holidays/12\\/25\//2010"). + /// + /// The callback can use callback_item() and callback_reason() respectively to determine + /// the item changed and the reason the callback was called. + /// + /// \param[in] path -- the tree item's pathname (e.g. "Flintstones/Fred") + /// \param[in] docallback -- A flag that determines if the callback() is invoked or not: + /// - 0 - the callback() is not invoked + /// - 1 - the callback() is invoked if item changed state, + /// callback_reason() will be FL_TREE_REASON_DESELECTED + /// \returns + /// - 1 - OK: item's state was changed + /// - 0 - OK: item was already deselected, no change was made + /// - -1 - ERROR: item was not found + /// + int deselect(const char *path, int docallback=1) { + Fl_Tree_Item *item = find_item(path); + if ( ! item ) return(-1); + return(deselect(item, docallback)); + } + + int deselect_all(Fl_Tree_Item *item=0, int docallback=1); + int select_only(Fl_Tree_Item *selitem, int docallback=1); + int select_all(Fl_Tree_Item *item=0, int docallback=1); + void set_item_focus(Fl_Tree_Item *o); + + /// See if the specified \p item is selected. + /// + /// \param[in] item -- the item to be tested. Must not be NULL. + /// + /// \return + /// - 1 : item selected + /// - 0 : item deselected + /// + int is_selected(Fl_Tree_Item *item) const { + return(item->is_selected()?1:0); + } + /// See if item specified by \p path (eg: "Parent/child/item") is selected. + /// + /// Items or submenus that themselves contain slashes ('/' or '\') + /// should be escaped, e.g. is_selected("Holidays/12\\/25\//2010"). + /// + /// \param[in] path -- the tree item's pathname (e.g. "Flintstones/Fred") + /// \returns + /// - 1 : item selected + /// - 0 : item deselected + /// - -1 : item was not found + /// + int is_selected(const char *path) { + Fl_Tree_Item *item = find_item(path); + if ( ! item ) return(-1); + return(is_selected(item)); + } + /// Print the tree as 'ascii art' to stdout. + /// Used mainly for debugging. + /// + void show_self() { + if ( ! _root ) return; + _root->show_self(); + } + + ///////////////////////////////// + // Item attribute related methods + ///////////////////////////////// + + /// Get the default label fontsize used for creating new items. + Fl_Fontsize item_labelsize() const { + return(_prefs.labelsize()); + } + /// Set the default label font size used for creating new items. + /// To change the font size on a per-item basis, use Fl_Tree_Item::labelsize(Fl_Fontsize) + /// + void item_labelsize(Fl_Fontsize val) { + _prefs.labelsize(val); + } + /// Get the default font face used for creating new items. + Fl_Font item_labelfont() const { + return(_prefs.labelfont()); + } + /// Set the default font face used for creating new items. + /// To change the font face on a per-item basis, use Fl_Tree_Item::labelfont(Fl_Font) + /// + void item_labelfont(Fl_Font val) { + _prefs.labelfont(val); + } + /// Get the default label foreground color used for creating new items. + Fl_Color item_labelfgcolor(void) const { + return(_prefs.labelfgcolor()); + } + /// Set the default label foreground color used for creating new items. + /// To change the foreground color on a per-item basis, use Fl_Tree_Item::labelfgcolor(Fl_Color) + /// + void item_labelfgcolor(Fl_Color val) { + _prefs.labelfgcolor(val); + } + /// Get the default label background color used for creating new items. + Fl_Color item_labelbgcolor(void) const { + return(_prefs.labelbgcolor()); + } + /// Set the default label background color used for creating new items. + /// To change the background color on a per-item basis, use Fl_Tree_Item::labelbgcolor(Fl_Color) + /// + void item_labelbgcolor(Fl_Color val) { + _prefs.labelbgcolor(val); + } + /// Get the connector color used for tree connection lines. + Fl_Color connectorcolor() const { + return(_prefs.connectorcolor()); + } + /// Set the connector color used for tree connection lines. + void connectorcolor(Fl_Color val) { + _prefs.connectorcolor(val); + } + /// Get the amount of white space (in pixels) that should appear + /// between the widget's left border and the tree's contents. + /// + int marginleft() const { + return(_prefs.marginleft()); + } + /// Set the amount of white space (in pixels) that should appear + /// between the widget's left border and the left side of the tree's contents. + /// + void marginleft(int val) { + _prefs.marginleft(val); + redraw(); + } + /// Get the amount of white space (in pixels) that should appear + /// between the widget's top border and the top of the tree's contents. + /// + int margintop() const { + return(_prefs.margintop()); + } + /// Sets the amount of white space (in pixels) that should appear + /// between the widget's top border and the top of the tree's contents. + /// + void margintop(int val) { + _prefs.margintop(val); + redraw(); + } + /// Get the amount of white space (in pixels) that should appear + /// below an open child tree's contents. + /// + int openchild_marginbottom() const { + return(_prefs.openchild_marginbottom()); + } + /// Set the amount of white space (in pixels) that should appear + /// below an open child tree's contents. + /// + void openchild_marginbottom(int val) { + _prefs.openchild_marginbottom(val); + redraw(); + } + /// Gets the width of the horizontal connection lines (in pixels) + /// that appear to the left of each tree item's label. + /// + int connectorwidth() const { + return(_prefs.connectorwidth()); + } + /// Sets the width of the horizontal connection lines (in pixels) + /// that appear to the left of each tree item's label. + /// + void connectorwidth(int val) { + _prefs.connectorwidth(val); + redraw(); + } + /// Returns the Fl_Image being used as the default user icon for all + /// newly created items. + /// Returns zero if no icon has been set, which is the default. + /// + Fl_Image *usericon() const { + return(_prefs.usericon()); + } + /// Sets the Fl_Image to be used as the default user icon for all + /// newly created items. + /// + /// If you want to specify user icons on a per-item basis, + /// use Fl_Tree_Item::usericon() instead. + /// + /// \param[in] val -- The new image to be used, or + /// zero to disable user icons. + /// + void usericon(Fl_Image *val) { + _prefs.usericon(val); + redraw(); + } + /// Returns the icon to be used as the 'open' icon. + /// If none was set, the internal default is returned, + /// a simple '[+]' icon. + /// + Fl_Image *openicon() const { + return(_prefs.openicon()); + } + /// Sets the icon to be used as the 'open' icon. + /// This overrides the built in default '[+]' icon. + /// + /// \param[in] val -- The new image, or zero to use the default [+] icon. + /// + void openicon(Fl_Image *val) { + _prefs.openicon(val); + redraw(); + } + /// Returns the icon to be used as the 'close' icon. + /// If none was set, the internal default is returned, + /// a simple '[-]' icon. + /// + Fl_Image *closeicon() const { + return(_prefs.closeicon()); + } + /// Sets the icon to be used as the 'close' icon. + /// This overrides the built in default '[-]' icon. + /// + /// \param[in] val -- The new image, or zero to use the default [-] icon. + /// + void closeicon(Fl_Image *val) { + _prefs.closeicon(val); + redraw(); + } + /// Returns 1 if the collapse icon is enabled, 0 if not. + int showcollapse() const { + return(_prefs.showcollapse()); + } + /// Set if we should show the collapse icon or not. + /// If collapse icons are disabled, the user will not be able + /// to interactively collapse items in the tree, unless the application + /// provides some other means via open() and close(). + /// + /// \param[in] val 1: shows collapse icons (default),\n + /// 0: hides collapse icons. + /// + void showcollapse(int val) { + _prefs.showcollapse(val); + redraw(); + } + /// Returns 1 if the root item is to be shown, or 0 if not. + int showroot() const { + return(_prefs.showroot()); + } + /// Set if the root item should be shown or not. + /// \param[in] val 1 -- show the root item (default)\n + /// 0 -- hide the root item. + /// + void showroot(int val) { + _prefs.showroot(val); + redraw(); + } + /// Returns the line drawing style for inter-connecting items. + Fl_Tree_Connector connectorstyle() const { + return(_prefs.connectorstyle()); + } + /// Sets the line drawing style for inter-connecting items. + void connectorstyle(Fl_Tree_Connector val) { + _prefs.connectorstyle(val); + redraw(); + } + /// Set the default sort order used when items are added to the tree. + /// See Fl_Tree_Sort for possible values. + /// + Fl_Tree_Sort sortorder() const { + return(_prefs.sortorder()); + } + /// Gets the sort order used to add items to the tree. + void sortorder(Fl_Tree_Sort val) { + _prefs.sortorder(val); + // no redraw().. only affects new add()itions + } + /// Sets the style of box used to draw selected items. + /// This is an fltk Fl_Boxtype. + /// The default is influenced by FLTK's current Fl::scheme() + /// + Fl_Boxtype selectbox() const { + return(_prefs.selectbox()); + } + /// Gets the style of box used to draw selected items. + /// This is an fltk Fl_Boxtype. + /// The default is influenced by FLTK's current Fl::scheme() + /// + void selectbox(Fl_Boxtype val) { + _prefs.selectbox(val); + redraw(); + } + /// Gets the tree's current selection mode. + Fl_Tree_Select selectmode() const { + return(_prefs.selectmode()); + } + /// Sets the tree's selection mode. + void selectmode(Fl_Tree_Select val) { + _prefs.selectmode(val); + } + int displayed(Fl_Tree_Item *item); + void show_item(Fl_Tree_Item *item, int yoff); + void show_item(Fl_Tree_Item *item); + void show_item_bottom(Fl_Tree_Item *item); + void show_item_middle(Fl_Tree_Item *item); + void show_item_top(Fl_Tree_Item *item); + void display(Fl_Tree_Item *item); + int vposition() const; + void vposition(int ypos); + + /// See if widget \p w is one of the Fl_Tree widget's scrollbars. + /// Use this to skip over the scrollbars when walking the child() array. Example: + /// \code + /// for ( int i=0; i<tree->children(); i++ ) { // walk children + /// Fl_Widget *w= tree->child(i); + /// if ( brow->is_scrollbar(w) ) continue; // skip scrollbars + /// ..do work here.. + /// } + /// \endcode + /// \param[in] w Widget to test + /// \returns 1 if \p w is a scrollbar, 0 if not. + /// + int is_scrollbar(Fl_Widget *w) { + return( ( w == _vscroll ) ? 1 : 0 ); + } + /// Gets the current size of the scrollbars' troughs, in pixels. + /// + /// If this value is zero (default), this widget will use the global + /// Fl::scrollbar_size() value as the scrollbar's width. + /// + /// \returns Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used. + /// \see Fl::scrollbar_size(int) + /// + int scrollbar_size() const { + return(_scrollbar_size); + } + /// Sets the pixel size of the scrollbars' troughs to the \p size, in pixels. + /// + /// Normally you should not need this method, and should use the global + /// Fl::scrollbar_size(int) instead to manage the size of ALL + /// your widgets' scrollbars. This ensures your application + /// has a consistent UI, is the default behavior, and is normally + /// what you want. + /// + /// Only use THIS method if you really need to override the global + /// scrollbar size. The need for this should be rare. + /// + /// Setting \p size to the special value of 0 causes the widget to + /// track the global Fl::scrollbar_size(), which is the default. + /// + /// \param[in] size Sets the scrollbar size in pixels.\n + /// If 0 (default), scrollbar size tracks the global Fl::scrollbar_size() + /// \see Fl::scrollbar_size() + /// + void scrollbar_size(int size) { + _scrollbar_size = size; + int scrollsize = _scrollbar_size ? _scrollbar_size : Fl::scrollbar_size(); + if ( _vscroll->w() != scrollsize ) { + _vscroll->resize(x()+w()-scrollsize, h(), scrollsize, _vscroll->h()); + } + } + + /////////////////////// + // callback related + /////////////////////// + + /// Sets the item that was changed for this callback. + /// Used internally to pass the item that invoked the callback. + /// + void callback_item(Fl_Tree_Item* item) { + _callback_item = item; + } + /// Gets the item that caused the callback. + /// The callback() can use this value to see which item changed. + /// + Fl_Tree_Item* callback_item() { + return(_callback_item); + } + /// Sets the reason for this callback. + /// Used internally to pass the reason the callback was invoked. + /// + void callback_reason(Fl_Tree_Reason reason) { + _callback_reason = reason; + } + /// Gets the reason for this callback. + /// + /// The callback() can use this value to see why it was called. Example: + /// \code + /// void MyTreeCallback(Fl_Widget *w, void *userdata) { + /// Fl_Tree *tree = (Fl_Tree*)w; + /// Fl_Tree_Item *item = tree->callback_item(); // the item changed (can be NULL if more than one item was changed!) + /// switch ( tree->callback_reason() ) { // reason callback was invoked + /// case FL_TREE_REASON_OPENED: ..item was opened.. + /// case FL_TREE_REASON_CLOSED: ..item was closed.. + /// case FL_TREE_REASON_SELECTED: ..item was selected.. + /// case FL_TREE_REASON_DESELECTED: ..item was deselected.. + /// } + /// } + /// \endcode + /// + Fl_Tree_Reason callback_reason() const { + return(_callback_reason); + } + + /// Load FLTK preferences + void load(class Fl_Preferences&); +}; + +#endif /*FL_TREE_H*/ + +// +// End of "$Id: Fl_Tree.H 8632 2011-05-04 02:59:50Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Tree_Item.H b/common/fltk/FL/Fl_Tree_Item.H new file mode 100644 index 00000000..3c579faf --- /dev/null +++ b/common/fltk/FL/Fl_Tree_Item.H @@ -0,0 +1,337 @@ +// +// "$Id: Fl_Tree_Item.H 8340 2011-01-30 20:22:06Z greg.ercolano $" +// + +#ifndef FL_TREE_ITEM_H +#define FL_TREE_ITEM_H + +#include <FL/Fl.H> +#include <FL/Fl_Widget.H> +#include <FL/Fl_Image.H> +#include <FL/fl_draw.H> + +#include <FL/Fl_Tree_Item_Array.H> +#include <FL/Fl_Tree_Prefs.H> + +////////////////////// +// FL/Fl_Tree_Item.H +////////////////////// +// +// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK +// Copyright (C) 2009-2010 by Greg Ercolano. +// +// 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. +// + +/// +/// \file +/// \brief This file contains the definitions for Fl_Tree_Item +/// + +/// \brief Tree item +/// +/// This class is a single tree item, and manages all of the item's attributes. +/// Fl_Tree_Item is used by Fl_Tree, which is comprised of many instances of Fl_Tree_Item. +/// +/// Fl_Tree_Item is hierarchical; it dynamically manages an Fl_Tree_Item_Array of children +/// that are themselves instances of Fl_Tree_Item. Each item can have zero or more children. +/// When an item has children, close() and open() can be used to hide or show them. +/// +/// Items have their own attributes; font size, face, color. +/// Items maintain their own hierarchy of children. +/// +/// When you make changes to items, you'll need to tell the tree to redraw() +/// for the changes to show up. +/// +class FL_EXPORT Fl_Tree_Item { + const char *_label; // label (memory managed) + Fl_Font _labelfont; // label's font face + Fl_Fontsize _labelsize; // label's font size + Fl_Color _labelfgcolor; // label's fg color + Fl_Color _labelbgcolor; // label's bg color + char _open; // item is open? + char _visible; // item is visible? + char _active; // item activated? + char _selected; // item selected? + int _xywh[4]; // xywh of this widget (if visible) + int _collapse_xywh[4]; // xywh of collapse icon (if any) + int _label_xywh[4]; // xywh of label + Fl_Widget *_widget; // item's label widget (optional) + Fl_Image *_usericon; // item's user-specific icon (optional) + Fl_Tree_Item_Array _children; // array of child items + Fl_Tree_Item *_parent; // parent item (=0 if root) + void *_userdata; // user data that can be associated with an item +protected: + void show_widgets(); + void hide_widgets(); + void draw_vertical_connector(int x, int y1, int y2, const Fl_Tree_Prefs &prefs); + void draw_horizontal_connector(int x1, int x2, int y, const Fl_Tree_Prefs &prefs); +public: + Fl_Tree_Item(const Fl_Tree_Prefs &prefs); // CTOR + ~Fl_Tree_Item(); // DTOR + Fl_Tree_Item(const Fl_Tree_Item *o); // COPY CTOR + int x() const { return(_xywh[0]); } + int y() const { return(_xywh[1]); } + int w() const { return(_xywh[2]); } + int h() const { return(_xywh[3]); } + void draw(int X, int &Y, int W, Fl_Widget *tree, Fl_Tree_Item *itemfocus, const Fl_Tree_Prefs &prefs, int lastchild=1); + void show_self(const char *indent = "") const; + void label(const char *val); + const char *label() const; + + /// Set a user-data value for the item. + inline void user_data( void* data ) { _userdata = data; } + + /// Retrieve the user-data value that has been assigned to the item. + inline void* user_data() const { return _userdata; } + + /// Set item's label font face. + void labelfont(Fl_Font val) { + _labelfont = val; + } + /// Get item's label font face. + Fl_Font labelfont() const { + return(_labelfont); + } + /// Set item's label font size. + void labelsize(Fl_Fontsize val) { + _labelsize = val; + } + /// Get item's label font size. + Fl_Fontsize labelsize() const { + return(_labelsize); + } + /// Set item's label foreground text color. + void labelfgcolor(Fl_Color val) { + _labelfgcolor = val; + } + /// Set item's label text color. + void labelcolor(Fl_Color val) { + _labelfgcolor = val; + } + /// Return item's label text color. + Fl_Color labelcolor() const { + return(_labelfgcolor); + } + /// Return item's label foreground text color. + Fl_Color labelfgcolor() const { + return(_labelfgcolor); + } + /// Set item's label background color. + void labelbgcolor(Fl_Color val) { + _labelbgcolor = val; + } + /// Return item's background text color. + Fl_Color labelbgcolor() const { + return(_labelbgcolor); + } + /// Assign an FLTK widget to this item. + void widget(Fl_Widget *val) { + _widget = val; + } + /// Return FLTK widget assigned to this item. + Fl_Widget *widget() const { + return(_widget); + } + /// Return the number of children this item has. + int children() const { + return(_children.total()); + } + /// Return the child item for the given 'index'. + Fl_Tree_Item *child(int index) { + return(_children[index]); + } + /// Return the const child item for the given 'index'. + const Fl_Tree_Item *child(int t) const; + /// See if this item has children. + int has_children() const { + return(children()); + } + int find_child(const char *name); + int find_child(Fl_Tree_Item *item); + int remove_child(Fl_Tree_Item *item); + int remove_child(const char *new_label); + void clear_children(); + void swap_children(int ax, int bx); + int swap_children(Fl_Tree_Item *a, Fl_Tree_Item *b); + const Fl_Tree_Item *find_child_item(char **arr) const; // const + Fl_Tree_Item *find_child_item(char **arr); // non-const + const Fl_Tree_Item *find_item(char **arr) const; // const + Fl_Tree_Item *find_item(char **arr); // non-const + ////////////////// + // Adding items + ////////////////// + Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs, const char *new_label); + Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs, char **arr); + Fl_Tree_Item *insert(const Fl_Tree_Prefs &prefs, const char *new_label, int pos=0); + Fl_Tree_Item *insert_above(const Fl_Tree_Prefs &prefs, const char *new_label); + int depth() const; + Fl_Tree_Item *prev(); + Fl_Tree_Item *next(); + Fl_Tree_Item *next_sibling(); + Fl_Tree_Item *prev_sibling(); + Fl_Tree_Item *next_displayed(Fl_Tree_Prefs &prefs); + Fl_Tree_Item *prev_displayed(Fl_Tree_Prefs &prefs); + + /// Return the parent for this item. Returns NULL if we are the root. + Fl_Tree_Item *parent() { + return(_parent); + } + /// Return the const parent for this item. Returns NULL if we are the root. + const Fl_Tree_Item *parent() const { + return(_parent); + } + /// Set the parent for this item. + /// Should only be used by Fl_Tree's internals. + /// + void parent(Fl_Tree_Item *val) { + _parent = val; + } + ////////////////// + // State + ////////////////// + void open(); + void close(); + /// See if the item is 'open'. + int is_open() const { + return(_open?1:0); + } + /// See if the item is 'closed'. + int is_close() const { + return(_open?0:1); + } + /// Toggle the item's open/closed state. + void open_toggle() { + _open?close():open(); + } + /// Change the item's selection state to the optionally specified 'val'. + /// If 'val' is not specified, the item will be selected. + /// + void select(int val=1) { + _selected = val; + } + /// Toggle the item's selection state. + void select_toggle() { + if ( is_selected() ) { + deselect(); // deselect if selected + } else { + select(); // select if deselected + } + } + /// Select self and all children + /// Returns count of how many items were in the 'deselected' state, + /// ie. how many items were "changed". + /// + int select_all() { + int count = 0; + if ( ! is_selected() ) { + select(); + ++count; + } + for ( int t=0; t<children(); t++ ) { + count += child(t)->select_all(); + } + return(count); + } + /// Disable the item's selection state. + void deselect() { + _selected = 0; + } + /// Deselect self and all children + /// Returns count of how many items were in the 'selected' state, + /// ie. how many items were "changed". + /// + int deselect_all() { + int count = 0; + if ( is_selected() ) { + deselect(); + ++count; + } + for ( int t=0; t<children(); t++ ) { + count += child(t)->deselect_all(); + } + return(count); + } + /// See if the item is selected. + char is_selected() const { + return(_selected); + } + /// Change the item's activation state to the optionally specified 'val'. + /// + /// When deactivated, the item will be 'grayed out'; the callback() + /// won't be invoked if the user clicks on the label. If the item + /// has a widget() associated with the item, its activation state + /// will be changed as well. + /// + /// If 'val' is not specified, the item will be activated. + /// + void activate(int val=1) { + _active = val; + if ( _widget && val != (int)_widget->active() ) { + if ( val ) { + _widget->activate(); + } else { + _widget->deactivate(); + } + _widget->redraw(); + } + } + /// Deactivate the item; the callback() won't be invoked when clicked. + /// Same as activate(0) + /// + void deactivate() { + activate(0); + } + /// See if the item is activated. + char is_activated() const { + return(_active); + } + /// See if the item is activated. + char is_active() const { + return(_active); + } + /// See if the item is visible. + int visible() const { + return(_visible ? 1 : 0); + } + int visible_r() const; + + /// Set the user icon's image. '0' will disable. + void usericon(Fl_Image *val) { + _usericon = val; + } + /// Get the user icon. Returns '0' if disabled. + Fl_Image *usericon() const { + return(_usericon); + } + ////////////////// + // Events + ////////////////// + const Fl_Tree_Item *find_clicked(const Fl_Tree_Prefs &prefs) const; + Fl_Tree_Item *find_clicked(const Fl_Tree_Prefs &prefs); + int event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const; + int event_on_label(const Fl_Tree_Prefs &prefs) const; + /// Is this item the root of the tree? + int is_root() const { + return(_parent==0?1:0); + } +}; + +#endif /*FL_TREE_ITEM_H*/ + +// +// End of "$Id: Fl_Tree_Item.H 8340 2011-01-30 20:22:06Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Tree_Item_Array.H b/common/fltk/FL/Fl_Tree_Item_Array.H new file mode 100644 index 00000000..5a91dee1 --- /dev/null +++ b/common/fltk/FL/Fl_Tree_Item_Array.H @@ -0,0 +1,90 @@ +// +// "$Id: Fl_Tree_Item_Array.H 7903 2010-11-28 21:06:39Z matt $" +// + +#ifndef _FL_TREE_ITEM_ARRAY_H +#define _FL_TREE_ITEM_ARRAY_H + +#include "Fl_Export.H" + +class FL_EXPORT Fl_Tree_Item; // forward decl must *precede* first doxygen comment block + // or doxygen will not document our class.. + +////////////////////////// +// FL/Fl_Tree_Item_Array.H +////////////////////////// +// +// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK +// Copyright (C) 2009-2010 by Greg Ercolano. +// +// 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. +// + +/// +/// \file +/// \brief This file defines a class that manages an array of Fl_Tree_Item pointers. +/// + +/// \brief Manages an array of Fl_Tree_Item pointers. +/// +/// Because FLTK 1.x.x. has mandated that templates and STL not be used, +/// we use this class to dynamically manage the arrays. +/// +/// None of the methods do range checking on index values; the caller +/// must be sure that index values are within the range 0<index<total() +/// (unless otherwise noted). +/// + +class FL_EXPORT Fl_Tree_Item_Array { + Fl_Tree_Item **_items; // items array + int _total; // #items in array + int _size; // #items *allocated* for array + int _chunksize; // #items to enlarge mem allocation + void enlarge(int count); +public: + Fl_Tree_Item_Array(int new_chunksize = 10); // CTOR + ~Fl_Tree_Item_Array(); // DTOR + Fl_Tree_Item_Array(const Fl_Tree_Item_Array *o); // COPY CTOR + /// Return the item and index \p i. + Fl_Tree_Item *operator[](int i) { + return(_items[i]); + } + /// Const version of operator[](int i) + const Fl_Tree_Item *operator[](int i) const { + return(_items[i]); + } + /// Return the total items in the array, or 0 if empty. + int total() const { + return(_total); + } + /// Swap the two items at index positions \p ax and \p bx. + void swap(int ax, int bx) { + Fl_Tree_Item *asave = _items[ax]; + _items[ax] = _items[bx]; + _items[bx] = asave; + } + void clear(); + void add(Fl_Tree_Item *val); + void insert(int pos, Fl_Tree_Item *new_item); + void remove(int index); + int remove(Fl_Tree_Item *item); +}; + +#endif /*_FL_TREE_ITEM_ARRAY_H*/ + +// +// End of "$Id: Fl_Tree_Item_Array.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_Tree_Prefs.H b/common/fltk/FL/Fl_Tree_Prefs.H new file mode 100644 index 00000000..57d72e38 --- /dev/null +++ b/common/fltk/FL/Fl_Tree_Prefs.H @@ -0,0 +1,343 @@ +// +// "$Id: Fl_Tree_Prefs.H 8340 2011-01-30 20:22:06Z greg.ercolano $" +// + +#ifndef FL_TREE_PREFS_H +#define FL_TREE_PREFS_H + +////////////////////// +// FL/Fl_Tree_Prefs.H +////////////////////// +// +// Fl_Tree -- This file is part of the Fl_Tree widget for FLTK +// Copyright (C) 2009-2010 by Greg Ercolano. +// +// 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. +// + +/// +/// \file +/// \brief This file contains the definitions for Fl_Tree's preferences. +/// +/// \code +/// Fl_Tree_Prefs +/// : +/// .....:....... +/// : : +/// Fl_Tree : +/// |_____ Fl_Tree_Item +/// +/// \endcode +/// + +/// \class Fl_Tree_Prefs +/// \brief Tree widget's preferences. + +/// \enum Fl_Tree_Sort +/// Sort order options for items added to the tree +/// +enum Fl_Tree_Sort { + FL_TREE_SORT_NONE=0, ///< No sorting; items are added in the order defined (default). + FL_TREE_SORT_ASCENDING=1, ///< Add items in ascending sort order. + FL_TREE_SORT_DESCENDING=2 ///< Add items in descending sort order. +}; + +/// \enum Fl_Tree_Connector +/// Defines the style of connection lines between items. +/// +enum Fl_Tree_Connector { + FL_TREE_CONNECTOR_NONE=0, ///< Use no lines connecting items + FL_TREE_CONNECTOR_DOTTED=1, ///< Use dotted lines connecting items (default) + FL_TREE_CONNECTOR_SOLID=2 ///< Use solid lines connecting items +}; + +/// \enum Fl_Tree_Select +/// Tree selection style. +/// +enum Fl_Tree_Select { + FL_TREE_SELECT_NONE=0, ///< Nothing selected when items are clicked + FL_TREE_SELECT_SINGLE=1, ///< Single item selected when item is clicked (default) + FL_TREE_SELECT_MULTI=2 ///< Multiple items can be selected by clicking with + ///< SHIFT or CTRL or mouse drags. +}; + +/// \class Fl_Tree_Prefs +/// +/// \brief Fl_Tree's Preferences class. +/// +/// This class manages the Fl_Tree's defaults. +/// You should probably be using the methods in Fl_Tree +/// instead of trying to accessing tree's preferences settings directly. +/// +class FL_EXPORT Fl_Tree_Prefs { + Fl_Font _labelfont; // label's font face + Fl_Fontsize _labelsize; // label's font size + int _margintop; // -- + int _marginleft; // |- tree's margins + //int _marginright; // | + //int _marginbottom; // -- + int _openchild_marginbottom; // extra space below an open child tree + int _usericonmarginleft; // space to left of user icon (if any) + int _labelmarginleft; // space to left of label + int _connectorwidth; // connector width (right of open/close icon) + int _linespacing; // vertical space between lines + // Colors + Fl_Color _labelfgcolor; // label's foreground color + Fl_Color _labelbgcolor; // background color + Fl_Color _connectorcolor; // connector dotted line color + Fl_Tree_Connector _connectorstyle; // connector line style + Fl_Image *_openimage; // the 'open' icon [+] + Fl_Image *_closeimage; // the 'close' icon [-] + Fl_Image *_userimage; // user's own icon + char _showcollapse; // 1=show collapse icons, 0=don't + char _showroot; // show the root item as part of the tree + Fl_Tree_Sort _sortorder; // none, ascening, descending, etc. + Fl_Boxtype _selectbox; // selection box type + Fl_Tree_Select _selectmode; // selection mode +public: + Fl_Tree_Prefs(); + + //////////////////////////// + // Labels + //////////////////////////// + /// Return the label's font. + inline Fl_Font labelfont() const { + return(_labelfont); + } + /// Set the label's font to \p val. + inline void labelfont(Fl_Font val) { + _labelfont = val; + } + /// Return the label's size in pixels. + inline Fl_Fontsize labelsize() const { + return(_labelsize); + } + /// Set the label's size in pixels to \p val. + inline void labelsize(Fl_Fontsize val) { + _labelsize = val; + } + + //////////////////////////// + // Margins + //////////////////////////// + /// Get the left margin's value in pixels + inline int marginleft() const { + return(_marginleft); + } + /// Set the left margin's value in pixels + inline void marginleft(int val) { + _marginleft = val; + } + /// Get the top margin's value in pixels + inline int margintop() const { + return(_margintop); + } + /// Set the top margin's value in pixels + inline void margintop(int val) { + _margintop = val; + } + /// Get the margin below an open child in pixels + inline int openchild_marginbottom() const { + return(_openchild_marginbottom); + } + /// Set the margin below an open child in pixels + inline void openchild_marginbottom(int val) { + _openchild_marginbottom = val; + } + + /****** NOT IMPLEMENTED + inline int marginright() const { + return(_marginright); + } + inline void marginright(int val) { + _marginright = val; + } + inline int marginbottom() const { + return(_marginbottom); + } + inline void marginbottom(int val) { + _marginbottom = val; + } + *******/ + + /// Get the user icon's left margin value in pixels + inline int usericonmarginleft() const { + return(_usericonmarginleft); + } + /// Set the user icon's left margin value in pixels + inline void usericonmarginleft(int val) { + _usericonmarginleft = val; + } + /// Get the label's left margin value in pixels + inline int labelmarginleft() const { + return(_labelmarginleft); + } + /// Set the label's left margin value in pixels + inline void labelmarginleft(int val) { + _labelmarginleft = val; + } + /// Get the line spacing value in pixels + inline int linespacing() const { + return(_linespacing); + } + /// Set the line spacing value in pixels + inline void linespacing(int val) { + _linespacing = val; + } + + //////////////////////////// + // Colors and Styles + //////////////////////////// + /// Get the default label foreground color + inline Fl_Color labelfgcolor() const { + return(_labelfgcolor); + } + /// Set the default label foreground color + inline void labelfgcolor(Fl_Color val) { + _labelfgcolor = val; + } + /// Get the default label background color + inline Fl_Color labelbgcolor() const { + return(_labelbgcolor); + } + /// Set the default label background color + inline void labelbgcolor(Fl_Color val) { + _labelbgcolor = val; + } + /// Get the connector color used for tree connection lines. + inline Fl_Color connectorcolor() const { + return(_connectorcolor); + } + /// Set the connector color used for tree connection lines. + inline void connectorcolor(Fl_Color val) { + _connectorcolor = val; + } + /// Get the connector style. + inline Fl_Tree_Connector connectorstyle() const { + return(_connectorstyle); + } + /// Set the connector style. + inline void connectorstyle(Fl_Tree_Connector val) { + _connectorstyle = val; + } + /// Set the connector style [integer]. + inline void connectorstyle(int val) { + _connectorstyle = Fl_Tree_Connector(val); + } + /// Get the tree connection line's width. + inline int connectorwidth() const { + return(_connectorwidth); + } + /// Set the tree connection line's width. + inline void connectorwidth(int val) { + _connectorwidth = val; + } + + //////////////////////////// + // Icons + //////////////////////////// + /// Get the current default 'open' icon. + /// Returns the Fl_Image* of the icon, or 0 if none. + /// + inline Fl_Image *openicon() const { + return(_openimage); + } + void openicon(Fl_Image *val); + /// Gets the default 'close' icon + /// Returns the Fl_Image* of the icon, or 0 if none. + /// + inline Fl_Image *closeicon() const { + return(_closeimage); + } + void closeicon(Fl_Image *val); + /// Gets the default 'user icon' (default is 0) + inline Fl_Image *usericon() const { + return(_userimage); + } + /// Sets the default 'user icon' + /// Returns the Fl_Image* of the icon, or 0 if none (default). + /// + inline void usericon(Fl_Image *val) { + _userimage = val; + } + + //////////////////////////// + // Options + //////////////////////////// + /// Returns 1 if the collapse icon is enabled, 0 if not. + inline char showcollapse() const { + return(_showcollapse); + } + /// Set if we should show the collapse icon or not. + /// If collapse icons are disabled, the user will not be able + /// to interactively collapse items in the tree, unless the application + /// provides some other means via open() and close(). + /// + /// \param[in] val 1: shows collapse icons (default),\n + /// 0: hides collapse icons. + /// + inline void showcollapse(int val) { + _showcollapse = val; + } + /// Get the default sort order value + inline Fl_Tree_Sort sortorder() const { + return(_sortorder); + } + /// Set the default sort order value. + /// Defines the order new items appear when add()ed to the tree. + /// See Fl_Tree_Sort for possible values. + /// + inline void sortorder(Fl_Tree_Sort val) { + _sortorder = val; + } + /// Get the default selection box's box drawing style as an Fl_Boxtype. + inline Fl_Boxtype selectbox() const { + return(_selectbox); + } + /// Set the default selection box's box drawing style to \p val. + inline void selectbox(Fl_Boxtype val) { + _selectbox = val; + } + /// Returns 1 if the root item is to be shown, or 0 if not. + inline int showroot() const { + return(int(_showroot)); + } + /// Set if the root item should be shown or not. + /// \param[in] val 1 -- show the root item (default)\n + /// 0 -- hide the root item. + /// + inline void showroot(int val) { + _showroot = char(val); + } + /// Get the selection mode used for the tree + inline Fl_Tree_Select selectmode() const { + return(_selectmode); + } + /// Set the selection mode used for the tree to \p val. + /// This affects how items in the tree are selected + /// when clicked on and dragged over by the mouse. + /// See Fl_Tree_Select for possible values. + /// + inline void selectmode(Fl_Tree_Select val) { + _selectmode = val; + } +}; + +#endif /*FL_TREE_PREFS_H*/ + +// +// End of "$Id: Fl_Tree_Prefs.H 8340 2011-01-30 20:22:06Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Valuator.H b/common/fltk/FL/Fl_Valuator.H new file mode 100644 index 00000000..73af078b --- /dev/null +++ b/common/fltk/FL/Fl_Valuator.H @@ -0,0 +1,144 @@ +// +// "$Id: Fl_Valuator.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Valuator header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Valuator widget . */ + +#ifndef Fl_Valuator_H +#define Fl_Valuator_H + +#ifndef Fl_Widget_H +#include "Fl_Widget.H" +#endif + +// shared type() values for classes that work in both directions: +#define FL_VERTICAL 0 ///< The valuator can work vertically +#define FL_HORIZONTAL 1 ///< The valuator can work horizontally + +/** + The Fl_Valuator class controls a single floating-point value + and provides a consistent interface to set the value, range, and step, + and insures that callbacks are done the same for every object. + <P>There are probably more of these classes in FLTK than any others: + <P ALIGN=CENTER>\image html valuators.png</P> + \image latex valuators.png "Valuators derived from Fl_Valuators" width=10cm + <P>In the above diagram each box surrounds an actual subclass. These + are further differentiated by setting the type() of the widget t + o the symbolic value labeling the widget. + The ones labelled "0" are the default versions with a type(0). + For consistency the symbol FL_VERTICAL is defined as zero. +*/ +class FL_EXPORT Fl_Valuator : public Fl_Widget { + + double value_; + double previous_value_; + double min, max; // truncates to this range *after* rounding + double A; int B; // rounds to multiples of A/B, or no rounding if A is zero + +protected: + /** Tells if the valuator is an FL_HORIZONTAL one */ + int horizontal() const {return type()& FL_HORIZONTAL;} + Fl_Valuator(int X, int Y, int W, int H, const char* L); + + /** Gets the previous floating point value before an event changed it */ + double previous_value() const {return previous_value_;} + /** Stores the current value in the previous value */ + void handle_push() {previous_value_ = value_;} + double softclamp(double); + void handle_drag(double newvalue); + void handle_release(); // use drag() value + virtual void value_damage(); // cause damage() due to value() changing + /** Sets the current floating point value. */ + void set_value(double v) {value_ = v;} + +public: + + /** Sets the minimum (a) and maximum (b) values for the valuator widget. */ + void bounds(double a, double b) {min=a; max=b;} + /** Gets the minimum value for the valuator. */ + double minimum() const {return min;} + /** Sets the minimum value for the valuator. */ + void minimum(double a) {min = a;} + /** Gets the maximum value for the valuator. */ + double maximum() const {return max;} + /** Sets the maximum value for the valuator. */ + void maximum(double a) {max = a;} + /** + Sets the minimum and maximum values for the valuator. When + the user manipulates the widget, the value is limited to this + range. This clamping is done <I>after</I> rounding to the step + value (this makes a difference if the range is not a multiple of + the step). + + <P>The minimum may be greater than the maximum. This has the + effect of "reversing" the object so the larger values + are in the opposite direction. This also switches which end of + the filled sliders is filled.</P> + + <P>Some widgets consider this a "soft" range. This + means they will stop at the range, but if the user releases and + grabs the control again and tries to move it further, it is + allowed.</P> + + <P>The range may affect the display. You must redraw() + the widget after changing the range. + */ + void range(double a, double b) {min = a; max = b;} + /** See double Fl_Valuator::step() const */ + void step(int a) {A = a; B = 1;} + /** See double Fl_Valuator::step() const */ + void step(double a, int b) {A = a; B = b;} + void step(double s); + /** + Gets or sets the step value. As the user moves the mouse the + value is rounded to the nearest multiple of the step value. This + is done <I>before</I> clamping it to the range. For most widgets + the default step is zero. + + <P>For precision the step is stored as the ratio of two + integers, A/B. You can set these integers directly. Currently + setting a floating point value sets the nearest A/1 or 1/B value + possible. + */ + double step() const {return A/B;} + void precision(int); + + /** Gets the floating point(double) value. See int value(double) */ + double value() const {return value_;} + int value(double); + + virtual int format(char*); + double round(double); // round to nearest multiple of step + double clamp(double); // keep in range + double increment(double, int); // add n*step to value +}; + +#endif + +// +// End of "$Id: Fl_Valuator.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Value_Input.H b/common/fltk/FL/Fl_Value_Input.H new file mode 100644 index 00000000..47ffcf33 --- /dev/null +++ b/common/fltk/FL/Fl_Value_Input.H @@ -0,0 +1,139 @@ +// +// "$Id: Fl_Value_Input.H 8337 2011-01-30 09:04:59Z manolo $" +// +// Value input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Value_Input widget . */ + +#ifndef Fl_Value_Input_H +#define Fl_Value_Input_H + +#include "Fl_Valuator.H" +#include "Fl_Input.H" + +/** + The Fl_Value_Input widget displays a numeric value. + The user can click in the text field and edit it - there is in + fact a hidden Fl_Input widget with + type(FL_FLOAT_INPUT) or type(FL_INT_INPUT) in + there - and when they hit return or tab the value updates to + what they typed and the callback is done. + + <P>If step() is non-zero and integral, then the range of numbers + is limited to integers instead of floating point numbers. As + well as displaying the value as an integer, typed input is also + limited to integer values, even if the hidden Fl_Input widget + is of type(FL_FLOAT_INPUT).</P> + + <P>If step() is non-zero, the user can also drag the + mouse across the object and thus slide the value. The left + button moves one step() per pixel, the middle by 10 + * step(), and the right button by 100 * step(). It + is therefore impossible to select text by dragging across it, + although clicking can still move the insertion cursor.</P> + + <P>If step() is non-zero and integral, then the range + of numbers are limited to integers instead of floating point + values. + + <P ALIGN="CENTER">\image html Fl_Value_Input.png + \image latex Fl_Value_Input.png "Fl_Value_Input" width=4cm +*/ +class FL_EXPORT Fl_Value_Input : public Fl_Valuator { +public: + /* This is the encapsulated Fl_input attribute to which + this class delegates the value font, color and shortcut */ + Fl_Input input; +private: + char soft_; + static void input_cb(Fl_Widget*,void*); + virtual void value_damage(); // cause damage() due to value() changing +public: + int handle(int); +protected: + void draw(); +public: + void resize(int,int,int,int); + Fl_Value_Input(int x,int y,int w,int h,const char *l=0); + ~Fl_Value_Input(); + + /** See void Fl_Value_Input::soft(char s) */ + void soft(char s) {soft_ = s;} + /** + If "soft" is turned on, the user is allowed to drag + the value outside the range. If they drag the value to one of + the ends, let go, then grab again and continue to drag, they can + get to any value. The default is true. + */ + char soft() const {return soft_;} + /** + Returns the current shortcut key for the Input. + \see Fl_Value_Input::shortcut(int) + */ + int shortcut() const {return input.shortcut();} + /** + Sets the shortcut key to \p s. Setting this + overrides the use of '&' in the label(). The value is a bitwise + OR of a key and a set of shift flags, for example FL_ALT | 'a' + , FL_ALT | (FL_F + 10), or just 'a'. A value + of 0 disables the shortcut. + + The key can be any value returned by + Fl::event_key(), but will usually be an ASCII letter. Use + a lower-case letter unless you require the shift key to be held down. + + The shift flags can be any set of values accepted by + Fl::event_state(). If the bit is on that shift key must + be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in + the shift flags (zero for the other bits indicates a "don't care" + setting). + */ + void shortcut(int s) {input.shortcut(s);} + + /** Gets the typeface of the text in the value box. */ + Fl_Font textfont() const {return input.textfont();} + /** Sets the typeface of the text in the value box. */ + void textfont(Fl_Font s) {input.textfont(s);} + /** Gets the size of the text in the value box. */ + Fl_Fontsize textsize() const {return input.textsize();} + /** Sets the size of the text in the value box. */ + void textsize(Fl_Fontsize s) {input.textsize(s);} + /** Gets the color of the text in the value box. */ + Fl_Color textcolor() const {return input.textcolor();} + /** Sets the color of the text in the value box.*/ + void textcolor(Fl_Color n) {input.textcolor(n);} + /** Gets the color of the text cursor. The text cursor is black by default. */ + Fl_Color cursor_color() const {return input.cursor_color();} + /** Sets the color of the text cursor. The text cursor is black by default. */ + void cursor_color(Fl_Color n) {input.cursor_color(n);} + +}; + +#endif + +// +// End of "$Id: Fl_Value_Input.H 8337 2011-01-30 09:04:59Z manolo $". +// diff --git a/common/fltk/FL/Fl_Value_Output.H b/common/fltk/FL/Fl_Value_Output.H new file mode 100644 index 00000000..afae308a --- /dev/null +++ b/common/fltk/FL/Fl_Value_Output.H @@ -0,0 +1,95 @@ +// +// "$Id: Fl_Value_Output.H 7989 2010-12-09 12:19:03Z greg.ercolano $" +// +// Value output header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Value_Output widget . */ + +#ifndef Fl_Value_Output_H +#define Fl_Value_Output_H + +#ifndef Fl_Valuator_H +#include "Fl_Valuator.H" +#endif + +/** + The Fl_Value_Output widget displays a floating point value. + If step() is not zero, the user can adjust the value by + dragging the mouse left and right. The left button moves one step() + per pixel, the middle by 10 * step(), and the right button by + 100 * step(). + <P>This is much lighter-weight than + Fl_Value_Input because it contains no text editing code or + character buffer. </P> + <P ALIGN=CENTER>\image html Fl_Value_Output.png + \image latex Fl_Value_Output.png "Fl_Value_Output" width=4cm +*/ +class FL_EXPORT Fl_Value_Output : public Fl_Valuator { + Fl_Font textfont_; + Fl_Fontsize textsize_; + uchar soft_; + Fl_Color textcolor_; + +protected: + void draw(); + +public: + int handle(int); + Fl_Value_Output(int x,int y,int w,int h,const char *l=0); + + /** + If "soft" is turned on, the user is allowed to drag the value outside + the range. If they drag the value to one of the ends, let go, then + grab again and continue to drag, they can get to any value. Default is + one. + */ + void soft(uchar s) {soft_ = s;} + /** + If "soft" is turned on, the user is allowed to drag the value outside + the range. If they drag the value to one of the ends, let go, then + grab again and continue to drag, they can get to any value. Default is + one. + */ + uchar soft() const {return soft_;} + + /** Gets the typeface of the text in the value box. */ + Fl_Font textfont() const {return textfont_;} + /** Sets the typeface of the text in the value box. */ + void textfont(Fl_Font s) {textfont_ = s;} + /** Gets the size of the text in the value box. */ + Fl_Fontsize textsize() const {return textsize_;} + void textsize(Fl_Fontsize s) {textsize_ = s;} + /** Sets the color of the text in the value box. */ + Fl_Color textcolor() const {return textcolor_;} + /** Gets the color of the text in the value box. */ + void textcolor(Fl_Color s) {textcolor_ = s;} +}; + +#endif + +// +// End of "$Id: Fl_Value_Output.H 7989 2010-12-09 12:19:03Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Value_Slider.H b/common/fltk/FL/Fl_Value_Slider.H new file mode 100644 index 00000000..21a42ff7 --- /dev/null +++ b/common/fltk/FL/Fl_Value_Slider.H @@ -0,0 +1,69 @@ +// +// "$Id: Fl_Value_Slider.H 7981 2010-12-08 23:53:04Z greg.ercolano $" +// +// Value slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Value_Slider widget . */ + +#ifndef Fl_Value_Slider_H +#define Fl_Value_Slider_H + +#include "Fl_Slider.H" + +/** + The Fl_Value_Slider widget is a Fl_Slider widget + with a box displaying the current value. + <P ALIGN=CENTER>\image html value_slider.png + \image latex value_slider.png "Fl_Value_Slider" width=4cm +*/ +class FL_EXPORT Fl_Value_Slider : public Fl_Slider { + Fl_Font textfont_; + Fl_Fontsize textsize_; + Fl_Color textcolor_; +protected: + void draw(); +public: + int handle(int); + Fl_Value_Slider(int x,int y,int w,int h, const char *l = 0); + /** Gets the typeface of the text in the value box. */ + Fl_Font textfont() const {return textfont_;} + /** Sets the typeface of the text in the value box. */ + void textfont(Fl_Font s) {textfont_ = s;} + /** Gets the size of the text in the value box. */ + Fl_Fontsize textsize() const {return textsize_;} + /** Sets the size of the text in the value box. */ + void textsize(Fl_Fontsize s) {textsize_ = s;} + /** Gets the color of the text in the value box. */ + Fl_Color textcolor() const {return textcolor_;} + /** Sets the color of the text in the value box. */ + void textcolor(Fl_Color s) {textcolor_ = s;} +}; + +#endif + +// +// End of "$Id: Fl_Value_Slider.H 7981 2010-12-08 23:53:04Z greg.ercolano $". +// diff --git a/common/fltk/FL/Fl_Widget.H b/common/fltk/FL/Fl_Widget.H new file mode 100644 index 00000000..780c6cba --- /dev/null +++ b/common/fltk/FL/Fl_Widget.H @@ -0,0 +1,1006 @@ +// +// "$Id: Fl_Widget.H 8623 2011-04-24 17:09:41Z AlbrechtS $" +// +// Widget header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file + Fl_Widget, Fl_Label classes . */ + +#ifndef Fl_Widget_H +#define Fl_Widget_H + +#include "Enumerations.H" + +/** + \todo typedef's fl_intptr_t and fl_uintptr_t should be documented. +*/ +#ifdef _WIN64 +#ifdef __GNUC__ +#include <stdint.h> +#else +#include <stddef.h> // M$VC +#endif +typedef intptr_t fl_intptr_t; +typedef uintptr_t fl_uintptr_t; +#else +typedef long fl_intptr_t; +typedef unsigned long fl_uintptr_t; +#endif + +class Fl_Widget; +class Fl_Window; +class Fl_Group; +class Fl_Image; + +/** Default callback type definition for all fltk widgets (by far the most used) */ +typedef void (Fl_Callback )(Fl_Widget*, void*); +/** Default callback type pointer definition for all fltk widgets */ +typedef Fl_Callback* Fl_Callback_p; // needed for BORLAND +/** One parameter callback type definition passing only the widget */ +typedef void (Fl_Callback0)(Fl_Widget*); +/** Callback type definition passing the widget and a long data value */ +typedef void (Fl_Callback1)(Fl_Widget*, long); + +/** This struct stores all information for a text or mixed graphics label. + + \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. + */ +struct FL_EXPORT Fl_Label { + /** label text */ + const char* value; + /** optional image for an active label */ + Fl_Image* image; + /** optional image for a deactivated label */ + Fl_Image* deimage; + /** label font used in text */ + Fl_Font font; + /** size of label font */ + Fl_Fontsize size; + /** text color */ + Fl_Color color; + /** alignment of label */ + Fl_Align align_; + /** type of label. \see Fl_Labeltype */ + uchar type; + + /** Draws the label aligned to the given box */ + void draw(int,int,int,int, Fl_Align) const ; + void measure(int &w, int &h) const ; +}; + + +/** 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. + + 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 { + friend class Fl_Group; + + Fl_Group* parent_; + Fl_Callback* callback_; + void* user_data_; + int x_,y_,w_,h_; + Fl_Label label_; + unsigned int flags_; + Fl_Color color_; + Fl_Color color2_; + uchar type_; + uchar damage_; + uchar box_; + uchar when_; + + const char *tooltip_; + + /** unimplemented copy ctor */ + Fl_Widget(const Fl_Widget &); + /** unimplemented assignment operator */ + Fl_Widget& operator=(const Fl_Widget &); + +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 + 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 + */ + Fl_Widget(int x, int y, int w, int h, const char *label=0L); + + /** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */ + void x(int v) {x_ = v;} + /** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */ + void y(int v) {y_ = v;} + /** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */ + void w(int v) {w_ = v;} + /** Internal use only. Use position(int,int), size(int,int) or resize(int,int,int,int) instead. */ + void h(int v) {h_ = v;} + /** Gets the widget flags mask */ + unsigned int flags() const {return flags_;} + /** Sets a flag in the flags mask */ + void set_flag(unsigned int c) {flags_ |= c;} + /** Clears a flag in the flags mask */ + void clear_flag(unsigned int c) {flags_ &= ~c;} + /** flags possible values enumeration. + See activate(), output(), visible(), changed(), set_visible_focus() + */ + enum { + 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 a few special events + OUTPUT = 1<<2, ///< for output only + NOBORDER = 1<<3, ///< don't draw a decoration (Fl_Window) + FORCE_POSITION = 1<<4, ///< don't let the window manager position the window (Fl_Window) + NON_MODAL = 1<<5, ///< this is 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) + NO_OVERLAY = 1<<15, ///< window not using a hardware overlay plane (Fl_Menu_Window) + GROUP_RELATIVE = 1<<16, ///< position this widget relative to the parent group, not to the window + COPIED_TOOLTIP = 1<<17, ///< the widget tooltip is internally copied, its destruction is handled by the widget + // (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 + }; + void draw_box() const; + 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; + void draw_label() const; + void draw_label(int, int, int, int) const; + +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 + 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. + */ + virtual ~Fl_Widget(); + + /** 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. + + Override this function to draw your own widgets. + + If you ever need to call another widget's draw method <I>from within your + own draw() method</I>, e.g. for an embedded scrollbar, you can do it + (because draw() is virtual) like this: + + \code + Fl_Widget *s = &scroll; // scroll is an embedded Fl_Scrollbar + s->draw(); // calls Fl_Scrollbar::draw() + \endcode + */ + virtual void draw() = 0; + + /** 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 + 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 + 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 + */ + virtual int handle(int event); + + /** 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. + + 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() + + /** 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" ? + */ + uchar type() const {return type_;} + + /** Sets the widget type. + This is used for Forms compatibility. + */ + void type(uchar t) {type_ = t;} + + /** Gets the widget position in its window. + \return the x position relative to the window + */ + int x() const {return x_;} + + /** Gets the widget position in its window. + \return the y position relative to the window + */ + int y() const {return y_;} + + /** Gets the widget width. + \return the width of the widget in pixels. + */ + int w() const {return w_;} + + /** Gets the widget height. + \return the height of the widget in pixels. + */ + int h() const {return h_;} + + /** 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) + */ + virtual void resize(int x, int y, int w, int h); + + /** Internal use only. */ + int damage_resize(int,int,int,int); + + /** 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 + \see resize(int,int,int,int), size(int,int) + */ + void position(int X,int Y) {resize(X,Y,w_,h_);} + + /** 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) + */ + void size(int W,int H) {resize(x_,y_,W,H);} + + /** Gets the label alignment. + + \return label alignment + \see label(), align(Fl_Align), Fl_Align + */ + 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 + the widget. + \param[in] alignment new label alignment + \see align(), Fl_Align + */ + void align(Fl_Align alignment) {label_.align_ = alignment;} + + /** Gets the box type of the widget. + \return the current box type + \see box(Fl_Boxtype), Fl_Boxtype + */ + Fl_Boxtype box() const {return (Fl_Boxtype)box_;} + + /** 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 + widget, but is usually FL_NO_BOX or FL_UP_BOX. + \param[in] new_box the new box type + \see box(), Fl_Boxtype + */ + void box(Fl_Boxtype new_box) {box_ = new_box;} + + /** Gets the background color of the widget. + \return current background color + \see color(Fl_Color), color(Fl_Color, Fl_Color) + */ + 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 + 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 + \see color(), color(Fl_Color, Fl_Color), selection_color(Fl_Color) + */ + void color(Fl_Color bg) {color_ = bg;} + + /** Gets the selection color. + \return the current selection color + \see selection_color(Fl_Color), color(Fl_Color, Fl_Color) + */ + 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 + 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. + + 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) + */ + void color(Fl_Color bg, Fl_Color sel) {color_=bg; color2_=sel;} + + /** Gets the current label text. + \return a pointer to the current label text + \see label(const char *), copy_label(const char *) + */ + const char* label() const {return label_.value;} + + /** 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() + */ + void label(const char* text); + + /** 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 + a new label or when the widget is destroyed. + + \param[in] new_label the new label text + \see label() + */ + void copy_label(const char *new_label); + + /** Shortcut to set the label text and type in one call. + \see label(const char *), labeltype(Fl_Labeltype) + */ + void label(Fl_Labeltype a, const char* b) {label_.type = a; label_.value = b;} + + /** Gets the label type. + \return the current label type. + \see Fl_Labeltype + */ + 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 + 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. + \return the current label color + */ + Fl_Color labelcolor() const {return label_.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. + 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. + \return current font used by the label + \see Fl_Font + */ + Fl_Font labelfont() const {return label_.font;} + + /** Sets the font to use. + 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. + \param[in] f the new font for the label + \see Fl_Font + */ + void labelfont(Fl_Font f) {label_.font=f;} + + /** Gets the font size in pixels. + The default size is 14 pixels. + \return the current font size + */ + Fl_Fontsize labelsize() const {return label_.size;} + + /** Sets the font size in pixels. + \param[in] pix the new font size + \see Fl_Fontsize labelsize() + */ + void labelsize(Fl_Fontsize pix) {label_.size=pix;} + + /** 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 + */ + Fl_Image* image() {return label_.image;} + const Fl_Image* image() const {return label_.image;} + + /** 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 + */ + void image(Fl_Image* img) {label_.image=img;} + + /** 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 + */ + void image(Fl_Image& img) {label_.image=&img;} + + /** 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 + */ + Fl_Image* deimage() {return label_.deimage;} + const Fl_Image* deimage() const {return label_.deimage;} + + /** Sets the image to use as part of the widget label. + This image is used when drawing the widget in the inactive state. + \param[in] img the new image for the deactivated widget + */ + void deimage(Fl_Image* img) {label_.deimage=img;} + + /** Sets the image to use as part of the widget label. + This image is used when drawing the widget in the inactive state. + \param[in] img the new image for the deactivated widget + */ + void deimage(Fl_Image& img) {label_.deimage=&img;} + + /** Gets the current tooltip text. + \return a pointer to the tooltip text or NULL + \see tooltip(const char*), copy_tooltip(const char*) + */ + const char *tooltip() const {return 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. + \return current callback + */ + Fl_Callback_p callback() const {return callback_;} + + /** Sets the current callback function for the widget. + Each widget has a single callback. + \param[in] cb new callback + \param[in] p user data + */ + void callback(Fl_Callback* cb, void* p) {callback_=cb; user_data_=p;} + + /** Sets the current callback function for the widget. + Each widget has a single callback. + \param[in] cb new callback + */ + void callback(Fl_Callback* cb) {callback_=cb;} + + /** Sets the current callback function for the widget. + Each widget has a single callback. + \param[in] cb new callback + */ + void callback(Fl_Callback0*cb) {callback_=(Fl_Callback*)cb;} + + /** Sets the current callback function for the widget. + Each widget has a single callback. + \param[in] cb new callback + \param[in] p user data + */ + void callback(Fl_Callback1*cb, long p=0) {callback_=(Fl_Callback*)cb; user_data_=(void*)p;} + + /** Gets the user data for this widget. + Gets the current user data (void *) argument that is passed to the callback function. + \return user data as a pointer + */ + void* user_data() const {return user_data_;} + + /** Sets the user data for this widget. + Sets the new user data (void *) argument that is passed to the callback function. + \param[in] v new user data + */ + void user_data(void* v) {user_data_ = v;} + + /** Gets the current user data (long) argument that is passed to the callback function. + */ + long argument() const {return (long)(fl_intptr_t)user_data_;} + + /** Sets the current user data (long) argument that is passed to the callback function. + \todo The user data value must be implemented using \em intptr_t or similar + to avoid 64-bit machine incompatibilities. + */ + void argument(long v) {user_data_ = (void*)v;} + + /** 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) + */ + Fl_When when() const {return (Fl_When)when_;} + + /** 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 + 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_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 + */ + void when(uchar i) {when_ = i;} + + /** Returns whether a widget is visible. + \retval 0 if the widget is not drawn and hence invisible. + \see show(), hide(), visible_r() + */ + unsigned int visible() const {return !(flags_&INVISIBLE);} + + /** Returns whether a widget and all its parents are visible. + \retval 0 if the widget or any of its parents are invisible. + \see show(), hide(), visible() + */ + int visible_r() const; + + /** Makes a widget visible. + + An invisible widget never gets redrawn and does not get keyboard + or mouse events, but can receive a few other events like FL_SHOW. + + 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() + */ + 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 + 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. + Normally you want to use the hide() method instead. + */ + void clear_visible() {flags_ |= INVISIBLE;} + + /** Returns whether the widget is active. + \retval 0 if the widget is inactive + \see active_r(), activate(), deactivate() + */ + unsigned int active() const {return !(flags_&INACTIVE);} + + /** 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 + 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>. + + 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() + */ + 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 + devices. + \retval 0 if the widget is used for input and output + \see set_output(), clear_output() + */ + unsigned int output() const {return (flags_&OUTPUT);} + + /** Sets a widget to output only. + \see output(), clear_output() + */ + void set_output() {flags_ |= OUTPUT;} + + /** Sets a widget to accept input. + \see set_output(), output() + */ + void clear_output() {flags_ &= ~OUTPUT;} + + /** Returns if the widget is able to take events. + This is the same as (active() && !output() && visible()) + but is faster. + \retval 0 if the widget takes no events + */ + unsigned int takesevents() const {return !(flags_&(INACTIVE|INVISIBLE|OUTPUT));} + + /** + Checks if the widget value changed since the last callback. + + "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() + */ + unsigned int changed() const {return flags_&CHANGED;} + + /** Marks the value of the widget as changed. + \see changed(), clear_changed() + */ + void set_changed() {flags_ |= CHANGED;} + + /** Marks the value of the widget as unchanged. + \see changed(), set_changed() + */ + void clear_changed() {flags_ &= ~CHANGED;} + + /** 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. + */ + int take_focus(); + + /** 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) + */ + void set_visible_focus() { flags_ |= VISIBLE_FOCUS; } + + /** Disables keyboard focus navigation with this widget. + Normally, all widgets participate in keyboard focus navigation. + \see set_visible_focus(), visible_focus(), visible_focus(int) + */ + void clear_visible_focus() { flags_ &= ~VISIBLE_FOCUS; } + + /** Modifies keyboard focus navigation. + \param[in] v set or clear 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(); } + + /** Checks whether this widget has a visible focus. + \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; } + + /** Sets the default callback for all widgets. + 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 + \see callback(), do_callback(), Fl::readqueue() + */ + static void default_callback(Fl_Widget *cb, void *d); + + /** Calls the widget callback. + Causes a widget to invoke its callback function with default arguments. + \see callback() + */ + void do_callback() {do_callback(this,user_data_);} + + /** Calls the widget callback. + Causes a widget to invoke its callback function with arbitrary arguments. + \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 + \see callback() + */ + void do_callback(Fl_Widget* o,long arg) {do_callback(o,(void*)arg);} + + // 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); + + /* Internal use only. */ + int test_shortcut(); + /* Internal use only. */ + static unsigned int label_shortcut(const char *t); + /* Internal use only. */ + static int test_shortcut(const char*, const bool require_alt = false); + + /** Checks if w is a child of this widget. + \param[in] w potential child widget + \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. + */ + int contains(const Fl_Widget *w) const ; + + /** Checks if this widget is a child of w. + Returns 1 if this widget is a child of \p w, or is + equal to \p w. Returns 0 if \p w is NULL. + \param[in] w the possible parent widget. + \see contains() + */ + int inside(const Fl_Widget* w) const {return w ? w->contains(this) : 0;} + + /** Schedules the drawing of the widget. + Marks the widget as needing its draw() routine called. + */ + void redraw(); + + /** Schedules the drawing of the label. + 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 + 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) + */ + uchar damage() const {return damage_;} + + /** Clears or sets the damage flags. + Damage flags are cleared when parts of the widget drawing is repaired. + + 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) + \see damage(uchar), damage() + */ + void clear_damage(uchar c = 0) {damage_ = c;} + + /** 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) + */ + void damage(uchar c); + + /** 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) + */ + void damage(uchar c, int x, int y, int w, int h); + + void draw_label(int, int, int, int, Fl_Align) const; + + /** Sets width ww and height hh accordingly with the label size. + Labels with images will return w() and h() of the image. + */ + void measure_label(int& ww, int& hh) const {label_.measure(ww, hh);} + + /** Returns a pointer to the primary Fl_Window widget. + \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. + */ + Fl_Window* window() const ; + + /** Returns an Fl_Group pointer if this widget is an Fl_Group. + + Use this method if you have a widget (pointer) and need to + know whether this widget is derived from Fl_Group. If it returns + 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"); + } + \endcode + + \retval NULL if this widget is not derived from Fl_Group. + \note This method is provided to avoid dynamic_cast. + \see Fl_Widget::as_window(), Fl_Widget::as_gl_window() + */ + virtual Fl_Group* as_group() {return 0;} + + /** Returns an Fl_Window pointer if this widget is an Fl_Window. + + Use this method if you have a widget (pointer) and need to + know whether this widget is derived from Fl_Window. If it returns + non-NULL, then the widget in question is derived from Fl_Window, + and you can use the returned pointer to access its children + or other Fl_Window-specific methods. + + \retval NULL if this widget is not derived from Fl_Window. + \note This method is provided to avoid dynamic_cast. + \see Fl_Widget::as_group(), Fl_Widget::as_gl_window() + */ + virtual Fl_Window* as_window() {return 0;} + + /** Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window. + + Use this method if you have a widget (pointer) and need to + know whether this widget is derived from Fl_Gl_Window. If it returns + non-NULL, then the widget in question is derived from Fl_Gl_Window. + + \retval NULL if this widget is not derived from Fl_Gl_Window. + \note This method is provided to avoid dynamic_cast. + \see Fl_Widget::as_group(), Fl_Widget::as_window() + */ + virtual class Fl_Gl_Window* as_gl_window() {return 0;} + + /** For back compatibility only. + \deprecated Use selection_color() instead. + */ + Fl_Color color2() const {return (Fl_Color)color2_;} + + /** For back compatibility only. + \deprecated Use selection_color(unsigned) instead. + */ + void color2(unsigned a) {color2_ = a;} +}; + +/** + Reserved type numbers (necessary for my cheapo RTTI) start here. + Grep the header files for "RESERVED_TYPE" to find the next available + number. +*/ +#define FL_RESERVED_TYPE 100 + +#endif + +// +// End of "$Id: Fl_Widget.H 8623 2011-04-24 17:09:41Z AlbrechtS $". +// diff --git a/common/fltk/FL/Fl_Window.H b/common/fltk/FL/Fl_Window.H new file mode 100644 index 00000000..8317fb4a --- /dev/null +++ b/common/fltk/FL/Fl_Window.H @@ -0,0 +1,465 @@ +// +// "$Id: Fl_Window.H 8593 2011-04-15 21:38:05Z manolo $" +// +// Window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Window widget . */ + +#ifndef Fl_Window_H +#define Fl_Window_H + +#include "Fl_Group.H" + +#define FL_WINDOW 0xF0 ///< window type id all subclasses have type() >= this +#define FL_DOUBLE_WINDOW 0xF1 ///< double window type id + +class Fl_X; + +/** + This widget produces an actual window. This can either be a main + window, with a border and title and all the window management controls, + or a "subwindow" inside a window. This is controlled by whether or not + the window has a parent(). + + Once you create a window, you usually add children Fl_Widget + 's to it by using window->add(child) for each new widget. + See Fl_Group for more information on how to add and remove children. + + There are several subclasses of Fl_Window that provide + double-buffering, overlay, menu, and OpenGL support. + + The window's callback is done if the user tries to close a window + using the window manager and Fl::modal() is zero or equal to the + window. Fl_Window has a default callback that calls Fl_Window::hide(). +*/ +class FL_EXPORT Fl_Window : public Fl_Group { + + static char *default_xclass_; + + friend class Fl_X; + Fl_X *i; // points at the system-specific stuff + + const char* iconlabel_; + char* xclass_; + const void* icon_; + // size_range stuff: + int minw, minh, maxw, maxh; + int dw, dh, aspect; + uchar size_range_set; + // cursor stuff + Fl_Cursor cursor_default; + Fl_Color cursor_fg, cursor_bg; + void size_range_(); + void _Fl_Window(); // constructor innards + + // unimplemented copy ctor and assignment operator + Fl_Window(const Fl_Window&); + Fl_Window& operator=(const Fl_Window&); + +protected: + + /** Stores the last window that was made current. See current() const */ + static Fl_Window *current_; + virtual void draw(); + /** Forces the window to be drawn, this window is also made current and calls draw(). */ + virtual void flush(); + + /** + Sets an internal flag that tells FLTK and the window manager to + honor position requests. + + This is used internally and should not be needed by user code. + + \param[in] force 1 to set the FORCE_POSITION flag, 0 to clear it + */ + void force_position(int force) { + if (force) set_flag(FORCE_POSITION); + else clear_flag(FORCE_POSITION); + } + /** + Returns the internal state of the window's FORCE_POSITION flag. + + \retval 1 if flag is set + \retval 0 otherwise + + \see force_position(int) + */ + int force_position() const { return ((flags() & FORCE_POSITION)?1:0); } + +public: + + /** + Creates a window from the given size and title. + If Fl_Group::current() is not NULL, the window is created as a + subwindow of the parent window. + + The (w,h) form of the constructor creates a top-level window + and asks the window manager to position the window. The (x,y,w,h) + form of the constructor either creates a subwindow or a + top-level window at the specified location (x,y) , subject to window + manager configuration. If you do not specify the position of the + window, the window manager will pick a place to show the window + or allow the user to pick a location. Use position(x,y) + or hotspot() before calling show() to request a + position on the screen. See Fl_Window::resize() + for some more details on positioning windows. + + Top-level windows initially have visible() set to 0 + and parent() set to NULL. Subwindows initially + have visible() set to 1 and parent() set to + the parent window pointer. + + Fl_Widget::box() defaults to FL_FLAT_BOX. If you plan to + completely fill the window with children widgets you should + change this to FL_NO_BOX. If you turn the window border off + you may want to change this to FL_UP_BOX. + + \see Fl_Window(int x, int y, int w, int h, const char* title) + */ + Fl_Window(int w, int h, const char* title= 0); + /** Creates a window from the given position, size and title. + + \see Fl_Window(int w, int h, const char *title) + */ + Fl_Window(int x, int y, int w, int h, const char* title = 0); + /** + The destructor <I>also deletes all the children</I>. This allows a + whole tree to be deleted at once, without having to keep a pointer to + all the children in the user code. A kludge has been done so the + Fl_Window and all of its children can be automatic (local) + variables, but you must declare the Fl_Window <I>first</I> so + that it is destroyed last. + */ + virtual ~Fl_Window(); + + virtual int handle(int); + + /** + Changes the size and position of the window. If shown() is true, + these changes are communicated to the window server (which may + refuse that size and cause a further resize). If shown() is + false, the size and position are used when show() is called. + See Fl_Group for the effect of resizing on the child widgets. + + You can also call the Fl_Widget methods size(x,y) and position(w,h), + which are inline wrappers for this virtual function. + + A top-level window can not force, but merely suggest a position and + size to the operating system. The window manager may not be willing or + able to display a window at the desired position or with the given + dimensions. It is up to the application developer to verify window + parameters after the resize request. + */ + virtual void resize(int,int,int,int); + /** + Sets whether or not the window manager border is around the + window. The default value is true. void border(int) can be + used to turn the border on and off. <I>Under most X window + managers this does not work after show() has been called, + although SGI's 4DWM does work.</I> + */ + void border(int b); + /** + Fast inline function to turn the window manager border + off. It only works before show() is called. + */ + void clear_border() {set_flag(NOBORDER);} + /** See void Fl_Window::border(int) */ + unsigned int border() const {return !(flags() & NOBORDER);} + /** Activates the flags NOBORDER|FL_OVERRIDE */ + void set_override() {set_flag(NOBORDER|OVERRIDE);} + /** Returns non zero if FL_OVERRIDE flag is set, 0 otherwise. */ + unsigned int override() const { return flags()&OVERRIDE; } + /** + A "modal" window, when shown(), will prevent any events from + being delivered to other windows in the same program, and will also + remain on top of the other windows (if the X window manager supports + the "transient for" property). Several modal windows may be shown at + once, in which case only the last one shown gets events. You can see + which window (if any) is modal by calling Fl::modal(). + */ + void set_modal() {set_flag(MODAL);} + /** Returns true if this window is modal. */ + unsigned int modal() const {return flags() & MODAL;} + /** + A "non-modal" window (terminology borrowed from Microsoft Windows) + acts like a modal() one in that it remains on top, but it has + no effect on event delivery. There are <I>three</I> states for a + window: modal, non-modal, and normal. + */ + void set_non_modal() {set_flag(NON_MODAL);} + /** Returns true if this window is modal or non-modal. */ + unsigned int non_modal() const {return flags() & (NON_MODAL|MODAL);} + + /** + Marks the window as a menu window. + + This is intended for internal use, but it can also be used if you + write your own menu handling. However, this is not recommended. + + This flag is used for correct "parenting" of windows in communication + with the windowing system. Modern X window managers can use different + flags to distinguish menu and tooltip windows from normal windows. + + This must be called before the window is shown and cannot be changed + later. + */ + void set_menu_window() {set_flag(MENU_WINDOW);} + + /** Returns true if this window is a menu window. */ + unsigned int menu_window() const {return flags() & MENU_WINDOW;} + + /** + Marks the window as a tooltip window. + + This is intended for internal use, but it can also be used if you + write your own tooltip handling. However, this is not recommended. + + This flag is used for correct "parenting" of windows in communication + with the windowing system. Modern X window managers can use different + flags to distinguish menu and tooltip windows from normal windows. + + This must be called before the window is shown and cannot be changed + later. + + \note Since Fl_Tooltip_Window is derived from Fl_Menu_Window, this + also \b clears the menu_window() state. + */ + void set_tooltip_window() { set_flag(TOOLTIP_WINDOW); + clear_flag(MENU_WINDOW); } + /** Returns true if this window is a tooltip window. */ + unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;} + + /** + Positions the window so that the mouse is pointing at the given + position, or at the center of the given widget, which may be the + window itself. If the optional offscreen parameter is + non-zero, then the window is allowed to extend off the screen (this + does not work with some X window managers). \see position() + */ + void hotspot(int x, int y, int offscreen = 0); + /** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */ + void hotspot(const Fl_Widget*, int offscreen = 0); + /** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */ + void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);} + + /** + Undoes the effect of a previous resize() or show() so that the next time + show() is called the window manager is free to position the window. + + This is for Forms compatibility only. + + \deprecated please use force_position(0) instead + */ + void free_position() {clear_flag(FORCE_POSITION);} + /** + Sets the allowable range the user can resize this window to. + This only works for top-level windows. + <UL> + <LI>minw and minh are the smallest the window can be. + Either value must be greater than 0.</LI> + <LI>maxw and maxh are the largest the window can be. If either is + <I>equal</I> to the minimum then you cannot resize in that direction. + If either is zero then FLTK picks a maximum size in that direction + such that the window will fill the screen.</LI> + <LI>dw and dh are size increments. The window will be constrained + to widths of minw + N * dw, where N is any non-negative integer. + If these are less or equal to 1 they are ignored (this is ignored + on WIN32).</LI> + <LI>aspect is a flag that indicates that the window should preserve its + aspect ratio. This only works if both the maximum and minimum have + the same aspect ratio (ignored on WIN32 and by many X window managers). + </LI> + </UL> + + If this function is not called, FLTK tries to figure out the range + from the setting of resizable(): + <UL> + <LI>If resizable() is NULL (this is the default) then the window cannot + be resized and the resize border and max-size control will not be + displayed for the window.</LI> + <LI>If either dimension of resizable() is less than 100, then that is + considered the minimum size. Otherwise the resizable() has a minimum + size of 100.</LI> + <LI>If either dimension of resizable() is zero, then that is also the + maximum size (so the window cannot resize in that direction).</LI> + </UL> + + It is undefined what happens if the current size does not fit in the + constraints passed to size_range(). + */ + void size_range(int a, int b, int c=0, int d=0, int e=0, int f=0, int g=0) { + minw=a; minh=b; maxw=c; maxh=d; dw=e; dh=f; aspect=g; size_range_();} + + /** See void Fl_Window::label(const char*) */ + const char* label() const {return Fl_Widget::label();} + /** See void Fl_Window::iconlabel(const char*) */ + const char* iconlabel() const {return iconlabel_;} + /** Sets the window title bar label. */ + void label(const char*); + /** Sets the icon label. */ + void iconlabel(const char*); + /** Sets the icon label. */ + void label(const char* label, const char* iconlabel); // platform dependent + void copy_label(const char* a); + + static void default_xclass(const char*); + static const char *default_xclass(); + const char* xclass() const; + void xclass(const char* c); + const void* icon() const; + void icon(const void * ic); + + /** + Returns non-zero if show() has been called (but not hide() + ). You can tell if a window is iconified with (w->shown() + && !w->visible()). + */ + int shown() {return i != 0;} + /** + Puts the window on the screen. Usually (on X) this has the side + effect of opening the display. + + If the window is already shown then it is restored and raised to the + top. This is really convenient because your program can call show() + at any time, even if the window is already up. It also means that + show() serves the purpose of raise() in other toolkits. + + Fl_Window::show(int argc, char **argv) is used for top-level + windows and allows standard arguments to be parsed from the + command-line. + + \see Fl_Window::show(int argc, char **argv) + */ + virtual void show(); + /** + Removes the window from the screen. If the window is already hidden or + has not been shown then this does nothing and is harmless. + */ + virtual void hide(); + /** + Puts the window on the screen and parses command-line arguments. + + Usually (on X) this has the side effect of opening the display. + + This form should be used for top-level windows, at least for the + first (main) window. It allows standard arguments to be parsed + from the command-line. You can use \p argc and \p argv from + main(int argc, char **argv) for this call. + + The first call also sets up some system-specific internal + variables like the system colors. + + \todo explain which system parameters are set up. + + \param argc command-line argument count, usually from main() + \param argv command-line argument vector, usually from main() + + \see virtual void Fl_Window::show() + */ + void show(int argc, char **argv); + /** + Makes the window completely fill the screen, without any window + manager border visible. You must use fullscreen_off() to undo + this. This may not work with all window managers. + */ + void fullscreen(); + /** + Turns off any side effects of fullscreen() and does + resize(x,y,w,h). + */ + void fullscreen_off(int,int,int,int); + /** + Iconifies the window. If you call this when shown() is false + it will show() it as an icon. If the window is already + iconified this does nothing. + + Call show() to restore the window. + + When a window is iconified/restored (either by these calls or by the + user) the handle() method is called with FL_HIDE and + FL_SHOW events and visible() is turned on and off. + + There is no way to control what is drawn in the icon except with the + string passed to Fl_Window::xclass(). You should not rely on + window managers displaying the icons. + */ + void iconize(); + + int x_root() const ; + int y_root() const ; + + static Fl_Window *current(); + /** + Sets things up so that the drawing functions in <FL/fl_draw.H> will go + into this window. This is useful for incremental update of windows, such + as in an idle callback, which will make your program behave much better + if it draws a slow graphic. <B>Danger: incremental update is very hard to + debug and maintain!</B> + + This method only works for the Fl_Window and Fl_Gl_Window derived classes. + */ + void make_current(); + + // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. + virtual Fl_Window* as_window() { return this; } + + /** + Changes the cursor for this window. This always calls the system, if + you are changing the cursor a lot you may want to keep track of how + you set it in a static variable and call this only if the new cursor + is different. + + The type Fl_Cursor is an enumeration defined in <FL/Enumerations.H>. + (Under X you can get any XC_cursor value by passing + Fl_Cursor((XC_foo/2)+1)). The colors only work on X, they are + not implemented on WIN32. + + For back compatibility only. + */ + void cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); // platform dependent + void default_cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); + static void default_callback(Fl_Window*, void* v); + + /** Returns the window width including any frame added by the window manager. + + Same as w() if applied to a subwindow. + */ + int decorated_w(); + /** Returns the window height including any window title bar and any frame + added by the window manager. + + Same as h() if applied to a subwindow. + */ + int decorated_h(); + +}; + +#endif + +// +// End of "$Id: Fl_Window.H 8593 2011-04-15 21:38:05Z manolo $". +// diff --git a/common/fltk/FL/Fl_Wizard.H b/common/fltk/FL/Fl_Wizard.H new file mode 100644 index 00000000..2dcf3151 --- /dev/null +++ b/common/fltk/FL/Fl_Wizard.H @@ -0,0 +1,70 @@ +// +// "$Id: Fl_Wizard.H 8306 2011-01-24 17:04:22Z matt $" +// +// Fl_Wizard widget definitions. +// +// Copyright 1999-2010 by Easy Software Products. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_Wizard widget . */ + +// +// Include necessary header files... +// + +#ifndef _Fl_Wizard_H_ +# define _Fl_Wizard_H_ + +# include <FL/Fl_Group.H> + + +/** + This widget is based off the Fl_Tabs + widget, but instead of displaying tabs it only changes "tabs" under + program control. Its primary purpose is to support "wizards" that + step a user through configuration or troubleshooting tasks. + + <P>As with Fl_Tabs, wizard panes are composed of child (usually + Fl_Group) widgets. Navigation buttons must be added separately. +*/ +class FL_EXPORT Fl_Wizard : public Fl_Group { + + Fl_Widget *value_; + + void draw(); + + public: + + Fl_Wizard(int, int, int, int, const char * = 0); + + void next(); + void prev(); + Fl_Widget *value(); + void value(Fl_Widget *); +}; + +#endif // !_Fl_Wizard_H_ + +// +// End of "$Id: Fl_Wizard.H 8306 2011-01-24 17:04:22Z matt $". +// diff --git a/common/fltk/FL/Fl_XBM_Image.H b/common/fltk/FL/Fl_XBM_Image.H new file mode 100644 index 00000000..53081ebd --- /dev/null +++ b/common/fltk/FL/Fl_XBM_Image.H @@ -0,0 +1,50 @@ +// +// "$Id: Fl_XBM_Image.H 7903 2010-11-28 21:06:39Z matt $" +// +// XBM image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + Fl_XBM_Image class . */ + +#ifndef Fl_XBM_Image_H +#define Fl_XBM_Image_H +# include "Fl_Bitmap.H" + +/** + The Fl_XBM_Image class supports loading, caching, + and drawing of X Bitmap (XBM) bitmap files. +*/ +class FL_EXPORT Fl_XBM_Image : public Fl_Bitmap { + + public: + + Fl_XBM_Image(const char* filename); +}; + +#endif // !Fl_XBM_Image_H + +// +// End of "$Id: Fl_XBM_Image.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Fl_XPM_Image.H b/common/fltk/FL/Fl_XPM_Image.H new file mode 100644 index 00000000..2f1a18ac --- /dev/null +++ b/common/fltk/FL/Fl_XPM_Image.H @@ -0,0 +1,51 @@ +// +// "$Id: Fl_XPM_Image.H 7903 2010-11-28 21:06:39Z matt $" +// +// XPM image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/* \file + + Fl_XPM_Image class . */ + +#ifndef Fl_XPM_Image_H +#define Fl_XPM_Image_H +# include "Fl_Pixmap.H" + +/** + The Fl_XPM_Image class supports loading, caching, + and drawing of X Pixmap (XPM) images, including transparency. +*/ +class FL_EXPORT Fl_XPM_Image : public Fl_Pixmap { + + public: + + Fl_XPM_Image(const char* filename); +}; + +#endif // !Fl_XPM_Image + +// +// End of "$Id: Fl_XPM_Image.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/Makefile.in b/common/fltk/FL/Makefile.in new file mode 100644 index 00000000..00503e4e --- /dev/null +++ b/common/fltk/FL/Makefile.in @@ -0,0 +1,63 @@ +# +# "$Id: Makefile.in 7913 2010-11-29 18:18:27Z greg.ercolano $" +# +# Header makefile for the Fast Light Tool Kit (FLTK). +# +# Copyright 1998-2010 by Bill Spitzak and others. +# +# 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. +# +# Please report all bugs and problems on the following page: +# +# http://www.fltk.org/str.php +# + +include ../makeinclude + +all: + +clean: + +depend: + +install: + echo "Installing include files in $(DESTDIR)$(includedir)..." + $(RMDIR) $(DESTDIR)$(includedir)/FL + $(INSTALL_DIR) $(DESTDIR)$(includedir)/FL + for file in *.[hH]; do \ + $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/FL; \ + done +@HLINKS@ cd $(DESTDIR)$(includedir)/FL;\ +@HLINKS@ for file in *.H; do\ +@HLINKS@ $(RM) "`basename $$file H`h";\ +@HLINKS@ $(LN) $$file "`basename $$file H`h";\ +@HLINKS@ done +@HLINKS@ $(RM) $(DESTDIR)$(includedir)/FL/fl_file_chooser.H +@HLINKS@ $(LN) Fl_File_Chooser.H $(DESTDIR)$(includedir)/FL/fl_file_chooser.H +@HLINKS@ $(RM) $(DESTDIR)$(includedir)/FL/fl_file_chooser.h +@HLINKS@ $(LN) Fl_File_Chooser.H $(DESTDIR)$(includedir)/FL/fl_file_chooser.h +@HLINKS@ $(RM) $(DESTDIR)$(includedir)/Fl +@HLINKS@ $(LN) FL $(DESTDIR)$(includedir)/Fl + +uninstall: + echo "Uninstalling include files..." + $(RMDIR) $(DESTDIR)$(includedir)/FL +@HLINKS@ $(RM) $(DESTDIR)$(includedir)/Fl + + +# +# End of "$Id: Makefile.in 7913 2010-11-29 18:18:27Z greg.ercolano $". +# diff --git a/common/fltk/FL/README.Xcode b/common/fltk/FL/README.Xcode new file mode 100644 index 00000000..2fa57ad8 --- /dev/null +++ b/common/fltk/FL/README.Xcode @@ -0,0 +1,2 @@ +All FLTK header files are in the FL subdirectory of the fltk.framework. +Image header files are located in "fltk.framework/Headers/FL/images/". diff --git a/common/fltk/FL/Xutf8.h b/common/fltk/FL/Xutf8.h new file mode 100644 index 00000000..b122d2e0 --- /dev/null +++ b/common/fltk/FL/Xutf8.h @@ -0,0 +1,189 @@ +/* "$Id: Xutf8.h 8399 2011-02-07 22:22:16Z ianmacarthur $" + * + * Author: Jean-Marc Lienher ( http://oksid.ch ) + * Copyright 2000-2010 by O'ksi'D. + * + * 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. + * + * Please report all bugs and problems on the following page: + * + * http://www.fltk.org/str.php + */ + +#ifndef _Xutf8_h +#define _Xutf8_h + +# ifdef __cplusplus +extern "C" { +# endif + +#include <X11/X.h> +#include <X11/Xlib.h> +#include <X11/Xlocale.h> +#include <X11/Xutil.h> + +typedef struct { + int nb_font; + char **font_name_list; + int *encodings; + XFontStruct **fonts; + Font fid; + int ascent; + int descent; + int *ranges; +} XUtf8FontStruct; + +XUtf8FontStruct * +XCreateUtf8FontStruct ( + Display *dpy, + const char *base_font_name_list); + +void +XUtf8DrawString( + Display *display, + Drawable d, + XUtf8FontStruct *font_set, + GC gc, + int x, + int y, + const char *string, + int num_bytes); + +void +XUtf8_measure_extents( + Display *display, + Drawable d, + XUtf8FontStruct *font_set, + GC gc, + int *xx, + int *yy, + int *ww, + int *hh, + const char *string, + int num_bytes); + +void +XUtf8DrawRtlString( + Display *display, + Drawable d, + XUtf8FontStruct *font_set, + GC gc, + int x, + int y, + const char *string, + int num_bytes); + +void +XUtf8DrawImageString( + Display *display, + Drawable d, + XUtf8FontStruct *font_set, + GC gc, + int x, + int y, + const char *string, + int num_bytes); + +int +XUtf8TextWidth( + XUtf8FontStruct *font_set, + const char *string, + int num_bytes); +int +XUtf8UcsWidth( + XUtf8FontStruct *font_set, + unsigned int ucs); + +int +XGetUtf8FontAndGlyph( + XUtf8FontStruct *font_set, + unsigned int ucs, + XFontStruct **fnt, + unsigned short *id); + +void +XFreeUtf8FontStruct( + Display *dpy, + XUtf8FontStruct *font_set); + + +int +XConvertUtf8ToUcs( + const unsigned char *buf, + int len, + unsigned int *ucs); + +int +XConvertUcsToUtf8( + unsigned int ucs, + char *buf); + +int +XUtf8CharByteLen( + const unsigned char *buf, + int len); + +int +XCountUtf8Char( + const unsigned char *buf, + int len); + +int +XFastConvertUtf8ToUcs( + const unsigned char *buf, + int len, + unsigned int *ucs); + +long +XKeysymToUcs( + KeySym keysym); + +int +XUtf8LookupString( + XIC ic, + XKeyPressedEvent* event, + char* buffer_return, + int bytes_buffer, + KeySym* keysym, + Status* status_return); + +unsigned short +XUtf8IsNonSpacing( + unsigned int ucs); + +unsigned short +XUtf8IsRightToLeft( + unsigned int ucs); + + +int +XUtf8Tolower( + int ucs); + +int +XUtf8Toupper( + int ucs); + + +# ifdef __cplusplus +} +# endif + +#endif + +/* + * End of "$Id: Xutf8.h 8399 2011-02-07 22:22:16Z ianmacarthur $". + */ diff --git a/common/fltk/FL/dirent.h b/common/fltk/FL/dirent.h new file mode 100644 index 00000000..7b68cd16 --- /dev/null +++ b/common/fltk/FL/dirent.h @@ -0,0 +1,34 @@ +// +// "$Id: dirent.h 8623 2011-04-24 17:09:41Z AlbrechtS $" +// +// Directory header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + + +// this file is for back-compatibility only +#include "filename.H" + +// +// End of "$Id: dirent.h 8623 2011-04-24 17:09:41Z AlbrechtS $". +// diff --git a/common/fltk/FL/filename.H b/common/fltk/FL/filename.H new file mode 100644 index 00000000..3acae578 --- /dev/null +++ b/common/fltk/FL/filename.H @@ -0,0 +1,180 @@ +/* + * "$Id: filename.H 8073 2010-12-20 13:35:43Z ianmacarthur $" + * + * Filename header file for the Fast Light Tool Kit (FLTK). + * + * Copyright 1998-2010 by Bill Spitzak and others. + * + * 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. + * + * Please report all bugs and problems on the following page: + * + * http://www.fltk.org/str.php + */ + +/* Xcode on OS X includes files by recursing down into directories. + * This code catches the cycle and directly includes the required file. + */ +#ifdef fl_dirent_h_cyclic_include +# include "/usr/include/dirent.h" +#endif + +#ifndef FL_FILENAME_H +# define FL_FILENAME_H + +# include "Fl_Export.H" + +/** \addtogroup filenames File names and URI utility functions + File names and URI functions defined in <FL/filename.H> + @{ */ + +# define FL_PATH_MAX 2048 /**< all path buffers should use this length */ +/** Gets the file name from a path. + Similar to basename(3), exceptions shown below. + \code + #include <FL/filename.H> + [..] + const char *out; + out = fl_filename_name("/usr/lib"); // out="lib" + out = fl_filename_name("/usr/"); // out="" (basename(3) returns "usr" instead) + out = fl_filename_name("/usr"); // out="usr" + out = fl_filename_name("/"); // out="" (basename(3) returns "/" instead) + out = fl_filename_name("."); // out="." + out = fl_filename_name(".."); // out=".." + \endcode + \return a pointer to the char after the last slash, or to \p filename if there is none. + */ +FL_EXPORT const char *fl_filename_name(const char * filename); +FL_EXPORT const char *fl_filename_ext(const char *buf); +FL_EXPORT char *fl_filename_setext(char *to, int tolen, const char *ext); +FL_EXPORT int fl_filename_expand(char *to, int tolen, const char *from); +FL_EXPORT int fl_filename_absolute(char *to, int tolen, const char *from); +FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from); +FL_EXPORT int fl_filename_match(const char *name, const char *pattern); +FL_EXPORT int fl_filename_isdir(const char *name); + +# if defined(__cplusplus) && !defined(FL_DOXYGEN) +/* + * Under WIN32, we include filename.H from numericsort.c; this should probably change... + */ + +inline char *fl_filename_setext(char *to, const char *ext) { return fl_filename_setext(to, FL_PATH_MAX, ext); } +inline int fl_filename_expand(char *to, const char *from) { return fl_filename_expand(to, FL_PATH_MAX, from); } +inline int fl_filename_absolute(char *to, const char *from) { return fl_filename_absolute(to, FL_PATH_MAX, from); } +FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from, const char *cwd); +inline int fl_filename_relative(char *to, const char *from) { return fl_filename_relative(to, FL_PATH_MAX, from); } +# endif /* __cplusplus */ + + +# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) + +struct dirent {char d_name[1];}; + +# elif defined(__WATCOMC__) +# include <sys/types.h> +# include <direct.h> + +# else +/* + * WARNING: on some systems (very few nowadays?) <dirent.h> may not exist. + * The correct information is in one of these files: + * + * #include <sys/ndir.h> + * #include <sys/dir.h> + * #include <ndir.h> + * + * plus you must do the following #define: + * + * #define dirent direct + * + * It would be best to create a <dirent.h> file that does this... + */ +# include <sys/types.h> +# define fl_dirent_h_cyclic_include +# include <dirent.h> +# undef fl_dirent_h_cyclic_include +# endif + +# if defined (__cplusplus) +extern "C" { +# endif /* __cplusplus */ + +# if !defined(FL_DOXYGEN) +FL_EXPORT int fl_alphasort(struct dirent **, struct dirent **); +FL_EXPORT int fl_casealphasort(struct dirent **, struct dirent **); +FL_EXPORT int fl_casenumericsort(struct dirent **, struct dirent **); +FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **); +# endif + + typedef int (Fl_File_Sort_F)(struct dirent **, struct dirent **); /**< File sorting function. \see fl_filename_list() */ + +# if defined(__cplusplus) +} + +/* + * Portable "scandir" function. Ugly but necessary... + */ + +FL_EXPORT int fl_filename_list(const char *d, struct dirent ***l, + Fl_File_Sort_F *s = fl_numericsort); +FL_EXPORT void fl_filename_free_list(struct dirent ***l, int n); + +/* + * Generic function to open a Uniform Resource Identifier (URI) using a + * system-defined program (added in FLTK 1.1.8) + */ + +FL_EXPORT int fl_open_uri(const char *uri, char *msg = (char *)0, + int msglen = 0); + +# ifndef FL_DOXYGEN +/* + * _fl_filename_isdir_quick() is a private function that checks for a + * trailing slash and assumes that the passed name is a directory if + * it finds one. This function is used by Fl_File_Browser and + * Fl_File_Chooser to avoid extra stat() calls, but is not supported + * outside of FLTK... + */ +int _fl_filename_isdir_quick(const char *name); +# endif + +# endif /* __cplusplus */ + +/* + * FLTK 1.0.x compatibility definitions... + */ + +# ifdef FLTK_1_0_COMPAT +# define filename_absolute fl_filename_absolute +# define filename_expand fl_filename_expand +# define filename_ext fl_filename_ext +# define filename_isdir fl_filename_isdir +# define filename_list fl_filename_list +# define filename_match fl_filename_match +# define filename_name fl_filename_name +# define filename_relative fl_filename_relative +# define filename_setext fl_filename_setext +# define numericsort fl_numericsort +# endif /* FLTK_1_0_COMPAT */ + + +#endif /* FL_FILENAME_H */ + +/** @} */ + +/* + * End of "$Id: filename.H 8073 2010-12-20 13:35:43Z ianmacarthur $". + */ diff --git a/common/fltk/FL/fl_ask.H b/common/fltk/FL/fl_ask.H new file mode 100644 index 00000000..98e7f396 --- /dev/null +++ b/common/fltk/FL/fl_ask.H @@ -0,0 +1,83 @@ +// +// "$Id: fl_ask.H 8441 2011-02-18 08:52:48Z AlbrechtS $" +// +// Standard dialog header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef fl_ask_H +# define fl_ask_H + +# include "Enumerations.H" + +class Fl_Widget; +/** Different system beeps available. \relatesalso fl_beep(int) */ +enum { + FL_BEEP_DEFAULT = 0, + FL_BEEP_MESSAGE, + FL_BEEP_ERROR, + FL_BEEP_QUESTION, + FL_BEEP_PASSWORD, + FL_BEEP_NOTIFICATION +}; + +# ifdef __GNUC__ +# define __fl_attr(x) __attribute__ (x) +# else +# define __fl_attr(x) +# endif // __GNUC__ + +FL_EXPORT void fl_beep(int type = FL_BEEP_DEFAULT); +FL_EXPORT void fl_message(const char *,...) __fl_attr((__format__ (__printf__, 1, 2))); +FL_EXPORT void fl_alert(const char *,...) __fl_attr((__format__ (__printf__, 1, 2))); +// fl_ask() is deprecated since it uses "Yes" and "No" for the buttons, +// which does not conform to the current FLTK Human Interface Guidelines. +// Use fl_choice() instead with the appropriate verbs instead. +FL_EXPORT int fl_ask(const char *,...) __fl_attr((__format__ (__printf__, 1, 2), __deprecated__)); +FL_EXPORT int fl_choice(const char *q,const char *b0,const char *b1,const char *b2,...) __fl_attr((__format__ (__printf__, 1, 5))); +FL_EXPORT const char *fl_input(const char *label, const char *deflt = 0, ...) __fl_attr((__format__ (__printf__, 1, 3))); +FL_EXPORT const char *fl_password(const char *label, const char *deflt = 0, ...) __fl_attr((__format__ (__printf__, 1, 3))); + +FL_EXPORT Fl_Widget *fl_message_icon(); +extern FL_EXPORT Fl_Font fl_message_font_; +extern FL_EXPORT Fl_Fontsize fl_message_size_; +inline void fl_message_font(Fl_Font f, Fl_Fontsize s) { + fl_message_font_ = f; fl_message_size_ = s;} + +FL_EXPORT void fl_message_hotspot(int enable); +FL_EXPORT int fl_message_hotspot(void); + +FL_EXPORT void fl_message_title(const char *title); +FL_EXPORT void fl_message_title_default(const char *title); + +// pointers you can use to change FLTK to a foreign language: +extern FL_EXPORT const char* fl_no; +extern FL_EXPORT const char* fl_yes; +extern FL_EXPORT const char* fl_ok; +extern FL_EXPORT const char* fl_cancel; +extern FL_EXPORT const char* fl_close; +#endif // !fl_ask_H + +// +// End of "$Id: fl_ask.H 8441 2011-02-18 08:52:48Z AlbrechtS $". +// diff --git a/common/fltk/FL/fl_draw.H b/common/fltk/FL/fl_draw.H new file mode 100644 index 00000000..93c0ce1a --- /dev/null +++ b/common/fltk/FL/fl_draw.H @@ -0,0 +1,784 @@ +// +// "$Id: fl_draw.H 8772 2011-06-02 08:06:09Z manolo $" +// +// Portable drawing function header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** + \file fl_draw.H + \brief utility header to pull drawing functions together +*/ + +#ifndef fl_draw_H +#define fl_draw_H + +#include <FL/x.H> // for Fl_Region +#include <FL/Enumerations.H> // for the color names +#include <FL/Fl_Window.H> // for fl_set_spot() +#include <FL/Fl_Device.H> // for fl_graphics_driver + +// Image class... +class Fl_Image; + +// Label flags... +FL_EXPORT extern char fl_draw_shortcut; + +/** \addtogroup fl_attributes + @{ +*/ + +// Colors: +/** + Sets the color for all subsequent drawing operations. + For colormapped displays, a color cell will be allocated out of + \p fl_colormap the first time you use a color. If the colormap fills up + then a least-squares algorithm is used to find the closest color. + If no valid graphical context (fl_gc) is available, + the foreground is not set for the current window. + \param[in] c color + */ +inline void fl_color(Fl_Color c) {fl_graphics_driver->color(c); } // select indexed color +/** for back compatibility - use fl_color(Fl_Color c) instead */ +inline void fl_color(int c) {fl_color((Fl_Color)c);} +/** + Sets the color for all subsequent drawing operations. + The closest possible match to the RGB color is used. + The RGB color is used directly on TrueColor displays. + For colormap visuals the nearest index in the gray + ramp or color cube is used. + If no valid graphical context (fl_gc) is available, + the foreground is not set for the current window. + \param[in] r,g,b color components + */ +inline void fl_color(uchar r, uchar g, uchar b) {fl_graphics_driver->color(r,g,b); } // select actual color +/** + Returns the last fl_color() that was set. + This can be used for state save/restore. +*/ +inline Fl_Color fl_color() {return fl_graphics_driver->color();} +/** @} */ + +/** \addtogroup fl_drawings + @{ +*/ +// clip: +/** + Intersects the current clip region with a rectangle and pushes this + new region onto the stack. + \param[in] x,y,w,h position and size + */ +inline void fl_push_clip(int x, int y, int w, int h) {fl_graphics_driver->push_clip(x,y,w,h); } +/** + Intersects the current clip region with a rectangle and pushes this + new region onto the stack (deprecated). + \param[in] x,y,w,h position and size + \deprecated + fl_clip(int, int, int, int) is deprecated and will be removed from future releases. + Please use fl_push_clip(int x, int y, int w, int h) instead. + */ +#define fl_clip fl_push_clip +/** + Pushes an empty clip region onto the stack so nothing will be clipped. + */ +inline void fl_push_no_clip() {fl_graphics_driver->push_no_clip(); } +/** + Restores the previous clip region. + + You must call fl_pop_clip() once for every time you call fl_push_clip(). + Unpredictable results may occur if the clip stack is not empty when + you return to FLTK. + */ +inline void fl_pop_clip() {fl_graphics_driver->pop_clip(); } +/** + Does the rectangle intersect the current clip region? + \param[in] x,y,w,h position and size of rectangle + \returns non-zero if any of the rectangle intersects the current clip + region. If this returns 0 you don't have to draw the object. + + \note + Under X this returns 2 if the rectangle is partially clipped, + and 1 if it is entirely inside the clip region. + */ +inline int fl_not_clipped(int x, int y, int w, int h) {return fl_graphics_driver->not_clipped(x,y,w,h); } +/** + Intersects the rectangle with the current clip region and returns the + bounding box of the result. + + Returns non-zero if the resulting rectangle is different to the original. + This can be used to limit the necessary drawing to a rectangle. + \p W and \p H are set to zero if the rectangle is completely outside the region. + \param[in] x,y,w,h position and size of rectangle + \param[out] X,Y,W,H position and size of resulting bounding box. + \returns Non-zero if the resulting rectangle is different to the original. + */ +inline int fl_clip_box(int x , int y, int w, int h, int& X, int& Y, int& W, int& H) + {return fl_graphics_driver->clip_box(x,y,w,h,X,Y,W,H); } +/** Undoes any clobbering of clip done by your program */ +inline void fl_restore_clip() { fl_graphics_driver->restore_clip(); } +/** + Replaces the top of the clipping stack with a clipping region of any shape. + + Fl_Region is an operating system specific type. + \param[in] r clipping region + */ +inline void fl_clip_region(Fl_Region r) { fl_graphics_driver->clip_region(r); } +/** + Returns the current clipping region. + */ +inline Fl_Region fl_clip_region() { return fl_graphics_driver->clip_region(); } + + +// points: +/** + Draws a single pixel at the given coordinates + */ +inline void fl_point(int x, int y) { fl_graphics_driver->point(x,y); } + +// line type: +/** + Sets how to draw lines (the "pen"). + If you change this it is your responsibility to set it back to the default + using \c fl_line_style(0). + + \param[in] style A bitmask which is a bitwise-OR of a line style, a cap + style, and a join style. If you don't specify a dash type you + will get a solid line. If you don't specify a cap or join type + you will get a system-defined default of whatever value is + fastest. + \param[in] width The thickness of the lines in pixels. Zero results in the + system defined default, which on both X and Windows is somewhat + different and nicer than 1. + \param[in] dashes A pointer to an array of dash lengths, measured in pixels. + The first location is how long to draw a solid portion, the next + is how long to draw the gap, then the solid, etc. It is terminated + with a zero-length entry. A \c NULL pointer or a zero-length + array results in a solid line. Odd array sizes are not supported + and result in undefined behavior. + + \note Because of how line styles are implemented on Win32 systems, + you \e must set the line style \e after setting the drawing + color. If you set the color after the line style you will lose + the line style settings. + \note The \p dashes array does not work under Windows 95, 98 or Me, + since those operating systems do not support complex line styles. + */ +inline void fl_line_style(int style, int width=0, char* dashes=0) {fl_graphics_driver->line_style(style,width,dashes); } +enum { + FL_SOLID = 0, ///< line style: <tt>___________</tt> + FL_DASH = 1, ///< line style: <tt>_ _ _ _ _ _</tt> + FL_DOT = 2, ///< line style: <tt>. . . . . .</tt> + FL_DASHDOT = 3, ///< line style: <tt>_ . _ . _ .</tt> + FL_DASHDOTDOT = 4, ///< line style: <tt>_ . . _ . .</tt> + + FL_CAP_FLAT = 0x100, ///< cap style: end is flat + FL_CAP_ROUND = 0x200, ///< cap style: end is round + FL_CAP_SQUARE = 0x300, ///< cap style: end wraps end point + + FL_JOIN_MITER = 0x1000, ///< join style: line join extends to a point + FL_JOIN_ROUND = 0x2000, ///< join style: line join is rounded + FL_JOIN_BEVEL = 0x3000 ///< join style: line join is tidied +}; + +// rectangles tweaked to exactly fill the pixel rectangle: + +/** + Draws a 1-pixel border \e inside the given bounding box. + This function is meant for quick drawing of simple boxes. The behavior is + undefined for line widths that are not 1. + */ +inline void fl_rect(int x, int y, int w, int h) { fl_graphics_driver->rect(x,y,w,h); } + +/** Draws with passed color a 1-pixel border \e inside the given bounding box */ +inline void fl_rect(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_rect(x,y,w,h);} +/** Colors with current color a rectangle that exactly fills the given bounding box */ +inline void fl_rectf(int x, int y, int w, int h) { fl_graphics_driver->rectf(x,y,w,h); } +/** Colors with passed color a rectangle that exactly fills the given bounding box */ +inline void fl_rectf(int x, int y, int w, int h, Fl_Color c) {fl_color(c); fl_rectf(x,y,w,h);} + +/** + Colors a rectangle with "exactly" the passed <tt>r,g,b</tt> color. + On screens with less than 24 bits of color this is done by drawing a + solid-colored block using fl_draw_image() so that the correct color + shade is produced. + */ +/* note: doxygen comment here to avoid triplication in os-speciic files */ +FL_EXPORT void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b); + +// line segments: +/** + Draws a line from (x,y) to (x1,y1) + */ +inline void fl_line(int x, int y, int x1, int y1) {fl_graphics_driver->line(x,y,x1,y1); } +/** + Draws a line from (x,y) to (x1,y1) and another from (x1,y1) to (x2,y2) + */ +inline void fl_line(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->line(x,y,x1,y1,x2,y2); } + +// closed line segments: +/** + Outlines a 3-sided polygon with lines + */ +inline void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->loop(x,y,x1,y1,x2,y2); } +/** + Outlines a 4-sided polygon with lines + */ +inline void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) + {fl_graphics_driver->loop(x,y,x1,y1,x2,y2,x3,y3); } + +// filled polygons +/** + Fills a 3-sided polygon. The polygon must be convex. + */ +inline void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {fl_graphics_driver->polygon(x,y,x1,y1,x2,y2); } +/** + Fills a 4-sided polygon. The polygon must be convex. + */ +inline void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) + { fl_graphics_driver->polygon(x,y,x1,y1,x2,y2,x3,y3); } + +// draw rectilinear lines, horizontal segment first: +/** + Draws a horizontal line from (x,y) to (x1,y) + */ +inline void fl_xyline(int x, int y, int x1) {fl_graphics_driver->xyline(x,y,x1);} +/** + Draws a horizontal line from (x,y) to (x1,y), then vertical from (x1,y) to (x1,y2) + */ +inline void fl_xyline(int x, int y, int x1, int y2) {fl_graphics_driver->xyline(x,y,x1,y2);} +/** + Draws a horizontal line from (x,y) to (x1,y), then a vertical from (x1,y) to (x1,y2) + and then another horizontal from (x1,y2) to (x3,y2) + */ +inline void fl_xyline(int x, int y, int x1, int y2, int x3) {fl_graphics_driver->xyline(x,y,x1,y2,x3);} + +// draw rectilinear lines, vertical segment first: +/** + Draws a vertical line from (x,y) to (x,y1) + */ +inline void fl_yxline(int x, int y, int y1) {fl_graphics_driver->yxline(x,y,y1);} +/** + Draws a vertical line from (x,y) to (x,y1), then a horizontal from (x,y1) to (x2,y1) + */ +inline void fl_yxline(int x, int y, int y1, int x2) {fl_graphics_driver->yxline(x,y,y1,x2);} +/** + Draws a vertical line from (x,y) to (x,y1) then a horizontal from (x,y1) + to (x2,y1), then another vertical from (x2,y1) to (x2,y3) + */ +inline void fl_yxline(int x, int y, int y1, int x2, int y3) {fl_graphics_driver->yxline(x,y,y1,x2,y3);} + +// circular lines and pie slices (code in fl_arci.C): +/** + Draw ellipse sections using integer coordinates. + + These functions match the rather limited circle drawing code provided by X + and WIN32. The advantage over using fl_arc with floating point coordinates + is that they are faster because they often use the hardware, and they draw + much nicer small circles, since the small sizes are often hard-coded bitmaps. + + If a complete circle is drawn it will fit inside the passed bounding box. + The two angles are measured in degrees counter-clockwise from 3 o'clock and + are the starting and ending angle of the arc, \p a2 must be greater or equal + to \p a1. + + fl_arc() draws a series of lines to approximate the arc. Notice that the + integer version of fl_arc() has a different number of arguments than the + double version fl_arc(double x, double y, double r, double start, double end) + + \param[in] x,y,w,h bounding box of complete circle + \param[in] a1,a2 start and end angles of arc measured in degrees + counter-clockwise from 3 o'clock. \p a2 must be greater + than or equal to \p a1. + */ +inline void fl_arc(int x, int y, int w, int h, double a1, double a2) {fl_graphics_driver->arc(x,y,w,h,a1,a2); } +/** + Draw filled ellipse sections using integer coordinates. + + Like fl_arc(), but fl_pie() draws a filled-in pie slice. + This slice may extend outside the line drawn by fl_arc(); + to avoid this use w - 1 and h - 1. + + \param[in] x,y,w,h bounding box of complete circle + \param[in] a1,a2 start and end angles of arc measured in degrees + counter-clockwise from 3 o'clock. \p a2 must be greater + than or equal to \p a1. + */ +inline void fl_pie(int x, int y, int w, int h, double a1, double a2) {fl_graphics_driver->pie(x,y,w,h,a1,a2); } +/** fl_chord declaration is a place holder - the function does not yet exist */ +FL_EXPORT void fl_chord(int x, int y, int w, int h, double a1, double a2); // nyi + +// scalable drawing code (code in fl_vertex.C and fl_arc.C): +/** + Saves the current transformation matrix on the stack. + The maximum depth of the stack is 32. + */ +inline void fl_push_matrix() { fl_graphics_driver->push_matrix(); } +/** + Restores the current transformation matrix from the stack. + */ +inline void fl_pop_matrix() { fl_graphics_driver->pop_matrix(); } +/** + Concatenates scaling transformation onto the current one. + \param[in] x,y scale factors in x-direction and y-direction + */ +inline void fl_scale(double x, double y) { fl_graphics_driver->scale(x, y); } +/** + Concatenates scaling transformation onto the current one. + \param[in] x scale factor in both x-direction and y-direction + */ +inline void fl_scale(double x) { fl_graphics_driver->scale(x, x); } +/** + Concatenates translation transformation onto the current one. + \param[in] x,y translation factor in x-direction and y-direction + */ +inline void fl_translate(double x, double y) { fl_graphics_driver->translate(x, y); } +/** + Concatenates rotation transformation onto the current one. + \param[in] d - rotation angle, counter-clockwise in degrees (not radians) + */ +inline void fl_rotate(double d) { fl_graphics_driver->rotate(d); } +/** + Concatenates another transformation onto the current one. + + \param[in] a,b,c,d,x,y transformation matrix elements such that + <tt> X' = aX + cY + x </tt> and <tt> Y' = bX +dY + y </tt> + */ +inline void fl_mult_matrix(double a, double b, double c, double d, double x,double y) + { fl_graphics_driver->mult_matrix(a, b, c, d, x, y); } +/** + Starts drawing a list of points. Points are added to the list with fl_vertex() + */ +inline void fl_begin_points() {fl_graphics_driver->begin_points(); } +/** + Starts drawing a list of lines. + */ +inline void fl_begin_line() {fl_graphics_driver->begin_line(); } +/** + Starts drawing a closed sequence of lines. + */ +inline void fl_begin_loop() {fl_graphics_driver->begin_loop(); } +/** + Starts drawing a convex filled polygon. + */ +inline void fl_begin_polygon() {fl_graphics_driver->begin_polygon(); } +/** + Adds a single vertex to the current path. + \param[in] x,y coordinate + */ +inline void fl_vertex(double x, double y) {fl_graphics_driver->vertex(x,y); } +/** + Adds a series of points on a Bezier curve to the path. + The curve ends (and two of the points) are at X0,Y0 and X3,Y3. + \param[in] X0,Y0 curve start point + \param[in] X1,Y1 curve control point + \param[in] X2,Y2 curve control point + \param[in] X3,Y3 curve end point + */ +inline void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3) + {fl_graphics_driver->curve(X0,Y0,X1,Y1,X2,Y2,X3,Y3); } +/** + Adds a series of points to the current path on the arc of a circle. + You can get elliptical paths by using scale and rotate before calling fl_arc(). + \param[in] x,y,r center and radius of circular arc + \param[in] start,end angles of start and end of arc measured in degrees + counter-clockwise from 3 o'clock. If \p end is less than \p start + then it draws the arc in a clockwise direction. + */ +inline void fl_arc(double x, double y, double r, double start, double end) {fl_graphics_driver->arc(x,y,r,start,end); } +/** + fl_circle() is equivalent to fl_arc(x,y,r,0,360), but may be faster. + + It must be the \e only thing in the path: if you want a circle as part of + a complex polygon you must use fl_arc() + \param[in] x,y,r center and radius of circle + */ +inline void fl_circle(double x, double y, double r) {fl_graphics_driver->circle(x,y,r); } +/** + Ends list of points, and draws. + */ +inline void fl_end_points() {fl_graphics_driver->end_points(); } +/** + Ends list of lines, and draws. + */ +inline void fl_end_line() {fl_graphics_driver->end_line(); } +/** + Ends closed sequence of lines, and draws. + */ +inline void fl_end_loop() {fl_graphics_driver->end_loop(); } +/** + Ends convex filled polygon, and draws. + */ +inline void fl_end_polygon() {fl_graphics_driver->end_polygon(); } +/** + Starts drawing a complex filled polygon. + + The polygon may be concave, may have holes in it, or may be several + disconnected pieces. Call fl_gap() to separate loops of the path. + + To outline the polygon, use fl_begin_loop() and replace each fl_gap() + with fl_end_loop();fl_begin_loop() pairs. + + \note + For portability, you should only draw polygons that appear the same + whether "even/odd" or "non-zero" winding rules are used to fill them. + Holes should be drawn in the opposite direction to the outside loop. + */ +inline void fl_begin_complex_polygon() {fl_graphics_driver->begin_complex_polygon(); } +/** + Call fl_gap() to separate loops of the path. + + It is unnecessary but harmless to call fl_gap() before the first vertex, + after the last vertex, or several times in a row. + */ +inline void fl_gap() {fl_graphics_driver->gap(); } +/** + Ends complex filled polygon, and draws. + */ +inline void fl_end_complex_polygon() {fl_graphics_driver->end_complex_polygon(); } +// get and use transformed positions: +/** + Transforms coordinate using the current transformation matrix. + \param[in] x,y coordinate + */ +inline double fl_transform_x(double x, double y) {return fl_graphics_driver->transform_x(x, y); } +/** + Transforms coordinate using the current transformation matrix. + \param[in] x,y coordinate + */ +inline double fl_transform_y(double x, double y) {return fl_graphics_driver->transform_y(x, y); } +/** + Transforms distance using current transformation matrix. + \param[in] x,y coordinate + */ +inline double fl_transform_dx(double x, double y) {return fl_graphics_driver->transform_dx(x, y); } +/** + Transforms distance using current transformation matrix. + \param[in] x,y coordinate + */ +inline double fl_transform_dy(double x, double y) {return fl_graphics_driver->transform_dy(x, y); } +/** + Adds coordinate pair to the vertex list without further transformations. + \param[in] xf,yf transformed coordinate + */ +inline void fl_transformed_vertex(double xf, double yf) {fl_graphics_driver->transformed_vertex(xf,yf); } +/** @} */ + +/** \addtogroup fl_attributes + @{ */ +/* NOTE: doxygen comments here to avoid triplication in os-specific sources */ + +// Fonts: +/** + Sets the current font, which is then used in various drawing routines. + You may call this outside a draw context if necessary to call fl_width(), + but on X this will open the display. + + The font is identified by a \p face and a \p size. + The size of the font is measured in pixels and not "points". + Lines should be spaced \p size pixels apart or more. +*/ +inline void fl_font(Fl_Font face, Fl_Fontsize size) { fl_graphics_driver->font(face,size); } + +/** + Returns the \p face set by the most recent call to fl_font(). + This can be used to save/restore the font. +*/ +inline Fl_Font fl_font() {return fl_graphics_driver->font();} +/** + Returns the \p size set by the most recent call to fl_font(). + This can be used to save/restore the font. +*/ +inline Fl_Fontsize fl_size() {return fl_graphics_driver->size();} + +// information you can get about the current font: +/** + Returns the recommended minimum line spacing for the current font. + You can also use the value of \p size passed to fl_font() +*/ +inline int fl_height() {return fl_graphics_driver->height();} +FL_EXPORT int fl_height(int font, int size); +/** + Returns the recommended distance above the bottom of a fl_height() tall box to + draw the text at so it looks centered vertically in that box. +*/ +inline int fl_descent() {return fl_graphics_driver->descent();} +/** Returns the typographical width of a nul-terminated string */ +FL_EXPORT double fl_width(const char* txt); +/** Returns the typographical width of a sequence of \p n characters */ +inline double fl_width(const char* txt, int n) {return fl_graphics_driver->width(txt, n);} +/** Returns the typographical width of a single character. + \note if a valid fl_gc is NOT found then it uses the first window gc, + or the screen gc if no fltk window is available when called. */ +inline double fl_width(unsigned int c) {return fl_graphics_driver->width(c);} +/** Determines the minimum pixel dimensions of a nul-terminated string. + + Usage: given a string "txt" drawn using fl_draw(txt, x, y) you would determine + its pixel extents on the display using fl_text_extents(txt, dx, dy, wo, ho) + such that a bounding box that exactly fits around the text could be drawn with + fl_rect(x+dx, y+dy, wo, ho). Note the dx, dy values hold the offset of the first + "colored in" pixel of the string, from the draw origin. +*/ +FL_EXPORT void fl_text_extents(const char*, int& dx, int& dy, int& w, int& h); // NO fltk symbol expansion will be performed +/** Determines the minimum pixel dimensions of a sequence of \p n characters. +\see fl_text_extents(const char*, int& dx, int& dy, int& w, int& h) +*/ +inline void fl_text_extents(const char *t, int n, int& dx, int& dy, int& w, int& h) + {fl_graphics_driver->text_extents(t, n, dx, dy, w, h);} + +// font encoding: +// Note: doxygen comments here to avoid duplication for os-sepecific cases +/** + Converts text from Windows/X11 latin1 character set to local encoding. + \param[in] t character string (latin1 encoding) + \param[in] n optional number of characters to convert (default is all) + \returns pointer to internal buffer containing converted characters + */ +FL_EXPORT const char *fl_latin1_to_local(const char *t, int n=-1); +/** + Converts text from local encoding to Windowx/X11 latin1 character set. + \param[in] t character string (local encoding) + \param[in] n optional number of characters to convert (default is all) + \returns pointer to internal buffer containing converted characters + */ +FL_EXPORT const char *fl_local_to_latin1(const char *t, int n=-1); +/** + Converts text from Mac Roman character set to local encoding. + \param[in] t character string (Mac Roman encoding) + \param[in] n optional number of characters to convert (default is all) + \returns pointer to internal buffer containing converted characters + */ +FL_EXPORT const char *fl_mac_roman_to_local(const char *t, int n=-1); +/** + Converts text from local encoding to Mac Roman character set. + \param[in] t character string (local encoding) + \param[in] n optional number of characters to convert (default is all) + \returns pointer to internal buffer containing converted characters + */ +FL_EXPORT const char *fl_local_to_mac_roman(const char *t, int n=-1); +/** @} */ + +/** \addtogroup fl_drawings + @{ */ +/** + Draws a nul-terminated string starting at the given location. + + Text is aligned to the left and to the baseline of the font. + To align to the bottom, subtract fl_descent() from \p y. + To align to the top, subtract fl_descent() and add fl_height(). + This version of fl_draw provides direct access to the text drawing + function of the underlying OS. It does not apply any special handling + to control characters. +*/ +FL_EXPORT void fl_draw(const char* str, int x, int y); +/** + Draws a nul-terminated string starting at the given location and + rotating \p angle degrees counter-clockwise. + This version of fl_draw provides direct access to the text drawing + function of the underlying OS and is supported by Xft, Win32 and MacOS + fltk subsets. +*/ +FL_EXPORT void fl_draw(int angle, const char* str, int x, int y); +/** + Draws an array of \p n characters starting at the given location. +*/ +inline void fl_draw(const char* str, int n, int x, int y) {fl_graphics_driver->draw(str,n,x,y); } +/** + Draws an array of \p n characters starting at the given location, + rotating \p angle degrees counter-clockwise. +*/ +inline void fl_draw(int angle,const char* str, int n, int x, int y) {fl_graphics_driver->draw(angle,str,n,x,y); } +/** + Draws an array of \p n characters right to left starting at given location. +*/ +inline void fl_rtl_draw(const char* str, int n, int x, int y) {fl_graphics_driver->rtl_draw(str,n,x,y); } +FL_EXPORT void fl_measure(const char* str, int& x, int& y, + int draw_symbols = 1); +FL_EXPORT void fl_draw(const char* str, int x, int y, int w, int h, + Fl_Align align, + Fl_Image* img=0, int draw_symbols = 1); +FL_EXPORT void fl_draw(const char* str, int x, int y, int w, int h, + Fl_Align align, + void (*callthis)(const char *,int,int,int), + Fl_Image* img=0, int draw_symbols = 1); + +// boxtypes: +FL_EXPORT void fl_frame(const char* s, int x, int y, int w, int h); +FL_EXPORT void fl_frame2(const char* s, int x, int y, int w, int h); +FL_EXPORT void fl_draw_box(Fl_Boxtype, int x, int y, int w, int h, Fl_Color); + +// images: + +/** + Draws an 8-bit per color RGB or luminance image. + \param[in] buf points at the "r" data of the top-left pixel. + Color data must be in <tt>r,g,b</tt> order. + Luminance data is only one <tt>gray</tt> byte. + \param[in] X,Y position where to put top-left corner of image + \param[in] W,H size of the image + \param[in] D delta to add to the pointer between pixels. It may be + any value greater than or equal to 1, or it can be + negative to flip the image horizontally + \param[in] L delta to add to the pointer between lines (if 0 is + passed it uses \p W * \p D), and may be larger than + \p W * \p D to crop data, or negative to flip the + image vertically + + It is highly recommended that you put the following code before the + first <tt>show()</tt> of \e any window in your program to get rid of + the dithering if possible: + \code + Fl::visual(FL_RGB); + \endcode + + Gray scale (1-channel) images may be drawn. This is done if + <tt>abs(D)</tt> is less than 3, or by calling fl_draw_image_mono(). + Only one 8-bit sample is used for each pixel, and on screens with + different numbers of bits for red, green, and blue only gray colors + are used. Setting \p D greater than 1 will let you display one channel + of a color image. + + \par Note: + The X version does not support all possible visuals. If FLTK cannot + draw the image in the current visual it will abort. FLTK supports + any visual of 8 bits or less, and all common TrueColor visuals up + to 32 bits. + */ +inline void fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) + { fl_graphics_driver->draw_image(buf, X, Y, W, H, D, L); } + +/** + Draws a gray-scale (1 channel) image. + \see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L) + */ +inline void fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) + { fl_graphics_driver->draw_image_mono(buf, X, Y, W, H, D, L); } + +/** + Draws an image using a callback function to generate image data. + + You can generate the image as it is being drawn, or do arbitrary + decompression of stored data, provided it can be decompressed to + individual scan lines easily. + \param[in] cb callback function to generate scan line data + \param[in] data user data passed to callback function + \param[in] X,Y screen position of top left pixel + \param[in] W,H image width and height + \param[in] D data size in bytes (must be greater than 0) + \see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L) + + The callback function \p cb is called with the <tt>void*</tt> \p data + user data pointer to allow access to a structure of information about + the image, and the \p x, \p y, and \p w of the scan line desired from + the image. 0,0 is the upper-left corner of the image, not \p x, \p y. + A pointer to a buffer to put the data into is passed. You must copy + \p w pixels from scanline \p y, starting at pixel \p x, to this buffer. + + Due to cropping, less than the whole image may be requested. So \p x + may be greater than zero, the first \p y may be greater than zero, + and \p w may be less than \p W. The buffer is long enough to store + the entire \p W * \p D pixels, this is for convenience with some + decompression schemes where you must decompress the entire line at + once: decompress it into the buffer, and then if \p x is not zero, + copy the data over so the \p x'th pixel is at the start of the buffer. + + You can assume the \p y's will be consecutive, except the first one + may be greater than zero. + + If \p D is 4 or more, you must fill in the unused bytes with zero. + */ +inline void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) + { fl_graphics_driver->draw_image(cb, data, X, Y, W, H, D); } + +/** + Draws a gray-scale image using a callback function to generate image data. + \see fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D) + */ +FL_EXPORT void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); + +/** + Checks whether platform supports true alpha blending for RGBA images. + \returns 1 if true alpha blending supported by platform + \returns 0 not supported so FLTK will use screen door transparency + */ +/* note: doxygen comment here to avoid triplication in os-speciic files */ +FL_EXPORT char fl_can_do_alpha_blending(); + +/** + Reads an RGB(A) image from the current window or off-screen buffer. + \param[in] p pixel buffer, or NULL to allocate one + \param[in] X,Y position of top-left of image to read + \param[in] W,H width and height of image to read + \param[in] alpha alpha value for image (0 for none) + \returns pointer to pixel buffer, or NULL if allocation failed. + + The \p p argument points to a buffer that can hold the image and must + be at least \p W*H*3 bytes when reading RGB images, or \p W*H*4 bytes + when reading RGBA images. If NULL, fl_read_image() will create an + array of the proper size which can be freed using <tt>delete[]</tt>. + + The \p alpha parameter controls whether an alpha channel is created + and the value that is placed in the alpha channel. If 0, no alpha + channel is generated. + */ +/* note: doxygen comment here to avoid triplication in os-speciic files */ +FL_EXPORT uchar *fl_read_image(uchar *p,int X,int Y,int W,int H,int alpha=0); + +// pixmaps: +FL_EXPORT int fl_draw_pixmap(/*const*/ char* const* data, int x,int y,Fl_Color=FL_GRAY); +FL_EXPORT int fl_draw_pixmap(const char* const* cdata, int x,int y,Fl_Color=FL_GRAY); +FL_EXPORT int fl_measure_pixmap(/*const*/ char* const* data, int &w, int &h); +FL_EXPORT int fl_measure_pixmap(const char* const* cdata, int &w, int &h); + +// other: +FL_EXPORT void fl_scroll(int X, int Y, int W, int H, int dx, int dy, + void (*draw_area)(void*, int,int,int,int), void* data); +FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut); +FL_EXPORT const char* fl_shortcut_label(unsigned int shortcut, const char **eom); +FL_EXPORT unsigned int fl_old_shortcut(const char* s); +FL_EXPORT void fl_overlay_rect(int x,int y,int w,int h); +FL_EXPORT void fl_overlay_clear(); +FL_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg=FL_BLACK, Fl_Color bg=FL_WHITE); +FL_EXPORT const char* fl_expand_text(const char* from, char* buf, int maxbuf, + double maxw, int& n, double &width, + int wrap, int draw_symbols = 0); + +// XIM: +/** \todo provide user documentation for fl_set_status function */ +FL_EXPORT void fl_set_status(int X, int Y, int W, int H); +/** \todo provide user documentation for fl_set_spot function */ +FL_EXPORT void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win=0); +/** \todo provide user documentation for fl_reset_spot function*/ +FL_EXPORT void fl_reset_spot(void); + + + +// XForms symbols: +FL_EXPORT int fl_draw_symbol(const char* label,int x,int y,int w,int h, Fl_Color); +FL_EXPORT int fl_add_symbol(const char* name, void (*drawit)(Fl_Color), int scalable); +/** @} */ + +#endif + +// +// End of "$Id: fl_draw.H 8772 2011-06-02 08:06:09Z manolo $". +// diff --git a/common/fltk/FL/fl_message.H b/common/fltk/FL/fl_message.H new file mode 100644 index 00000000..d07949e9 --- /dev/null +++ b/common/fltk/FL/fl_message.H @@ -0,0 +1,32 @@ +// +// "$Id: fl_message.H 7903 2010-11-28 21:06:39Z matt $" +// +// Standard message header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#include "fl_ask.H" + +// +// End of "$Id: fl_message.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/fl_show_colormap.H b/common/fltk/FL/fl_show_colormap.H new file mode 100644 index 00000000..762a3b4c --- /dev/null +++ b/common/fltk/FL/fl_show_colormap.H @@ -0,0 +1,58 @@ +// +// "$Id: fl_show_colormap.H 8621 2011-04-23 15:46:30Z AlbrechtS $" +// +// Colormap picker header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file + The fl_show_colormap() function hides the implementation classes used + to provide the popup window and color selection mechanism. +*/ + +#ifndef fl_show_colormap_H +#define fl_show_colormap_H + +/* doxygen comment here to avoid exposing ColorMenu in fl_show_colormap.cxx +*/ + +/** \addtogroup fl_attributes + @{ */ + +/** + \brief Pops up a window to let the user pick a colormap entry. + \image html fl_show_colormap.png + \image latex fl_show_colormap.png "fl_show_colormap" height=10cm + \param[in] oldcol color to be highlighted when grid is shown. + \retval Fl_Color value of the chosen colormap entry. + \see Fl_Color_Chooser +*/ +FL_EXPORT Fl_Color fl_show_colormap(Fl_Color oldcol); + +/** @} */ + +#endif + +// +// End of "$Id: fl_show_colormap.H 8621 2011-04-23 15:46:30Z AlbrechtS $". +// diff --git a/common/fltk/FL/fl_show_input.H b/common/fltk/FL/fl_show_input.H new file mode 100644 index 00000000..2d931a41 --- /dev/null +++ b/common/fltk/FL/fl_show_input.H @@ -0,0 +1,32 @@ +// +// "$Id: fl_show_input.H 7903 2010-11-28 21:06:39Z matt $" +// +// Standard input dialog header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#include "fl_ask.H" + +// +// End of "$Id: fl_show_input.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/fl_types.h b/common/fltk/FL/fl_types.h new file mode 100644 index 00000000..c019821a --- /dev/null +++ b/common/fltk/FL/fl_types.h @@ -0,0 +1,66 @@ +/* + * "$Id: fl_types.h 7903 2010-11-28 21:06:39Z matt $" + * + * Simple "C"-style types for the Fast Light Tool Kit (FLTK). + * + * Copyright 1998-2010 by Bill Spitzak and others. + * + * 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. + * + * Please report all bugs and problems on the following page: + * + * http://www.fltk.org/str.php + */ + +/** \file + * This file contains simple "C"-style type definitions. + */ + +#ifndef FL_TYPES_H +#define FL_TYPES_H + +/** \name Miscellaneous */ +/*@{*/ /* group: Miscellaneous */ + +/** unsigned char */ +typedef unsigned char uchar; +/** unsigned long */ +typedef unsigned long ulong; + +/** Flexible length utf8 Unicode text + * + * \todo FIXME: temporary (?) typedef to mark UTF8 and Unicode conversions + */ +typedef char *Fl_String; + +/** Flexible length utf8 Unicode read-only string + * \sa Fl_String + */ +typedef const char *Fl_CString; + +/** 24-bit Unicode character + 8-bit indicator for keyboard flags */ +typedef unsigned int Fl_Shortcut; + +/** 24-bit Unicode character - upper 8-bits are unused */ +typedef unsigned int Fl_Char; + +/*@}*/ /* group: Miscellaneous */ + +#endif + +/* + * End of "$Id: fl_types.h 7903 2010-11-28 21:06:39Z matt $". + */ diff --git a/common/fltk/FL/fl_utf8.h b/common/fltk/FL/fl_utf8.h new file mode 100644 index 00000000..311683eb --- /dev/null +++ b/common/fltk/FL/fl_utf8.h @@ -0,0 +1,263 @@ +/* "$Id: fl_utf8.h 8585 2011-04-13 15:43:22Z ianmacarthur $" + * + * Author: Jean-Marc Lienher ( http://oksid.ch ) + * Copyright 2000-2010 by O'ksi'D. + * + * 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. + * + * Please report all bugs and problems on the following page: + * + * http://www.fltk.org/str.php + */ + +/* Merged in some functionality from the fltk-2 version. IMM. + * The following code is an attempt to merge the functions incorporated in FLTK2 + * with the functions provided in OksiD's fltk-1.1.6-utf8 port + */ + +/** + \file fl_utf8.h + \brief header for Unicode and UTF8 chracter handling +*/ + +#ifndef _HAVE_FL_UTF8_HDR_ +#define _HAVE_FL_UTF8_HDR_ + +#include "Fl_Export.H" +#include "fl_types.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#ifdef WIN32 +# include <sys/types.h> +# include <sys/stat.h> +# include <locale.h> +# include <ctype.h> +# define xchar wchar_t +# if !defined(FL_DLL) && !defined(__CYGWIN__) +# undef strdup +# define strdup _strdup +# undef putenv +# define putenv _putenv +# undef stricmp +# define stricmp _stricmp +# undef strnicmp +# define strnicmp _strnicmp +# undef hypot +# define hypot _hypot +# undef chdir +# define chdir _chdir +# endif +#elif defined(__APPLE__) +# include <wchar.h> +# include <sys/stat.h> +# define xchar wchar_t +#else /* X11 */ +# include <sys/types.h> +# include <sys/stat.h> +# include "Xutf8.h" +# include <X11/Xlocale.h> +# include <X11/Xlib.h> +# include <locale.h> +# define xchar unsigned short +#endif + +# ifdef __cplusplus +extern "C" { +# endif + +/** \addtogroup fl_unicode + @{ +*/ + +/* F2: comes from FLTK2 */ +/* OD: comes from OksiD */ + +/** + Return the number of bytes needed to encode the given UCS4 character in UTF8. + \param [in] ucs UCS4 encoded character + \return number of bytes required + */ +FL_EXPORT int fl_utf8bytes(unsigned ucs); + +/* OD: returns the byte length of the first UTF-8 char sequence (returns -1 if not valid) */ +FL_EXPORT int fl_utf8len(char c); + +/* OD: returns the byte length of the first UTF-8 char sequence (returns +1 if not valid) */ +FL_EXPORT int fl_utf8len1(char c); + +/* OD: returns the number of Unicode chars in the UTF-8 string */ +FL_EXPORT int fl_utf_nb_char(const unsigned char *buf, int len); + +/* F2: Convert the next UTF8 char-sequence into a Unicode value (and say how many bytes were used) */ +FL_EXPORT unsigned fl_utf8decode(const char* p, const char* end, int* len); + +/* F2: Encode a Unicode value into a UTF8 sequence, return the number of bytes used */ +FL_EXPORT int fl_utf8encode(unsigned ucs, char* buf); + +/* F2: Move forward to the next valid UTF8 sequence start betwen start and end */ +FL_EXPORT const char* fl_utf8fwd(const char* p, const char* start, const char* end); + +/* F2: Move backward to the previous valid UTF8 sequence start */ +FL_EXPORT const char* fl_utf8back(const char* p, const char* start, const char* end); + +/* XX: Convert a single 32-bit Unicode value into UTF16 */ +FL_EXPORT unsigned fl_ucs_to_Utf16(const unsigned ucs, unsigned short *dst, const unsigned dstlen); + +/* F2: Convert a UTF8 string into UTF16 */ +FL_EXPORT unsigned fl_utf8toUtf16(const char* src, unsigned srclen, unsigned short* dst, unsigned dstlen); + +/* F2: Convert a UTF8 string into a wide character string - makes UTF16 on win32, "UCS4" elsewhere */ +FL_EXPORT unsigned fl_utf8towc(const char *src, unsigned srclen, wchar_t *dst, unsigned dstlen); + +/* F2: Convert a wide character string to UTF8 - takes in UTF16 on win32, "UCS4" elsewhere */ +FL_EXPORT unsigned fl_utf8fromwc(char *dst, unsigned dstlen, const wchar_t *src, unsigned srclen); + +/* F2: Convert a UTF8 string into ASCII, eliding untranslatable glyphs */ +FL_EXPORT unsigned fl_utf8toa (const char *src, unsigned srclen, char *dst, unsigned dstlen); +/* OD: convert UTF-8 string to latin1 */ +/* FL_EXPORT int fl_utf2latin1(const unsigned char *src, int srclen, char *dst); */ + +/* F2: Convert 8859-1 string to UTF8 */ +FL_EXPORT unsigned fl_utf8froma (char *dst, unsigned dstlen, const char *src, unsigned srclen); +/* OD: convert latin1 str to UTF-8 */ +/* FL_EXPORT int fl_latin12utf(const unsigned char *src, int srclen, char *dst); */ + +/* F2: Returns true if the current O/S locale is UTF8 */ +FL_EXPORT int fl_utf8locale(); + +/* F2: Examine the first len characters of src, to determine if the input text is UTF8 or not + * NOTE: The value returned is not simply boolean - it contains information about the probable + * type of the src text. */ +FL_EXPORT int fl_utf8test(const char *src, unsigned len); + +/* XX: return width of "raw" ucs character in columns. + * for internal use only */ +FL_EXPORT int fl_wcwidth_(unsigned int ucs); + +/* XX: return width of utf-8 character string in columns. + * NOTE: this may also do C1 control character (0x80 to 0x9f) to CP1252 mapping, + * depending on original build options */ +FL_EXPORT int fl_wcwidth(const char *src); + +/* OD: Return true if the character is non-spacing */ +FL_EXPORT unsigned int fl_nonspacing(unsigned int ucs); + +/* F2: Convert UTF8 to a local multi-byte encoding - mainly for win32? */ +FL_EXPORT unsigned fl_utf8to_mb(const char *src, unsigned srclen, char *dst, unsigned dstlen); +/* OD: Convert UTF8 to a local multi-byte encoding */ +FL_EXPORT char* fl_utf2mbcs(const char *src); + +/* F2: Convert a local multi-byte encoding to UTF8 - mainly for win32? */ +FL_EXPORT unsigned fl_utf8from_mb(char *dst, unsigned dstlen, const char *src, unsigned srclen); +/* OD: Convert a local multi-byte encoding to UTF8 */ +/* FL_EXPORT char* fl_mbcs2utf(const char *src); */ + +/*****************************************************************************/ +#ifdef WIN32 +/* OD: Attempt to convert the UTF8 string to the current locale */ +FL_EXPORT char *fl_utf8_to_locale(const char *s, int len, unsigned int codepage); + +/* OD: Attempt to convert a string in the current locale to UTF8 */ +FL_EXPORT char *fl_locale_to_utf8(const char *s, int len, unsigned int codepage); +#endif + +/***************************************************************************** + * The following functions are intended to provide portable, UTF8 aware + * versions of standard functions + */ + +/* OD: UTF8 aware strncasecmp - converts to lower case Unicode and tests */ +FL_EXPORT int fl_utf_strncasecmp(const char *s1, const char *s2, int n); + +/* OD: UTF8 aware strcasecmp - converts to Unicode and tests */ +FL_EXPORT int fl_utf_strcasecmp(const char *s1, const char *s2); + +/* OD: return the Unicode lower case value of ucs */ +FL_EXPORT int fl_tolower(unsigned int ucs); + +/* OD: return the Unicode upper case value of ucs */ +FL_EXPORT int fl_toupper(unsigned int ucs); + +/* OD: converts the UTF8 string to the lower case equivalent */ +FL_EXPORT int fl_utf_tolower(const unsigned char *str, int len, char *buf); + +/* OD: converts the UTF8 string to the upper case equivalent */ +FL_EXPORT int fl_utf_toupper(const unsigned char *str, int len, char *buf); + +/* OD: Portable UTF8 aware chmod wrapper */ +FL_EXPORT int fl_chmod(const char* f, int mode); + +/* OD: Portable UTF8 aware access wrapper */ +FL_EXPORT int fl_access(const char* f, int mode); + +/* OD: Portable UTF8 aware stat wrapper */ +FL_EXPORT int fl_stat( const char *path, struct stat *buffer ); + +/* OD: Portable UTF8 aware getcwd wrapper */ +FL_EXPORT char* fl_getcwd( char *buf, int maxlen); + +/* OD: Portable UTF8 aware fopen wrapper */ +FL_EXPORT FILE *fl_fopen(const char *f, const char *mode); + +/* OD: Portable UTF8 aware system wrapper */ +FL_EXPORT int fl_system(const char* f); + +/* OD: Portable UTF8 aware execvp wrapper */ +FL_EXPORT int fl_execvp(const char *file, char *const *argv); + +/* OD: Portable UTF8 aware open wrapper */ +FL_EXPORT int fl_open(const char* f, int o, ...); + +/* OD: Portable UTF8 aware unlink wrapper */ +FL_EXPORT int fl_unlink(const char *f); + +/* OD: Portable UTF8 aware rmdir wrapper */ +FL_EXPORT int fl_rmdir(const char *f); + +/* OD: Portable UTF8 aware getenv wrapper */ +FL_EXPORT char* fl_getenv(const char *name); + +/* OD: Portable UTF8 aware execvp wrapper */ +FL_EXPORT int fl_mkdir(const char* f, int mode); + +/* OD: Portable UTF8 aware rename wrapper */ +FL_EXPORT int fl_rename(const char* f, const char *t); + + +/* OD: Given a full pathname, this will create the directory path needed to hold the file named */ +FL_EXPORT void fl_make_path_for_file( const char *path ); + +/* OD: recursively create a path in the file system */ +FL_EXPORT char fl_make_path( const char *path ); + + +/** @} */ + +/*****************************************************************************/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _HAVE_FL_UTF8_HDR_ */ + +/* + * End of "$Id: fl_utf8.h 8585 2011-04-13 15:43:22Z ianmacarthur $". + */ diff --git a/common/fltk/FL/forms.H b/common/fltk/FL/forms.H new file mode 100644 index 00000000..3357fbc3 --- /dev/null +++ b/common/fltk/FL/forms.H @@ -0,0 +1,845 @@ +// +// "$Id: forms.H 8623 2011-04-24 17:09:41Z AlbrechtS $" +// +// Forms emulation header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef __FORMS_H__ +#define __FORMS_H__ + +#include "Fl.H" +#include "Fl_Group.H" +#include "Fl_Window.H" +#include "fl_draw.H" + +typedef Fl_Widget FL_OBJECT; +typedef Fl_Window FL_FORM; + +//////////////////////////////////////////////////////////////// +// Random constants & symbols defined by forms.h file: + +#ifndef NULL +#define NULL 0 +#endif +#ifndef FALSE +#define FALSE 0 +#define TRUE 1 +#endif + +#define FL_ON 1 +#define FL_OK 1 +#define FL_VALID 1 +#define FL_PREEMPT 1 +#define FL_AUTO 2 +#define FL_WHEN_NEEDED FL_AUTO +#define FL_OFF 0 +#define FL_NONE 0 +#define FL_CANCEL 0 +#define FL_INVALID 0 +#define FL_IGNORE -1 +//#define FL_CLOSE -2 // this variable is never used in FLTK Forms. It is removed becaus it conflicts with the window FL_CLOSE event + +#define FL_LCOL FL_BLACK +#define FL_COL1 FL_GRAY +#define FL_MCOL FL_LIGHT1 +#define FL_LEFT_BCOL FL_LIGHT3 // 53 is better match +#define FL_TOP_BCOL FL_LIGHT2 // 51 +#define FL_BOTTOM_BCOL FL_DARK2 // 40 +#define FL_RIGHT_BCOL FL_DARK3 // 36 +#define FL_INACTIVE FL_INACTIVE_COLOR +#define FL_INACTIVE_COL FL_INACTIVE_COLOR +#define FL_FREE_COL1 FL_FREE_COLOR +#define FL_FREE_COL2 ((Fl_Color)(FL_FREE_COLOR+1)) +#define FL_FREE_COL3 ((Fl_Color)(FL_FREE_COLOR+2)) +#define FL_FREE_COL4 ((Fl_Color)(FL_FREE_COLOR+3)) +#define FL_FREE_COL5 ((Fl_Color)(FL_FREE_COLOR+4)) +#define FL_FREE_COL6 ((Fl_Color)(FL_FREE_COLOR+5)) +#define FL_FREE_COL7 ((Fl_Color)(FL_FREE_COLOR+6)) +#define FL_FREE_COL8 ((Fl_Color)(FL_FREE_COLOR+7)) +#define FL_FREE_COL9 ((Fl_Color)(FL_FREE_COLOR+8)) +#define FL_FREE_COL10 ((Fl_Color)(FL_FREE_COLOR+9)) +#define FL_FREE_COL11 ((Fl_Color)(FL_FREE_COLOR+10)) +#define FL_FREE_COL12 ((Fl_Color)(FL_FREE_COLOR+11)) +#define FL_FREE_COL13 ((Fl_Color)(FL_FREE_COLOR+12)) +#define FL_FREE_COL14 ((Fl_Color)(FL_FREE_COLOR+13)) +#define FL_FREE_COL15 ((Fl_Color)(FL_FREE_COLOR+14)) +#define FL_FREE_COL16 ((Fl_Color)(FL_FREE_COLOR+15)) +#define FL_TOMATO ((Fl_Color)(131)) +#define FL_INDIANRED ((Fl_Color)(164)) +#define FL_SLATEBLUE ((Fl_Color)(195)) +#define FL_DARKGOLD ((Fl_Color)(84)) +#define FL_PALEGREEN ((Fl_Color)(157)) +#define FL_ORCHID ((Fl_Color)(203)) +#define FL_DARKCYAN ((Fl_Color)(189)) +#define FL_DARKTOMATO ((Fl_Color)(113)) +#define FL_WHEAT ((Fl_Color)(174)) + +#define FL_ALIGN_BESIDE FL_ALIGN_INSIDE + +#define FL_PUP_TOGGLE 2 // FL_MENU_TOGGLE +#define FL_PUP_INACTIVE 1 // FL_MENU_INACTIVE +#define FL_NO_FRAME FL_NO_BOX +#define FL_ROUNDED3D_UPBOX FL_ROUND_UP_BOX +#define FL_ROUNDED3D_DOWNBOX FL_ROUND_DOWN_BOX +#define FL_OVAL3D_UPBOX FL_ROUND_UP_BOX +#define FL_OVAL3D_DOWNBOX FL_ROUND_DOWN_BOX + +#define FL_MBUTTON1 1 +#define FL_LEFTMOUSE 1 +#define FL_MBUTTON2 2 +#define FL_MIDDLEMOUSE 2 +#define FL_MBUTTON3 3 +#define FL_RIGHTMOUSE 3 +#define FL_MBUTTON4 4 +#define FL_MBUTTON5 5 + +#define FL_INVALID_STYLE 255 +#define FL_NORMAL_STYLE FL_HELVETICA +#define FL_BOLD_STYLE FL_HELVETICA_BOLD +#define FL_ITALIC_STYLE FL_HELVETICA_ITALIC +#define FL_BOLDITALIC_STYLE FL_HELVETICA_BOLD_ITALIC +#define FL_FIXED_STYLE FL_COURIER +#define FL_FIXEDBOLD_STYLE FL_COURIER_BOLD +#define FL_FIXEDITALIC_STYLE FL_COURIER_ITALIC +#define FL_FIXEDBOLDITALIC_STYLE FL_COURIER_BOLD_ITALIC +#define FL_TIMES_STYLE FL_TIMES +#define FL_TIMESBOLD_STYLE FL_TIMES_BOLD +#define FL_TIMESITALIC_STYLE FL_TIMES_ITALIC +#define FL_TIMESBOLDITALIC_STYLE FL_TIMES_BOLD_ITALIC + +// hacks to change the labeltype() when passed to fl_set_object_lstyle(): +#define FL_SHADOW_STYLE (FL_SHADOW_LABEL<<8) +#define FL_ENGRAVED_STYLE (FL_ENGRAVED_LABEL<<8) +#define FL_EMBOSSED_STYLE (FL_EMBOSSED_LABEL<<0) + +// size values are different from XForms, match older Forms: +#define FL_TINY_SIZE 8 +#define FL_SMALL_SIZE 11 // 10 +//#define FL_NORMAL_SIZE 14 // 12 +#define FL_MEDIUM_SIZE 18 // 14 +#define FL_LARGE_SIZE 24 // 18 +#define FL_HUGE_SIZE 32 // 24 +#define FL_DEFAULT_SIZE FL_SMALL_SIZE +#define FL_TINY_FONT FL_TINY_SIZE +#define FL_SMALL_FONT FL_SMALL_SIZE +#define FL_NORMAL_FONT FL_NORMAL_SIZE +#define FL_MEDIUM_FONT FL_MEDIUM_SIZE +#define FL_LARGE_FONT FL_LARGE_SIZE +#define FL_HUGE_FONT FL_HUGE_SIZE +#define FL_NORMAL_FONT1 FL_SMALL_FONT +#define FL_NORMAL_FONT2 FL_NORMAL_FONT +#define FL_DEFAULT_FONT FL_SMALL_FONT + +#define FL_RETURN_END_CHANGED FL_WHEN_RELEASE +#define FL_RETURN_CHANGED FL_WHEN_CHANGED +#define FL_RETURN_END FL_WHEN_RELEASE_ALWAYS +#define FL_RETURN_ALWAYS (FL_WHEN_CHANGED|FL_WHEN_NOT_CHANGED) + +#define FL_BOUND_WIDTH 3 + +typedef int FL_Coord; +typedef int FL_COLOR; + +//////////////////////////////////////////////////////////////// +// fltk interaction: + +#define FL_CMD_OPT void +extern FL_EXPORT void fl_initialize(int*, char*[], const char*, FL_CMD_OPT*, int); +inline void fl_finish() {} + +typedef void (*FL_IO_CALLBACK) (int, void*); +inline void fl_add_io_callback(int fd, short w, FL_IO_CALLBACK cb, void* v) { + Fl::add_fd(fd,w,cb,v);} +inline void fl_remove_io_callback(int fd, short, FL_IO_CALLBACK) { + Fl::remove_fd(fd);} // removes all the callbacks! + +// type of callback is different and no "id" number is returned: +inline void fl_add_timeout(long msec, void (*cb)(void*), void* v) { + Fl::add_timeout(msec*.001, cb, v);} +inline void fl_remove_timeout(int) {} + +// type of callback is different! +inline void fl_set_idle_callback(void (*cb)()) {Fl::set_idle(cb);} + +FL_EXPORT Fl_Widget* fl_do_forms(void); +FL_EXPORT Fl_Widget* fl_check_forms(); +inline Fl_Widget* fl_do_only_forms(void) {return fl_do_forms();} +inline Fl_Widget* fl_check_only_forms(void) {return fl_check_forms();} + +// because of new redraw behavior, these are no-ops: +inline void fl_freeze_object(Fl_Widget*) {} +inline void fl_unfreeze_object(Fl_Widget*) {} +inline void fl_freeze_form(Fl_Window*) {} +inline void fl_unfreeze_form(Fl_Window*) {} +inline void fl_freeze_all_forms() {} +inline void fl_unfreeze_all_forms() {} + +inline void fl_set_focus_object(Fl_Window*, Fl_Widget* o) {Fl::focus(o);} +inline void fl_reset_focus_object(Fl_Widget* o) {Fl::focus(o);} +#define fl_set_object_focus fl_set_focus_object + +// void fl_set_form_atclose(Fl_Window*w,int (*cb)(Fl_Window*,void*),void* v) +// void fl_set_atclose(int (*cb)(Fl_Window*,void*),void*) +// fl_set_form_atactivate/atdeactivate not implemented! + +//////////////////////////////////////////////////////////////// +// Fl_Widget: + +inline void fl_set_object_boxtype(Fl_Widget* o, Fl_Boxtype a) {o->box(a);} +inline void fl_set_object_lsize(Fl_Widget* o,int s) {o->labelsize(s);} + +/* forms lib font indexes must be byte sized - extract correct byte from style word */ +inline void fl_set_object_lstyle(Fl_Widget* o,int a) { + o->labelfont((Fl_Font)(a&0xff)); o->labeltype((Fl_Labeltype)(a>>8));} +inline void fl_set_object_lcol(Fl_Widget* o, Fl_Color a) {o->labelcolor(a);} +#define fl_set_object_lcolor fl_set_object_lcol +inline void fl_set_object_lalign(Fl_Widget* o, Fl_Align a) {o->align(a);} +#define fl_set_object_align fl_set_object_lalign +inline void fl_set_object_color(Fl_Widget* o,Fl_Color a,Fl_Color b) {o->color(a,b);} +inline void fl_set_object_label(Fl_Widget* o, const char* a) {o->label(a); o->redraw();} +inline void fl_set_object_position(Fl_Widget*o,int x,int y) {o->position(x,y);} +inline void fl_set_object_size(Fl_Widget* o, int w, int h) {o->size(w,h);} +inline void fl_set_object_geometry(Fl_Widget* o,int x,int y,int w,int h) {o->resize(x,y,w,h);} + +inline void fl_get_object_geometry(Fl_Widget* o,int*x,int*y,int*w,int*h) { + *x = o->x(); *y = o->y(); *w = o->w(); *h = o->h();} +inline void fl_get_object_position(Fl_Widget* o,int*x,int*y) { + *x = o->x(); *y = o->y();} + +typedef void (*Forms_CB)(Fl_Widget*, long); +inline void fl_set_object_callback(Fl_Widget*o,Forms_CB c,long a) {o->callback(c,a);} +#define fl_set_call_back fl_set_object_callback +inline void fl_call_object_callback(Fl_Widget* o) {o->do_callback();} +inline void fl_trigger_object(Fl_Widget* o) {o->do_callback();} +inline void fl_set_object_return(Fl_Widget* o, int v) { + o->when((Fl_When)(v|FL_WHEN_RELEASE));} + +inline void fl_redraw_object(Fl_Widget* o) {o->redraw();} +inline void fl_show_object(Fl_Widget* o) {o->show();} +inline void fl_hide_object(Fl_Widget* o) {o->hide();} +inline void fl_free_object(Fl_Widget* x) {delete x;} +inline void fl_delete_object(Fl_Widget* o) {o->parent()->remove(*o);} +inline void fl_activate_object(Fl_Widget* o) {o->activate();} +inline void fl_deactivate_object(Fl_Widget* o) {o->deactivate();} + +inline void fl_add_object(Fl_Window* f, Fl_Widget* x) {f->add(x);} +inline void fl_insert_object(Fl_Widget* o, Fl_Widget* b) {b->parent()->insert(*o,b);} + +inline Fl_Window* FL_ObjWin(Fl_Widget* o) {return o->window();} + +//////////////////////////////////////////////////////////////// +// things that appered in the demos a lot that I don't emulate, but +// I did not want to edit out of all the demos... + +inline int fl_get_border_width() {return 3;} +inline void fl_set_border_width(int) {} +inline void fl_set_object_dblbuffer(Fl_Widget*, int) {} +inline void fl_set_form_dblbuffer(Fl_Window*, int) {} + +//////////////////////////////////////////////////////////////// +// Fl_Window: + +inline void fl_free_form(Fl_Window* x) {delete x;} +inline void fl_redraw_form(Fl_Window* f) {f->redraw();} + +inline Fl_Window* fl_bgn_form(Fl_Boxtype b,int w,int h) { + Fl_Window* g = new Fl_Window(w,h,0); + g->box(b); + return g; +} +FL_EXPORT void fl_end_form(); +inline void fl_addto_form(Fl_Window* f) {f->begin();} +inline Fl_Group* fl_bgn_group() {return new Fl_Group(0,0,0,0,0);} +inline void fl_end_group() {Fl_Group::current()->forms_end();} +inline void fl_addto_group(Fl_Widget* o) {((Fl_Group* )o)->begin();} +#define resizebox _ddfdesign_kludge() + +inline void fl_scale_form(Fl_Window* f, double x, double y) { + f->resizable(f); f->size(int(f->w()*x),int(f->h()*y));} +inline void fl_set_form_position(Fl_Window* f,int x,int y) {f->position(x,y);} +inline void fl_set_form_size(Fl_Window* f, int w, int h) {f->size(w,h);} +inline void fl_set_form_geometry(Fl_Window* f,int x,int y,int w,int h) { + f->resize(x,y,w,h);} +#define fl_set_initial_placement fl_set_form_geometry +inline void fl_adjust_form_size(Fl_Window*) {} + +FL_EXPORT void fl_show_form(Fl_Window* f,int p,int b,const char* n); +enum { // "p" argument values: + FL_PLACE_FREE = 0, // make resizable + FL_PLACE_MOUSE = 1, // mouse centered on form + FL_PLACE_CENTER = 2, // center of the screen + FL_PLACE_POSITION = 4,// fixed position, resizable + FL_PLACE_SIZE = 8, // fixed size, normal fltk behavior + FL_PLACE_GEOMETRY =16,// fixed size and position + FL_PLACE_ASPECT = 32, // keep aspect ratio (ignored) + FL_PLACE_FULLSCREEN=64,// fill screen + FL_PLACE_HOTSPOT = 128,// enables hotspot + FL_PLACE_ICONIC = 256,// iconic (ignored) + FL_FREE_SIZE=(1<<14), // force resizable + FL_FIX_SIZE =(1<<15) // force off resizable +}; +#define FL_PLACE_FREE_CENTER (FL_PLACE_CENTER|FL_FREE_SIZE) +#define FL_PLACE_CENTERFREE (FL_PLACE_CENTER|FL_FREE_SIZE) +enum { // "b" arguement values: + FL_NOBORDER = 0, + FL_FULLBORDER, + FL_TRANSIENT +//FL_MODAL = (1<<8) // not implemented yet in Forms +}; +inline void fl_set_form_hotspot(Fl_Window* w,int x,int y) {w->hotspot(x,y);} +inline void fl_set_form_hotobject(Fl_Window* w, Fl_Widget* o) {w->hotspot(o);} +extern FL_EXPORT char fl_flip; // in forms.C +inline void fl_flip_yorigin() {fl_flip = 1;} + +#define fl_prepare_form_window fl_show_form +inline void fl_show_form_window(Fl_Window*) {} + +inline void fl_raise_form(Fl_Window* f) {f->show();} + +inline void fl_hide_form(Fl_Window* f) {f->hide();} +inline void fl_pop_form(Fl_Window* f) {f->show();} + +extern FL_EXPORT char fl_modal_next; // in forms.C +inline void fl_activate_all_forms() {} +inline void fl_deactivate_all_forms() {fl_modal_next = 1;} +inline void fl_deactivate_form(Fl_Window*w) {w->deactivate();} +inline void fl_activate_form(Fl_Window*w) {w->activate();} + +inline void fl_set_form_title(Fl_Window* f, const char* s) {f->label(s);} +inline void fl_title_form(Fl_Window* f, const char* s) {f->label(s);} + +typedef void (*Forms_FormCB)(Fl_Widget*); +inline void fl_set_form_callback(Fl_Window* f,Forms_FormCB c) {f->callback(c);} +#define fl_set_form_call_back fl_set_form_callback + +inline void fl_init() {} +FL_EXPORT void fl_set_graphics_mode(int,int); + +inline int fl_form_is_visible(Fl_Window* f) {return f->visible();} + +inline int fl_mouse_button() {return Fl::event_button();} +#define fl_mousebutton fl_mouse_button + +#define fl_free free +#define fl_malloc malloc +#define fl_calloc calloc +#define fl_realloc realloc + +//////////////////////////////////////////////////////////////// +// Drawing functions. Only usable inside an Fl_Free object? + +inline void fl_drw_box(Fl_Boxtype b,int x,int y,int w,int h,Fl_Color bgc,int=3) { + fl_draw_box(b,x,y,w,h,bgc);} +inline void fl_drw_frame(Fl_Boxtype b,int x,int y,int w,int h,Fl_Color bgc,int=3) { + fl_draw_box(b,x,y,w,h,bgc);} + +inline void fl_drw_text(Fl_Align align, int x, int y, int w, int h, + Fl_Color fgcolor, int size, Fl_Font style, + const char* s) { + fl_font(style,size); + fl_color(fgcolor); + fl_draw(s,x,y,w,h,align); +} + +// this does not work except for CENTER... +inline void fl_drw_text_beside(Fl_Align align, int x, int y, int w, int h, + Fl_Color fgcolor, int size, Fl_Font style, + const char* s) { + fl_font(style,size); + fl_color(fgcolor); + fl_draw(s,x,y,w,h,align); +} + +inline void fl_set_font_name(Fl_Font n,const char* s) {Fl::set_font(n,s);} + +inline void fl_mapcolor(Fl_Color c, uchar r, uchar g, uchar b) {Fl::set_color(c,r,g,b);} + +#define fl_set_clipping(x,y,w,h) fl_push_clip(x,y,w,h) +#define fl_unset_clipping() fl_pop_clip() + +//////////////////////////////////////////////////////////////// +// Forms classes: + +inline Fl_Widget* fl_add_new(Fl_Widget* p) {return p;} +inline Fl_Widget* fl_add_new(uchar t,Fl_Widget* p) {p->type(t); return p;} + +#define forms_constructor(type,name) \ +inline type* name(uchar t,int x,int y,int w,int h,const char* l) { \ + return (type*)(fl_add_new(t, new type(x,y,w,h,l)));} +#define forms_constructort(type,name) \ +inline type* name(uchar t,int x,int y,int w,int h,const char* l) { \ + return (type*)(fl_add_new(new type(t,x,y,w,h,l)));} +#define forms_constructorb(type,name) \ +inline type* name(Fl_Boxtype t,int x,int y,int w,int h,const char* l) { \ + return (type*)(fl_add_new(new type(t,x,y,w,h,l)));} + +#include "Fl_FormsBitmap.H" +#define FL_NORMAL_BITMAP FL_NO_BOX +forms_constructorb(Fl_FormsBitmap, fl_add_bitmap) +inline void fl_set_bitmap_data(Fl_Widget* o, int w, int h, const uchar* b) { + ((Fl_FormsBitmap*)o)->set(w,h,b); +} + +#include "Fl_FormsPixmap.H" +#define FL_NORMAL_PIXMAP FL_NO_BOX +forms_constructorb(Fl_FormsPixmap, fl_add_pixmap) +inline void fl_set_pixmap_data(Fl_Widget* o, char*const* b) { + ((Fl_FormsPixmap*)o)->set(b); +} +//inline void fl_set_pixmap_file(Fl_Widget*, const char*); +inline void fl_set_pixmap_align(Fl_Widget* o,Fl_Align a,int,int) {o->align(a);} +//inline void fl_set_pixmap_colorcloseness(int, int, int); + +#include "Fl_Box.H" +forms_constructorb(Fl_Box, fl_add_box) + +#include "Fl_Browser.H" +forms_constructor(Fl_Browser, fl_add_browser) + +inline void fl_clear_browser(Fl_Widget* o) { + ((Fl_Browser*)o)->clear();} +inline void fl_add_browser_line(Fl_Widget* o, const char* s) { + ((Fl_Browser*)o)->add(s);} +inline void fl_addto_browser(Fl_Widget* o, const char* s) { + ((Fl_Browser*)o)->add(s);} /* should also scroll to bottom */ +//inline void fl_addto_browser_chars(Fl_Widget*, const char*) +//#define fl_append_browser fl_addto_browser_chars +inline void fl_insert_browser_line(Fl_Widget* o, int n, const char* s) { + ((Fl_Browser*)o)->insert(n,s);} +inline void fl_delete_browser_line(Fl_Widget* o, int n) { + ((Fl_Browser*)o)->remove(n);} +inline void fl_replace_browser_line(Fl_Widget* o, int n, const char* s) { + ((Fl_Browser*)o)->replace(n,s);} +inline char* fl_get_browser_line(Fl_Widget* o, int n) { + return (char*)(((Fl_Browser*)o)->text(n));} +inline int fl_load_browser(Fl_Widget* o, const char* f) { + return ((Fl_Browser*)o)->load(f);} +inline void fl_select_browser_line(Fl_Widget* o, int n) { + ((Fl_Browser*)o)->select(n,1);} +inline void fl_deselect_browser_line(Fl_Widget* o, int n) { + ((Fl_Browser*)o)->select(n,0);} +inline void fl_deselect_browser(Fl_Widget* o) { + ((Fl_Browser*)o)->deselect();} +inline int fl_isselected_browser_line(Fl_Widget* o, int n) { + return ((Fl_Browser*)o)->selected(n);} +inline int fl_get_browser_topline(Fl_Widget* o) { + return ((Fl_Browser*)o)->topline();} +inline int fl_get_browser(Fl_Widget* o) { + return ((Fl_Browser*)o)->value();} +inline int fl_get_browser_maxline(Fl_Widget* o) { + return ((Fl_Browser*)o)->size();} +//linline int fl_get_browser_screenlines(Fl_Widget*); +inline void fl_set_browser_topline(Fl_Widget* o, int n) { + ((Fl_Browser*)o)->topline(n);} +inline void fl_set_browser_fontsize(Fl_Widget* o, int s) { + ((Fl_Browser*)o)->textsize(s);} +inline void fl_set_browser_fontstyle(Fl_Widget* o, Fl_Font s) { + ((Fl_Browser*)o)->textfont(s);} +inline void fl_set_browser_specialkey(Fl_Widget* o, char c) { + ((Fl_Browser*)o)->format_char(c);} +//inline void fl_set_browser_vscrollbar(Fl_Widget*, int); +//inline void fl_set_browser_hscrollbar(Fl_Widget*, int); +//inline void fl_set_browser_leftslider(Fl_Widget*, int); +//#define fl_set_browser_leftscrollbar fl_set_browser_leftslider +//inline void fl_set_browser_line_selectable(Fl_Widget*, int, int); +//inline void fl_get_browser_dimension(Fl_Widget*,int*,int*,int*,int*); +//inline void fl_set_browser_dblclick_callback(Fl_Widget*,FL_CALLBACKPTR,long); +//inline void fl_set_browser_xoffset(Fl_Widget*, FL_Coord); +//inline void fl_set_browser_scrollbarsize(Fl_Widget*, int, int); +inline void fl_setdisplayed_browser_line(Fl_Widget* o, int n, int i) { + ((Fl_Browser*)o)->display(n,i);} +inline int fl_isdisplayed_browser_line(Fl_Widget* o, int n) { + return ((Fl_Browser*)o)->displayed(n);} + +#include "Fl_Button.H" + +#define FL_NORMAL_BUTTON 0 +#define FL_TOUCH_BUTTON 4 +#define FL_INOUT_BUTTON 5 +#define FL_RETURN_BUTTON 6 +#define FL_HIDDEN_RET_BUTTON 7 +#define FL_PUSH_BUTTON FL_TOGGLE_BUTTON +#define FL_MENU_BUTTON 9 + +FL_EXPORT Fl_Button* fl_add_button(uchar t,int x,int y,int w,int h,const char* l); +inline int fl_get_button(Fl_Widget* b) {return ((Fl_Button*)b)->value();} +inline void fl_set_button(Fl_Widget* b, int v) {((Fl_Button*)b)->value(v);} +inline int fl_get_button_numb(Fl_Widget*) {return Fl::event_button();} +inline void fl_set_button_shortcut(Fl_Widget* b, const char* s,int=0) { + ((Fl_Button*)b)->shortcut(s);} +//#define fl_set_object_shortcut(b,s) fl_set_button_shortcut(b,s) + +#include "Fl_Light_Button.H" +forms_constructor(Fl_Light_Button, fl_add_lightbutton) + +#include "Fl_Round_Button.H" +forms_constructor(Fl_Round_Button, fl_add_roundbutton) +forms_constructor(Fl_Round_Button, fl_add_round3dbutton) + +#include "Fl_Check_Button.H" +forms_constructor(Fl_Check_Button, fl_add_checkbutton) + +inline Fl_Widget* fl_add_bitmapbutton(int t,int x,int y,int w,int h,const char* l) {Fl_Widget* o = fl_add_button(t,x,y,w,h,l); return o;} +inline void fl_set_bitmapbutton_data(Fl_Widget* o,int a,int b,uchar* c) { + (new Fl_Bitmap(c,a,b))->label(o);} // does not delete old Fl_Bitmap! + +inline Fl_Widget* fl_add_pixmapbutton(int t,int x,int y,int w,int h,const char* l) {Fl_Widget* o = fl_add_button(t,x,y,w,h,l); return o;} +inline void fl_set_pixmapbutton_data(Fl_Widget* o, const char*const* c) { + (new Fl_Pixmap(c))->label(o);} // does not delete old Fl_Pixmap! + +// Fl_Canvas object not yet implemented! + +#include "Fl_Chart.H" + +forms_constructor(Fl_Chart, fl_add_chart) +inline void fl_clear_chart(Fl_Widget* o) { + ((Fl_Chart*)o)->clear();} +inline void fl_add_chart_value(Fl_Widget* o,double v,const char* s,uchar c){ + ((Fl_Chart*)o)->add(v,s,c);} +inline void fl_insert_chart_value(Fl_Widget* o, int i, double v, const char* s, uchar c) { + ((Fl_Chart*)o)->insert(i,v,s,c);} +inline void fl_replace_chart_value(Fl_Widget* o, int i, double v, const char* s, uchar c) { + ((Fl_Chart*)o)->replace(i,v,s,c);} +inline void fl_set_chart_bounds(Fl_Widget* o, double a, double b) { + ((Fl_Chart*)o)->bounds(a,b);} +inline void fl_set_chart_maxnumb(Fl_Widget* o, int v) { + ((Fl_Chart*)o)->maxsize(v);} +inline void fl_set_chart_autosize(Fl_Widget* o, int v) { + ((Fl_Chart*)o)->autosize(v);} +inline void fl_set_chart_lstyle(Fl_Widget* o, Fl_Font v) { + ((Fl_Chart*)o)->textfont(v);} +inline void fl_set_chart_lsize(Fl_Widget* o, int v) { + ((Fl_Chart*)o)->textsize(v);} +inline void fl_set_chart_lcolor(Fl_Widget* o, Fl_Color v) { + ((Fl_Chart*)o)->textcolor(v);} +#define fl_set_chart_lcol fl_set_chart_lcolor + +#include "Fl_Choice.H" + +#define FL_NORMAL_CHOICE 0 +#define FL_NORMAL_CHOICE2 0 +#define FL_DROPLIST_CHOICE 0 + +forms_constructor(Fl_Choice, fl_add_choice) +inline void fl_clear_choice(Fl_Widget* o) { + ((Fl_Choice*)o)->clear();} +inline void fl_addto_choice(Fl_Widget* o, const char* s) { + ((Fl_Choice*)o)->add(s);} +inline void fl_replace_choice(Fl_Widget* o, int i, const char* s) { + ((Fl_Choice*)o)->replace(i-1,s);} +inline void fl_delete_choice(Fl_Widget* o, int i) { + ((Fl_Choice*)o)->remove(i-1);} +inline void fl_set_choice(Fl_Widget* o, int i) { + ((Fl_Choice*)o)->value(i-1);} +// inline void fl_set_choice_text(Fl_Widget*, const char*); +inline int fl_get_choice(Fl_Widget* o) { + return ((Fl_Choice*)o)->value()+1;} +// inline const char* fl_get_choice_item_text(Fl_Widget*, int); +// inline int fl_get_choice_maxitems(Fl_Widget*); +inline const char* fl_get_choice_text(Fl_Widget* o) { + return ((Fl_Choice*)o)->text();} +inline void fl_set_choice_fontsize(Fl_Widget* o, int x) { + ((Fl_Choice*)o)->textsize(x);} +inline void fl_set_choice_fontstyle(Fl_Widget* o, Fl_Font x) { + ((Fl_Choice*)o)->textfont(x);} +// inline void fl_set_choice_item_mode(Fl_Widget*, int, unsigned); +// inline void fl_set_choice_item_shortcut(Fl_Widget*, int, const char*); + +#include "Fl_Clock.H" +forms_constructort(Fl_Clock, fl_add_clock) +inline void fl_get_clock(Fl_Widget* o, int* h, int* m, int* s) { + *h = ((Fl_Clock*)o)->hour(); + *m = ((Fl_Clock*)o)->minute(); + *s = ((Fl_Clock*)o)->second(); +} + +#include "Fl_Counter.H" +forms_constructor(Fl_Counter, fl_add_counter) +inline void fl_set_counter_value(Fl_Widget* o, double v) { + ((Fl_Counter*)o)->value(v);} +inline void fl_set_counter_bounds(Fl_Widget* o, double a, double b) { + ((Fl_Counter*)o)->bounds(a,b);} +inline void fl_set_counter_step(Fl_Widget* o, double a, double b) { + ((Fl_Counter*)o)->step(a,b);} +inline void fl_set_counter_precision(Fl_Widget* o, int v) { + ((Fl_Counter*)o)->precision(v);} +inline void fl_set_counter_return(Fl_Widget* o, int v) { + ((Fl_Counter*)o)->when((Fl_When)(v|FL_WHEN_RELEASE));} +inline double fl_get_counter_value(Fl_Widget* o) { + return ((Fl_Counter*)o)->value();} +inline void fl_get_counter_bounds(Fl_Widget* o, float* a, float* b) { + *a = float(((Fl_Counter*)o)->minimum()); + *b = float(((Fl_Counter*)o)->maximum()); +} +//inline void fl_set_counter_filter(Fl_Widget*,const char* (*)(Fl_Widget*,double,int)); + +// Cursor stuff cannot be emulated because it uses X stuff +inline void fl_set_cursor(Fl_Window* w, Fl_Cursor c) {w->cursor(c);} +#define FL_INVISIBLE_CURSOR FL_CURSOR_NONE +#define FL_DEFAULT_CURSOR FL_CURSOR_DEFAULT + +#include "Fl_Dial.H" + +#define FL_DIAL_COL1 FL_GRAY +#define FL_DIAL_COL2 37 + +forms_constructor(Fl_Dial, fl_add_dial) +inline void fl_set_dial_value(Fl_Widget* o, double v) { + ((Fl_Dial*)o)->value(v);} +inline double fl_get_dial_value(Fl_Widget* o) { + return ((Fl_Dial*)o)->value();} +inline void fl_set_dial_bounds(Fl_Widget* o, double a, double b) { + ((Fl_Dial*)o)->bounds(a, b);} +inline void fl_get_dial_bounds(Fl_Widget* o, float* a, float* b) { + *a = float(((Fl_Dial*)o)->minimum()); + *b = float(((Fl_Dial*)o)->maximum()); +} +inline void fl_set_dial_return(Fl_Widget* o, int i) { + ((Fl_Dial*)o)->when((Fl_When)(i|FL_WHEN_RELEASE));} +inline void fl_set_dial_angles(Fl_Widget* o, int a, int b) { + ((Fl_Dial*)o)->angles((short)a, (short)b);} +//inline void fl_set_dial_cross(Fl_Widget* o, int); +// inline void fl_set_dial_direction(Fl_Widget* o, uchar d) { +// ((Fl_Dial*)o)->direction(d);} +inline void fl_set_dial_step(Fl_Widget* o, double v) { + ((Fl_Dial*)o)->step(v);} + +// Frames: + +inline Fl_Widget* fl_add_frame(Fl_Boxtype i,int x,int y,int w,int h,const char* l) { + return fl_add_box(i,x-3,y-3,w+6,h+6,l);} + +// labelframe nyi +inline Fl_Widget* fl_add_labelframe(Fl_Boxtype i,int x,int y,int w,int h,const char* l) { + Fl_Widget* o = fl_add_box(i,x-3,y-3,w+6,h+6,l); + o->align(FL_ALIGN_TOP_LEFT); + return o; +} + +#include "Fl_Free.H" +inline Fl_Free* +fl_add_free(int t,double x,double y,double w,double h,const char* l, + FL_HANDLEPTR hdl) { + return (Fl_Free*)(fl_add_new( + new Fl_Free(t,int(x),int(y),int(w),int(h),l,hdl))); +} + +#include "fl_ask.H" +#include "fl_show_colormap.H" + +inline int fl_show_question(const char* c, int = 0) {return fl_choice("%s",fl_no,fl_yes,0L,c);} +FL_EXPORT void fl_show_message(const char *,const char *,const char *); +FL_EXPORT void fl_show_alert(const char *,const char *,const char *,int=0); +FL_EXPORT int fl_show_question(const char *,const char *,const char *); +inline const char *fl_show_input(const char *l,const char*d=0) {return fl_input("%s",d,l);} +FL_EXPORT /*const*/ char *fl_show_simple_input(const char *label, const char *deflt = 0); +FL_EXPORT int fl_show_choice( + const char *m1, + const char *m2, + const char *m3, + int numb, + const char *b0, + const char *b1, + const char *b2); + +inline void fl_set_goodies_font(Fl_Font a, Fl_Fontsize b) {fl_message_font(a,b);} +#define fl_show_messages fl_message +inline int fl_show_choices(const char* c,int n,const char* b1,const char* b2, + const char* b3, int) { + return fl_show_choice(0,c,0,n,b1,b2,b3); +} + +#include "filename.H" +#include "Fl_File_Chooser.H" +inline int do_matching(char* a, const char* b) {return fl_filename_match(a,b);} + +// Forms-compatible file chooser (implementation in fselect.C): +FL_EXPORT char* fl_show_file_selector(const char* message,const char* dir, + const char* pat,const char* fname); +FL_EXPORT char* fl_get_directory(); +FL_EXPORT char* fl_get_pattern(); +FL_EXPORT char* fl_get_filename(); + +#include "Fl_Input.H" +forms_constructor(Fl_Input, fl_add_input) +inline void fl_set_input(Fl_Widget* o, const char* v) { + ((Fl_Input*)o)->value(v);} +inline void fl_set_input_return(Fl_Widget* o, int x) { + ((Fl_Input*)o)->when((Fl_When)(x | FL_WHEN_RELEASE));} +inline void fl_set_input_color(Fl_Widget* o, Fl_Color a, Fl_Color b) { + ((Fl_Input*)o)->textcolor(a); + ((Fl_Input*)o)->cursor_color(b); +} +// inline void fl_set_input_scroll(Fl_Widget*, int); +inline void fl_set_input_cursorpos(Fl_Widget* o, int x, int /*y*/) { + ((Fl_Input*)o)->position(x);} +// inline void fl_set_input_selected(Fl_Widget*, int); +// inline void fl_set_input_selected_range(Fl_Widget*, int, int); +// inline void fl_set_input_maxchars(Fl_Widget*, int); +// inline void fl_set_input_format(Fl_Widget*, int, int); +// inline void fl_set_input_hscrollbar(Fl_Widget*, int); +// inline void fl_set_input_vscrollbar(Fl_Widget*, int); +// inline void fl_set_input_xoffset(Fl_Widget*, int); +// inline void fl_set_input_topline(Fl_Widget*, int); +// inline void fl_set_input_scrollbarsize(Fl_Widget*, int, int); +// inline int fl_get_input_topline(Fl_Widget*); +// inline int fl_get_input_screenlines(Fl_Widget*); +inline int fl_get_input_cursorpos(Fl_Widget* o, int*x, int*y) { + *x = ((Fl_Input*)o)->position(); *y = 0; return *x;} +// inline int fl_get_input_numberoflines(Fl_Widget*); +// inline void fl_get_input_format(Fl_Widget*, int*, int*); +inline const char* fl_get_input(Fl_Widget* o) {return ((Fl_Input*)o)->value();} + +#include "Fl_Menu_Button.H" + +// types are not implemented, they all act like FL_PUSH_MENU: +#define FL_TOUCH_MENU 0 +#define FL_PUSH_MENU 1 +#define FL_PULLDOWN_MENU 2 +forms_constructor(Fl_Menu_Button, fl_add_menu) + +inline void fl_clear_menu(Fl_Widget* o) { + ((Fl_Menu_Button*)o)->clear();} +inline void fl_set_menu(Fl_Widget* o, const char* s) { + ((Fl_Menu_Button*)o)->clear(); ((Fl_Menu_Button*)o)->add(s);} +inline void fl_addto_menu(Fl_Widget* o, const char* s) { + ((Fl_Menu_Button*)o)->add(s);} +inline void fl_replace_menu_item(Fl_Widget* o, int i, const char* s) { + ((Fl_Menu_Button*)o)->replace(i-1,s);} +inline void fl_delete_menu_item(Fl_Widget* o, int i) { + ((Fl_Menu_Button*)o)->remove(i-1);} +inline void fl_set_menu_item_shortcut(Fl_Widget* o, int i, const char* s) { + ((Fl_Menu_Button*)o)->shortcut(i-1,fl_old_shortcut(s));} +inline void fl_set_menu_item_mode(Fl_Widget* o, int i, long x) { + ((Fl_Menu_Button*)o)->mode(i-1,x);} +inline void fl_show_menu_symbol(Fl_Widget*, int ) { +/* ((Fl_Menu_Button*)o)->show_menu_symbol(i); */} +// inline void fl_set_menu_popup(Fl_Widget*, int); +inline int fl_get_menu(Fl_Widget* o) { + return ((Fl_Menu_Button*)o)->value()+1;} +inline const char* fl_get_menu_item_text(Fl_Widget* o, int i) { + return ((Fl_Menu_Button*)o)->text(i);} +inline int fl_get_menu_maxitems(Fl_Widget* o) { + return ((Fl_Menu_Button*)o)->size();} +inline int fl_get_menu_item_mode(Fl_Widget* o, int i) { + return ((Fl_Menu_Button*)o)->mode(i);} +inline const char* fl_get_menu_text(Fl_Widget* o) { + return ((Fl_Menu_Button*)o)->text();} + +#include "Fl_Positioner.H" +#define FL_NORMAL_POSITIONER 0 +forms_constructor(Fl_Positioner, fl_add_positioner) +inline void fl_set_positioner_xvalue(Fl_Widget* o, double v) { + ((Fl_Positioner*)o)->xvalue(v);} +inline double fl_get_positioner_xvalue(Fl_Widget* o) { + return ((Fl_Positioner*)o)->xvalue();} +inline void fl_set_positioner_xbounds(Fl_Widget* o, double a, double b) { + ((Fl_Positioner*)o)->xbounds(a,b);} +inline void fl_get_positioner_xbounds(Fl_Widget* o, float* a, float* b) { + *a = float(((Fl_Positioner*)o)->xminimum()); + *b = float(((Fl_Positioner*)o)->xmaximum()); +} +inline void fl_set_positioner_yvalue(Fl_Widget* o, double v) { + ((Fl_Positioner*)o)->yvalue(v);} +inline double fl_get_positioner_yvalue(Fl_Widget* o) { + return ((Fl_Positioner*)o)->yvalue();} +inline void fl_set_positioner_ybounds(Fl_Widget* o, double a, double b) { + ((Fl_Positioner*)o)->ybounds(a,b);} +inline void fl_get_positioner_ybounds(Fl_Widget* o, float* a, float* b) { + *a = float(((Fl_Positioner*)o)->yminimum()); + *b = float(((Fl_Positioner*)o)->ymaximum()); +} +inline void fl_set_positioner_xstep(Fl_Widget* o, double v) { + ((Fl_Positioner*)o)->xstep(v);} +inline void fl_set_positioner_ystep(Fl_Widget* o, double v) { + ((Fl_Positioner*)o)->ystep(v);} +inline void fl_set_positioner_return(Fl_Widget* o, int v) { + ((Fl_Positioner*)o)->when((Fl_When)(v|FL_WHEN_RELEASE));} + +#include "Fl_Slider.H" + +#define FL_HOR_BROWSER_SLIDER FL_HOR_SLIDER +#define FL_VERT_BROWSER_SLIDER FL_VERT_SLIDER + +forms_constructort(Fl_Slider, fl_add_slider) +#define FL_SLIDER_COL1 FL_GRAY +inline void fl_set_slider_value(Fl_Widget* o, double v) { + ((Fl_Slider*)o)->value(v);} +inline double fl_get_slider_value(Fl_Widget* o) { + return ((Fl_Slider*)o)->value();} +inline void fl_set_slider_bounds(Fl_Widget* o, double a, double b) { + ((Fl_Slider*)o)->bounds(a, b);} +inline void fl_get_slider_bounds(Fl_Widget* o, float* a, float* b) { + *a = float(((Fl_Slider*)o)->minimum()); + *b = float(((Fl_Slider*)o)->maximum()); +} +inline void fl_set_slider_return(Fl_Widget* o, int i) { + ((Fl_Slider*)o)->when((Fl_When)(i|FL_WHEN_RELEASE));} +inline void fl_set_slider_step(Fl_Widget* o, double v) { + ((Fl_Slider*)o)->step(v);} +// inline void fl_set_slider_increment(Fl_Widget* o, double v, double); +inline void fl_set_slider_size(Fl_Widget* o, double v) { + ((Fl_Slider*)o)->slider_size(v);} + +#include "Fl_Value_Slider.H" +forms_constructor(Fl_Value_Slider, fl_add_valslider) + +inline void fl_set_slider_precision(Fl_Widget* o, int i) { + ((Fl_Value_Slider*)o)->precision(i);} +// filter function! + +// The forms text object was the same as an Fl_Box except it inverted the +// meaning of FL_ALIGN_INSIDE. Implementation in forms.cxx +class FL_EXPORT Fl_FormsText : public Fl_Widget { +protected: + void draw(); +public: + Fl_FormsText(Fl_Boxtype b, int X, int Y, int W, int H, const char* l=0) + : Fl_Widget(X,Y,W,H,l) {box(b); align(FL_ALIGN_LEFT);} +}; +#define FL_NORMAL_TEXT FL_NO_BOX +forms_constructorb(Fl_FormsText, fl_add_text) + +#include "Fl_Timer.H" +forms_constructort(Fl_Timer, fl_add_timer) +inline void fl_set_timer(Fl_Widget* o, double v) {((Fl_Timer*)o)->value(v);} +inline double fl_get_timer(Fl_Widget* o) {return ((Fl_Timer*)o)->value();} +inline void fl_suspend_timer(Fl_Widget* o) {((Fl_Timer*)o)->suspended(1);} +inline void fl_resume_timer(Fl_Widget* o) {((Fl_Timer*)o)->suspended(0);} +inline void fl_set_timer_countup(Fl_Widget* o,char d) {((Fl_Timer*)o)->direction(d);} +void fl_gettime(long* sec, long* usec); + +// Fl_XYPlot nyi + + +// stuff from DDForms: + +inline int fl_double_click() {return Fl::event_clicks();} +inline void fl_draw() {Fl::flush();} + +#endif /* define __FORMS_H__ */ + +// +// End of "$Id: forms.H 8623 2011-04-24 17:09:41Z AlbrechtS $". +// diff --git a/common/fltk/FL/gl.h b/common/fltk/FL/gl.h new file mode 100644 index 00000000..ecf37a48 --- /dev/null +++ b/common/fltk/FL/gl.h @@ -0,0 +1,112 @@ +// +// "$Id: gl.h 8623 2011-04-24 17:09:41Z AlbrechtS $" +// +// OpenGL header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// You must include this instead of GL/gl.h to get the Microsoft +// APIENTRY stuff included (from <windows.h>) prior to the OpenGL +// header files. +// +// This file also provides "missing" OpenGL functions, and +// gl_start() and gl_finish() to allow OpenGL to be used in any window +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +/** \file gl.h + * This file defines wrapper functions for OpenGL in FLTK + * + * To use OpenGL from within an FLTK application you MUST use gl_visual() + * to select the default visual before doing show() on any windows. Mesa + * will crash if yoy try to use a visual not returned by glxChooseVidual. + * + * This does not work with Fl_Double_Window's! It will try to draw + * into the front buffer. Depending on the system this will either + * crash or do nothing (when pixmaps are being used as back buffer + * and GL is being done by hardware), work correctly (when GL is done + * with software, such as Mesa), or draw into the front buffer and + * be erased when the buffers are swapped (when double buffer hardware + * is being used) + */ + +#ifndef FL_gl_H +# define FL_gl_H + +# include "Enumerations.H" // for color names +# ifdef WIN32 +# include <windows.h> +# endif +# ifndef APIENTRY +# if defined(__CYGWIN__) +# define APIENTRY __attribute__ ((__stdcall__)) +# else +# define APIENTRY +# endif +# endif + +# ifdef __APPLE__ +# include <OpenGL/gl.h> +# else +# include <GL/gl.h> +# endif + +FL_EXPORT void gl_start(); +FL_EXPORT void gl_finish(); + +FL_EXPORT void gl_color(Fl_Color i); +/** back compatibility */ +inline void gl_color(int c) {gl_color((Fl_Color)c);} + +FL_EXPORT void gl_rect(int x,int y,int w,int h); +/** + Fills the given rectangle with the current color. + \see gl_rect(int x, int y, int w, int h) + */ +inline void gl_rectf(int x,int y,int w,int h) {glRecti(x,y,x+w,y+h);} + +FL_EXPORT void gl_font(int fontid, int size); +FL_EXPORT int gl_height(); +FL_EXPORT int gl_descent(); +FL_EXPORT double gl_width(const char *); +FL_EXPORT double gl_width(const char *, int n); +FL_EXPORT double gl_width(uchar); + +FL_EXPORT void gl_draw(const char*); +FL_EXPORT void gl_draw(const char*, int n); +FL_EXPORT void gl_draw(const char*, int x, int y); +FL_EXPORT void gl_draw(const char*, float x, float y); +FL_EXPORT void gl_draw(const char*, int n, int x, int y); +FL_EXPORT void gl_draw(const char*, int n, float x, float y); +FL_EXPORT void gl_draw(const char*, int x, int y, int w, int h, Fl_Align); +FL_EXPORT void gl_measure(const char*, int& x, int& y); +#ifdef __APPLE__ +extern FL_EXPORT void gl_texture_pile_height(int max); +extern FL_EXPORT int gl_texture_pile_height(); +#endif + +FL_EXPORT void gl_draw_image(const uchar *, int x,int y,int w,int h, int d=3, int ld=0); + +#endif // !FL_gl_H + +// +// End of "$Id: gl.h 8623 2011-04-24 17:09:41Z AlbrechtS $". +// diff --git a/common/fltk/FL/gl2opengl.h b/common/fltk/FL/gl2opengl.h new file mode 100644 index 00000000..b89614e0 --- /dev/null +++ b/common/fltk/FL/gl2opengl.h @@ -0,0 +1,35 @@ +/* gl.h + + GL to OpenGL translator. + If you include this, you might be able to port old GL programs. + There are also much better emulators available on the net. + +*/ + +#include <FL/gl.h> +#include "gl_draw.H" + +inline void clear() {glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);} +#define RGBcolor(r,g,b) glColor3ub(r,g,b) +#define bgnline() glBegin(GL_LINE_STRIP) +#define bgnpolygon() glBegin(GL_POLYGON) +#define bgnclosedline() glBegin(GL_LINE_LOOP) +#define endline() glEnd() +#define endpolygon() glEnd() +#define endclosedline() glEnd() +#define v2f(v) glVertex2fv(v) +#define v2s(v) glVertex2sv(v) +#define cmov(x,y,z) glRasterPos3f(x,y,z) +#define charstr(s) gl_draw(s) +#define fmprstr(s) gl_draw(s) +typedef float Matrix[4][4]; +inline void pushmatrix() {glPushMatrix();} +inline void popmatrix() {glPopMatrix();} +inline void multmatrix(Matrix m) {glMultMatrixf((float *)m);} +inline void color(int n) {glIndexi(n);} +inline void rect(int x,int y,int r,int t) {gl_rect(x,y,r-x,t-y);} +inline void rectf(int x,int y,int r,int t) {glRectf(x,y,r+1,t+1);} +inline void recti(int x,int y,int r,int t) {gl_rect(x,y,r-x,t-y);} +inline void rectfi(int x,int y,int r,int t) {glRecti(x,y,r+1,t+1);} +inline void rects(int x,int y,int r,int t) {gl_rect(x,y,r-x,t-y);} +inline void rectfs(int x,int y,int r,int t) {glRects(x,y,r+1,t+1);} diff --git a/common/fltk/FL/gl_draw.H b/common/fltk/FL/gl_draw.H new file mode 100644 index 00000000..ad0f819b --- /dev/null +++ b/common/fltk/FL/gl_draw.H @@ -0,0 +1,35 @@ +// +// "$Id: gl_draw.H 7903 2010-11-28 21:06:39Z matt $" +// +// OpenGL header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#include "gl.h" + +extern FL_EXPORT void gl_remove_displaylist_fonts(); + + +// +// End of "$Id: gl_draw.H 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/glu.h b/common/fltk/FL/glu.h new file mode 100644 index 00000000..9156198d --- /dev/null +++ b/common/fltk/FL/glu.h @@ -0,0 +1,60 @@ +// +// "$Id: glu.h 7903 2010-11-28 21:06:39Z matt $" +// +// GLu header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// You must include this instead of GL/gl.h to get the Microsoft +// APIENTRY stuff included (from <windows.h>) prior to the OpenGL +// header files. +// +// This file also provides "missing" OpenGL functions, and +// gl_start() and gl_finish() to allow OpenGL to be used in any window +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +#ifndef FL_glu_H +# define FL_glu_H + +# include "Enumerations.H" // for color names +# ifdef WIN32 +# include <windows.h> +# endif +# ifndef APIENTRY +# if defined(__CYGWIN__) +# define APIENTRY __attribute__ ((__stdcall__)) +# else +# define APIENTRY +# endif +# endif + +# ifdef __APPLE__ +# include <OpenGL/glu.h> +# else +# include <GL/glu.h> +# endif + +#endif // !FL_glu_H + +// +// End of "$Id: glu.h 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/glut.H b/common/fltk/FL/glut.H new file mode 100644 index 00000000..98674871 --- /dev/null +++ b/common/fltk/FL/glut.H @@ -0,0 +1,491 @@ +// +// "$Id: glut.H 8623 2011-04-24 17:09:41Z AlbrechtS $" +// +// GLUT emulation header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// Emulation of GLUT using fltk. + +// GLUT is Copyright (c) Mark J. Kilgard, 1994, 1995, 1996: +// "This program is freely distributable without licensing fees and is +// provided without guarantee or warrantee expressed or implied. This +// program is -not- in the public domain." + +// Although I have copied the GLUT API, none of my code is based on +// any GLUT implementation details and is therefore covered by the LGPL. + +// Commented out lines indicate parts of GLUT that are not emulated. + +#ifndef Fl_glut_H +# define Fl_glut_H + +# include "gl.h" + + +# include "Fl.H" +# include "Fl_Gl_Window.H" + +/** + GLUT is emulated using this window class and these static variables + (plus several more static variables hidden in glut_compatability.cxx): +*/ +class FL_EXPORT Fl_Glut_Window : public Fl_Gl_Window { + void _init(); + int mouse_down; +protected: + void draw(); + void draw_overlay(); + int handle(int); +public: // so the inline functions work + int number; + int menu[3]; + void make_current(); + void (*display)(); + void (*overlaydisplay)(); + void (*reshape)(int w, int h); + void (*keyboard)(uchar, int x, int y); + void (*mouse)(int b, int state, int x, int y); + void (*motion)(int x, int y); + void (*passivemotion)(int x, int y); + void (*entry)(int); + void (*visibility)(int); + void (*special)(int, int x, int y); + Fl_Glut_Window(int w, int h, const char *); + Fl_Glut_Window(int x, int y, int w, int h, const char *); + ~Fl_Glut_Window(); +}; + +extern FL_EXPORT Fl_Glut_Window *glut_window; // the current window +extern FL_EXPORT int glut_menu; // the current menu + +// function pointers that are not per-window: +extern FL_EXPORT void (*glut_idle_function)(); +extern FL_EXPORT void (*glut_menustate_function)(int); +extern FL_EXPORT void (*glut_menustatus_function)(int,int,int); + +//////////////////////////////////////////////////////////////// + +//# define GLUT_API_VERSION This does not match any version of GLUT exactly... + +FL_EXPORT void glutInit(int *argcp, char **argv); // creates first window + +FL_EXPORT void glutInitDisplayMode(unsigned int mode); +// the FL_ symbols have the same value as the GLUT ones: +# define GLUT_RGB FL_RGB +# define GLUT_RGBA FL_RGB +# define GLUT_INDEX FL_INDEX +# define GLUT_SINGLE FL_SINGLE +# define GLUT_DOUBLE FL_DOUBLE +# define GLUT_ACCUM FL_ACCUM +# define GLUT_ALPHA FL_ALPHA +# define GLUT_DEPTH FL_DEPTH +# define GLUT_STENCIL FL_STENCIL +# define GLUT_MULTISAMPLE FL_MULTISAMPLE +# define GLUT_STEREO FL_STEREO +// # define GLUT_LUMINANCE 512 + +FL_EXPORT void glutInitWindowPosition(int x, int y); + +FL_EXPORT void glutInitWindowSize(int w, int h); + +FL_EXPORT void glutMainLoop(); + +FL_EXPORT int glutCreateWindow(char *title); +FL_EXPORT int glutCreateWindow(const char *title); + +FL_EXPORT int glutCreateSubWindow(int win, int x, int y, int width, int height); + +FL_EXPORT void glutDestroyWindow(int win); + +inline void glutPostRedisplay() {glut_window->redraw();} + +FL_EXPORT void glutPostWindowRedisplay(int win); + +FL_EXPORT void glutSwapBuffers(); + +inline int glutGetWindow() {return glut_window->number;} + +FL_EXPORT void glutSetWindow(int win); + +inline void glutSetWindowTitle(char *t) {glut_window->label(t);} + +inline void glutSetIconTitle(char *t) {glut_window->iconlabel(t);} + +inline void glutPositionWindow(int x, int y) {glut_window->position(x,y);} + +inline void glutReshapeWindow(int w, int h) {glut_window->size(w,h);} + +inline void glutPopWindow() {glut_window->show();} + +inline void glutPushWindow() { /* do nothing */ } + +inline void glutIconifyWindow() {glut_window->iconize();} + +inline void glutShowWindow() {glut_window->show();} + +inline void glutHideWindow() {glut_window->hide();} + +inline void glutFullScreen() {glut_window->fullscreen();} + +inline void glutSetCursor(Fl_Cursor cursor) {glut_window->cursor(cursor);} +// notice that the numeric values are different than glut: +# define GLUT_CURSOR_RIGHT_ARROW ((Fl_Cursor)2) +# define GLUT_CURSOR_LEFT_ARROW ((Fl_Cursor)67) +# define GLUT_CURSOR_INFO FL_CURSOR_HAND +# define GLUT_CURSOR_DESTROY ((Fl_Cursor)45) +# define GLUT_CURSOR_HELP FL_CURSOR_HELP +# define GLUT_CURSOR_CYCLE ((Fl_Cursor)26) +# define GLUT_CURSOR_SPRAY ((Fl_Cursor)63) +# define GLUT_CURSOR_WAIT FL_CURSOR_WAIT +# define GLUT_CURSOR_TEXT FL_CURSOR_INSERT +# define GLUT_CURSOR_CROSSHAIR FL_CURSOR_CROSS +# define GLUT_CURSOR_UP_DOWN FL_CURSOR_NS +# define GLUT_CURSOR_LEFT_RIGHT FL_CURSOR_WE +# define GLUT_CURSOR_TOP_SIDE FL_CURSOR_N +# define GLUT_CURSOR_BOTTOM_SIDE FL_CURSOR_S +# define GLUT_CURSOR_LEFT_SIDE FL_CURSOR_W +# define GLUT_CURSOR_RIGHT_SIDE FL_CURSOR_E +# define GLUT_CURSOR_TOP_LEFT_CORNER FL_CURSOR_NW +# define GLUT_CURSOR_TOP_RIGHT_CORNER FL_CURSOR_NE +# define GLUT_CURSOR_BOTTOM_RIGHT_CORNER FL_CURSOR_SE +# define GLUT_CURSOR_BOTTOM_LEFT_CORNER FL_CURSOR_SW +# define GLUT_CURSOR_INHERIT FL_CURSOR_DEFAULT +# define GLUT_CURSOR_NONE FL_CURSOR_NONE +# define GLUT_CURSOR_FULL_CROSSHAIR FL_CURSOR_CROSS + +inline void glutWarpPointer(int, int) { /* do nothing */ } + +inline void glutEstablishOverlay() {glut_window->make_overlay_current();} + +inline void glutRemoveOverlay() {glut_window->hide_overlay();} + +inline void glutUseLayer(GLenum layer) { + layer ? glut_window->make_overlay_current() : glut_window->make_current();} +enum {GLUT_NORMAL, GLUT_OVERLAY}; + +inline void glutPostOverlayRedisplay() {glut_window->redraw_overlay();} + +inline void glutShowOverlay() {glut_window->redraw_overlay();} + +inline void glutHideOverlay() {glut_window->hide_overlay();} + +FL_EXPORT int glutCreateMenu(void (*)(int)); + +FL_EXPORT void glutDestroyMenu(int menu); + +inline int glutGetMenu() {return glut_menu;} + +inline void glutSetMenu(int m) {glut_menu = m;} + +FL_EXPORT void glutAddMenuEntry(char *label, int value); + +FL_EXPORT void glutAddSubMenu(char *label, int submenu); + +FL_EXPORT void glutChangeToMenuEntry(int item, char *labela, int value); + +FL_EXPORT void glutChangeToSubMenu(int item, char *label, int submenu); + +FL_EXPORT void glutRemoveMenuItem(int item); + +inline void glutAttachMenu(int b) {glut_window->menu[b] = glut_menu;} + +inline void glutDetachMenu(int b) {glut_window->menu[b] = 0;} + +inline void glutDisplayFunc(void (*f)()) {glut_window->display = f;} + +inline void glutReshapeFunc(void (*f)(int w, int h)) {glut_window->reshape=f;} + +inline void glutKeyboardFunc(void (*f)(uchar key, int x, int y)) { + glut_window->keyboard = f;} + +inline void glutMouseFunc(void (*f)(int b, int state, int x, int y)) { + glut_window->mouse = f;} +# define GLUT_LEFT_BUTTON 0 +# define GLUT_MIDDLE_BUTTON 1 +# define GLUT_RIGHT_BUTTON 2 +# define GLUT_DOWN 0 +# define GLUT_UP 1 + +inline void glutMotionFunc(void (*f)(int x, int y)) {glut_window->motion= f;} + +inline void glutPassiveMotionFunc(void (*f)(int x, int y)) { + glut_window->passivemotion= f;} + +inline void glutEntryFunc(void (*f)(int s)) {glut_window->entry = f;} +enum {GLUT_LEFT, GLUT_ENTERED}; + +inline void glutVisibilityFunc(void (*f)(int s)) {glut_window->visibility=f;} +enum {GLUT_NOT_VISIBLE, GLUT_VISIBLE}; + +FL_EXPORT void glutIdleFunc(void (*f)()); + +// Warning: this cast may not work on all machines: +inline void glutTimerFunc(unsigned int msec, void (*f)(int), int value) { + Fl::add_timeout(msec*.001, (void (*)(void *))f, (void *)value); +} + +inline void glutMenuStateFunc(void (*f)(int state)) { + glut_menustate_function = f;} + +inline void glutMenuStatusFunc(void (*f)(int status, int x, int y)) { + glut_menustatus_function = f;} +enum {GLUT_MENU_NOT_IN_USE, GLUT_MENU_IN_USE}; + +inline void glutSpecialFunc(void (*f)(int key, int x, int y)) { + glut_window->special = f;} +# define GLUT_KEY_F1 1 +# define GLUT_KEY_F2 2 +# define GLUT_KEY_F3 3 +# define GLUT_KEY_F4 4 +# define GLUT_KEY_F5 5 +# define GLUT_KEY_F6 6 +# define GLUT_KEY_F7 7 +# define GLUT_KEY_F8 8 +# define GLUT_KEY_F9 9 +# define GLUT_KEY_F10 10 +# define GLUT_KEY_F11 11 +# define GLUT_KEY_F12 12 +// WARNING: Different values than GLUT uses: +# define GLUT_KEY_LEFT FL_Left +# define GLUT_KEY_UP FL_Up +# define GLUT_KEY_RIGHT FL_Right +# define GLUT_KEY_DOWN FL_Down +# define GLUT_KEY_PAGE_UP FL_Page_Up +# define GLUT_KEY_PAGE_DOWN FL_Page_Down +# define GLUT_KEY_HOME FL_Home +# define GLUT_KEY_END FL_End +# define GLUT_KEY_INSERT FL_Insert + +//inline void glutSpaceballMotionFunc(void (*)(int x, int y, int z)); + +//inline void glutSpaceballRotateFunc(void (*)(int x, int y, int z)); + +//inline void glutSpaceballButtonFunc(void (*)(int button, int state)); + +//inline void glutButtonBoxFunc(void (*)(int button, int state)); + +//inline void glutDialsFunc(void (*)(int dial, int value)); + +//inline void glutTabletMotionFunc(void (*)(int x, int y)); + +//inline void glutTabletButtonFunc(void (*)(int button, int state, int x, int y)); + +inline void glutOverlayDisplayFunc(void (*f)()) { + glut_window->overlaydisplay = f;} + +//inline void glutWindowStatusFunc(void (*)(int state)); +//enum {GLUT_HIDDEN, GLUT_FULLY_RETAINED, GLUT_PARTIALLY_RETAINED, +// GLUT_FULLY_COVERED}; + +//inline void glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue); + +//inline GLfloat glutGetColor(int ndx, int component); +//#define GLUT_RED 0 +//#define GLUT_GREEN 1 +//#define GLUT_BLUE 2 + +//inline void glutCopyColormap(int win); + +// Warning: values are changed from GLUT! +// Also relies on the GL_ symbols having values greater than 100 +FL_EXPORT int glutGet(GLenum type); +enum { + GLUT_RETURN_ZERO = 0, + GLUT_WINDOW_X, + GLUT_WINDOW_Y, + GLUT_WINDOW_WIDTH, + GLUT_WINDOW_HEIGHT, + GLUT_WINDOW_PARENT, + GLUT_SCREEN_WIDTH, + GLUT_SCREEN_HEIGHT, + GLUT_MENU_NUM_ITEMS, + GLUT_DISPLAY_MODE_POSSIBLE, + GLUT_INIT_WINDOW_X, + GLUT_INIT_WINDOW_Y, + GLUT_INIT_WINDOW_WIDTH, + GLUT_INIT_WINDOW_HEIGHT, + GLUT_INIT_DISPLAY_MODE, + GLUT_WINDOW_BUFFER_SIZE, + GLUT_VERSION +//GLUT_WINDOW_NUM_CHILDREN, +//GLUT_WINDOW_CURSOR, +//GLUT_SCREEN_WIDTH_MM, +//GLUT_SCREEN_HEIGHT_MM, +//GLUT_ELAPSED_TIME, +}; + +# define GLUT_WINDOW_STENCIL_SIZE GL_STENCIL_BITS +# define GLUT_WINDOW_DEPTH_SIZE GL_DEPTH_BITS +# define GLUT_WINDOW_RED_SIZE GL_RED_BITS +# define GLUT_WINDOW_GREEN_SIZE GL_GREEN_BITS +# define GLUT_WINDOW_BLUE_SIZE GL_BLUE_BITS +# define GLUT_WINDOW_ALPHA_SIZE GL_ALPHA_BITS +# define GLUT_WINDOW_ACCUM_RED_SIZE GL_ACCUM_RED_BITS +# define GLUT_WINDOW_ACCUM_GREEN_SIZE GL_ACCUM_GREEN_BITS +# define GLUT_WINDOW_ACCUM_BLUE_SIZE GL_ACCUM_BLUE_BITS +# define GLUT_WINDOW_ACCUM_ALPHA_SIZE GL_ACCUM_ALPHA_BITS +# define GLUT_WINDOW_DOUBLEBUFFER GL_DOUBLEBUFFER +# define GLUT_WINDOW_RGBA GL_RGBA +# define GLUT_WINDOW_COLORMAP_SIZE GL_INDEX_BITS +# ifdef GL_SAMPLES_SGIS +# define GLUT_WINDOW_NUM_SAMPLES GL_SAMPLES_SGIS +# else +# define GLUT_WINDOW_NUM_SAMPLES GLUT_RETURN_ZERO +# endif +# define GLUT_WINDOW_STEREO GL_STEREO + +# define GLUT_HAS_KEYBOARD 600 +# define GLUT_HAS_MOUSE 601 +# define GLUT_HAS_SPACEBALL 602 +# define GLUT_HAS_DIAL_AND_BUTTON_BOX 603 +# define GLUT_HAS_TABLET 604 +# define GLUT_NUM_MOUSE_BUTTONS 605 +# define GLUT_NUM_SPACEBALL_BUTTONS 606 +# define GLUT_NUM_BUTTON_BOX_BUTTONS 607 +# define GLUT_NUM_DIALS 608 +# define GLUT_NUM_TABLET_BUTTONS 609 +FL_EXPORT int glutDeviceGet(GLenum type); + +// WARNING: these values are different than GLUT uses: +# define GLUT_ACTIVE_SHIFT FL_SHIFT +# define GLUT_ACTIVE_CTRL FL_CTRL +# define GLUT_ACTIVE_ALT FL_ALT +inline int glutGetModifiers() {return Fl::event_state() & (GLUT_ACTIVE_SHIFT | GLUT_ACTIVE_CTRL | GLUT_ACTIVE_ALT);} + +FL_EXPORT int glutLayerGet(GLenum); +# define GLUT_OVERLAY_POSSIBLE 800 +//#define GLUT_LAYER_IN_USE 801 +//#define GLUT_HAS_OVERLAY 802 +# define GLUT_TRANSPARENT_INDEX 803 +# define GLUT_NORMAL_DAMAGED 804 +# define GLUT_OVERLAY_DAMAGED 805 + +extern "C" { +typedef void (*GLUTproc)(); +} + +FL_EXPORT GLUTproc glutGetProcAddress(const char *procName); + +//inline int glutVideoResizeGet(GLenum param); +//#define GLUT_VIDEO_RESIZE_POSSIBLE 900 +//#define GLUT_VIDEO_RESIZE_IN_USE 901 +//#define GLUT_VIDEO_RESIZE_X_DELTA 902 +//#define GLUT_VIDEO_RESIZE_Y_DELTA 903 +//#define GLUT_VIDEO_RESIZE_WIDTH_DELTA 904 +//#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 905 +//#define GLUT_VIDEO_RESIZE_X 906 +//#define GLUT_VIDEO_RESIZE_Y 907 +//#define GLUT_VIDEO_RESIZE_WIDTH 908 +//#define GLUT_VIDEO_RESIZE_HEIGHT 909 + +//inline void glutSetupVideoResizing(); + +//inline void glutStopVideoResizing(); + +//inline void glutVideoResize(int x, int y, int width, int height); + +//inline void glutVideoPan(int x, int y, int width, int height); + +// Font argument must be a void* for compatibility, so... +/** fltk glut font/size attributes used in the glutXXX functions */ +struct Fl_Glut_Bitmap_Font {Fl_Font font; Fl_Fontsize size;}; + +extern FL_EXPORT struct Fl_Glut_Bitmap_Font + glutBitmap9By15, glutBitmap8By13, glutBitmapTimesRoman10, + glutBitmapTimesRoman24, glutBitmapHelvetica10, glutBitmapHelvetica12, + glutBitmapHelvetica18; +# define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15) +# define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13) +# define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10) +# define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24) +# define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10) +# define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12) +# define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18) + +FL_EXPORT void glutBitmapCharacter(void *font, int character); +FL_EXPORT int glutBitmapHeight(void *font); +FL_EXPORT int glutBitmapLength(void *font, const unsigned char *string); +FL_EXPORT void glutBitmapString(void *font, const unsigned char *string); +FL_EXPORT int glutBitmapWidth(void *font, int character); + +FL_EXPORT int glutExtensionSupported(char *name); + +/* GLUT stroked font sub-API */ +struct Fl_Glut_StrokeVertex { + GLfloat X, Y; +}; + +struct Fl_Glut_StrokeStrip { + int Number; + const Fl_Glut_StrokeVertex* Vertices; +}; + +struct Fl_Glut_StrokeChar { + GLfloat Right; + int Number; + const Fl_Glut_StrokeStrip* Strips; +}; + +struct Fl_Glut_StrokeFont { + char* Name; // The source font name + int Quantity; // Number of chars in font + GLfloat Height; // Height of the characters + const Fl_Glut_StrokeChar** Characters;// The characters mapping +}; +extern FL_EXPORT Fl_Glut_StrokeFont glutStrokeRoman; +extern FL_EXPORT Fl_Glut_StrokeFont glutStrokeMonoRoman; +# define GLUT_STROKE_ROMAN (&glutStrokeRoman) +# define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman) + +FL_EXPORT void glutStrokeCharacter(void *font, int character); +FL_EXPORT GLfloat glutStrokeHeight(void *font); +FL_EXPORT int glutStrokeLength(void *font, const unsigned char *string); +FL_EXPORT void glutStrokeString(void *font, const unsigned char *string); +FL_EXPORT int glutStrokeWidth(void *font, int character); + +/* GLUT pre-built models sub-API */ +FL_EXPORT void glutWireSphere(GLdouble radius, GLint slices, GLint stacks); +FL_EXPORT void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks); +FL_EXPORT void glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); +FL_EXPORT void glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks); +FL_EXPORT void glutWireCube(GLdouble size); +FL_EXPORT void glutSolidCube(GLdouble size); +FL_EXPORT void glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); +FL_EXPORT void glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings); +FL_EXPORT void glutWireDodecahedron(); +FL_EXPORT void glutSolidDodecahedron(); +FL_EXPORT void glutWireTeapot(GLdouble size); +FL_EXPORT void glutSolidTeapot(GLdouble size); +FL_EXPORT void glutWireOctahedron(); +FL_EXPORT void glutSolidOctahedron(); +FL_EXPORT void glutWireTetrahedron(); +FL_EXPORT void glutSolidTetrahedron(); +FL_EXPORT void glutWireIcosahedron(); +FL_EXPORT void glutSolidIcosahedron(); + +#endif // !Fl_glut_H + +// +// End of "$Id: glut.H 8623 2011-04-24 17:09:41Z AlbrechtS $". +// diff --git a/common/fltk/FL/mac.H b/common/fltk/FL/mac.H new file mode 100644 index 00000000..704f521d --- /dev/null +++ b/common/fltk/FL/mac.H @@ -0,0 +1,237 @@ +// +// "$Id: mac.H 8657 2011-05-12 11:50:43Z manolo $" +// +// Mac header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// Do not directly include this file, instead use <FL/x.H>. It will +// include this file if "__APPLE__" is defined. This is to encourage +// portability of even the system-specific code... +#ifndef FL_DOXYGEN + +#if !defined(Fl_X_H) +# error "Never use <FL/mac.H> directly; include <FL/x.H> instead." +#endif // !Fl_X_H +#include <FL/Fl_Widget.H> + +typedef void* Window; // this is really a pointer to the subclass FLWindow of NSWindow +typedef void* Fl_Offscreen; // this is really a CGContextRef +typedef void* Fl_Bitmask; // this is really a CGImageRef + +#include <AvailabilityMacros.h> +#ifndef MAC_OS_X_VERSION_10_3 +#define MAC_OS_X_VERSION_10_3 1030 +#endif +#ifndef MAC_OS_X_VERSION_10_4 +#define MAC_OS_X_VERSION_10_4 1040 +#endif +#ifndef MAC_OS_X_VERSION_10_5 +#define MAC_OS_X_VERSION_10_5 1050 +#endif +#ifndef MAC_OS_X_VERSION_10_6 +#define MAC_OS_X_VERSION_10_6 1060 +#endif + +#if !(defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part is used when compiling an application program + +typedef void* Fl_Region; +typedef void* Fl_CGContextRef; +typedef void* Fl_PMPrintSettings; +typedef void* Fl_PMPageFormat; +typedef void* Fl_PMPrintSession; + +#else // this part must be compiled when building the FLTK libraries + +// Standard MacOS C/C++ includes... +#include <ApplicationServices/ApplicationServices.h> +#undef check // because of Fl::check() + +typedef CGContextRef Fl_CGContextRef; +typedef PMPrintSettings Fl_PMPrintSettings; +typedef PMPageFormat Fl_PMPageFormat; +typedef PMPrintSession Fl_PMPrintSession; + +typedef struct flCocoaRegion { + int count; + CGRect *rects; +} *Fl_Region; // a region is the union of a series of rectangles + +# include "Fl_Window.H" + +// Some random X equivalents +struct XPoint { int x, y; }; +struct XRectangle {int x, y, width, height;}; +#ifndef CGFLOAT_DEFINED //appears with 10.5 in CGBase.h +#if defined(__LP64__) && __LP64__ +typedef double CGFloat; +#else +typedef float CGFloat; +#endif +#endif // CGFLOAT_DEFINED + +extern CGRect fl_cgrectmake_cocoa(int x, int y, int w, int h); +inline Fl_Region XRectangleRegion(int x, int y, int w, int h) { + Fl_Region R = (Fl_Region)malloc(sizeof(*R)); + R->count = 1; + R->rects = (CGRect *)malloc(sizeof(CGRect)); + *(R->rects) = fl_cgrectmake_cocoa(x, y, w, h); + return R; +} +inline void XDestroyRegion(Fl_Region r) { + if(r) { + free(r->rects); + free(r); + } +} +extern void *fl_system_menu; +extern void *fl_default_cursor; + +// This object contains all mac-specific stuff about a window: +// WARNING: this object is highly subject to change! +class Fl_X { + +public: + Window xid; // pointer to the Cocoa window object (FLWindow*) + Fl_Offscreen other_xid; // pointer for offscreen bitmaps (overlay window) + Fl_Window *w; // FLTK window for + Fl_Region region; + Fl_Region subRegion; // region for this specific subwindow + Fl_X *next; // linked tree to support subwindows + Fl_X *xidChildren, *xidNext; // more subwindow tree + int wait_for_expose; + void *cursor; // is really NSCursor* + static Fl_X* first; + static Fl_X* i(const Fl_Window* w) {return w->i;} + static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&); + static void make(Fl_Window*); + void flush(); + // Quartz additions: + CGContextRef gc; // graphics context (NULL when using QD) + static void q_fill_context(); // fill a Quartz context with current FLTK state + static void q_clear_clipping(); // remove all clipping from a Quartz context + static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc + static void q_begin_image(CGRect&, int x, int y, int w, int h); + static void q_end_image(); + // Cocoa additions + void destroy(void); + void map(void); + void unmap(void); + int unlink(Fl_X* start = NULL); + void collapse(void); + WindowRef window_ref(void); + void set_key_window(void); + void set_cursor(Fl_Cursor); + static CGImageRef CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, int h); + static unsigned char *bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel); + static Fl_Region intersect_region_and_rect(Fl_Region current, int x,int y,int w, int h); + static CGContextRef watch_cursor_image(void); + static CGContextRef help_cursor_image(void); + static CGContextRef nesw_cursor_image(void); + static CGContextRef nwse_cursor_image(void); + static CGContextRef none_cursor_image(void); + static void *get_carbon_function(const char *name); +private: + static void relink(Fl_Window*, Fl_Window*); + bool subwindow; +}; + +extern struct Fl_XMap { + RGBColor rgb; + ulong pen; +} *fl_current_xmap; +extern FL_EXPORT Window fl_window; + +#endif // FL_LIBRARY || FL_INTERNALS + +extern FL_EXPORT Fl_CGContextRef fl_gc; +extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar; + +extern Window fl_xid(const Fl_Window*); +void fl_clip_region(Fl_Region); + +extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); +extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data); +extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); +extern Fl_Offscreen fl_create_offscreen(int w, int h); +extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy); +extern void fl_delete_offscreen(Fl_Offscreen gWorld); +extern void fl_begin_offscreen(Fl_Offscreen gWorld); +extern void fl_end_offscreen(); + +extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); +extern void fl_open_display(); + +#endif // FL_DOXYGEN + +/** \defgroup group_macosx Mac OS X-specific symbols + Mac OS X-specific symbols declared in <FL/x.H> or <FL/gl.h> + @{ */ + +/** @brief Register a function called for each file dropped onto an application icon. + \e cb will be called with a single Unix-style file name and path. + If multiple files were dropped, \e cb will be called multiple times. + */ +extern void fl_open_callback(void (*cb)(const char *)); + +/** + * \brief Attaches a callback to the "About myprog" item of the system application menu. + * + * \param cb a callback that will be called by "About myprog" menu item + * with NULL 1st argument. + * \param user_data a pointer transmitted as 2nd argument to the callback. + * \param shortcut optional shortcut to attach to the "About myprog" menu item (e.g., FL_META+'a') + */ +extern void fl_mac_set_about( Fl_Callback *cb, void *user_data, int shortcut = 0); + +/** \brief The version number of the running Mac OS X (e.g., 100604 for 10.6.4) + */ +extern int fl_mac_os_version; + +class Fl_Mac_App_Menu { +public: + /** Localizable text for the "About xxx" application menu item */ + static const char *about; + /** Localizable text for the "Print Front Window" application menu item. + This menu item won't be displayed if Fl_Mac_App_Menu::print + is set to an empty string. + */ + static const char *print; + /** Localizable text for the "Services" application menu item */ + static const char *services; + /** Localizable text for the "Hide xxx" application menu item */ + static const char *hide; + /** Localizable text for the "Hide Others" application menu item */ + static const char *hide_others; + /** Localizable text for the "Show All" application menu item */ + static const char *show; + /** Localizable text for the "Quit xxx" application menu item */ + static const char *quit; +}; + +/** @} */ + +// +// End of "$Id: mac.H 8657 2011-05-12 11:50:43Z manolo $". +// + diff --git a/common/fltk/FL/math.h b/common/fltk/FL/math.h new file mode 100644 index 00000000..e0f1d405 --- /dev/null +++ b/common/fltk/FL/math.h @@ -0,0 +1,71 @@ +// +// "$Id: math.h 7903 2010-11-28 21:06:39Z matt $" +// +// Math header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// Xcode on OS X includes files by recursing down into directories. +// This code catches the cycle and directly includes the required file. +#ifdef fl_math_h_cyclic_include +# include "/usr/include/math.h" +#endif + +#ifndef fl_math_h +# define fl_math_h + +# define fl_math_h_cyclic_include +# include <math.h> +# undef fl_math_h_cyclic_include + +# ifdef __EMX__ +# include <float.h> +# endif + + +# ifndef M_PI +# define M_PI 3.14159265358979323846 +# define M_PI_2 1.57079632679489661923 +# define M_PI_4 0.78539816339744830962 +# define M_1_PI 0.31830988618379067154 +# define M_2_PI 0.63661977236758134308 +# endif // !M_PI + +# ifndef M_SQRT2 +# define M_SQRT2 1.41421356237309504880 +# define M_SQRT1_2 0.70710678118654752440 +# endif // !M_SQRT2 + +# if (defined(WIN32) || defined(CRAY)) && !defined(__MINGW32__) && !defined(__MWERKS__) + +inline double rint(double v) {return floor(v+.5);} +inline double copysign(double a, double b) {return b<0 ? -a : a;} + +# endif // (WIN32 || CRAY) && !__MINGW32__ && !__MWERKS__ + +#endif // !fl_math_h + + +// +// End of "$Id: math.h 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/names.h b/common/fltk/FL/names.h new file mode 100644 index 00000000..952acc02 --- /dev/null +++ b/common/fltk/FL/names.h @@ -0,0 +1,123 @@ +// +// "$Id: names.h 7903 2010-11-28 21:06:39Z matt $" +// +// Event names header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// Thanks to Greg Ercolano for this addition. + +#ifndef FL_NAMES_H +#define FL_NAMES_H + +/** \defgroup fl_events Events handling functions + @{ + */ + +/** + This is an array of event names you can use to convert event numbers into names. + + The array gets defined inline wherever your '\#include <FL/names.h>' appears. + + \b Example: + \code + #include <FL/names.h> // array will be defined here + int MyClass::handle(int e) { + printf("Event was %s (%d)\n", fl_eventnames[e], e); + // ..resulting output might be e.g. "Event was FL_PUSH (1)".. + [..] + } + \endcode + */ +const char * const fl_eventnames[] = +{ + "FL_NO_EVENT", + "FL_PUSH", + "FL_RELEASE", + "FL_ENTER", + "FL_LEAVE", + "FL_DRAG", + "FL_FOCUS", + "FL_UNFOCUS", + "FL_KEYDOWN", + "FL_KEYUP", + "FL_CLOSE", + "FL_MOVE", + "FL_SHORTCUT", + "FL_DEACTIVATE", + "FL_ACTIVATE", + "FL_HIDE", + "FL_SHOW", + "FL_PASTE", + "FL_SELECTIONCLEAR", + "FL_MOUSEWHEEL", + "FL_DND_ENTER", + "FL_DND_DRAG", + "FL_DND_LEAVE", + "FL_DND_RELEASE", +}; + +/** + This is an array of font names you can use to convert font numbers into names. + + The array gets defined inline wherever your '\#include <FL/names.h>' appears. + + \b Example: + \code + #include <FL/names.h> // array will be defined here + int MyClass::my_callback(Fl_Widget *w, void*) { + int fnum = w->labelfont(); + // Resulting output might be e.g. "Label's font is FL_HELVETICA (0)" + printf("Label's font is %s (%d)\n", fl_fontnames[fnum], fnum); + // ..resulting output might be e.g. "Label's font is FL_HELVETICA (0)".. + [..] + } + \endcode + */ +const char * const fl_fontnames[] = +{ + "FL_HELVETICA", + "FL_HELVETICA_BOLD", + "FL_HELVETICA_ITALIC", + "FL_HELVETICA_BOLD_ITALIC", + "FL_COURIER", + "FL_COURIER_BOLD", + "FL_COURIER_ITALIC", + "FL_COURIER_BOLD_ITALIC", + "FL_TIMES", + "FL_TIMES_BOLD", + "FL_TIMES_ITALIC", + "FL_TIMES_BOLD_ITALIC", + "FL_SYMBOL", + "FL_SCREEN", + "FL_SCREEN_BOLD", + "FL_ZAPF_DINGBATS", +}; + +/** @} */ + +#endif /* FL_NAMES_H */ + +// +// End of "$Id: names.h 7903 2010-11-28 21:06:39Z matt $". +// diff --git a/common/fltk/FL/win32.H b/common/fltk/FL/win32.H new file mode 100644 index 00000000..2150505a --- /dev/null +++ b/common/fltk/FL/win32.H @@ -0,0 +1,165 @@ +// +// "$Id: win32.H 8726 2011-05-23 18:32:47Z AlbrechtS $" +// +// WIN32 header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// Do not directly include this file, instead use <FL/x.H>. It will +// include this file if WIN32 is defined. This is to encourage +// portability of even the system-specific code... + +#ifndef FL_DOXYGEN +#ifndef Fl_X_H +# error "Never use <FL/win32.H> directly; include <FL/x.H> instead." +#endif // !Fl_X_H + +#include <windows.h> +typedef HRGN Fl_Region; +typedef HWND Window; +typedef POINT XPoint; + +#include <FL/Fl_Window.H> + +// this part is included only when compiling the FLTK library or if requested explicitly +#if defined(FL_LIBRARY) || defined(FL_INTERNALS) + +// In some of the distributions, the gcc header files are missing some stuff: +#ifndef LPMINMAXINFO +#define LPMINMAXINFO MINMAXINFO* +#endif +#ifndef VK_LWIN +#define VK_LWIN 0x5B +#define VK_RWIN 0x5C +#define VK_APPS 0x5D +#endif + +// some random X equivalents +struct XRectangle {int x, y, width, height;}; +extern Fl_Region XRectangleRegion(int x, int y, int w, int h); +inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);} +inline void XClipBox(Fl_Region r,XRectangle* rect) { + RECT win_rect; GetRgnBox(r,&win_rect); + rect->x=win_rect.left; + rect->y=win_rect.top; + rect->width=win_rect.right-win_rect.left; + rect->height=win_rect.bottom-win_rect.top; +} +#define XDestroyWindow(a,b) DestroyWindow(b) +#define XMapWindow(a,b) ShowWindow(b, SW_RESTORE) +#define XUnmapWindow(a,b) ShowWindow(b, SW_HIDE) + +// this object contains all win32-specific stuff about a window: +// Warning: this object is highly subject to change! +class FL_EXPORT Fl_X { +public: + // member variables - add new variables only at the end of this block + Window xid; + HBITMAP other_xid; // for double-buffered windows + Fl_Window* w; + Fl_Region region; + Fl_X *next; + int wait_for_expose; + HDC private_dc; // used for OpenGL + HCURSOR cursor; + HDC saved_hdc; // saves the handle of the DC currently loaded + // static variables, static functions and member functions + static Fl_X* first; + static Fl_X* i(const Fl_Window* w) {return w->i;} + static int fake_X_wm(const Fl_Window* w,int &X, int &Y, + int &bt,int &bx,int &by); + void setwindow(Fl_Window* wi) {w=wi; wi->i=this;} + void flush() {w->flush();} + void set_minmax(LPMINMAXINFO minmax); + void mapraise(); + static Fl_X* make(Fl_Window*); +}; +extern FL_EXPORT HCURSOR fl_default_cursor; +extern FL_EXPORT UINT fl_wake_msg; +extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid() +extern FL_EXPORT int fl_background_pixel; // hack into Fl_Window::make_xid() +extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays! +extern FL_EXPORT void fl_release_dc(HWND w, HDC dc); +extern FL_EXPORT void fl_save_dc( HWND w, HDC dc); + +inline Window fl_xid(const Fl_Window* w) { Fl_X *temp = Fl_X::i(w); return temp ? temp->xid : 0; } + +#else +FL_EXPORT Window fl_xid_(const Fl_Window* w); +#define fl_xid(w) fl_xid_(w) +#endif // FL_LIBRARY || FL_INTERNALS + +FL_EXPORT Fl_Window* fl_find(Window xid); +void fl_clip_region(Fl_Region); + +// most recent fl_color() or fl_rgbcolor() points at one of these: +extern FL_EXPORT struct Fl_XMap { + COLORREF rgb; // this should be the type the RGB() macro returns + HPEN pen; // pen, 0 if none created yet + int brush; // ref to solid brush, 0 if none created yet +} *fl_current_xmap; +inline COLORREF fl_RGB() {return fl_current_xmap->rgb;} +inline HPEN fl_pen() {return fl_current_xmap->pen;} +FL_EXPORT HBRUSH fl_brush(); // allocates a brush if necessary +FL_EXPORT HBRUSH fl_brush_action(int); // now does the real work + +extern FL_EXPORT HINSTANCE fl_display; +extern FL_EXPORT Window fl_window; +extern FL_EXPORT HDC fl_gc; +extern FL_EXPORT MSG fl_msg; +extern FL_EXPORT HDC fl_GetDC(Window); +extern FL_EXPORT HDC fl_makeDC(HBITMAP); + +// off-screen pixmaps: create, destroy, draw into, copy to window +typedef HBITMAP Fl_Offscreen; +#define fl_create_offscreen(w, h) \ + CreateCompatibleBitmap( (fl_gc ? fl_gc : fl_GetDC(0) ) , w, h) + +# define fl_begin_offscreen(b) \ + HDC _sgc=fl_gc; Window _sw=fl_window; \ + Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \ + fl_gc=fl_makeDC(b); int _savedc = SaveDC(fl_gc); fl_window=(HWND)b; fl_push_no_clip() + +# define fl_end_offscreen() \ + fl_pop_clip(); RestoreDC(fl_gc, _savedc); DeleteDC(fl_gc); _ss->set_current(); fl_window=_sw; fl_gc = _sgc + + +FL_EXPORT void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy); +FL_EXPORT void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy); +#define fl_delete_offscreen(bitmap) DeleteObject(bitmap) + +// Bitmap masks +typedef HBITMAP Fl_Bitmask; + +extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); +extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data); +extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); + +// Dummy function to register a function for opening files via the window manager... +inline void fl_open_callback(void (*)(const char *)) {} + +extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); +#endif // FL_DOXYGEN +// +// End of "$Id: win32.H 8726 2011-05-23 18:32:47Z AlbrechtS $". +// diff --git a/common/fltk/FL/x.H b/common/fltk/FL/x.H new file mode 100644 index 00000000..002e429f --- /dev/null +++ b/common/fltk/FL/x.H @@ -0,0 +1,199 @@ +// +// "$Id: x.H 8706 2011-05-21 10:05:19Z AlbrechtS $" +// +// X11 header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// 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. +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// These are internal fltk symbols that are necessary or useful for +// calling Xlib. You should include this file if (and ONLY if) you +// need to call Xlib directly. These symbols may not exist on non-X +// systems. + +/** \class Fl_Mac_App_Menu + Mac OS-specific class allowing to localize the application menu. + + These character strings are used to build the application menu. They can be localized + at run time to any UTF-8 text by placing instructions such as this \e very + early in the program: + \verbatim + Fl_Mac_App_Menu::print = "Imprimer la fenĂȘtre"; + \endverbatim +*/ + +#if !defined(Fl_X_H) && !defined(FL_DOXYGEN) +# define Fl_X_H + +# include "Enumerations.H" + +# ifdef WIN32 +# include "win32.H" +# elif defined(__APPLE__) +# include "mac.H" +# else +# if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files +# pragma set woff 3322 +# endif +# include <X11/Xlib.h> +# include <X11/Xutil.h> +# if defined(_ABIN32) || defined(_ABI64) +# pragma reset woff 3322 +# endif +# include <X11/Xatom.h> +# include "Fl_Window.H" +# include "Xutf8.h" +// Mirror X definition of Region to Fl_Region, for portability... +typedef Region Fl_Region; + +FL_EXPORT void fl_open_display(); +FL_EXPORT void fl_open_display(Display*); +FL_EXPORT void fl_close_display(); + +// constant info about the X server connection: +extern FL_EXPORT Display *fl_display; +extern FL_EXPORT int fl_screen; +extern FL_EXPORT XVisualInfo *fl_visual; +extern FL_EXPORT Colormap fl_colormap; + + +// drawing functions: +extern FL_EXPORT GC fl_gc; +extern FL_EXPORT Window fl_window; +FL_EXPORT ulong fl_xpixel(Fl_Color i); +FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b); +FL_EXPORT void fl_clip_region(Fl_Region); +FL_EXPORT Fl_Region fl_clip_region(); + +// feed events into fltk: +FL_EXPORT int fl_handle(const XEvent&); + +// you can use these in Fl::add_handler() to look at events: +extern FL_EXPORT const XEvent* fl_xevent; +extern FL_EXPORT ulong fl_event_time; + +// off-screen pixmaps: create, destroy, draw into, copy to window: +typedef ulong Fl_Offscreen; +# define fl_create_offscreen(w,h) \ + XCreatePixmap(fl_display, \ + (Fl_Surface_Device::surface()->class_name() == Fl_Display_Device::class_id ? \ + fl_window : fl_xid(Fl::first_window()) ) , \ + w, h, fl_visual->depth) +// begin/end are macros that save the old state in local variables: +# define fl_begin_offscreen(pixmap) \ + Window _sw=fl_window; fl_window=pixmap; \ + Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \ + fl_push_no_clip() +# define fl_end_offscreen() \ + fl_pop_clip(); fl_window = _sw; _ss->set_current() + +extern void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); +# define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap) + +// Bitmap masks +typedef ulong Fl_Bitmask; + +extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); +extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data); +extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); + +#if defined(FL_LIBRARY) || defined(FL_INTERNALS) +extern FL_EXPORT Window fl_message_window; +extern FL_EXPORT void *fl_xftfont; +FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx + +// access to core fonts: +// This class provides a "smart pointer" that returns a pointer to an XFontStruct. +// The global variable fl_xfont can be called wherever a bitmap "core" font is +// needed, e.g. when rendering to a GL context under X11. +// With Xlib / X11 fonts, fl_xfont will return the current selected font. +// With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most +// similar to (usually the same as) the current XFT font. +class Fl_XFont_On_Demand +{ +public: + Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { } + Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x) + { ptr = x.ptr; return *this; } + Fl_XFont_On_Demand& operator=(XFontStruct* p) + { ptr = p; return *this; } + XFontStruct* value(); + operator XFontStruct*() { return value(); } + XFontStruct& operator*() { return *value(); } + XFontStruct* operator->() { return value(); } + bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; } + bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; } +private: + XFontStruct *ptr; +}; +extern FL_EXPORT Fl_XFont_On_Demand fl_xfont; + +// this object contains all X-specific stuff about a window: +// Warning: this object is highly subject to change! +// FL_LIBRARY or FL_INTERNALS must be defined to access this class. +class FL_EXPORT Fl_X { +public: + Window xid; + Window other_xid; + Fl_Window *w; + Fl_Region region; + Fl_X *next; + char wait_for_expose; + char backbuffer_bad; // used for XDBE + static Fl_X* first; + static Fl_X* i(const Fl_Window* wi) {return wi->i;} + void setwindow(Fl_Window* wi) {w=wi; wi->i=this;} + void sendxjunk(); + static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap); + static Fl_X* set_xid(Fl_Window*, Window); + // kludges to get around protection: + void flush() {w->flush();} + static void x(Fl_Window* wi, int X) {wi->x(X);} + static void y(Fl_Window* wi, int Y) {wi->y(Y);} +}; + +extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid() +extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid() + +inline Window fl_xid(const Fl_Window* w) { Fl_X *temp = Fl_X::i(w); return temp ? temp->xid : 0; } + +#else + +extern Window fl_xid_(const Fl_Window* w); +#define fl_xid(w) fl_xid_(w) + +#endif // FL_LIBRARY || FL_INTERNALS + +FL_EXPORT Fl_Window* fl_find(Window xid); + + +// Dummy function to register a function for opening files via the window manager... +inline void fl_open_callback(void (*)(const char *)) {} + +extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); + +# endif +#endif + +// +// End of "$Id: x.H 8706 2011-05-21 10:05:19Z AlbrechtS $". +// |