diff --git a/cgo_linux_amd64.go b/cgo_linux_amd64.go index 59cd209..561247e 100644 --- a/cgo_linux_amd64.go +++ b/cgo_linux_amd64.go @@ -3,6 +3,6 @@ package fltk // #cgo linux,amd64 CXXFLAGS: -std=c++11 -// #cgo linux,amd64 CPPFLAGS: -I${SRCDIR}/lib/linux/amd64 -I${SRCDIR}/include -I${SRCDIR}/include/FL/images -I${SRCDIR}/include/png -I${SRCDIR}/include/zlib -I${SRCDIR}/include/jpeg -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -// #cgo linux,amd64 LDFLAGS: ${SRCDIR}/lib/linux/amd64/libfltk_images.a ${SRCDIR}/lib/linux/amd64/libfltk_jpeg.a ${SRCDIR}/lib/linux/amd64/libfltk_png.a ${SRCDIR}/lib/linux/amd64/libfltk_z.a ${SRCDIR}/lib/linux/amd64/libfltk_gl.a -lGLU -lGL ${SRCDIR}/lib/linux/amd64/libfltk_forms.a ${SRCDIR}/lib/linux/amd64/libfltk.a -lm -lX11 -lXext -lpthread -lXinerama -lXfixes -lXcursor -lXft -lXrender -lm -lfontconfig -ldl +// #cgo linux,amd64 CPPFLAGS: -I${SRCDIR}/include/linux/amd64 -I${SRCDIR}/include/linux/amd64/png -I${SRCDIR}/include/linux/amd64/zlib -I${SRCDIR}/include/linux/amd64/jpeg -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT +// #cgo linux,amd64 LDFLAGS: ${SRCDIR}/lib/linux/amd64/libfltk_images.a /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libz.so ${SRCDIR}/lib/linux/amd64/libfltk_gl.a -L/usr/lib/x86_64-linux-gnu -lwayland-egl -lwayland-client -lEGL -lGLU -lGL ${SRCDIR}/lib/linux/amd64/libfltk_forms.a ${SRCDIR}/lib/linux/amd64/libfltk.a -lm -lpthread -lXinerama -lXfixes -lXcursor -L/usr/lib/x86_64-linux-gnu -lpangoxft-1.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -lXft -lpangocairo-1.0 -lcairo -lX11 -lXrender -lwayland-cursor -lwayland-client -lxkbcommon -ldbus-1 -ldecor-0 -ldl import "C" diff --git a/fltk-build.go b/fltk-build.go index 448ca10..2ad1cd0 100644 --- a/fltk-build.go +++ b/fltk-build.go @@ -13,7 +13,7 @@ import ( "strings" ) -const commit = "eb759cb118fbf09da51938c04978e609822dbb48" +const commit = "d547e1956778ed584248179d9141843b86101a0a" func main() { if runtime.GOOS == "" { @@ -36,13 +36,20 @@ func main() { os.Exit(1) } - libdir := filepath.Join("lib", runtime.GOOS, runtime.GOARCH) + libDir := filepath.Join("lib", runtime.GOOS, runtime.GOARCH) - if err := os.MkdirAll(libdir, 0750); err != nil { - fmt.Printf("Could not create directory %s, %v\n", libdir, err) + if err := os.MkdirAll(libDir, 0750); err != nil { + fmt.Printf("Could not create directory %s, %v\n", libDir, err) os.Exit(1) } + includeDir := filepath.Join("include", runtime.GOOS, runtime.GOARCH) + if err := os.MkdirAll(includeDir, 0750); err != nil { + fmt.Printf("Could not create directory %s, %v\n", includeDir, err) + os.Exit(1) + } + + if err := os.MkdirAll("fltk_build", 0750); err != nil { fmt.Printf("Could not create directory fltk_build, %v\n", err) os.Exit(1) @@ -134,9 +141,9 @@ func main() { "-DOPTION_USE_SYSTEM_LIBPNG=OFF", "-DOPTION_USE_SYSTEM_ZLIB=OFF", "-DCMAKE_INSTALL_PREFIX="+currentDir, - "-DCMAKE_INSTALL_INCLUDEDIR=include", - "-DCMAKE_INSTALL_LIBDIR="+libdir, - "-DFLTK_INCLUDEDIR="+filepath.Join(currentDir, "include"), + "-DCMAKE_INSTALL_INCLUDEDIR=" + includeDir, + "-DCMAKE_INSTALL_LIBDIR="+libDir, + "-DFLTK_INCLUDEDIR="+filepath.Join(currentDir, "include", runtime.GOOS, runtime.GOARCH), "-DFLTK_LIBDIR="+filepath.Join(currentDir, "lib", runtime.GOOS, runtime.GOARCH)) if runtime.GOOS == "darwin" { @@ -180,17 +187,6 @@ func main() { os.Exit(1) } - flConfigTargetDir := filepath.Join(libdir, "FL") - if err := os.MkdirAll(flConfigTargetDir, 0750); err != nil { - fmt.Printf("Error creating directory %s, %v", flConfigTargetDir, err) - os.Exit(1) - } - flConfigPath := filepath.Join("include", "FL", "fl_config.h") - if err := os.Rename(flConfigPath, filepath.Join(flConfigTargetDir, "fl_config.h")); err != nil { - fmt.Printf("Error moving %s to %s, %v", flConfigPath, flConfigTargetDir, err) - os.Exit(1) - } - cgoFilename := "cgo_" + runtime.GOOS + "_" + runtime.GOARCH + ".go" cgoFile, err := os.Create(cgoFilename) if err != nil { @@ -227,7 +223,7 @@ func main() { if runtime.GOOS == "openbsd" { fltkConfigCxxFlags = "-I/usr/X11R6/include " + fltkConfigCxxFlags } - fmt.Fprintf(cgoFile, "// #cgo %s,%s CPPFLAGS: -I${SRCDIR}/%s %s", runtime.GOOS, runtime.GOARCH, libdir, fltkConfigCxxFlags) + fmt.Fprintf(cgoFile, "// #cgo %s,%s CPPFLAGS: %s", runtime.GOOS, runtime.GOARCH, fltkConfigCxxFlags) if fltkConfigCxxFlags[len(fltkConfigCxxFlags)-1] != '\n' { fmt.Fprintln(cgoFile, "") } @@ -235,7 +231,7 @@ func main() { fltkConfigLdCmd := exec.Command(fltkConfigPath, "--use-gl", "--use-images", "--use-forms", "--ldstaticflags") ldOutput, err := fltkConfigLdCmd.Output() if err != nil { - fmt.Printf("Error running fltk-config --ldflags, %v\n", err) + fmt.Printf("Error running fltk-config --ldstaticflags, %v\n", err) os.Exit(1) } fltkConfigLdFlags := strings.ReplaceAll(string(ldOutput), currentDir, "${SRCDIR}") @@ -248,11 +244,11 @@ func main() { } } else { - // Switching to slashes in paths in cgo directives as backslashes are cause problems when being passed to gcc. - libdir := filepath.ToSlash(libdir) + // Switching to slashes in paths in cgo directives as backslashes are causing problems when being passed to gcc. + libdir := filepath.ToSlash(libDir) // Hardcoding contents of cgo directive for windows, // as we cannot extract it from fltk-config if we're not using a UNIX shell. - fmt.Fprintf(cgoFile, "// #cgo %s,%s CPPFLAGS: -I${SRCDIR}/%s -I${SRCDIR}/include -I${SRCDIR}/include/FL/images -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64\n", runtime.GOOS, runtime.GOARCH, libdir) + fmt.Fprintf(cgoFile, "// #cgo %s,%s CPPFLAGS: -I${SRCDIR}/%s -I${SRCDIR}/%s/FL/images -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64\n", runtime.GOOS, runtime.GOARCH, includeDir, includeDir) fmt.Fprintf(cgoFile, "// #cgo %s,%s LDFLAGS: -mwindows ${SRCDIR}/%s/libfltk_images.a ${SRCDIR}/%s/libfltk_jpeg.a ${SRCDIR}/%s/libfltk_png.a ${SRCDIR}/%s/libfltk_z.a ${SRCDIR}/%s/libfltk_gl.a -lglu32 -lopengl32 ${SRCDIR}/%s/libfltk_forms.a ${SRCDIR}/%s/libfltk.a -lgdiplus -lole32 -luuid -lcomctl32 -lws2_32\n", runtime.GOOS, runtime.GOARCH, libdir, libdir, libdir, libdir, libdir, libdir, libdir) } fmt.Fprintln(cgoFile, "import \"C\"") diff --git a/include/linux/amd64/FL/Enumerations.H b/include/linux/amd64/FL/Enumerations.H new file mode 100644 index 0000000..97b4c70 --- /dev/null +++ b/include/linux/amd64/FL/Enumerations.H @@ -0,0 +1,1396 @@ +// +// Enumerations for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file + This file contains type definitions and general enumerations. + */ + +#ifndef Fl_Enumerations_H +#define Fl_Enumerations_H + +/* + ****************************************************************************** + * FL_ABI_VERSION is defined by configure or CMake since FLTK 1.3.4. + * It is written to FL/fl_config.h and #included here. + ****************************************************************************** + * For more informations on FL_ABI_VERSION see README.abi-version.txt. + ****************************************************************************** + */ + +#include + +# include "Fl_Export.H" +# include "fl_types.h" +# include // for FL_COMMAND and FL_CONTROL + +/** \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. + \see 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 4 + +/** + 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 \em double that describes the major, minor, and patch + version numbers. + + Version 1.2.3 is actually stored as 1.0203 to allow for more than 9 + minor and patch releases. + + \deprecated This \p double version number is retained for compatibility + with existing program code. New code should use \em int FL_API_VERSION + instead. FL_VERSION is deprecated because comparisons of floating point + values may fail due to rounding errors. However, there are currently no + plans to remove this deprecated constant. + + FL_VERSION is equivalent to (double)FL_API_VERSION / 10000. + + \see Fl::version() (deprecated as well) + \see FL_API_VERSION + \see Fl::api_version() + */ +#define FL_VERSION ( (double)FL_MAJOR_VERSION + \ + (double)FL_MINOR_VERSION * 0.01 + \ + (double)FL_PATCH_VERSION * 0.0001 ) + +/** + The FLTK API version number as an \em int. + + FL_API_VERSION is an \em int that describes the major, minor, and patch + version numbers. + + Version 1.2.3 is actually stored as 10203 to allow for more than 9 + minor and patch 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. + + \note FL_API_VERSION is intended to replace the deprecated + \em double FL_VERSION. + + \see Fl::api_version() + */ +#define FL_API_VERSION (FL_MAJOR_VERSION*10000 + FL_MINOR_VERSION*100 + FL_PATCH_VERSION) + +/** + The FLTK ABI (Application Binary Interface) version number as an \em int. + + FL_ABI_VERSION is an \em int that describes the major, minor, and patch + ABI version numbers in the same format as FL_API_VERSION. + + The ABI version number \p FL_ABI_VERSION is usually the same as the + API version \p FL_API_VERSION with the last two digits set to '00'. + + FLTK retains the ABI (Application Binary Interface) during patch + releases of the same major and minor versions. Examples: + + \verbatim + FLTK Version FL_API_VERSION FL_ABI_VERSION FL_VERSION (deprecated) + 1.3.0 10300 10300 1.0300 + 1.3.4 10304 10300 1.0304 + \endverbatim + + Version 1.2.3 is actually stored as 10203 to allow for more than 9 + minor and patch 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. + + To enable new ABI-breaking features in patch releases you can configure + FLTK to use a higher FL_ABI_VERSION. + + \see README.abi-version.txt + */ +#ifndef FL_ABI_VERSION +#define FL_ABI_VERSION (FL_MAJOR_VERSION*10000 + FL_MINOR_VERSION*100) +#endif + +/* + Check if FL_ABI_VERSION is out of allowed range; redefine if necessary. + + This is done to prevent users from defining an illegal ABI version. + + Rule: FL_MAJOR_VERSION * 10000 + FL_MINOR_VERSION * 100 + <= FL_ABI_VERSION <= FL_API_VERSION. + + Example (FLTK 1.3.4): + + 10300 <= FL_ABI_VERSION <= 10304 + + Note: configure + CMake can be used to define FL_ABI_VERSION, but they + do not check validity. This is done here. +*/ + +#if FL_ABI_VERSION < FL_MAJOR_VERSION*10000 + FL_MINOR_VERSION*100 + +# undef FL_ABI_VERSION +# define FL_ABI_VERSION (FL_MAJOR_VERSION*10000 + FL_MINOR_VERSION*100) + +#elif FL_ABI_VERSION > FL_API_VERSION + +# undef FL_ABI_VERSION +# define FL_ABI_VERSION FL_API_VERSION + +#endif + +/**@}*/ // 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. + + Event numbers can be converted to their actual names using the + \ref fl_eventnames[] array defined in \#include <FL/names.h> + + \see Fl::event_text(), Fl::event_key(), class Fl:: + */ +// DEV NOTE: Keep this list in sync with FL/names.h +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 attempt 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, + /** The screen configuration (number, positions) was changed. + Use Fl::add_handler() to be notified of this event. + */ + FL_SCREEN_CONFIGURATION_CHANGED = 24, + /** The fullscreen state of the window has changed. + This event is sent to the window's handle method. + */ + FL_FULLSCREEN = 25, + /** The user has made a zoom/pinch/magnification gesture (Mac OS platform only). + The Fl::event_dy() method can be used to find magnification amount, + Fl::event_x() and Fl::event_y() are set as well. + This event is sent to the window's handle method. + */ + FL_ZOOM_GESTURE = 26, + /** A zoom event (ctrl/+/-/0/ or cmd/+/-/0/) was processed. + Use Fl::add_handler() to be notified of this event. + */ + FL_ZOOM_EVENT = 27 + // DEV NOTE: Keep this list in sync with FL/names.h +}; + +/** \name When Conditions */ +/**@{*/ +/** These constants determine when a callback is performed. + + Fl_When is a bit field. Some values are merely shortcuts for common bit + combinations. New flags may be added in the future, so it's important to + mask the required bit when reading via \p when(). + + \note Some widgets may not fully support \p FL_WHEN_... flags. + + \see Fl_Widget::when(), Fl::callback_reason(), Fl_Callback_Reason, Fl_Widget::do_callback() + */ +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, ///< Do callbacks whether the value changed or not, and when the ENTER key is pressed + FL_WHEN_CLOSED = 16 ///< Do the callback when a child of Fl_Tabs is closed +}; +/**@}*/ // group: When Conditions + + +/** \name Callback Reasons */ +/**@{*/ +/** These constants describe why a callback is performed. + + \see Fl::callback_reason(), Fl_Widget::when(), Fl_When + */ +enum Fl_Callback_Reason { + FL_REASON_UNKNOWN=0, ///< unknown or unset reason + FL_REASON_SELECTED, ///< an item was selected + FL_REASON_DESELECTED, ///< an item was de-selected + FL_REASON_RESELECTED, ///< an item was re-selected (double-clicked). + FL_REASON_OPENED, ///< an item was opened + FL_REASON_CLOSED, ///< an item was closed + FL_REASON_DRAGGED, ///< an item was dragged into a new place + FL_REASON_CANCELLED, ///< a dialog was cancelled + FL_REASON_CHANGED, ///< the value of the widget was modified + FL_REASON_GOT_FOCUS, ///< a widget received focus + FL_REASON_LOST_FOCUS, ///< a widget lost focus + FL_REASON_RELEASED, ///< the mouse button was released + FL_REASON_ENTER_KEY, ///< user finished input pressing Enter + FL_REASON_USER = 32 ///< user defined callback reasons +}; +/**@}*/ // group: Callback Reasons + + +/** \name Names of Non-ASCII keys and mouse buttons + + The following constants define the names of non-ASCII keys on the + keyboard and of mouse buttons for FL_KEYBOARD and FL_SHORTCUT events. + + \see 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 \c n. +#define FL_BackSpace 0xff08 ///< The backspace key. +#define FL_Tab 0xff09 ///< The tab key. +#define FL_Iso_Key 0xff0c ///< The additional key of ISO keyboards. +#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_Kana 0xff2e ///< The Kana key of JIS keyboards. +#define FL_Eisu 0xff2f ///< The Eisu key of JIS keyboards. +#define FL_Yen 0xff30 ///< The Yen key of JIS keyboards. +#define FL_JIS_Underscore 0xff31 ///< The underscore key of JIS keyboards. +#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 digit 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. +#define FL_Alt_Gr 0xfe03 ///< The AltGr key on some international keyboards. + +// 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: Non-ASCII key names + +/** \name Mouse Buttons + + These constants define the button numbers for FL_PUSH and FL_RELEASE events. + + \see 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 +#define FL_BACK_MOUSE 4 ///< The back mouse button (side button 1) +#define FL_FORWARD_MOUSE 5 ///< The forward mouse button (side button 2) + +/**@}*/ // 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 bits so that +// a unicode key (21 bits) 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 +// Mouse buttons + +#define FL_BUTTON1 0x01000000 ///< Mouse button 1 is pushed (L) +#define FL_BUTTON2 0x02000000 ///< Mouse button 2 is pushed (M) +#define FL_BUTTON3 0x04000000 ///< Mouse button 3 is pushed (R) +#define FL_BUTTON4 0x08000000 ///< Mouse button 4 is pushed (BACK) +#define FL_BUTTON5 0x10000000 ///< Mouse button 5 is pushed (FORWARD) +#define FL_BUTTONS 0x1f000000 ///< Bitmask: any mouse button (1-5) is pushed + +#define FL_BUTTON(n) (0x00800000<<(n)) ///< Mouse button n (n = 1..5) is pushed, + ///< *undefined* if n outside 1..5 + +#define FL_KEY_MASK 0x0000ffff ///< All keys are 16 bit for now + // FIXME: Unicode needs 21 bits! + +/**@}*/ // group: Event States + +/** \name Box Types + \brief FLTK standard box types + + This enum defines the standard box types included with FLTK. + + \note The documented \p enum \p Fl_Boxtype contains some values (names) + with leading underscores, e.g. \p \b _FL_SHADOW_BOX. This is due to + technical reasons - please use the same values (names) without the + leading underscore in your code! Enum values with leading underscores + are reserved for internal use and subject to change without notice! + + 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 the image below + is the area that is not drawn by the frame types. + + \anchor boxTypesImage + \image html boxtypes.png "FLTK Standard Box Types" + \image latex boxtypes.png "FLTK Standard Box Types" width=12cm + + \note Not all box types are depicted in the figure above. + See enum \ref Fl_Boxtype below for the complete list of box types. + \see Fl::get_system_colors() +*/ + +/**@{*/ // group: Box Types + +/** + \brief FLTK standard box types + + This enum defines the standard box types included with FLTK. + + \note The documented \p enum \p Fl_Boxtype contains some values (names) + with leading underscores, e.g. \p \b _FL_SHADOW_BOX. This is due to + technical reasons - please use the same values (names) without the + leading underscore in your code! Enum values with leading underscores + are reserved for internal use and subject to change without notice! +*/ +enum Fl_Boxtype { // boxtypes (if you change these you must also change fl_boxtype.cxx): + + FL_NO_BOX = 0, ///< nothing is drawn at all, this box is invisible + FL_FLAT_BOX, ///< a flat box + FL_UP_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_DOWN_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_UP_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_DOWN_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_THIN_UP_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_THIN_DOWN_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_THIN_UP_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_THIN_DOWN_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_ENGRAVED_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_EMBOSSED_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_ENGRAVED_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_EMBOSSED_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage) + FL_BORDER_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage) + _FL_SHADOW_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_SHADOW_BOX + FL_BORDER_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage) + _FL_SHADOW_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_SHADOW_FRAME + _FL_ROUNDED_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_ROUNDED_BOX + _FL_RSHADOW_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_RSHADOW_BOX + _FL_ROUNDED_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_ROUNDED_FRAME + _FL_RFLAT_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_RFLAT_BOX + _FL_ROUND_UP_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_ROUND_UP_BOX + _FL_ROUND_DOWN_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_ROUND_DOWN_BOX + _FL_DIAMOND_UP_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_DIAMOND_UP_BOX + _FL_DIAMOND_DOWN_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_DIAMOND_DOWN_BOX + _FL_OVAL_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_OVAL_BOX + _FL_OSHADOW_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_OSHADOW_BOX + _FL_OVAL_FRAME, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_OVAL_FRAME + _FL_OFLAT_BOX, ///< see figure [Standard Box Types](@ref boxTypesImage), use FL_OFLAT_BOX + _FL_PLASTIC_UP_BOX, ///< plastic version of FL_UP_BOX, use FL_PLASTIC_UP_BOX + _FL_PLASTIC_DOWN_BOX, ///< plastic version of FL_DOWN_BOX, use FL_PLASTIC_DOWN_BOX + _FL_PLASTIC_UP_FRAME, ///< plastic version of FL_UP_FRAME, use FL_PLASTIC_UP_FRAME + _FL_PLASTIC_DOWN_FRAME, ///< plastic version of FL_DOWN_FRAME, use FL_PLASTIC_DOWN_FRAME + _FL_PLASTIC_THIN_UP_BOX, ///< plastic version of FL_THIN_UP_BOX, use FL_PLASTIC_THIN_UP_BOX + _FL_PLASTIC_THIN_DOWN_BOX, ///< plastic version of FL_THIN_DOWN_BOX, use FL_PLASTIC_THIN_DOWN_BOX + _FL_PLASTIC_ROUND_UP_BOX, ///< plastic version of FL_ROUND_UP_BOX, use FL_PLASTIC_ROUND_UP_BOX + _FL_PLASTIC_ROUND_DOWN_BOX, ///< plastic version of FL_ROUND_DOWN_BOX, use FL_PLASTIC_ROUND_DOWN_BOX + _FL_GTK_UP_BOX, ///< gtk+ version of FL_UP_BOX, use FL_GTK_UP_BOX + _FL_GTK_DOWN_BOX, ///< gtk+ version of FL_DOWN_BOX, use FL_GTK_DOWN_BOX + _FL_GTK_UP_FRAME, ///< gtk+ version of FL_UP_FRAME, use FL_GTK_UP_FRAME + _FL_GTK_DOWN_FRAME, ///< gtk+ version of FL_DOWN_FRAME, use FL_GTK_DOWN_FRAME + _FL_GTK_THIN_UP_BOX, ///< gtk+ version of FL_THIN_UP_BOX, use FL_GTK_THIN_UP_BOX + _FL_GTK_THIN_DOWN_BOX, ///< gtk+ version of FL_THIN_DOWN_BOX, use FL_GTK_THIN_DOWN_BOX + _FL_GTK_THIN_UP_FRAME, ///< gtk+ version of FL_THIN_UP_FRAME, use FL_GTK_THIN_UP_FRAME + _FL_GTK_THIN_DOWN_FRAME, ///< gtk+ version of FL_THIN_DOWN_FRAME, use FL_GTK_THIN_DOWN_FRAME + _FL_GTK_ROUND_UP_BOX, ///< gtk+ version of FL_ROUND_UP_BOX, use FL_GTK_ROUND_UP_BOX + _FL_GTK_ROUND_DOWN_BOX, ///< gtk+ version of FL_ROUND_DOWN_BOX, use FL_GTK_ROUND_DOWN_BOX + _FL_GLEAM_UP_BOX, ///< gleam version of FL_UP_BOX, use FL_GLEAM_UP_BOX + _FL_GLEAM_DOWN_BOX, ///< gleam version of FL_DOWN_BOX, use FL_GLEAM_DOWN_BOX + _FL_GLEAM_UP_FRAME, ///< gleam version of FL_UP_FRAME, use FL_GLEAM_UP_FRAME + _FL_GLEAM_DOWN_FRAME, ///< gleam version of FL_DOWN_FRAME, use FL_GLEAM_DOWN_FRAME + _FL_GLEAM_THIN_UP_BOX, ///< gleam version of FL_THIN_UP_BOX, use FL_GLEAM_THIN_UP_BOX + _FL_GLEAM_THIN_DOWN_BOX, ///< gleam version of FL_THIN_DOWN_BOX, use FL_GLEAM_THIN_DOWN_BOX + _FL_GLEAM_ROUND_UP_BOX, ///< gleam version of FL_ROUND_UP_BOX, use FL_GLEAM_ROUND_UP_BOX + _FL_GLEAM_ROUND_DOWN_BOX, ///< gleam version of FL_ROUND_DOWN_BOX, use FL_GLEAM_ROUND_DOWN_BOX + _FL_OXY_UP_BOX, ///< oxy version of FL_UP_BOX, use FL_OXY_UP_BOX + _FL_OXY_DOWN_BOX, ///< oxy version of FL_DOWN_BOX, use FL_OXY_DOWN_BOX + _FL_OXY_UP_FRAME, ///< oxy version of FL_UP_FRAME, use FL_OXY_UP_FRAME + _FL_OXY_DOWN_FRAME, ///< oxy version of FL_DOWN_FRAME, use FL_OXY_DOWN_FRAME + _FL_OXY_THIN_UP_BOX, ///< oxy version of FL_THIN_UP_BOX, use FL_OXY_THIN_UP_BOX + _FL_OXY_THIN_DOWN_BOX, ///< oxy version of FL_THIN_DOWN_BOX, use FL_OXY_THIN_DOWN_BOX + _FL_OXY_THIN_UP_FRAME, ///< oxy version of FL_THIN_UP_FRAME, use FL_OXY_THIN_UP_FRAME + _FL_OXY_THIN_DOWN_FRAME, ///< oxy version of FL_THIN_DOWN_FRAME, use FL_OXY_THIN_DOWN_FRAME + _FL_OXY_ROUND_UP_BOX, ///< oxy version of FL_ROUND_UP_BOX, use FL_OXY_ROUND_UP_BOX + _FL_OXY_ROUND_DOWN_BOX, ///< oxy version of FL_ROUND_DOWN_BOX, use FL_OXY_ROUND_DOWN_BOX + _FL_OXY_BUTTON_UP_BOX, ///< FL_OXY_BUTTON_UP_BOX (new boxtype ?), use FL_OXY_BUTTON_UP_BOX + _FL_OXY_BUTTON_DOWN_BOX, ///< FL_OXY_BUTTON_DOWN_BOX (new boxtype ?), use FL_OXY_BUTTON_DOWN_BOX + FL_FREE_BOXTYPE, ///< the first free box type for creation of new box types + FL_MAX_BOXTYPE = 255 ///< highest legal index for a box type +}; + +#ifndef FL_DOXYGEN + +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) + +extern FL_EXPORT Fl_Boxtype fl_define_FL_GLEAM_UP_BOX(); +#define FL_GLEAM_UP_BOX fl_define_FL_GLEAM_UP_BOX() +#define FL_GLEAM_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GLEAM_UP_BOX()+1) +#define FL_GLEAM_UP_FRAME (Fl_Boxtype)(fl_define_FL_GLEAM_UP_BOX()+2) +#define FL_GLEAM_DOWN_FRAME (Fl_Boxtype)(fl_define_FL_GLEAM_UP_BOX()+3) +#define FL_GLEAM_THIN_UP_BOX (Fl_Boxtype)(fl_define_FL_GLEAM_UP_BOX()+4) +#define FL_GLEAM_THIN_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GLEAM_UP_BOX()+5) +#define FL_GLEAM_ROUND_UP_BOX (Fl_Boxtype)(fl_define_FL_GLEAM_UP_BOX()+6) +#define FL_GLEAM_ROUND_DOWN_BOX (Fl_Boxtype)(fl_define_FL_GLEAM_UP_BOX()+7) + +extern FL_EXPORT Fl_Boxtype fl_define_FL_OXY_UP_BOX(); +#define FL_OXY_UP_BOX fl_define_FL_OXY_UP_BOX() +#define FL_OXY_DOWN_BOX (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+1) +#define FL_OXY_UP_FRAME (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+2) +#define FL_OXY_DOWN_FRAME (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+3) +#define FL_OXY_THIN_UP_BOX (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+4) +#define FL_OXY_THIN_DOWN_BOX (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+5) +#define FL_OXY_THIN_UP_FRAME (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+6) +#define FL_OXY_THIN_DOWN_FRAME (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+7) +#define FL_OXY_ROUND_UP_BOX (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+8) +#define FL_OXY_ROUND_DOWN_BOX (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+9) +#define FL_OXY_BUTTON_UP_BOX (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+10) +#define FL_OXY_BUTTON_DOWN_BOX (Fl_Boxtype)(fl_define_FL_OXY_UP_BOX()+11) + +#endif // ! FL_DOXYGEN + +// 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)((b1)?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)((bvirtual colormap + or 24-bit RGB color values. (See \ref drawing_colors for the default FLTK colormap) + + Color indices occupy the lower 8 bits of the value, while + RGB colors occupy the upper 24 bits, for a byte organization of RGBI. + +
+ Fl_Color => 0xrrggbbii
+                | | | |
+                | | | +--- \ref drawing_colors "index" between 0 and 255
+                | | +----- blue color component (8 bit)
+                | +------- green component (8 bit)
+                +--------- red component (8 bit)
+ 
+ + 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; see also \ref drawing_colors */ +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' +/** Default background color */ +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; + +/** Colors numbered between FL_FREE_COLOR and FL_FREE_COLOR + FL_NUM_FREE_COLOR - 1 +are free for the user to be given any value using Fl::set_color(). */ +#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); + +/** + Type of a custom fl_contrast() function. + + Use this signature to define your own custom fl_contrast() function together + with fl_contrast_mode(FL_CONTRAST_CUSTOM). + Example: + \code + Fl_Color my_contrast(Fl_Color fg, Fl_Color bg, int context, int size) { + // calculate contrast and ... + return color; + } + // call this early in your main() program: + fl_contrast_function(my_contrast); + fl_contrast_mode(FL_CONTRAST_CUSTOM); + fl_contrast_level(50); // optional, must be called after fl_contrast_mode() + \endcode + + For parameters and types see fl_contrast(Fl_Color, Fl_Color, int, int). + + \see fl_contrast(Fl_Color, Fl_Color, int, int) + \see fl_contrast_mode(int) +*/ +typedef Fl_Color (Fl_Contrast_Function)(Fl_Color, Fl_Color, int, int); + +FL_EXPORT void fl_contrast_function(Fl_Contrast_Function *f); + +/** + Define the possible modes to calculate fl_contrast(). +*/ +enum Fl_Contrast_Mode { + FL_CONTRAST_NONE = 0, ///< always return foreground color + FL_CONTRAST_LEGACY, ///< legacy (FLTK 1.3.x) contrast function + FL_CONTRAST_CIELAB, ///< new (FLTK 1.4.0) default function + FL_CONTRAST_CUSTOM, ///< optional custom contrast function + FL_CONTRAST_LAST ///< internal use only (invalid contrast mode) +}; + +// The following functions are defined and documented in src/fl_contrast.cxx + +FL_EXPORT void fl_contrast_level(int level); +FL_EXPORT int fl_contrast_level(); +FL_EXPORT void fl_contrast_mode(int mode); +FL_EXPORT int fl_contrast_mode(); + +FL_EXPORT Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg, int context = 0, int size = 0); + +FL_EXPORT double fl_lightness(Fl_Color color); +FL_EXPORT double fl_luminance(Fl_Color color); + +// Other color functions are defined and documented in src/fl_color.cxx + +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. + + Cursors are provided by the system when available, or bitmaps built into + FLTK as a fallback. +*/ +/* FIXME: We should renumber these, but that will break the ABI */ +enum Fl_Cursor { + FL_CURSOR_DEFAULT = 0, /**< the default cursor, usually an arrow: ↖*/ // U+2196 + FL_CURSOR_ARROW = 35, /**< an arrow pointer: ↖*/ // U+2196 + FL_CURSOR_CROSS = 66, /**< crosshair: +*/ // U+FF0B + FL_CURSOR_WAIT = 76, /**< busy indicator (for instance hourglass): ⌚,⌛*/ // U+231A, U+231B + FL_CURSOR_INSERT = 77, /**< I-beam: ⌶*/ // U+2336 + FL_CURSOR_HAND = 31, /**< pointing hand: ☜*/ // U+261C + FL_CURSOR_HELP = 47, /**< question mark pointer: ?*/ + FL_CURSOR_MOVE = 27, /**< 4-pointed arrow or hand: ✥, ✋*/ // U+2725, U+270B + + /* Resize indicators */ + FL_CURSOR_NS = 78, /**< up/down resize: ⇕ */ // U+21D5 + FL_CURSOR_WE = 79, /**< left/right resize: ⇔*/ // U+21D4 + FL_CURSOR_NWSE = 80, /**< diagonal resize: ⤡*/ // U+2921 + FL_CURSOR_NESW = 81, /**< diagonal resize: ⤢*/ // U+2922 + FL_CURSOR_N = 70, /**< upwards resize: ⤒*/ // U+2912 + FL_CURSOR_NE = 69, /**< upwards, right resize: ↗*/ // U+2197 + FL_CURSOR_E = 49, /**< rightwards resize: ⇥*/ // U+21E5 + FL_CURSOR_SE = 8, /**< downwards, right resize: ⇲*/ // U+21F2 + FL_CURSOR_S = 9, /**< downwards resize: ⤓*/ // U+2913 + FL_CURSOR_SW = 7, /**< downwards, left resize: ↙*/ // U+2199 + FL_CURSOR_W = 36, /**< leftwards resize: ⇤*/ // U+21E4 + FL_CURSOR_NW = 68, /**< upwards, left resize: ⇱*/ // U+21F1 + + FL_CURSOR_NONE =255 /**< invisible. */ +}; +/**@}*/ // 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 + FL_OPENGL3 = 1024 +}; + +// 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. Used by other widgets for other widget specific damages. */ + 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 (FLTK_1_0_COMPAT) dropped in 1.4.0 + +/** Arrow types define the type of arrow drawing function. + + FLTK schemes can draw several graphical elements in their particular way. + One of these elements is an arrow type that can be in different GUI + elements like scrollbars, choice buttons, and FLTK's Fl_Return_Button. + + \note This enum is not yet stable (as of FLTK 1.4.0) and may be changed + without notice as necessary. + + \since 1.4.0 +*/ + +enum Fl_Arrow_Type { + FL_ARROW_SINGLE = 0x01, ///< Single arrow, e.g. in Fl_Scrollbar + FL_ARROW_DOUBLE = 0x02, ///< Double arrow, e.g. in Fl_Counter + FL_ARROW_CHOICE = 0x03, ///< Dropdown box, e.g. in Fl_Choice + FL_ARROW_RETURN = 0x04 ///< Return arrow, e.g. in Fl_Return_Button +}; + +/** Fl_Orientation describes the orientation of a GUI element. + + FLTK schemes can draw several graphical elements, for instance arrows, + pointing at different directions. This enum defines the direction + to use for drawing a particular GUI element. + + The definition of this enum was chosen such that the enum value can + be multiplied by 45 to get a rotation angle in degrees starting + at the horizontal axis (0 = right, 1 = NE, 2 = up, ...) that can be + used with fl_rotate(). Note: angle is counter-clockwise in degrees. + + The 'unspecified' value \b FL_ORIENT_NONE shall be used for elements + that would usually not be rotated, like the return arrow of the + Fl_Return_Button. It can still be used as an angle though since it is + the same value as \p FL_ORIENT_RIGHT (0 degrees). + + \note This enum is not yet stable (as of FLTK 1.4.0) and may be changed + without notice as necessary. + + \since 1.4.0 +*/ + +enum Fl_Orientation { + FL_ORIENT_NONE = 0x00, ///< GUI element direction is unspecified + FL_ORIENT_RIGHT = 0x00, ///< GUI element pointing right ( 0°) + FL_ORIENT_NE = 0x01, ///< GUI element pointing NE ( 45°) + FL_ORIENT_UP = 0x02, ///< GUI element pointing up ( 90°) + FL_ORIENT_NW = 0x03, ///< GUI element pointing NW (135°) + FL_ORIENT_LEFT = 0x04, ///< GUI element pointing left (180°) + FL_ORIENT_SW = 0x05, ///< GUI element pointing SW (225°) + FL_ORIENT_DOWN = 0x06, ///< GUI element pointing down (270°) + FL_ORIENT_SE = 0x07 ///< GUI element pointing SE (315°) +}; + +#endif diff --git a/include/linux/amd64/FL/Fl.H b/include/linux/amd64/FL/Fl.H new file mode 100644 index 0000000..769dcad --- /dev/null +++ b/include/linux/amd64/FL/Fl.H @@ -0,0 +1,1636 @@ +// +// Main header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file FL/Fl.H + \brief Fl static class. +*/ + +#ifndef Fl_H +# define Fl_H + +#include // build configuration +#include +#include // for FL_SOCKET +#include // experimental + +#ifdef FLTK_HAVE_CAIRO +# include +#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 + +# ifdef BSD +# undef BSD +# endif + +#include // FIXME: Fl::is_scheme(): strcmp needs string.h + +class Fl_Widget; +class Fl_Window; +class Fl_Image; +struct Fl_Label; +class Fl_Screen_Driver; +class Fl_System_Driver; + +// Pointers you can use to change FLTK to another language. +// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx + +extern FL_EXPORT const char* fl_local_alt; ///< string pointer used in shortcuts, you can change it to another language +extern FL_EXPORT const char* fl_local_ctrl; ///< string pointer used in shortcuts, you can change it to another language +extern FL_EXPORT const char* fl_local_meta; ///< string pointer used in shortcuts, you can change it to another language +extern FL_EXPORT const char* fl_local_shift; ///< string pointer used in shortcuts, you can change it to another language + +/** \defgroup callback_functions Callback Function Typedefs + + \brief Typedefs defined in 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 box focus frame drawing functions */ +typedef void (Fl_Box_Draw_Focus_F)(Fl_Boxtype bt, int x, int y, int w, int h, Fl_Color fg, Fl_Color bg); + +/** Signature of timeout callback functions passed as parameters. + Please see Fl::add_timeout() for details. +*/ +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)(FL_SOCKET fd, void *data); + +/** Signature of add_handler functions passed as parameters */ +typedef int (*Fl_Event_Handler)(int event); + +/** Signature of add_system_handler functions passed as parameters */ +typedef int (*Fl_System_Handler)(void *event, void *data); + +/** 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); + +/** Signature of add_clipboard_notify functions passed as parameters */ +typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data); + +/** @} */ /* 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 { + friend class Fl_System_Driver; + Fl() {} // no constructor! + +private: + + static int use_high_res_GL_; + static int draw_GL_text_with_textures_; + static int box_shadow_width_; + static int box_border_radius_max_; + static int selection_to_clipboard_; + +public: + + static Fl_Screen_Driver *screen_driver(); + static Fl_System_Driver *system_driver(); +#ifdef __APPLE__ // deprecated in 1.4 - only for compatibility with 1.3 + static void reset_marked_text(); + static void insertion_point_location(int x, int y, int height); +#endif + + + /** Get the box shadow width of all "shadow" boxtypes in pixels. + \since 1.4.0 + */ + static int box_shadow_width() { return box_shadow_width_; } + /** Set the box shadow width of all "shadow" boxtypes in pixels. + Must be at least 1, default = 3. There is no upper limit. + \since 1.4.0 + */ + static void box_shadow_width(int W) { box_shadow_width_ = W < 1 ? 1 : W; } + + /** Get the maximum border radius of all "rounded" boxtypes in pixels. + \since 1.4.0 + */ + static int box_border_radius_max() { return box_border_radius_max_; } + /** Set the maximum border radius of all "rounded" boxtypes in pixels. + Must be at least 5, default = 15. + + \note This does \b not apply to the "round" boxtypes which have really round sides + (i.e. composed of half circles) as opposed to "rounded" boxtypes that have only + rounded corners with a straight border between corners. + + The box border radius of "rounded" boxtypes is typically calculated as about 2/5 of + the box height or width, whichever is smaller. The upper limit can be set by this + method for all "rounded" boxtypes. + \since 1.4.0 + */ + static void box_border_radius_max(int R) { box_border_radius_max_ = R < 5 ? 5 : R; } + +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 void *e_clipboard_data; + static const char *e_clipboard_type; + static Fl_Event_Dispatch e_dispatch; + static Fl_Callback_Reason callback_reason_; + 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; // used for dead keys (Windows) or marked text (MacOS) + static void call_screen_init(); // recompute screen number and dimensions +#endif // FL_DOXYGEN + + + /** + 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. + /// (This is considered 'old' behavior) + /// + /// When switched off (default), the cursor will stop at the end of the text. + /// Pressing Tab or Ctrl-Tab will advance the keyboard focus. + /// + /// See also: Fl_Input_::tab_nav() + /// + 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 (default), 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 (default), 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 (default), 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, + /// When switched on (default), Fl_Native_File_Chooser runs GTK file dialogs + /// if the GTK library is available on the platform (linux/unix only). + /// When switched off, GTK file dialogs aren't used even if the GTK library is available. + OPTION_FNFC_USES_GTK, + /// Meaningful for the Wayland/X11 platform only. When switched on, the library uses a Zenity-based file dialog. + /// When switched off (default), no zenity-based file dialog is used. + OPTION_FNFC_USES_ZENITY, + /// Meaningful for the Wayland/X11 platform only. + /// When switched on, the library uses a kdialog-based file dialog if command 'kdialog' is available on the running system. + /// When switched off (default), no kdialog-based file dialog is used. + OPTION_FNFC_USES_KDIALOG, + /// When switched on (default), Fl_Printer runs the GTK printer dialog + /// if the GTK library is available on the platform (linux/unix only). + /// When switched off, the GTK printer dialog isn't used even if the GTK library is available. + OPTION_PRINTER_USES_GTK, + /// When switched on (default), the library shows in a transient yellow window the zoom factor + /// value. + /// When switched off, no such window gets displayed. + OPTION_SHOW_SCALING, + /// When switched on and when the keyboard in use has '+' in the shifted position of its key, + /// pressing that key and ctrl triggers the zoom-in operation. + /// When switched off (default), the zoom-in operation requires that also the shift key is pressed. + /// Under macOS, this option has no effect because the OS itself generates ⌘= followed + /// by ⌘+ when pressing ⌘ and the '=|+' key without pressing shift. + OPTION_SIMPLE_ZOOM_SHORTCUT, + // 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_; + static int program_should_quit_; // non-zero means the program was asked to cleanly terminate + +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 +private: + 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_; +public: + static const char* scheme_; + static Fl_Image* scheme_bg_; + + static int e_original_keysym; // late addition + static int scrollbar_size_; + static int menu_linespacing_; // STR #2927 +#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(); + static int api_version(); + + // ABI version number + static int abi_version(); + + /** + Returns whether the runtime library ABI version is correct. + + This enables you to check the ABI version of the linked FLTK + library at runtime. + + Returns 1 (true) if the compiled ABI version (in the header files) + and the linked library ABI version (used at runtime) are the same, + 0 (false) otherwise. + + Argument \p val can be used to query a particular library ABI version. + Use for instance 10303 to query if the runtime library is compatible + with FLTK ABI version 1.3.3. This is rarely useful. + + The default \p val argument is FL_ABI_VERSION, which checks the version + defined at configure time (i.e. in the header files at program + compilation time) against the linked library version used at runtime. + This is particularly useful if you linked with a shared object library, + but it also concerns static linking. + + \see Fl::abi_version() + */ + static inline int abi_check(const int val = FL_ABI_VERSION) { + return val == abi_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 must 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 *name); + /** See void scheme(const char *name) */ + static const char* scheme() {return scheme_;} + + /** Returns whether the current scheme is the given name. + + This is a fast inline convenience function to support scheme-specific + code in widgets, e.g. in their draw() methods, if required. + + Use a valid scheme name, not \p NULL (although \p NULL is allowed, + this is not a useful argument - see below). + + If Fl::scheme() has not been set or has been set to the default + scheme ("none" or "base"), then this will always return 0 regardless + of the argument, because Fl::scheme() is \p NULL in this case. + + \note The stored scheme name is always lowercase, and this method will + do a case-sensitive compare, so you \b must provide a lowercase string to + return the correct value. This is intentional for performance reasons. + + Example: + \code + if (Fl::is_scheme("gtk+")) { your_code_here(); } + \endcode + + \param[in] name \b lowercase string of requested scheme name. + + \return 1 if the given scheme is active, 0 otherwise. + + \see Fl::scheme(const char *name) + */ + static int is_scheme(const char *name) { + return (scheme_ && name && !strcmp(name,scheme_)); + } + + static int reload_scheme(); // defined in 'src/Fl_get_system_colors.cxx' + + static int scrollbar_size(); + static void scrollbar_size(int W); + static int menu_linespacing(); + static void menu_linespacing(int H); + + // execution: + static int wait(); + static double wait(double time); + static int check(); + static int ready(); + static int run(); + /** Returns non-zero when a request for program termination was received and accepted. + On the MacOS platform, the "Quit xxx" item of the application menu is such a request, + that is considered accepted when all windows are closed. On other platforms, this function + returns 0 until \p Fl::program_should_quit(1) is called. + \version 1.4.0 + */ + static int program_should_quit() {return program_should_quit_;} + /** Indicate to the FLTK library whether a program termination request was received and accepted. + A program may set this to 1, for example, while performing a platform-independent command asking the program to cleanly + terminate, similarly to the "Quit xxx" item of the application menu under MacOS. + \version 1.4.0 + */ + static void program_should_quit(int should_i) { program_should_quit_ = should_i; } + static void hide_all_windows(); + + static Fl_Widget* readqueue(); + + // + // cross-platform timer support + // + + static void add_timeout(double t, Fl_Timeout_Handler cb, void *data = 0); + static void repeat_timeout(double t, Fl_Timeout_Handler cb, void *data = 0); + static int has_timeout(Fl_Timeout_Handler cb, void *data = 0); + static void remove_timeout(Fl_Timeout_Handler cb, void *data = 0); + static int remove_next_timeout(Fl_Timeout_Handler cb, void *data = 0, void **data_return = 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); + + static Fl_Timestamp now(double offset = 0); + static double seconds_since(Fl_Timestamp& then); + static double seconds_between(Fl_Timestamp& back, Fl_Timestamp& further_back); + static long ticks_since(Fl_Timestamp& then); + static long ticks_between(Fl_Timestamp& back, Fl_Timestamp& further_back); + + // private + static void run_idle(); + static void run_checks(); + static void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0); // platform dependent + 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 + */ + 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 + */ + 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 + */ + static void (*fatal)(const char*, ...); + /** @} */ + + /** \defgroup fl_windows Windows handling functions + \brief Windows and standard dialogs handling declared in + @{ */ + 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 does not have + to be shown() , 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 Windows + some 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). + + Be careful that your program does not enter an infinite loop + while grab() is on. On X this will lock up your screen! + 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 + @{ + */ + // 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 &); + /** + 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 next + 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 + \retval FL_BACK_MOUSE + \retval FL_FORWARD_MOUSE + \see Fl::event_buttons(), Fl::event_state() + */ + static int event_button() { return e_keysym - FL_Button; } + /** + Returns the keyboard and mouse button states of the last event. + + This is a bitfield of what shift states were on and what mouse buttons + were held down during the most recent event. + + \note FLTK platforms differ in what Fl::event_state() returns when it is called + while a modifier key or mouse button is being pressed or released. + + - Under X11 and Wayland, Fl::event_state() indicates the state of the modifier keys and + mouse buttons just \b prior to the event. Thus, during the \c FL_KEYDOWN event generated + when pressing the shift key, for example, the \c FL_SHIFT bit of event_state() is 0 and + becomes 1 only at the next event which can be any other event, including e.g. \c FL_MOVE. + - Under other platforms the reported state of modifier keys or mouse buttons includes that + of the key or button being pressed or released. + - Fl::event_state() returns the same value under all platforms when it's called while a + non-modifier key (e.g. a letter or function key) is being pressed or released. + - X servers do not agree on shift states, and \c FL_NUM_LOCK, \c FL_META, and \c FL_SCROLL_LOCK + may not work. + - The values were selected to match the XFree86 server on Linux. + + \note This inconsistency \b may be fixed (on X11 and Wayland) in a later release. + + The legal event state bits are: + + | Device | State Bit | Key or Button | Since | + |----------|----------------|-------------------------|--------| + | Keyboard | FL_SHIFT | Shift | | + | Keyboard | FL_CAPS_LOCK | Caps Lock | | + | Keyboard | FL_CTRL | Ctrl | | + | Keyboard | FL_ALT | Alt | | + | Keyboard | FL_NUM_LOCK | Num Lock | | + | Keyboard | FL_META | Meta, e.g. "Windows" | | + | Keyboard | FL_SCROLL_LOCK | Scroll Lock | | + | Mouse | FL_BUTTON1 | left button | | + | Mouse | FL_BUTTON2 | middle button | | + | Mouse | FL_BUTTON3 | right button | | + | Mouse | FL_BUTTON4 | side button 1 (back) | 1.3.10 | + | Mouse | FL_BUTTON5 | side button 2 (forward) | 1.3.10 | + */ + static int event_state() {return e_state;} + + /** Returns non-zero if any of the passed event state bits are turned on. + + Use \p mask to pass the event states you're interested in. + The legal event state bits are defined in Fl::event_state(). + */ + static int event_state(int mask) {return e_state&mask;} + /** + 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) during 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 now. + Under X this requires a round-trip to the server and is much + slower than Fl::event_key(int). + + Keys are identified by the unshifted 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 + (e.g., FL_KP + '4', 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_Iso_Key, 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 Windows 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 now. + Under X this requires a round-trip to the server and is much + 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, and 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 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;} + + /** During an FL_PASTE event of non-textual data, returns a pointer to the pasted data. + The returned data is an Fl_RGB_Image * when the result of Fl::event_clipboard_type() is Fl::clipboard_image. + */ + static void *event_clipboard() { return e_clipboard_data; } + /** Returns the type of the pasted data during an FL_PASTE event. + This type can be Fl::clipboard_plain_text or Fl::clipboard_image. + */ + static const char *event_clipboard_type() {return e_clipboard_type; } + + + 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); + + static void enable_im(); + static void disable_im(); + + // 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 ha); + static void add_handler(Fl_Event_Handler ha, Fl_Event_Handler before); + static Fl_Event_Handler last_handler(); + static void remove_handler(Fl_Event_Handler h); + static void add_system_handler(Fl_System_Handler h, void *data); + static void remove_system_handler(Fl_System_Handler h); + static void event_dispatch(Fl_Event_Dispatch d); + static Fl_Event_Dispatch event_dispatch(); + static Fl_Callback_Reason callback_reason(); + /** @} */ + + /** \defgroup fl_clipboard Selection & Clipboard functions + FLTK global copy/cut/paste functions declared in + @{ */ + // cut/paste: + /** + Copies the data pointed to by \p stuff to the selection buffer + (\p destination is 0), the clipboard (\p destination is 1), or + both (\p destination is 2). Copying to both is only relevant on X11, + on other platforms it maps to the clipboard (1). + \p len is the number of relevant bytes in \p stuff. + \p type is always Fl::clipboard_plain_text. + 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. + + \note This function is, at present, intended only to copy UTF-8 encoded textual data. + To copy graphical data, use the Fl_Copy_Surface class. The \p type argument may allow + in the future to copy other kinds of data. + */ + + /** + Copies data to the selection buffer, the clipboard, or both. + + The \p destination can be: + - 0: selection buffer (see note below) + - 1: clipboard + - 2: both + + The selection buffer exists only on the X11 platform and is used for middle-mouse + pastes and for drag-and-drop selections. The clipboard is used for traditional + copy/cut/paste operations. On all other platforms the selection buffer + (\p destination = 0) is mapped to the clipboard, i.e. on platforms other than X11 + all \p destinations are equivalent and the data is always copied to the clipboard. + + \note Please see Fl::section_to_clipboard() to enable duplication of the + selection buffer to the clipboard on X11, i.e. if \p destination = 0 + (selection buffer) \b and Fl::selection_to_clipboard() is enabled, then + the data is copied to both the selection buffer and the clipboard. + This makes the X11 behavior similar to other platforms but keeps the + selection buffer for X11 specific inter process communication. + + \p type should always be \p Fl::clipboard_plain_text which is the default. + Other values are ignored and reserved for future extensions. + + \note This function is, at present, intended only to copy UTF-8 encoded + textual data. To copy graphical data, use the Fl_Copy_Surface class. + The \p type argument may allow to copy other kinds of data in the future. + + \param[in] stuff text data to be copied + \param[in] len the number of relevant bytes in \p stuff + \param[in] destination 0 = selection, 1 = clipboard, 2 = both (see description) + \param[in] type usually plain text (see description) + + \internal + Documented here because it is platform dependent (calls the platform driver): + \code + Fl::screen_driver()->copy(stuff, len, clipboard, type); + \endcode + */ + static void copy(const char *stuff, int len, int destination = 0, + const char *type = Fl::clipboard_plain_text); + + /** + Copies selections on X11 directly to the clipboard if enabled. + + This method can be called on all platforms. Other platforms than X11 are + not affected by this feature. + + If this is switched on (\p mode = 1), Fl::copy() copies all data to the + clipboard regardless of its \p destination argument. If the destination is 0 + (selection buffer) data is copied to both the selection buffer and the clipboard. + + Drag and drop is also affected since drag-and-drop data is copied to the selection + buffer. + + You can use this to make the experience of data selection and copying more like + that on other platforms (Windows, macOS, and even Wayland). + + The default operation mode is the standard X11 behavior (disabled). + + \note This feature is experimental and enabling it may have unexpected side effects. + It is your own responsibility if you enable it. + + \since 1.4.0 + + \param[in] mode 1 = enable selection_to_clipboard, 0 = disable selection_to_clipboard + + \see copy(const char *, int, int, const char *) + */ + static void selection_to_clipboard(int mode) { + selection_to_clipboard_ = mode ? 1 : 0; + } + + /** + \brief Returns the current selection_to_clipboard mode. + + \see void selection_to_clipboard(int) + */ + static int selection_to_clipboard() { return selection_to_clipboard_; } + + /** + Pastes the data from the selection buffer (\p source is 0) or the clipboard + (\p source is 1) into \p receiver. + + The selection buffer (\p source is 0) is used for middle-mouse pastes and for + drag-and-drop selections. The clipboard (\p source is 1) is used for + copy/cut/paste operations. + + If \p source is 1, the optional \p type argument indicates what type of data is requested from the clipboard. + At present, Fl::clipboard_plain_text (requesting text data) and + Fl::clipboard_image (requesting image data) are possible. + Set things up so the handle function of the \p receiver widget will be called with an FL_PASTE event some + time in the future if the clipboard does contain data of the requested type. + + The handle function of \p receiver can process the FL_PASTE event as follows: + \li If the \p receiver widget is known to only receive text data, the text string + from the specified \p source is in Fl::event_text() with UTF-8 encoding, and the + number of bytes is in Fl::event_length(). If Fl::paste() gets called during the + drop step of a files-drag-and-drop operation, + Fl::event_text() contains a list of filenames (see \ref events_dnd). + \li If the \p receiver widget can potentially receive non-text data, use + Fl::event_clipboard_type() to determine what sort of data is being sent. + If Fl::event_clipboard_type() returns Fl::clipboard_plain_text, proceed as above. + It it returns Fl::clipboard_image, the pointer returned by Fl::event_clipboard() + can be safely cast to type Fl_RGB_Image * to obtain a pointer to the pasted image. + If \p receiver accepts the clipboard image, receiver.handle() should return 1 and the + application should take ownership of this image (that is, delete it after use). + Conversely, if receiver.handle() returns 0, the application must not use the image. + + The receiver should be prepared to be called \e directly by this, or for + it to happen \e later, or possibly not at all. 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. + + \par Platform details for image data: + \li Unix/Linux platform: Clipboard images in PNG or BMP formats are recognized. Requires linking with the fltk_images library. + \li Windows platform: Both bitmap and vectorial (Enhanced metafile) data from clipboard + can be pasted as image data. + \li Mac OS X platform: Both bitmap (TIFF) and vectorial (PDF) data from clipboard + can be pasted as image data. + */ + static void paste(Fl_Widget &receiver, int source, const char *type = Fl::clipboard_plain_text); + + /** + FLTK will call the registered callback whenever there is a change to the + selection buffer or the clipboard. The source argument indicates which + of the two has changed. Only changes by other applications are reported. + + Example: + \code + void clip_callback(int source, void *data) { + if ( source == 0 ) printf("CLIP CALLBACK: selection buffer changed\n"); + if ( source == 1 ) printf("CLIP CALLBACK: clipboard changed\n"); + } + [..] + int main() { + [..] + Fl::add_clipboard_notify(clip_callback); + [..] + } + \endcode + \note Some systems require polling to monitor the clipboard and may + therefore have some delay in detecting changes. + */ + static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data = 0); + /** + Stop calling the specified callback when there are changes to the selection + buffer or the clipboard. + */ + static void remove_clipboard_notify(Fl_Clipboard_Notify_Handler h); + /** Returns non 0 if the clipboard contains data matching \p type. + The clipboard can contain both text and image data; in that situation this function + returns non 0 to both requests. + This function is \e not meant to check whether the clipboard is empty. + This function does not allow to query the selection buffer because FLTK + allows to copy/paste non-textual data only from/to the clipboard. + \param type can be Fl::clipboard_plain_text or Fl::clipboard_image. + */ + static int clipboard_contains(const char *type); + /** Denotes plain textual data + */ + static char const * const clipboard_plain_text; + /** Denotes image data + */ + static char const * const clipboard_image; + + /** + 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 text. + + 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 . + + FLTK supports high-DPI screens using a screen scaling factor. + The scaling factor is initialized by the library to a value + based on information obtained from the OS. If this initial value + is not satisfactory, the FLTK_SCALING_FACTOR environment variable + can be set to a value FLTK will multiply to the OS-given value. + The 2 variants of functions Fl::screen_scale() allow to programmatically get and set + scaling factor values. The scaling factor value can be further changed at runtime + by typing \c Ctrl/+/-/0/ (\c Cmd/+/-/0/ under macOS). + See \ref events_fl_shortcut for more details about these shortcuts. + @{ */ + static int x(); // via screen driver + static int y(); // via screen driver + static int w(); // via screen driver + static int h(); // via screen driver + + // multi-head support: + static int screen_count(); // via screen driver + static void screen_xywh(int &X, int &Y, int &W, int &H); // via screen driver + static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my); // via screen driver + static void screen_xywh(int &X, int &Y, int &W, int &H, int n); // via screen driver + static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh); // via screen driver + static int screen_num(int x, int y); // via screen driver + static int screen_num(int x, int y, int w, int h); // via screen driver + static void screen_dpi(float &h, float &v, int n=0); // via screen driver + static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my); // via screen driver + static void screen_work_area(int &X, int &Y, int &W, int &H, int n); // via screen driver + static void screen_work_area(int &X, int &Y, int &W, int &H); // via screen driver + static float screen_scale(int n); // via screen driver + static void screen_scale(int n, float factor); // via screen driver + static int screen_scaling_supported(); + static void keyboard_screen_scaling(int value); + +/** @} */ + + + /** \defgroup fl_attributes Color & Font functions + fl global color, font functions. + These functions are declared in or . + @{ */ + + // color map: + static void set_color(Fl_Color, uchar, uchar, uchar); + static void set_color(Fl_Color, uchar, 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); + static void get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue, uchar &alpha); + /** + 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 only argument to this function is somewhat obsolete since FLTK and most + underlying operating systems move to support Unicode. For completeness, + following is the original documentation and a few updates: + + On X11, 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 the Xft option on Linux, this parameter is ignored. + + With Windows, `NULL` selects fonts with ANSI_CHARSET encoding and non-NULL + selects all fonts. + + On macOS, this parameter is ignored. + + 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 , + and in for offscreen buffer-related ones. + @{ */ + // + /** @} */ + + // 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, + Fl_Box_Draw_Focus_F* =NULL); + 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(); + static Fl_Color box_color(Fl_Color); + static void set_box_color(Fl_Color); + + // 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_BUTTON5] } + */ + static int event_buttons() {return e_state & FL_BUTTONS;} + /** + 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 mouse 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 mouse button 3 is currently held down. + For more details, see Fl::event_buttons(). + */ + static int event_button3() {return e_state & FL_BUTTON3;} + /** + Returns non-zero if mouse button 4 is currently held down. + For more details, see Fl::event_buttons(). + */ + static int event_button4() {return e_state & FL_BUTTON4;} + /** + Returns non-zero if mouse button 5 is currently held down. + For more details, see Fl::event_buttons(). + */ + static int event_button5() {return e_state & FL_BUTTON5;} + /** @} */ + + /** + 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... + /** + 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 whether drag and drop text operations are + supported. This returns 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 + @{ */ + + // 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 , 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); + /** @} */ + + /** sets whether GL windows should be drawn at high resolution on Apple + computers with retina displays + \version 1.3.4 + */ + static void use_high_res_GL(int val) { use_high_res_GL_ = val; } + /** returns whether GL windows should be drawn at high resolution on Apple + computers with retina displays. + Default is no. + \version 1.3.4 + */ + static int use_high_res_GL() { return use_high_res_GL_; } + + /** sets whether OpenGL uses textures to draw all text. + By default, FLTK draws OpenGL text using textures, if the necessary + hardware support is available. Call \p Fl::draw_GL_text_with_textures(0) + once in your program before the first call to gl_font() to have FLTK + draw instead OpenGL text using a legacy, platform-dependent procedure. + It's recommended not to deactivate textures under the MacOS platform + because the MacOS legacy procedure is extremely rudimentary. + \param val use 0 to prevent FLTK from drawing GL text with textures + \see gl_texture_pile_height(int max) + \version 1.4.0 + */ + static void draw_GL_text_with_textures(int val) { draw_GL_text_with_textures_ = val; } + + /** returns whether whether OpenGL uses textures to draw all text. + Default is yes. + \see draw_GL_text_with_textures(int val) + \version 1.4.0 + */ + static int draw_GL_text_with_textures() { return draw_GL_text_with_textures_; } + + static int system(const char *command); + + // Convert Windows commandline arguments to UTF-8 (documented in src/Fl.cxx) + static int args_to_utf8(int argc, char ** &argv); + +#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 Cairo 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 + 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); + } + + /** Flush Cairo drawings on Cairo context \p c. + This is \b required on Windows if you use the Cairo context provided + by the "Cairo autolink" option. Call this when all your drawings on + the Cairo context are finished. This is maybe not necessary on other + platforms than Windows but it does no harm if you call it always. + + You don't need to use this if you use an Fl_Cairo_Window which does + this automatically after the draw callback returns. + + Code example for "Cairo autolink" mode: + + In the overridden draw() method of your subclass of Fl_Window or any + widget: + \code + cairo_t *cc = Fl::cairo_cc(); // get the "autolink" Cairo context + // ... your Cairo drawings are here ... + Fl::cairo_flush(cc); // flush Cairo drawings to the device + \endcode + + If you configure FLTK with \c '--enable-cairo' or CMake option + \c 'FLTK_OPTION_CAIRO_WINDOW' (i.e. without \c '--enable-cairoext' or CMake option + \c 'FLTK_OPTION_CAIRO_EXT') or if you don't enable the \c 'autolink' Cairo + context you may do the equivalent to use Cairo drawings in an + overridden draw() method of derived classes by using + \code + // get the Cairo context for the \c window + cairo_t *cc = Fl::cairo_make_current(window); + // ... your Cairo drawings are here ... + Fl::cairo_flush(cc); // flush Cairo drawings to the device + \endcode + \see Fl::cairo_autolink_context(bool) + \see Fl::cairo_make_current(Fl_Window*); + */ + static void cairo_flush(cairo_t *c) { + // flush Cairo drawings: necessary at least for Windows + cairo_surface_t *s = cairo_get_target(c); + cairo_surface_flush(s); + } + +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 whether 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 automatically + releases the widget pointer from the widget watch list. + + Fl_Widget_Tracker is intended to be used as an automatic (local/stack) + variable, such that its 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 no longer needed. + + 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, + // and it is safe to access the widget: + + box(FL_FLAT_BOX); + color(FL_WHITE); + redraw(); + } + } + \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 + + if (wp.widget() == 0) // ... + + 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 + + if (wp.widget() != 0) // ... + + 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 + @{ */ + /** @} */ + +#endif // !Fl_H diff --git a/include/linux/amd64/FL/Fl_Adjuster.H b/include/linux/amd64/FL/Fl_Adjuster.H new file mode 100644 index 0000000..be7a107 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Adjuster.H @@ -0,0 +1,67 @@ +// +// Adjuster widget header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 +

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() FL_OVERRIDE; + int handle(int) FL_OVERRIDE; + void value_damage() FL_OVERRIDE; +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 diff --git a/include/linux/amd64/FL/Fl_Anim_GIF_Image.H b/include/linux/amd64/FL/Fl_Anim_GIF_Image.H new file mode 100644 index 0000000..ca1c445 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Anim_GIF_Image.H @@ -0,0 +1,185 @@ +// +// Fl_Anim_GIF_Image class header for the Fast Light Tool Kit (FLTK). +// +// Copyright 2016-2023 by Christian Grabner . +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Anim_Gif_Image_H +#define Fl_Anim_Gif_Image_H + +// forward declarations +class Fl_Image; +class Fl_Widget; + +#include + +// Load and display animated GIF images +class FL_EXPORT Fl_Anim_GIF_Image : public Fl_GIF_Image { + + class FrameInfo; // internal helper class + +public: + + /** + When opening an Fl_Anim_GIF_Image there are some options + that can be passed in a `flags` value. + */ + enum Flags { + /** + This flag indicates to the loader that it should not start + the animation immediately after successful load, which is + the default. + It can be started later using the \ref start() method. + */ + DONT_START = 1, + /** + This flag indicates to the loader that it should not + resize the canvas widget of the animation to the dimensions + of the animation, which is the default. + Needed for special use cases. + */ + DONT_RESIZE_CANVAS = 2, + /** + This flag indicates to the loader that it should not + set the animation as \ref image() member of the canvas widget, + which is the default. + Needed for special use cases. + */ + DONT_SET_AS_IMAGE = 4, + /** + Often frames change just a small area of the animation canvas. + This flag indicates to the loader to try using less memory + by storing frame data not as canvas-sized images but use the + sizes defined in the GIF file. + The drawbacks are higher cpu usage during playback and maybe + minor artifacts when resized. + */ + OPTIMIZE_MEMORY = 8, + /** + This flag can be used to print informations about the + decoding process to the console. + */ + LOG_FLAG = 64, + /** + This flag can be used to print even more informations about + the decoding process to the console. + */ + DEBUG_FLAG = 128 + }; + + // -- constructors and destructor + Fl_Anim_GIF_Image(const char *filename, Fl_Widget *canvas = 0, unsigned short flags = 0); + Fl_Anim_GIF_Image(const char* imagename, const unsigned char *data, + const size_t length, Fl_Widget *canvas = 0, + unsigned short flags = 0); + Fl_Anim_GIF_Image(); + ~Fl_Anim_GIF_Image() FL_OVERRIDE; + + // -- file handling + bool load(const char *name, const unsigned char *imgdata=NULL, size_t imglength=0); + bool valid() const; + + // -- getters and setters + void frame_uncache(bool uncache); + bool frame_uncache() const; + double delay(int frame_) const; + void delay(int frame, double delay); + void canvas(Fl_Widget *canvas, unsigned short flags = 0); + Fl_Widget *canvas() const; + int canvas_w() const; + int canvas_h() const; + bool is_animated() const; + const char *name() const; + void speed(double speed); + double speed() const; + + // -- animation + int frames() const; + void frame(int frame); + int frame() const; + Fl_Image *image() const; + Fl_Image *image(int frame) const; + bool start(); + bool stop(); + bool next(); + + /** Return if the animation is currently running or stopped. + \return true if the animation is running + */ + bool playing() const { return valid() && Fl::has_timeout(cb_animate, (void *)this); } + + // -- image data + Fl_Anim_GIF_Image& resize(int w, int h); + Fl_Anim_GIF_Image& resize(double scale); + int frame_x(int frame) const; + int frame_y(int frame) const; + int frame_w(int frame) const; + int frame_h(int frame) const; + + // -- overridden methods + void color_average(Fl_Color c, float i) FL_OVERRIDE; + Fl_Image *copy(int W, int H) const FL_OVERRIDE; + Fl_Image *copy() const { return Fl_Pixmap::copy(); } + void desaturate() FL_OVERRIDE; + void draw(int x, int y, int w, int h, int cx = 0, int cy = 0) FL_OVERRIDE; + void uncache() FL_OVERRIDE; + + // -- debugging and logging + int debug() const; + + // -- static methods + static int frame_count(const char *name, const unsigned char *imgdata = NULL, size_t imglength = 0); + + /** + The loop flag can be used to (dis-)allow loop count. + If set (which is the default), the animation will be + stopped after the number of repeats specified in the + GIF file (typically this count is set to 'forever' anyway). + If cleared the animation will always be 'forever', + regardless of what is specified in the GIF file. + */ + static bool loop; + + /** + The min_delay value can be used to set a minimum value + for the frame delay for playback. This is to prevent + CPU hogs caused by images with very low delay rates. + This is a global value for all Fl_Anim_GIF_Image objects. + */ + static double min_delay; + +protected: + + bool next_frame(); + void clear_frames(); + void set_frame(int frame); + + static void cb_animate(void *d); + void scale_frame(); + void set_frame(); + void on_frame_data(Fl_GIF_Image::GIF_FRAME &f) FL_OVERRIDE; + void on_extension_data(Fl_GIF_Image::GIF_FRAME &f) FL_OVERRIDE; + +private: + + char *name_; + unsigned short flags_; + Fl_Widget *canvas_; + bool uncache_; + bool valid_; + int frame_; // current frame + double speed_; + FrameInfo *fi_; +}; + +#endif // Fl_Anim_Gif_Image_H diff --git a/include/linux/amd64/FL/Fl_BMP_Image.H b/include/linux/amd64/FL/Fl_BMP_Image.H new file mode 100644 index 0000000..462d619 --- /dev/null +++ b/include/linux/amd64/FL/Fl_BMP_Image.H @@ -0,0 +1,41 @@ +// +// BMP image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); + Fl_BMP_Image(const char* imagename, const unsigned char *data, const long length = -1); + +protected: + + void load_bmp_(class Fl_Image_Reader &rdr, int ico_height = 0, int ico_width = 0); + +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Bitmap.H b/include/linux/amd64/FL/Fl_Bitmap.H new file mode 100644 index 0000000..677af7d --- /dev/null +++ b/include/linux/amd64/FL/Fl_Bitmap.H @@ -0,0 +1,68 @@ +// +// Bitmap header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2017 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Bitmap widget . */ + +#ifndef Fl_Bitmap_H +#define Fl_Bitmap_H +#include "Fl_Image.H" +#include "Fl_Widget.H" // for fl_uintptr_t + +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_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: + /** for internal use */ + fl_uintptr_t id_; + int cache_w_, cache_h_; // size of bitmap when cached + +public: + /** The constructors create a new bitmap from the specified bitmap data. + \see Fl_Bitmap(const uchar *bits, int bits_length, int W, int H) */ + Fl_Bitmap(const uchar *bits, int W, int H) : + Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0), cache_w_(0),cache_h_(0) {data((const char **)&array, 1);} + /** The constructors create a new bitmap from the specified bitmap data. + \see Fl_Bitmap(const char *bits, int bits_length, int W, int H) */ + Fl_Bitmap(const char *bits, int W, int H) : + Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id_(0), cache_w_(0),cache_h_(0) {data((const char **)&array, 1);} + Fl_Bitmap(const uchar *bits, int bits_length, int W, int H); + Fl_Bitmap(const char *bits, int bits_length, int W, int H); + virtual ~Fl_Bitmap(); + Fl_Image *copy(int W, int H) const FL_OVERRIDE; + Fl_Image *copy() const { return Fl_Image::copy(); } + void draw(int X, int Y, int W, int H, int cx=0, int cy=0) FL_OVERRIDE; + void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} + void label(Fl_Widget*w) FL_OVERRIDE; + void label(Fl_Menu_Item*m) FL_OVERRIDE; + void uncache() FL_OVERRIDE; + int cache_w() {return cache_w_;} + int cache_h() {return cache_h_;} +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Box.H b/include/linux/amd64/FL/Fl_Box.H new file mode 100644 index 0000000..56e1ff5 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Box.H @@ -0,0 +1,53 @@ +// +// Box header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file FL/Fl_Box.H + \brief 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 its 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() FL_OVERRIDE; +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. + + The destructor removes the box. + */ + Fl_Box(int X, int Y, int W, int H, const char *l=0); + + /** 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); + + int handle(int) FL_OVERRIDE; +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Browser.H b/include/linux/amd64/FL/Fl_Browser.H new file mode 100644 index 0000000..f1e1009 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Browser.H @@ -0,0 +1,330 @@ +// +// Browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + \image html fl_hold_browser.png "Fl_Hold_Browser" + \image latex fl_hold_browser.png "Fl_Hold_Browser" width=4cm + + \par + + \image html fl_multi_browser.png "Fl_Multi_Browser" + \image latex fl_multi_browser.png "Fl_Multi_Browser" width=4cm + + Each line in the browser is identified by number. The numbers + start at one (this is so that zero can be reserved for "no line" in + the selective browsers). 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(). + + 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 subclassing 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 FL_OVERRIDE; + void* item_next(void* item) const FL_OVERRIDE; + void* item_prev(void* item) const FL_OVERRIDE; + void* item_last()const FL_OVERRIDE; + int item_selected(void* item) const FL_OVERRIDE; + void item_select(void* item, int val) FL_OVERRIDE; + int item_height(void* item) const FL_OVERRIDE; + int item_width(void* item) const FL_OVERRIDE; + void item_draw(void* item, int X, int Y, int W, int H) const FL_OVERRIDE; + int full_height() const FL_OVERRIDE; + int incr_height() const FL_OVERRIDE; + const char *item_text(void *item) const FL_OVERRIDE; + /** 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) FL_OVERRIDE { 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 FL_OVERRIDE { 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); } + + /** + Gets the default text size (in pixels) for the lines in the browser. + */ + Fl_Fontsize textsize() const { return Fl_Browser_::textsize(); } + + /* + Sets the default text size for the lines in the browser to newSize. + Defined and documented in Fl_Browser.cxx + */ + void textsize(Fl_Fontsize newSize); + + 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_OVERRIDE { Fl_Widget::show(); } + void hide(int line); + /** Hides the entire Fl_Browser widget -- opposite of show(). */ + void hide() FL_OVERRIDE { 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 '\@.' Print rest of line, don't look for more '\@' signs + \li '\@\@' Doubling the format character prints the format + character once, followed by the rest of line + \li '\@l' Use a LARGE (24 point) font + \li '\@m' Use a medium large (18 point) font + \li '\@s' Use a small (11 point) font + \li '\@b' Use a bold font (adds FL_BOLD to font) + \li '\@i' Use an italic font (adds FL_ITALIC to font) + \li '\@f' or '\@t' Use a fixed-pitch + font (sets font to FL_COURIER) + \li '\@c' Center the line horizontally + \li '\@r' Right-justify the text + \li '\@N' Use fl_inactive_color() to draw the text + \li '\@B0', '\@B1', ... '\@B255' Fill the background with + fl_color(n) + \li '\@C0', '\@C1', ... '\@C255' Use fl_color(n) to draw the text + \li '\@F0', '\@F1', ... Use fl_font(n) to draw the text + \li '\@S1', '\@S2', ... Use point size n to draw the text + \li '\@u' or '\@_' Underline the text. + \li '\@-' 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 + sprintf("@C%d@.%s", color, string) 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(..); + static 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 diff --git a/include/linux/amd64/FL/Fl_Browser_.H b/include/linux/amd64/FL/Fl_Browser_.H new file mode 100644 index 0000000..5db510f --- /dev/null +++ b/include/linux/amd64/FL/Fl_Browser_.H @@ -0,0 +1,417 @@ +// +// Common browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2016 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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::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 */ +#define FL_SORT_CASEINSENSITIVE 0x2 /**< sort case insensitively */ + +/** + 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. + + Callbacks are called when the value changes with \p FL_REASON_CHANGED. + If \p FL_WHEN_RELEASE is set, callbacks are called when the mouse button is + released with \p FL_REASON_CHANGED or \p FL_REASON_RESELECTED if the selection + did not change. If \p FL_WHEN_ENTER_KEY is set, callbacks are also called when + key presses or double clicks change the selection. + +Keyboard navigation of browser items +------------------------------------ + + The keyboard navigation of browser items is only possible if + visible_focus() is enabled. If disabled, the widget rejects keyboard focus; + Tab and Shift-Tab focus navigation will skip the widget. + + In 'Select' and 'Normal' mode, the widget rejects keyboard focus; + no navigation keys are supported (other than scrollbar positioning). + + In 'Hold' mode, the widget accepts keyboard focus, and Up/Down arrow + keys can navigate the selected item. + + In 'Multi' mode, the widget accepts keyboard focus, and Up/Down arrow + keys navigate the focus box; Space toggles the current item's selection, + Enter selects only the current item (deselects all others). If Shift + (or Ctrl) is combined with Up/Down arrow keys, the current item's + selection state is extended to the next item. In this way one can + extend a selection or de-selection. +*/ +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 + int linespacing_; + + 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_OVERRIDE; + 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. + + Use `scrollbar_left()` or `scrollbar_right()` to change what side + the vertical scrollbar is drawn on. + + Use `scrollbar.align(int)` (see `Fl_Widget::align(Fl_Align)`) + to change what side either of the scrollbars is 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. + */ + Fl_Scrollbar scrollbar; + /** + Horizontal scrollbar. Public, so that it can be accessed directly. + */ + Fl_Scrollbar hscrollbar; + + int handle(int event) FL_OVERRIDE; + void resize(int X,int Y,int W,int H) FL_OVERRIDE; + + 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 vposition() const { return position_; } + FL_DEPRECATED("since 1.4.0 - use vposition() instead", + int position() const) { return vposition(); } + + void vposition(int pos); // scroll to here + FL_DEPRECATED("since 1.4.0 - use vposition(pos) instead", + void position(int pos)) { return vposition(pos); } + void position(int x, int y) { Fl_Group::position(x, y); } + + /** + 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 newSize) { textsize_ = newSize; } + + /** + 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::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 \p newSize, 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 newSize to the special value of 0 causes the widget to + track the global Fl::scrollbar_size(), which is the default. + + \param[in] newSize 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 newSize) { + scrollbar_size_ = newSize; + } + /** + Returns the global value Fl::scrollbar_size(). + \deprecated Use scrollbar_size() instead. + \todo This method should eventually be removed in 1.4+ + */ + int scrollbar_width() const { + return(Fl::scrollbar_size()); + } + /** + Sets the global Fl::scrollbar_size(), and forces this instance of the widget to use it. + \deprecated Use scrollbar_size() instead. + \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); + + /** + Add some space between browser lines. + \param[in] pixels number of additional pixels between lines. + */ + void linespacing(int pixels) { linespacing_ = pixels; } + + /** Return the height of additional spacing between browser lines. + \return spacing height in pixel units. + */ + int linespacing() const { return linespacing_; } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Button.H b/include/linux/amd64/FL/Fl_Button.H new file mode 100644 index 0000000..31b71a4 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Button.H @@ -0,0 +1,181 @@ +// +// Button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2014 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 type() == FL_RADIO_BUTTON + 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(uchar) and + when(uchar). 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. + \see Fl_Widget::shortcut_label(int) + + 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 type() == FL_RADIO_BUTTON + are set to zero. + + 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. The reason is + \p FL_REASON_RELEASED. + \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). The reason is set to + \p FL_REASON_CHANGED + \li \c FL_WHEN_NOT_CHANGED: The callback is done when the mouse button is + released, but the value did not changed. The reason is set to + \p FL_REASON_SELECTED +*/ + +class FL_EXPORT Fl_Button : public Fl_Widget { + + int shortcut_; + char value_; + char oldval; + uchar down_box_; + uchar compact_; + +protected: + + static Fl_Widget_Tracker *key_release_tracker; + static void key_release_timeout(void*); + void simulate_key_action(); + + void draw() FL_OVERRIDE; + +public: + + int handle(int) FL_OVERRIDE; + + 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: + FL_ALT | 'a', or + 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). + \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(). + + Some derived classes (e.g. Fl_Round_Button and Fl_Light_Button use + down_box() for special purposes. See docs of these classes. + + \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);} + + // handle flag for compact buttons, documentation in source code + void compact(uchar v); + + /// Return true if buttons are rendered as compact buttons. + /// \return 0 if compact mode is off, 1 if it is on + /// \see compact(bool) + uchar compact() { return compact_; } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Cairo.H b/include/linux/amd64/FL/Fl_Cairo.H new file mode 100644 index 0000000..cf43de4 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Cairo.H @@ -0,0 +1,101 @@ +// +// Main Cairo support header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file Fl_Cairo.H + Cairo is currently supported for the following platforms: + Windows, macOS, Unix/Linux (X11 + Wayland). + + \note In FLTK 1.3.x this header file (Fl_Cairo.H) included the platform + specific Cairo headers. This is no longer true since 1.4.0. + + This header file is platform agnostic. If you need platform specific Cairo + headers you need to \#include them in your source file. + + To use FLTK's builtin Cairo support you need to \#include \ + \b before you include any other FLTK header which is officially required anyway. + Since FLTK 1.4.0 the preprocessor constants \p FLTK_HAVE_CAIRO and/or + \p FLTK_HAVE_CAIROEXT are defined in \ by including \. +*/ + +#ifndef FL_CAIRO_H +#define FL_CAIRO_H + +#include + +# ifdef FLTK_HAVE_CAIRO + +# include + +/** + \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 or + --enable-cairoext option or one or both of the CMake options + FLTK_OPTION_CAIRO_WINDOW or FLTK_OPTION_CAIRO_EXT is set (ON) +*/ +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 == \e true (the default) indicates that the cairo context \p c + will be deleted by FLTK internally when another cc is set later. + + \p own == \e false indicates cc deletion is handled externally + by the user program. + */ + 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_; // false by default, prevents 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 diff --git a/include/linux/amd64/FL/Fl_Cairo_Window.H b/include/linux/amd64/FL/Fl_Cairo_Window.H new file mode 100644 index 0000000..ebffb51 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Cairo_Window.H @@ -0,0 +1,128 @@ +// +// Fl_Cairo_Window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file FL/Fl_Cairo_Window.H + \brief Fl_Cairo_Window, an FLTK window incorporating a Cairo draw callback. +*/ + +#ifndef FL_CAIRO_WINDOW_H +# define FL_CAIRO_WINDOW_H + +#include + +# ifdef FLTK_HAVE_CAIRO + +// Cairo is currently supported for the following platforms: +// Win32, Apple Quartz, X11, Wayland + +# include +# include + +/** + \addtogroup group_cairo + @{ +*/ + +/** + This defines an FLTK window with Cairo support. + + 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. + + The default coordinate system for Cairo drawing commands within Fl_Cairo_Window + is FLTK's coordinate system, where the `x,y,w,h` values are relative to the + top/left corner of the Fl_Cairo_Window, as one would expect with regular + FLTK drawing commands, e.g.: `(0 ≤ x ≤ w-1), (0 ≤ y ≤ h-1)`. + \b Example: + \code + static void my_cairo_draw_cb(Fl_Cairo_Window *window, cairo_t *cr) { + // Draw an "X" + const double xmax = (window->w() - 1); + const double ymax = (window->h() - 1); + cairo_set_line_width(cr, 1.00); // line width for drawing + cairo_set_source_rgb(cr, 1.0, 0.5, 0.0); // orange + cairo_move_to(cr, 0.0, 0.0); cairo_line_to(cr, xmax, ymax); // draw diagonal "\" + cairo_move_to(cr, 0.0, ymax); cairo_line_to(cr, xmax, 0.0); // draw diagonal "/" + cairo_stroke(cr); // stroke the lines + } + \endcode + + The FLTK coordinate system differs from the default native Cairo coordinate system + which uses normalized `(0.0 … 1.0)` values for x and y, e.g.: `(0 ≤ x ≤ 1.0), (0 ≤ y ≤ 1.0)`. + So beware of this when copy/pasting Cairo example programs that assume normalized values. + If need be, you can revert to the Cairo coordinate system by simply calling `cairo_scale()` + with the widget's `w()` and `h()` values. \b Example: + + \code + static void my_cairo_draw_cb(Fl_Cairo_Window *window, cairo_t *cr) { + cairo_scale(cr, window->w(), window->h()); // use Cairo's default coordinate system + [..use 0.0 to 1.0 values from here on..] + } + \endcode + + \see examples/cairo-draw-x.cxx + \see test/cairo_test.cxx + + \note Class Fl_Cairo_Window requires the FLTK library to have been built with + CMake option FLTK_OPTION_CAIRO_WINDOW or configure --enable-cairo. + + \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 this 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, const char *L = 0) + : Fl_Double_Window(W, H, L), draw_cb_(0) {} + Fl_Cairo_Window(int X, int Y, int W, int H, const char *L = 0) + : Fl_Double_Window(X, Y, W, H, L), draw_cb_(0) {} + +protected: + /** Overloaded to provide Cairo callback support. */ + void draw() FL_OVERRIDE { + Fl_Double_Window::draw(); + if (draw_cb_) { // call the Cairo draw callback + // manual method ? if yes explicitly get a cairo_context here + if (!Fl::cairo_autolink_context()) + Fl::cairo_make_current(this); + draw_cb_(this, Fl::cairo_cc()); + // flush Cairo drawings: necessary at least for Windows + Fl::cairo_flush(Fl::cairo_cc()); + } + } + +public: + /** The Cairo draw callback prototype you need to implement. */ + typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def); + + /** + You must provide a draw callback that implements your Cairo rendering. + This method permits 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 diff --git a/include/linux/amd64/FL/Fl_Chart.H b/include/linux/amd64/FL/Fl_Chart.H new file mode 100644 index 0000000..0a0f7ff --- /dev/null +++ b/include/linux/amd64/FL/Fl_Chart.H @@ -0,0 +1,178 @@ +// +// Fl_Chart widget header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file FL/Fl_Chart.H + \brief 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: + + | Chart Type | Description | + |---------------------|-------------------------------------------------------------------------------------------------| + | FL_BAR_CHART | Each sample value is drawn as a vertical bar. | + | FL_FILLED_CHART | The chart is filled from the bottom of the graph to the sample values. | + | FL_HORBAR_CHART | Each sample value is drawn as a horizontal bar. | + | FL_LINE_CHART | The chart is drawn as a polyline with vertices at each sample value. | + | FL_PIE_CHART | A pie chart is drawn with each sample value being drawn as a proportionate slice in the circle. | + | FL_SPECIALPIE_CHART | Like \c FL_PIE_CHART, but the first slice is separated from the pie. | + | 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() FL_OVERRIDE; + + // (static) protected draw methods (STR 2022) + // these methods are documented in src/Fl_Chart.cxx + + static void draw_barchart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[], + double min, double max, int autosize, int maxnumb, Fl_Color textcolor); + + static void draw_horbarchart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[], + double min, double max, int autosize, int maxnumb, + Fl_Color textcolor); + + static void draw_linechart(int type, int x, int y, int w, int h, int numb, + FL_CHART_ENTRY entries[], double min, double max, int autosize, + int maxnumb, Fl_Color textcolor); + + static void draw_piechart(int x, int y, int w, int h, int numb, FL_CHART_ENTRY entries[], + int special, Fl_Color textcolor); + +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; } + + /** + Sets the widget size (width, height). + + This is the same as calling Fl_Widget::size(int W, int H); + + \param[in] W,H new width and height of the widget + */ + 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_; } + + /** Sets 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_; } + + /** Sets the chart's text color to \p n. */ + void textcolor(Fl_Color n) { textcolor_ = n; } + + /** + Gets 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_; } + + /** + Sets 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 diff --git a/include/linux/amd64/FL/Fl_Check_Browser.H b/include/linux/amd64/FL/Fl_Check_Browser.H new file mode 100644 index 0000000..50a719f --- /dev/null +++ b/include/linux/amd64/FL/Fl_Check_Browser.H @@ -0,0 +1,110 @@ +// +// Fl_Check_Browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2020 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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_ { + +protected: + /* required routines for Fl_Browser_ subclass: */ + void *item_first() const FL_OVERRIDE; + void *item_next(void *) const FL_OVERRIDE; + void *item_prev(void *) const FL_OVERRIDE; + int item_height(void *) const FL_OVERRIDE; + int item_width(void *) const FL_OVERRIDE; + void item_draw(void *, int, int, int, int) const FL_OVERRIDE; + void item_select(void *, int) FL_OVERRIDE; + int item_selected(void *) const FL_OVERRIDE; + const char *item_text(void *item) const FL_OVERRIDE; + +public: + void *item_at(int index) const FL_OVERRIDE; + void item_swap(int ia, int ib); + void item_swap(void *a, void *b) FL_OVERRIDE; + + /* 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) FL_OVERRIDE; +}; + +#endif // Fl_Check_Browser_H diff --git a/include/linux/amd64/FL/Fl_Check_Button.H b/include/linux/amd64/FL/Fl_Check_Button.H new file mode 100644 index 0000000..29a0a4a --- /dev/null +++ b/include/linux/amd64/FL/Fl_Check_Button.H @@ -0,0 +1,33 @@ +// +// Check button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2014 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Check_Button_H +#define Fl_Check_Button_H + +#include "Fl_Light_Button.H" + +/* + class: Fl_Check_Button. + + A button with a "checkmark" to show its status. +*/ + +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 diff --git a/include/linux/amd64/FL/Fl_Choice.H b/include/linux/amd64/FL/Fl_Choice.H new file mode 100644 index 0000000..944f4d3 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Choice.H @@ -0,0 +1,123 @@ +// +// Choice header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + \image html choice.png + \image latex choice.png "Fl_Choice" width=4cm + + 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 clicks a menu item, value() is set to that item + and then: + + - The item's callback is done if one has been set; the + Fl_Choice is passed as the Fl_Widget* argument, + along with any userdata configured for the callback. + + - If the item does not have a callback, the Fl_Choice widget's + callback is done instead, along with any userdata configured + for it. The callback can determine which item was picked using + value(), mvalue(), item_pathname(), etc. + + 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. + + The inherited Fl_Widget::changed() and related methods can be used as follows: + \li int Fl_Widget::changed() const + This value is true when the user picks a different value. It is turned + off by value() and just before doing a callback (the callback can turn + it back on if desired). + \li void Fl_Widget::set_changed() + This method sets the changed() flag. + \li void Fl_Widget::clear_changed() + This method clears the changed() flag. + + The inherited Fl_Menu_::down_box() methods can be used as follows: + \li Fl_Boxtype Fl_Menu_::down_box() const + 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 void Fl_Menu_::down_box(Fl_Boxtype b) + Sets the current down box type to \p b. + + Simple example: + \par + \code + #include + #include + #include + int main() { + Fl_Window *win = new Fl_Window(300,200); + Fl_Choice *choice = new Fl_Choice(100,10,100,25,"Choice:"); + choice->add("Zero"); + choice->add("One"); + choice->add("Two"); + choice->add("Three"); + choice->value(2); // make "Two" selected by default (zero based!) + win->end(); + win->show(); + return Fl::run(); + } + \endcode + + */ +class FL_EXPORT Fl_Choice : public Fl_Menu_ { +protected: + void draw() FL_OVERRIDE; +public: + int handle(int) FL_OVERRIDE; + + 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 -1 initially. + */ + int value() const {return Fl_Menu_::value();} + + int value(int v); + + int value(const Fl_Menu_Item* v); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Clock.H b/include/linux/amd64/FL/Fl_Clock.H new file mode 100644 index 0000000..0a5eac4 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Clock.H @@ -0,0 +1,163 @@ +// +// Clock header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2017 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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(): +// Please change doxygen documentation below (class Fl_Clock_Output) +// accordingly as well when changing the following type values: + +#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 vertical 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
+
type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK
\endhtmlonly + \image html clock.png + \htmlonly \endhtmlonly + \image html round_clock.png + \htmlonly
\endhtmlonly + \image latex clock.png "FL_SQUARE_CLOCK type" width=4cm + \image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm + + Values for clock type() (\#include \): + + \code + #define FL_SQUARE_CLOCK 0 // Square Clock variant + #define FL_ROUND_CLOCK 1 // 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 + \endcode + + */ +class FL_EXPORT Fl_Clock_Output : public Fl_Widget { + int hour_, minute_, second_; + ulong value_; + int shadow_; // draw shadows of hands + void drawhands(Fl_Color,Fl_Color); // part of draw +protected: + void draw() FL_OVERRIDE; + 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_;} + + /** + Returns the shadow drawing mode of the hands. + + \returns shadow drawing mode of the hands + \retval 0 no shadows + \retval 1 draw shadows of hands (default) + */ + int shadow() const {return shadow_;} + + /** + Sets the shadow drawing mode of the hands. + + Enables (1) or disables (0) drawing the hands with shadows. + + Values except 0 and 1 are reserved for future extensions and + yield undefined behavior. + + The default is to draw the shadows (1). + + \param[in] mode 1 = shadows (default), 0 = no shadows + */ + void shadow(int mode) { shadow_ = mode ? 1 : 0; } +}; + +// a Fl_Clock displays the current time always by using a timeout: + +/** + \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(). + Please see Fl_Clock_Output widget for applicable values. + + \htmlonly
+
type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK
\endhtmlonly + \image html clock.png + \htmlonly \endhtmlonly + \image html round_clock.png + \htmlonly
\endhtmlonly + \image latex clock.png "FL_SQUARE_CLOCK type" width=4cm + \image latex round_clock.png "FL_ROUND_CLOCK type" width=4cm + + \see class Fl_Clock_Output + */ +class FL_EXPORT Fl_Clock : public Fl_Clock_Output { +public: + int handle(int) FL_OVERRIDE; + + 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 diff --git a/include/linux/amd64/FL/Fl_Color_Chooser.H b/include/linux/amd64/FL/Fl_Color_Chooser.H new file mode 100644 index 0000000..29baece --- /dev/null +++ b/include/linux/amd64/FL/Fl_Color_Chooser.H @@ -0,0 +1,193 @@ +// +// Color chooser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2019 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 +#include +#include +#include +#include + +#ifndef FL_DOXYGEN + +/** For internal use only */ +class FL_EXPORT Flcc_HueBox : public Fl_Widget { + int px, py; +protected: + void draw() FL_OVERRIDE; + int handle_key(int); +public: + int handle(int) FL_OVERRIDE; + 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() FL_OVERRIDE; + int handle_key(int); +public: + int handle(int) FL_OVERRIDE; + 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*) FL_OVERRIDE; + 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). + + The user can press CTRL-C to copy the currently selected color value as + text in RGB hex format with leading zeroes to the clipboard, for instance + \p FL_GREEN would be '00FF00' (since FLTK 1.4.0). + + 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. + + Callback reasons can be \c FL_REASON_DRAGGED, \c FL_REASON_CHANGED, or + \c FL_REASON_RESELECTED. + */ +/** @} */ +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: + + int handle(int e) FL_OVERRIDE; + + /** + 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. + This value is convenient for the internal calculations - some other + systems consider hue to run from zero to one, or from 0 to 360. + */ + 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 diff --git a/include/linux/amd64/FL/Fl_Copy_Surface.H b/include/linux/amd64/FL/Fl_Copy_Surface.H new file mode 100644 index 0000000..c9e74e2 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Copy_Surface.H @@ -0,0 +1,107 @@ +// +// Copy-to-clipboard code for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Copy_Surface_H +#define Fl_Copy_Surface_H + +#include + +/** Supports copying of graphical data to the clipboard. + +
After creation of an Fl_Copy_Surface object, make it the current drawing surface calling Fl_Surface_Device::push_current(), and all subsequent graphics requests + will be recorded in the clipboard. It's possible to draw widgets (using Fl_Copy_Surface::draw() + ) or to use any of the \ref fl_drawings or the \ref fl_attributes. + Finally, delete the Fl_Copy_Surface object to load the clipboard with the graphical data. +
Fl_Gl_Window 's can be copied to the clipboard as well. +
Usage example: + \code + Fl_Widget *g = ...; // a widget you want to copy to the clipboard + Fl_Copy_Surface *copy_surf = new Fl_Copy_Surface(g->w(), g->h()); // create an Fl_Copy_Surface object + Fl_Surface_Device::push_current(copy_surf); // direct graphics requests to the clipboard + fl_color(FL_WHITE); fl_rectf(0, 0, g->w(), g->h()); // draw a white background + copy_surf->draw(g); // draw the g widget in the clipboard + Fl_Surface_Device::pop_current(); // direct graphics requests back to their previous destination + delete copy_surf; // after this, the clipboard is loaded + \endcode + Platform details: + \li Windows: Transparent RGB images copy without transparency. + The graphical data are copied to the clipboard in two formats: 1) as an 'enhanced metafile'; + 2) as a color bitmap. Applications to which the clipboard content is pasted can use the format + that suits them best. + \li Mac OS: The graphical data are copied to the clipboard (a.k.a. pasteboard) in two 'flavors': + 1) in vectorial form as PDF data; 2) in bitmap form as a TIFF image. + Applications to which the clipboard content is pasted can use the flavor that suits them best. + \li X11 and Wayland: the graphical data are copied to the clipboard as an image in BMP format. +*/ +class FL_EXPORT Fl_Copy_Surface : public Fl_Widget_Surface { +private: + class Fl_Copy_Surface_Driver *platform_surface; +protected: + void translate(int x, int y) FL_OVERRIDE; + void untranslate() FL_OVERRIDE; +public: + Fl_Copy_Surface(int w, int h); + ~Fl_Copy_Surface(); + void set_current() FL_OVERRIDE; + bool is_current() FL_OVERRIDE; + /** Returns the pixel width of the copy surface */ + int w(); + /** Returns the pixel height of the copy surface */ + int h(); + void origin(int *x, int *y) FL_OVERRIDE; + void origin(int x, int y) FL_OVERRIDE; + int printable_rect(int *w, int *h) FL_OVERRIDE; +}; + + +/** + \cond DriverDev + \addtogroup DriverDeveloper + \{ + */ + +/** + A base class describing the interface between FLTK and draw-to-clipboard operations. + + This class is only for internal use by the FLTK library. + + A supported platform should implement the virtual methods of this class + in order to support drawing to the clipboard through class Fl_Copy_Surface. + */ +class Fl_Copy_Surface_Driver : public Fl_Widget_Surface { + friend class Fl_Copy_Surface; +protected: + int width; + int height; + Fl_Copy_Surface_Driver(int w, int h) : Fl_Widget_Surface(NULL), width(w), height(h) {} + virtual ~Fl_Copy_Surface_Driver() {} + void set_current() FL_OVERRIDE = 0; + void translate(int x, int y) FL_OVERRIDE = 0; + void untranslate() FL_OVERRIDE = 0; + int printable_rect(int *w, int *h) FL_OVERRIDE; + /** Each platform implements this function its own way. + It returns an object implementing all virtual functions + of class Fl_Copy_Surface_Driver for the platform. + */ + static Fl_Copy_Surface_Driver *newCopySurfaceDriver(int w, int h); +}; + +/** + \} + \endcond + */ + +#endif // Fl_Copy_Surface_H diff --git a/include/linux/amd64/FL/Fl_Counter.H b/include/linux/amd64/FL/Fl_Counter.H new file mode 100644 index 0000000..dddcfa4 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Counter.H @@ -0,0 +1,109 @@ +// +// Counter header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + \image html counter.png + \image latex counter.png "Fl_Counter" width=4cm + + The type of an Fl_Counter object can be set using Fl_Widget::type(uchar) 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() FL_OVERRIDE; + // compute widths of arrow boxes + void arrow_widths(int &w1, int &w2); + +public: + + int handle(int) FL_OVERRIDE; + + 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 diff --git a/include/linux/amd64/FL/Fl_Device.H b/include/linux/amd64/FL/Fl_Device.H new file mode 100644 index 0000000..764bcd1 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Device.H @@ -0,0 +1,127 @@ +// +// Definition of classes Fl_Surface_Device, Fl_Display_Device +// for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010-2021 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file Fl_Device.H + \brief declaration of classes Fl_Surface_Device, Fl_Display_Device, Fl_Device_Plugin. +*/ + +#ifndef Fl_Device_H +#define Fl_Device_H + +#include +#include + +class Fl_Graphics_Driver; +class Fl_RGB_Image; +class Fl_Widget; +class Fl_Image_Surface; + +/** + A drawing surface that's susceptible to receive graphical output. + Any FLTK application has at any time a current drawing surface to which all drawing requests are directed. + The current surface is given by Fl_Surface_Device::surface(). + When main() begins running, the current drawing surface has been set to the computer's display, + an instance of the Fl_Display_Device class. + + A drawing surface other than the computer's display, is typically used as follows: +

  1. Create \c surface, an object from an Fl_Surface_Device derived class (e.g., Fl_Image_Surface, Fl_Printer, Fl_Copy_Surface). +
  2. Call \c Fl_Surface_Device::push_current(surface); to redirect all graphics requests to + \c surface which becomes the new current drawing surface (not necessary with classes Fl_Printer / Fl_PostScript_File_Device / + Fl_PDF_File_Surface because it is done by Fl_Paged_Device::begin_page()). +
  3. At this point all of the \ref fl_drawings (e.g., fl_rect()) or the \ref fl_attributes or \ref drawing_images functions + (e.g., fl_draw_image(), Fl_Image::draw()) operate on the new current drawing surface. + It's also possible to draw to the current surface any widget with Fl_Widget_Surface::draw(Fl_Widget*, int, int), a window and its + titlebar with Fl_Widget_Surface::draw_decorated_window(), or the content of a rectangular zone of a window + with Fl_Widget_Surface::print_window_part(). +
  4. After all drawing requests have been performed, redirect graphics requests back to their previous destination + with \c Fl_Surface_Device::pop_current(); (not necessary with classes Fl_Printer / Fl_PostScript_File_Device / Fl_PDF_File_Surface). +
  5. Delete \c surface. +
+ For back-compatibility, it is also possible to use the Fl_Surface_Device::set_current() member function + to change the current drawing surface, once to the new surface, once to the previous one. + */ +class FL_EXPORT Fl_Surface_Device { + /** The graphics driver in use by this surface. */ + Fl_Graphics_Driver *pGraphicsDriver; + static Fl_Surface_Device *surface_; // the surface that currently receives graphics requests + static Fl_Surface_Device *default_surface(); // create surface if none exists yet +protected: + /** FLTK calls this each time a surface ceases to be the current drawing surface. + This member function is mostly of interest to developers of new Fl_Surface_Device derived classes. + It allows to perform surface-specific operations necessary when this surface ceases to be current. + Each implementation should end with a call to Fl_Surface_Device::end_current(). */ + virtual void end_current() { surface_ = 0;} + /** Constructor that sets the graphics driver to use for the created surface. */ + Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver; } + /** Sets the graphics driver of this drawing surface. */ + inline void driver(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver;} +public: + virtual void set_current(void); + virtual bool is_current(); + /** \brief Returns the graphics driver of this drawing surface. */ + inline Fl_Graphics_Driver *driver() {return pGraphicsDriver; } + /** The current drawing surface. + In other words, the Fl_Surface_Device object that currently receives all graphics requests. + \note It's possible to transiently remove the GUI scaling factor in place in the current + drawing surface with \ref fl_override_scale(). */ + static inline Fl_Surface_Device *surface() { + return surface_ ? surface_ : default_surface(); + } + /** \brief The destructor. */ + virtual ~Fl_Surface_Device(); + static void push_current(Fl_Surface_Device *new_current); + static Fl_Surface_Device *pop_current(); +}; + +/** + The computer's display. + When FLTK begins to access the computer's display, it creates an object of class Fl_Display_Device and makes + it the current drawing surface. + */ +class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device { + Fl_Display_Device(Fl_Graphics_Driver *graphics_driver); +public: + static Fl_Display_Device *display_device(); +}; + +/** + This plugin socket allows the integration of new device drivers for special + window or screen types. + This class is not intended for use outside the FLTK library. + It is currently used to provide an automated printing + service and screen capture for OpenGL windows, if linked with fltk_gl. + */ +class Fl_Device_Plugin : public Fl_Plugin { +public: + /** \brief The constructor */ + Fl_Device_Plugin(const char *pluginName) + : Fl_Plugin(klass(), pluginName) { } + /** \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 */ + virtual int print(Fl_Widget* w) = 0; + /** Captures a rectangle of a widget as an image + \return The captured pixels as an RGB image + */ + virtual Fl_RGB_Image* rectangle_capture(Fl_Widget *widget, int x, int y, int w, int h) = 0; + /** Returns the OpenGL plugin */ + static Fl_Device_Plugin *opengl_plugin(); +}; + +#endif // Fl_Device_H diff --git a/include/linux/amd64/FL/Fl_Dial.H b/include/linux/amd64/FL/Fl_Dial.H new file mode 100644 index 0000000..2440b5c --- /dev/null +++ b/include/linux/amd64/FL/Fl_Dial.H @@ -0,0 +1,82 @@ +// +// Dial header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + \image html dial.png + \image latex dial.png "Fl_Dial" width=4cm + Use type() to set the type of the dial to: +
    +
  • FL_NORMAL_DIAL - Draws a normal dial with a knob.
  • +
  • FL_LINE_DIAL - Draws a dial with a line.
  • +
  • FL_FILL_DIAL - Draws a dial with a filled arc.
  • +
+ +*/ +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() FL_OVERRIDE; + +public: + + int handle(int) FL_OVERRIDE; + /** + 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 diff --git a/include/linux/amd64/FL/Fl_Double_Window.H b/include/linux/amd64/FL/Fl_Double_Window.H new file mode 100644 index 0000000..0cf127a --- /dev/null +++ b/include/linux/amd64/FL/Fl_Double_Window.H @@ -0,0 +1,55 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + It will draw the window data into an off-screen pixmap, and then + copy it to the on-screen window. +*/ +class FL_EXPORT Fl_Double_Window : public Fl_Window +{ +public: + Fl_Double_Window *as_double_window() FL_OVERRIDE {return this; } + void show() FL_OVERRIDE; + /** Same as Fl_Window::show(int a, char **b) */ + void show(int a, char **b) {Fl_Window::show(a,b);} + void resize(int,int,int,int) FL_OVERRIDE; + void hide() FL_OVERRIDE; + void flush() FL_OVERRIDE; + ~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); + + /** + 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); + +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Export.H b/include/linux/amd64/FL/Fl_Export.H new file mode 100644 index 0000000..84c619b --- /dev/null +++ b/include/linux/amd64/FL/Fl_Export.H @@ -0,0 +1,37 @@ +/* + * Windows DLL export . + * + * Copyright 1998-2018 by Bill Spitzak and others. + * + * This library is free software. Distribution and use rights are outlined in + * the file "COPYING" which should have been included with this file. If this + * file is missing or damaged, see the license at: + * + * https://www.fltk.org/COPYING.php + * + * Please see the following page on how to report bugs and issues: + * + * https://www.fltk.org/bugs.php + */ + +#ifndef Fl_Export_H +# define Fl_Export_H + +/* + * The following is used when building DLLs under Windows + * and when building .so's under unix/linux. + */ + +# if defined(FL_DLL) +# ifdef FL_LIBRARY +# define FL_EXPORT __declspec(dllexport) +# else +# define FL_EXPORT __declspec(dllimport) +# endif /* FL_LIBRARY */ +# elif __GNUC__ >= 4 +# define FL_EXPORT __attribute__ ((visibility ("default"))) +# else +# define FL_EXPORT +# endif /* FL_DLL */ + +#endif /* !Fl_Export_H */ diff --git a/include/linux/amd64/FL/Fl_File_Browser.H b/include/linux/amd64/FL/Fl_File_Browser.H new file mode 100644 index 0000000..620315c --- /dev/null +++ b/include/linux/amd64/FL/Fl_File_Browser.H @@ -0,0 +1,99 @@ +// +// FileBrowser definitions. +// +// Copyright 1999-2010 by Michael Sweet. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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_; + const char *errmsg_; + + int full_height() const FL_OVERRIDE; + int item_height(void *) const FL_OVERRIDE; + int item_width(void *) const FL_OVERRIDE; + void item_draw(void *, int, int, int, int) const FL_OVERRIDE; + int incr_height() const FL_OVERRIDE { return (item_height(0) + linespacing()); } + +public: + enum { FILES, DIRECTORIES }; + + Fl_File_Browser(int, int, int, int, const char * = 0); + ~Fl_File_Browser(); + + /** 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_); } + 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; } + void errmsg(const char *emsg); + /** + Returns OS error messages, or NULL if none. Use when advised. + */ + const char* errmsg() const { return errmsg_; } +}; + +#endif // !_Fl_File_Browser_H_ diff --git a/include/linux/amd64/FL/Fl_File_Chooser.H b/include/linux/amd64/FL/Fl_File_Chooser.H new file mode 100644 index 0000000..4b7efa2 --- /dev/null +++ b/include/linux/amd64/FL/Fl_File_Chooser.H @@ -0,0 +1,257 @@ +// +// Fl_File_Chooser dialog for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// +// ======================================================================= +// DO NOT EDIT FL/Fl_File_Chooser.H and src/Fl_File_Chooser.cxx !!! +// ======================================================================= +// Please use fluid to change src/Fl_File_Chooser.fl interactively +// and then use fluid to "write code" or edit and use fluid -c . +// ======================================================================= +// + +// generated by Fast Light User Interface Designer (fluid) version 1.0400 + +#ifndef Fl_File_Chooser_H +#define Fl_File_Chooser_H +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class FL_EXPORT Fl_File_Chooser { +public: + /** + \enum Type + Determines the type of file chooser presented to the user. + */ + enum Type { + SINGLE = 0, ///< Select a single, existing file. + MULTI = 1, ///< Select one or more existing files. + CREATE = 2, ///< When used alone, select a single, existing file or specify a new filename. + ///< Can be combined with DIRECTORY (e.g. CREATE|DIRECTORY) to have the same + ///< effect for directories. + DIRECTORY = 4 ///< Select a single, existing directory. Can be combined with CREATE. + }; +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 *pathname, const char *pattern, int type_val, const char *title); +private: + Fl_Double_Window *window; + inline void cb_window_i(Fl_Double_Window*, void*); + static void cb_window(Fl_Double_Window*, void*); + Fl_Choice *showChoice; + inline void cb_showChoice_i(Fl_Choice*, void*); + static void cb_showChoice(Fl_Choice*, void*); + Fl_Menu_Button *favoritesButton; + inline void cb_favoritesButton_i(Fl_Menu_Button*, void*); + static void cb_favoritesButton(Fl_Menu_Button*, void*); +public: + Fl_Button *newButton; +private: + inline void cb_newButton_i(Fl_Button*, void*); + static void cb_newButton(Fl_Button*, void*); + inline void cb__i(Fl_Tile*, void*); + static void cb_(Fl_Tile*, void*); + Fl_File_Browser *fileList; + inline void cb_fileList_i(Fl_File_Browser*, void*); + static void cb_fileList(Fl_File_Browser*, void*); + Fl_Box *errorBox; + Fl_Box *previewBox; +public: + Fl_Check_Button *previewButton; +private: + inline void cb_previewButton_i(Fl_Check_Button*, void*); + static void cb_previewButton(Fl_Check_Button*, void*); +public: + Fl_Check_Button *showHiddenButton; +private: + inline void cb_showHiddenButton_i(Fl_Check_Button*, void*); + static void cb_showHiddenButton(Fl_Check_Button*, void*); + Fl_File_Input *fileName; + inline void cb_fileName_i(Fl_File_Input*, void*); + static void cb_fileName(Fl_File_Input*, void*); + Fl_Return_Button *okButton; + inline void cb_okButton_i(Fl_Return_Button*, void*); + static void cb_okButton(Fl_Return_Button*, void*); + Fl_Button *cancelButton; + inline void cb_cancelButton_i(Fl_Button*, void*); + static void cb_cancelButton(Fl_Button*, void*); + Fl_Double_Window *favWindow; + Fl_File_Browser *favList; + inline void cb_favList_i(Fl_File_Browser*, void*); + static void cb_favList(Fl_File_Browser*, void*); + Fl_Button *favUpButton; + inline void cb_favUpButton_i(Fl_Button*, void*); + static void cb_favUpButton(Fl_Button*, void*); + Fl_Button *favDeleteButton; + inline void cb_favDeleteButton_i(Fl_Button*, void*); + static void cb_favDeleteButton(Fl_Button*, void*); + Fl_Button *favDownButton; + inline void cb_favDownButton_i(Fl_Button*, void*); + static void cb_favDownButton(Fl_Button*, void*); + Fl_Button *favCancelButton; + inline void cb_favCancelButton_i(Fl_Button*, void*); + static void cb_favCancelButton(Fl_Button*, void*); + Fl_Return_Button *favOkButton; + inline 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 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(); + void hide(); + 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(); + void position(int x, int y); + int x() const; + int y() const; + int w() const; + int h() const; + void size(int w, int h); + void resize(int x, int y, int w, int h); + /** + [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); +protected: + void show_error_box(int val); +}; +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 diff --git a/include/linux/amd64/FL/Fl_File_Icon.H b/include/linux/amd64/FL/Fl_File_Icon.H new file mode 100644 index 0000000..c633586 --- /dev/null +++ b/include/linux/amd64/FL/Fl_File_Icon.H @@ -0,0 +1,153 @@ +// +// Fl_File_Icon definitions. +// +// Copyright 1999-2010 by Michael Sweet. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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_ diff --git a/include/linux/amd64/FL/Fl_File_Input.H b/include/linux/amd64/FL/Fl_File_Input.H new file mode 100644 index 0000000..832db01 --- /dev/null +++ b/include/linux/amd64/FL/Fl_File_Input.H @@ -0,0 +1,102 @@ +// +// File_Input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// Original version Copyright 1998 by Curtis Edwards. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_File_Input widget . */ + +#ifndef Fl_File_Input_H +# define Fl_File_Input_H + +# include + +/** + \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. + + \image html Fl_File_Input.png + \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 { + + 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); + + int handle(int event) FL_OVERRIDE; + +protected: + void draw() FL_OVERRIDE; + +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. + + Returns \p FL_RED since FLTK 1.4.0 (default in 1.3.x). + Retained for backwards compatibility. + + \deprecated Will be removed in FLTK 1.5.0 or higher. + \todo Remove Fl_File_Input::errorcolor() in FLTK 1.5.0 or higher. + */ + Fl_Color errorcolor() const { return FL_RED; } + + /** + Sets the current error color to \p c. + + Does nothing since FLTK 1.4.0. Retained for backwards compatibility. + + \deprecated Will be removed in FLTK 1.5.0 or higher. + \todo Remove Fl_File_Input::errorcolor(Fl_Color) in FLTK 1.5.0 or higher. + */ + void errorcolor(Fl_Color c) {(void)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 diff --git a/include/linux/amd64/FL/Fl_Fill_Dial.H b/include/linux/amd64/FL/Fl_Fill_Dial.H new file mode 100644 index 0000000..3b6bf7f --- /dev/null +++ b/include/linux/amd64/FL/Fl_Fill_Dial.H @@ -0,0 +1,32 @@ +// +// Filled dial header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 = NULL); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Fill_Slider.H b/include/linux/amd64/FL/Fl_Fill_Slider.H new file mode 100644 index 0000000..9290ed0 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Fill_Slider.H @@ -0,0 +1,31 @@ +// +// Filled slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Flex.H b/include/linux/amd64/FL/Fl_Flex.H new file mode 100644 index 0000000..ef46dac --- /dev/null +++ b/include/linux/amd64/FL/Fl_Flex.H @@ -0,0 +1,354 @@ +// +// Fl_Flex widget header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 2020 by Karsten Pedersen +// Copyright 2022-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Flex_H +#define Fl_Flex_H + +#include + +/** + Fl_Flex is a container (layout) widget for one row or one column of widgets. + + It provides flexible positioning of its children either in one row or in one + column. + + Fl_Flex is designed to be as simple as possible. You can set individual widget + sizes or let Fl_Flex position and size the widgets to fit in the container. + All "flexible" (i.e. non-fixed size) widgets are assigned the same width or + height, respectively. For details see below. + + You can set the margins \b around all children at the inner side of the box + frame (if any). Fl_Flex supports setting different margin sizes on top, + bottom, left, and right sides. + The default margin size is 0 on all edges of the container. + + You can set the gap size \b between all children. The gap size is always the + same between all of its children. This is similar to the 'spacing' of Fl_Pack. + The default gap size is 0. + + Fl_Flex can either consist of a single row, i.e. \p type(Fl_Flex::HORIZONTAL) + or a single column, i.e. \p type(Fl_Flex::VERTICAL). The default value is + Fl_Flex::VERTICAL for consistency with Fl_Pack but you can use \p type() + to assign a row (Fl_Flex::HORIZONTAL) layout. + + If type() == Fl_Flex::HORIZONTAL widgets are resized horizontally to fit in + the container and their height is the full Fl_Flex height minus border size + and margins. You can set a fixed widget width by using fixed(). + + If type() == Fl_Flex::VERTICAL widgets are resized vertically to fit in + the container and their width is the full Fl_Flex width minus border size + and margins. You can set a fixed widget height by using fixed(). + + To create arbitrary spacing you can use invisible boxes of flexible or + fixed sizes (see example below). + + Alternate constructors let you specify the layout as Fl_Flex::HORIZONTAL or + Fl_Flex::VERTICAL directly. Fl_Flex::ROW is an alias of Fl_Flex::HORIZONTAL + and Fl_Flex::COLUMN is an alias of Fl_Flex::VERTICAL. + + The default box type is FL_NO_BOX as inherited from Fl_Group. You \b may + need to set a box type with a solid background depending on your layout. + + \b Important: You should always make sure that the Fl_Flex container cannot + be resized smaller than its designed minimal size. This can usually be done by + setting a size_range() on the window as shown in the example below. Fl_Flex + does not take care of sensible sizes. If it is resized too small the behavior + is undefined, i.e. widgets may overlap and/or shrink to zero size. + + \b Hint: In many cases Fl_Flex can be used as a drop-in replacement + for Fl_Pack. This is the recommended single row/column container + since FLTK 1.4.0. Its resizing behavior is much more predictable + than that of Fl_Pack which "resizes itself to shrink-wrap itself + around all of the children". + + Fl_Flex containers can be nested so you can create flexible layouts with + multiple columns and rows. However, if your UI design is more complex you + may want to use Fl_Grid instead. + + Example: + \image html Fl_Flex_simple.png + \image latex Fl_Flex_simple.png "Fl_Flex" width=6cm + + Example code: + \code + #include + #include + #include + #include + #include + + int main(int argc, char **argv) { + Fl_Double_Window window(410, 40, "Simple Fl_Flex Demo"); + Fl_Flex flex(5, 5, 400, 30, Fl_Flex::HORIZONTAL); + Fl_Button b1(0, 0, 0, 0, "File"); + Fl_Button b2(0, 0, 0, 0, "Save"); + Fl_Box bx(0, 0, 0, 0); + Fl_Button b3(0, 0, 0, 0, "Exit"); + flex.fixed(bx, 60); // set fix width of invisible box + flex.gap(10); + flex.end(); + window.resizable(flex); + window.end(); + window.size_range(300, 30); + window.show(argc, argv); + return Fl::run(); + } + \endcode + + \since 1.4.0 +*/ +class FL_EXPORT Fl_Flex : public Fl_Group { + + int margin_left_; // left margin + int margin_top_; // top margin + int margin_right_; // right margin + int margin_bottom_; // bottom margin + int gap_; // gap between widgets + int fixed_size_size_; // number of fixed size widgets in array + int fixed_size_alloc_; // allocated size of fixed size array + Fl_Widget **fixed_size_; // array of fixed size widgets + bool need_layout_; // true if layout needs to be calculated + +public: + + enum { // values for type(int) + VERTICAL = 0, ///< vertical layout (one column) + HORIZONTAL = 1, ///< horizontal layout (one row) + COLUMN = 0, ///< alias for VERTICAL + ROW = 1 ///< alias for HORIZONTAL + }; + + // FLTK standard constructor + Fl_Flex(int X, int Y, int W, int H, const char *L = 0); + + // original Fl_Flex constructors: + // backwards compatible if direction enums { ROW | COLUMN } are used + + Fl_Flex(int direction); + Fl_Flex(int w, int h, int direction); + Fl_Flex(int x, int y, int w, int h, int direction); + + virtual ~Fl_Flex(); + + virtual void end(); + void resize(int x, int y, int w, int h) FL_OVERRIDE; + + /** + Set the horizontal or vertical size of a child widget. + + \param[in] w widget to be affected + \param[in] size width (Fl_Flex::HORIZONTAL) or height (Fl_Flex::VERTICAL) + + \see fixed(Fl_Widget *w, int size) + */ + void fixed(Fl_Widget &w, int size) { + fixed(&w, size); + } + + void fixed(Fl_Widget *w, int size); + int fixed(Fl_Widget *w) const; + +protected: + + void init(int t = VERTICAL); + + virtual int alloc_size(int size) const; + + void on_remove(int) FL_OVERRIDE; + void draw() FL_OVERRIDE; + +public: + + /** + Set or reset the request to calculate the layout of children. + + This is intended for internal use but can also be used by user + code to request layout calculation before the widget is drawn. + + Call this if you changed attributes or sizes of children to ensure + that the layout is calculated properly. Changing other Fl_Flex + attributes or resizing the widget does this automatically. + + \note Never call this with '\c set == 0' because this would defeat its + purpose to recalculate the layout before the widget is drawn. + */ + void need_layout(int set) { + if (set) need_layout_ = true; + else need_layout_ = false; + } + + /** + Returns whether layout calculation is required. + + This should rarely be needed by user code. Used internally in draw(). + */ + bool need_layout() const { + return need_layout_; + } + + /** Returns the left margin size of the widget. + + This returns the \b left margin of the widget which is not necessarily + the same as all other margins. + + \note This method is useful if you never set different margin sizes. + + \see int margin(int *left, int *top, int *right, int *bottom) + to get all four margin values. + \return size of left margin. + */ + int margin() const { return margin_left_; } + + /** Returns all (four) margin sizes of the widget. + + All margin sizes are returned in the given arguments. If any argument + is \p NULL the respective value is not returned. + + \param[in] left returns left margin if not \p NULL + \param[in] top returns top margin if not \p NULL + \param[in] right returns right margin if not \p NULL + \param[in] bottom returns bottom margin if not \p NULL + + \return whether all margins are equal + \retval 1 all margins have the same size + \retval 0 at least one margin has a different size + */ + int margin(int *left, int *top, int *right, int *bottom) const { + if (left) *left = margin_left_; + if (top) *top = margin_top_; + if (right) *right = margin_right_; + if (bottom) *bottom = margin_bottom_; + if (margin_left_ == margin_top_ && margin_top_ == margin_right_ && margin_right_ == margin_bottom_) + return 1; + return 0; + } + + /** Set the margin and optionally the gap size of the widget. + This method can be used to set both the margin and the gap size. + + If you don't use the second parameter \p g or supply a negative value + the gap size is not changed. + + The margin is the free space inside the widget border \b around all child widgets. + + This method sets the margin to the same size at all four edges of the Fl_Flex widget. + + The gap size \p g is the free space \b between child widgets. Negative values + do not change the gap value. This is the default if this argument is omitted. + + \param[in] m margin size, must be \>= 0 + \param[in] g gap size (ignored, if negative) + + \see gap(int) + */ + + void margin(int m, int g = -1) { + if (m < 0) + m = 0; + margin_left_ = margin_top_ = margin_right_ = margin_bottom_ = m; + if (g >= 0) + gap_ = g; + need_layout(1); + } + + /** Set the margin sizes at all four edges of the Fl_Flex widget. + + The margin is the free space inside the widget border \b around all child widgets. + + You must use all four parameters of this method to set the four margins in the + order \p left, \p top, \p right, \p bottom. Negative values are set to 0 (zero). + + To set all margins to equal sizes, use margin(int m) which sets all four margins + to the same size. + + \param[in] left,top,right,bottom margin sizes, must be \>= 0 + + \see margin(int, int) + */ + void margin(int left, int top, int right, int bottom) { + margin_left_ = left < 0 ? 0 : left; + margin_top_ = top < 0 ? 0 : top; + margin_right_ = right < 0 ? 0 : right; + margin_bottom_ = bottom < 0 ? 0 : bottom; + need_layout(1); + } + + /** Return the gap size of the widget. + \return gap size between all child widgets. + */ + int gap() const { + return gap_; + } + + /** + Set the gap size of the widget. + + The gap size is some free space \b between child widgets. + The size must be \>= 0. Negative values are clamped to 0. + + \param[in] g gap size + */ + void gap(int g) { + gap_ = g < 0 ? 0 : g; + need_layout(1); + } + + /** Returns non-zero (true) if Fl_Flex alignment is horizontal (row mode). + + \returns non-zero if Fl_Flex alignment is horizontal + \retval 1 if type() == Fl_Flex::HORIZONTAL + \retval 0 if type() == Fl_Flex::VERTICAL + + See class Fl_Flex documentation for details. + */ + int horizontal() const { + return type() == Fl_Flex::HORIZONTAL ? 1 : 0; + } + + // Calculate the layout of the widget and redraw it. + void layout(); + + /** + Gets the number of extra pixels of blank space that are added + between the children. + + This method is the same as 'int gap()' and is defined to enable + using Fl_Flex as a drop-in replacement of Fl_Pack. + + \see int gap() + */ + int spacing() const { + return gap_; + } + + /** + Sets the number of extra pixels of blank space that are added + between the children. + + This method is the same as 'gap(int)' and is defined to enable + using Fl_Flex as a drop-in replacement of Fl_Pack. + + \see void gap(int) + */ + void spacing(int i) { + gap(i); + need_layout(1); + } + +}; + +#endif // Fl_Flex_H diff --git a/include/linux/amd64/FL/Fl_Float_Input.H b/include/linux/amd64/FL/Fl_Float_Input.H new file mode 100644 index 0000000..7524e8d --- /dev/null +++ b/include/linux/amd64/FL/Fl_Float_Input.H @@ -0,0 +1,41 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + */ + Fl_Float_Input(int X,int Y,int W,int H,const char *l = 0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_FormsBitmap.H b/include/linux/amd64/FL/Fl_FormsBitmap.H new file mode 100644 index 0000000..edde9a1 --- /dev/null +++ b/include/linux/amd64/FL/Fl_FormsBitmap.H @@ -0,0 +1,41 @@ +// +// Forms bitmap header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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() FL_OVERRIDE; +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 diff --git a/include/linux/amd64/FL/Fl_FormsPixmap.H b/include/linux/amd64/FL/Fl_FormsPixmap.H new file mode 100644 index 0000000..3cbe7c0 --- /dev/null +++ b/include/linux/amd64/FL/Fl_FormsPixmap.H @@ -0,0 +1,48 @@ +// +// Forms pixmap header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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() FL_OVERRIDE; +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 diff --git a/include/linux/amd64/FL/Fl_Free.H b/include/linux/amd64/FL/Fl_Free.H new file mode 100644 index 0000000..138a213 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Free.H @@ -0,0 +1,74 @@ +// +// Forms free header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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() FL_OVERRIDE; +public: + int handle(int e) FL_OVERRIDE; + 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 diff --git a/include/linux/amd64/FL/Fl_GIF_Image.H b/include/linux/amd64/FL/Fl_GIF_Image.H new file mode 100644 index 0000000..51562e1 --- /dev/null +++ b/include/linux/amd64/FL/Fl_GIF_Image.H @@ -0,0 +1,86 @@ +// +// GIF image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 GIFSM 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); + // deprecated constructor w/o length (for backwards compatibility) + Fl_GIF_Image(const char* imagename, const unsigned char *data); + // constructor with length (since 1.4.0) + Fl_GIF_Image(const char* imagename, const unsigned char *data, const size_t length); + + static bool is_animated(const char *name_); + /** Sets how the shared image core routine should treat animated GIF files. + The default is to treat them as ordinary GIF's e.g. it creates a Fl_GIF_Image object. + If this variable is set, then an animated GIF object Fl_Anim_GIF_Image is created. + */ + static bool animate; + +protected: + + // Protected constructors needed for animated GIF support through Fl_Anim_GIF_Image. + Fl_GIF_Image(const char* filename, bool anim); + Fl_GIF_Image(const char* imagename, const unsigned char *data, const size_t length, bool anim); + // Protected default constructor needed for Fl_Anim_GIF_Image. + Fl_GIF_Image(); + + void load_gif_(class Fl_Image_Reader &rdr, bool anim=false); + + void load(const char* filename, bool anim); + void load(const char* imagename, const unsigned char *data, const size_t length, bool anim); + + // Internal structure to "glue" animated GIF support into Fl_GIF_Image. + // This data is passed during decoding to the Fl_Anim_GIF_Image class. + struct GIF_FRAME { + int ifrm, width, height, x, y, w, h, + clrs, bkgd, trans, + dispose, delay; + const uchar *bptr; + const struct CPAL { + uchar r, g, b; + } *cpal; + GIF_FRAME(int frame, uchar *data) : ifrm(frame), bptr(data) {} + GIF_FRAME(int frame, int W, int H, int fx, int fy, int fw, int fh, uchar *data) : + ifrm(frame), width(W), height(H), x(fx), y(fy), w(fw), h(fh), bptr(data) {} + void disposal(int mode, int time) { dispose = mode; this->delay = time; } + void colors(int nclrs, int bg, int tp) { clrs = nclrs; bkgd = bg; trans = tp; } + }; + + // Internal virtual methods, which are called during decoding to pass data + // to the Fl_Anim_GIF_Image class. + virtual void on_frame_data(GIF_FRAME &) {} + virtual void on_extension_data(GIF_FRAME &) {} + +private: + + void lzw_decode(Fl_Image_Reader &rdr, uchar *Image, int Width, int Height, int CodeSize, int ColorMapSize, int Interlace); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Gl_Window.H b/include/linux/amd64/FL/Fl_Gl_Window.H new file mode 100644 index 0000000..8506359 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Gl_Window.H @@ -0,0 +1,257 @@ +// +// OpenGL header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Gl_Window widget . */ + +#ifndef Fl_Gl_Window_H +#define Fl_Gl_Window_H + +#include "Fl_Window.H" + +class Fl_Gl_Choice; // structure to hold result of glXChooseVisual +class Fl_Gl_Window_Driver; +/** + 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. + + \see \ref opengl_highdpi + + \note FLTK 1.4 introduces a driver system for graphic calls. It is now possible + to add a selection of widgets to an OpenGL window. The widgets will draw on top + of any OpenGL rendering. The number of supported widgets will increase as the + driver development improves. Program test/cube.cxx illustrates how to do that. + + \note FLTK expects that when an Fl_Gl_Window is a child of a parent Fl_Window, + the child window lies entirely inside its parent window. If that's not the case, what + happens to the part of the GL subwindow which leaks outside its parent is undefined + and susceptible to be platform-specific. +*/ +class FL_EXPORT Fl_Gl_Window : public Fl_Window { + friend class Fl_Gl_Window_Driver; + Fl_Gl_Window_Driver *pGlWindowDriver; + + 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; + + static int can_do(int, const int *); + int mode(int, const int *); + static int gl_plugin_linkage(); +protected: + void draw_begin(); + void draw() FL_OVERRIDE; + void draw_end(); + +public: + void show() FL_OVERRIDE; + /** Same as Fl_Window::show(int a, char **b) */ + void show(int a, char **b) {Fl_Window::show(a,b);} + void flush() FL_OVERRIDE; + void hide() FL_OVERRIDE; + void resize(int,int,int,int) FL_OVERRIDE; + int handle(int) FL_OVERRIDE; + + /** + 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,pixel_w(),pixel_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 OpenGL mode. */ + static int can_do(int m) {return can_do(m,0);} + /** Returns non-zero if the hardware supports the given OpenGL mode. + \see Fl_Gl_Window::mode(const int *a) */ + static int can_do(const int *m) {return can_do(0, m);} + /** Returns non-zero if the hardware supports the current OpenGL mode. */ + int can_do() {return can_do(mode_,alist);} + /** Returns the current OpenGL capabilities of the window. + Don't use this if capabilities were set through Fl_Gl_Window::mode(const int *a). + */ + Fl_Mode mode() const {return (Fl_Mode)mode_;} + /** + Set or change the OpenGL capabilities 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 + - \c FL_OPENGL3 - use OpenGL version 3.0 or more. + + 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. + + The FL_OPENGL3 flag is recommended to use OpenGL version 3 or more. + This flag is required (not just recommended) if GL ≥ 3.0 is in use + and at least one of these conditions applies: + - the program runs on the macOS platform; + - the Fl_Gl_Window has child widgets. + + See more details in \ref opengl3. + + \version the FL_OPENGL3 flag appeared in version 1.3.4 + */ + int mode(int a) {return mode(a,0);} + /** Set the OpenGL capabilities of the window using platform-specific data. + \param a zero-ending array of platform-specific attributes and attribute values +

Unix/Linux platform: attributes are GLX attributes adequate for the 3rd argument of + the glXChooseVisual() function (e.g., GLX_DOUBLEBUFFER, defined by including ). + \note What attributes are adequate here is subject to change. + The preferred, stable public API is Fl_Gl_Window::mode(int a). +

Windows platform: this member function is of no use. +

Mac OS X platform: attributes belong to the CGLPixelFormatAttribute enumeration + (defined by including , e.g., kCGLPFADoubleBuffer) + and may be followed by adequate attribute values. + */ + int mode(const int *a) {return mode(0, a);} + /** Returns a pointer to the window's OpenGL rendering context. + \see void context(GLContext c, int destroy_flag) + */ + GLContext context() const {return context_;} + void context(GLContext, int destroy_flag = 0); + void make_current(); + void swap_buffers(); + void swap_interval(int); + int swap_interval() const; + void ortho(); + + int can_do_overlay(); + void redraw_overlay(); + void hide_overlay(); + void make_overlay_current(); + + // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. + Fl_Gl_Window* as_gl_window() FL_OVERRIDE { return this; } + Fl_Gl_Window const* as_gl_window() const FL_OVERRIDE { return this; } + + float pixels_per_unit(); + /** Gives the window width in OpenGL pixels. + When an Fl_Gl_Window is mapped to a HighDPI display, the value given by Fl_Gl_Window::w() + which is expressed in FLTK units, may differ from the window width in pixels. + Calls to OpenGL functions expecting pixel values (\em e.g., \c glViewport) should therefore + use pixel_w() rather than w(). + Method pixel_w() detects when the GUI is rescaled or when the window has been moved + between low and high resolution displays and automatically adjusts the returned value. + \version 1.3.4 + */ + int pixel_w() { return int(pixels_per_unit() * w() + 0.5f); } + /** Gives the window height in OpenGL pixels. + When an Fl_Gl_Window is mapped to a HighDPI display, the value given by Fl_Gl_Window::h() + which is expressed in FLTK units, may differ from the window height in pixels. + Calls to OpenGL functions expecting pixel values (\em e.g., \c glViewport) should therefore + use pixel_h() rather than h(). + Method pixel_h() detects when the GUI is rescaled or when the window has been moved + between low and high resolution displays and automatically adjusts the returned value. + \version 1.3.4 + */ + int pixel_h() { return int(pixels_per_unit() * h() + 0.5f); } + + ~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();} +}; + +#endif // Fl_Gl_Window_H diff --git a/include/linux/amd64/FL/Fl_Graphics_Driver.H b/include/linux/amd64/FL/Fl_Graphics_Driver.H new file mode 100644 index 0000000..2ac70ba --- /dev/null +++ b/include/linux/amd64/FL/Fl_Graphics_Driver.H @@ -0,0 +1,504 @@ +// +// Declaration of classes Fl_Graphics_Driver, Fl_Scalable_Graphics_Driver, +// and Fl_Font_Descriptor for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** + \cond DriverDev + \addtogroup DriverDeveloper + \{ + */ + +/** \file Fl_Graphics_Driver.H + \brief Declaration of class Fl_Graphics_Driver. +*/ + +#ifndef FL_GRAPHICS_DRIVER_H +#define FL_GRAPHICS_DRIVER_H + +#include +#include +#include +#include +#include + +class Fl_Graphics_Driver; +class Fl_Font_Descriptor; +class Fl_Image_Surface; +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); + +struct Fl_Fontdesc; +typedef struct _PangoFontDescription PangoFontDescription; + +#define FL_REGION_STACK_SIZE 10 +#define FL_MATRIX_STACK_SIZE 32 + +/** + An abstract class subclassed for each graphics driver FLTK uses. + Typically, FLTK applications do not use directly objects from this class. Rather, they perform + drawing operations (e.g., fl_rectf()) that operate on the current drawing surface (see Fl_Surface_Device). + Drawing operations are functionally presented in \ref drawing and as function lists + in the \ref fl_drawings and \ref fl_attributes modules. + + Fl_Surface_Device::surface()->driver() + gives at any time the graphics driver used by all drawing operations. + For compatibility with older FLTK versions, the \ref fl_graphics_driver global variable gives the same result. + Its value changes when + drawing operations are directed to another drawing surface by Fl_Surface_Device::push_current() / + Fl_Surface_Device::pop_current() / Fl_Surface_Device::set_current(). + + The Fl_Graphics_Driver class is essential for developers of the FLTK library. + Each platform supported by FLTK requires to create a derived class of Fl_Graphics_Driver that + implements all its virtual member functions according to the platform. + */ +class FL_EXPORT Fl_Graphics_Driver { + friend class Fl_Surface_Device; + friend class Fl_Pixmap; + friend class Fl_Bitmap; + friend class Fl_RGB_Image; + friend class Fl_SVG_Image; + 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_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D); + friend void fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D); + friend void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); + friend int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg); + friend FL_EXPORT void gl_start(); + /* ============== Implementation note about image drawing ========================= + A graphics driver can implement up to 6 virtual member functions to draw images: + virtual void draw_pixmap(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, int cx, int cy) + virtual void draw_bitmap(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, int cx, int cy) + virtual void draw_rgb(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy) +and + virtual void draw_fixed(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, int cx, int cy) + virtual void draw_fixed(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, int cx, int cy) + virtual void draw_fixed(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy) + - The 1st group of functions is used when the driver can directly map the image data, + sized at data_w() x data_h(), to the image drawing area, sized at w()*scale x h()*scale + where scale is the current GUI scale factor. + - If the driver does not support such scale-and-draw operation for a given image type, + it should implement the draw_fixed() function which is called by the library after the + image has been internally resized to the drawing size and cached. + - The platform-independent Fl_Graphics_Driver class implements the 1st group of functions. + Each resizes the image, caches it, and calls the platform-specific implementation of + draw_fixed(image-class *,....) with the cached image. + - Consider an image object, say from class Fl_RGB_Image. Fl_RGB_Image::draw() + calls the virtual member function draw_rgb(Fl_RGB_Image *,....). If Fl_XXX_Graphics_Driver + re-implements this function, this code runs and is expected to draw the image + adequately scaled to its drawing size. If Fl_XXX_Graphics_Driver does not re-implement + this function, Fl_Graphics_Driver::draw_rgb(Fl_RGB_Image *,....) runs. It internally + resizes the image, caches it, and calls Fl_XXX_Graphics_Driver::draw_fixed(Fl_RGB_Image *,....) + that draws the image from its cached form which already has the adequate size. + - Some drivers implement, for a given image class, only the function of the 1st group or + only draw_fixed() as in these examples: + - Fl_Quartz_Graphics_Driver implements only draw_rgb(Fl_RGB_Image *,....) because it + can perform the scale-and-draw operation whatever the RGB image and the required scaling. + - Fl_Xlib_Graphics_Driver implements only draw_fixed(Fl_Pixmap *,....). The library + takes care of resizing and caching the Pixmap to the adequate drawing size. + - Some drivers implement, for a given image class, the function of both groups, e.g. : + Fl_GDI_Graphics_Driver implements both draw_rgb(Fl_RGB_Image *,....) and + draw_fixed(Fl_RGB_Image *,....) because scale-and-draw may require function Alphablend() + from MSIMG32.DLL. In the absence of that, the draw_rgb() implementation calls + Fl_Graphics_Driver::draw_rgb() which runs Fl_GDI_Graphics_Driver::draw_fixed(Fl_RGB_Image*,...). + + Graphics drivers also implement cache(Fl_Pixmap*), cache(Fl_Bitmap*) and cache(Fl_RGB_Image*) + to compute the cached form of all image types, and uncache(Fl_RGB_Image *,...), + uncache_pixmap(fl_uintptr_t) and delete_bitmask(fl_uintptr_t) to destroy cached image forms. + Graphics drivers that use the mask_ variable of class Fl_Pixmap to cache an Fl_Pixmap + object also reimplement the uchar **Fl_Graphics_Driver::mask_bitmap() member function. + */ +private: + virtual void draw_fixed(Fl_Pixmap *pxm,int XP, int YP, int WP, int HP, int cx, int cy); + virtual void draw_fixed(Fl_Bitmap *bm,int XP, int YP, int WP, int HP, int cx, int cy); + virtual void draw_fixed(Fl_RGB_Image *rgb,int XP, int YP, int WP, int HP, int cx, int cy); + // the default implementation of make_unused_color_() is most probably enough + virtual void make_unused_color_(unsigned char &r, unsigned char &g, unsigned char &b, int color_count, void **data); + // some platforms may need to reimplement this + virtual void set_current_(); + float scale_; // scale between FLTK and drawing coordinates: drawing = FLTK * scale_ +public: + /** Creates the graphics driver that is used for core operations. */ + static Fl_Graphics_Driver *newMainGraphicsDriver(); + /** A 2D coordinate transformation matrix */ + struct matrix {double a, b, c, d, x, y;}; + /** Features that a derived class may possess. */ + typedef enum { + NATIVE = 1, /**< native graphics driver for the platform */ + PRINTER = 2 /**< graphics driver for a printer drawing surface */ + } driver_feature; + +protected: + int fl_clip_state_number; ///< For internal use by FLTK + static const matrix m0; ///< For internal use by FLTK + Fl_Font font_; ///< current font + Fl_Fontsize size_; ///< current font size + Fl_Color color_; ///< current color + int sptr;///< For internal use by FLTK + static const int matrix_stack_size = FL_MATRIX_STACK_SIZE; ///< For internal use by FLTK + matrix stack[FL_MATRIX_STACK_SIZE]; ///< For internal use by FLTK + matrix m; ///< current transformation matrix + int n; ///< For internal use by FLTK + int gap_; ///< For internal use by FLTK + enum SHAPE {NONE=0, LINE, LOOP, POLYGON, POINTS, COMPLEX_POLYGON} what; + int rstackptr; ///< For internal use by FLTK + static const int region_stack_max = FL_REGION_STACK_SIZE - 1; ///< For internal use by FLTK + Fl_Region rstack[FL_REGION_STACK_SIZE]; ///< For internal use by FLTK + Fl_Font_Descriptor *font_descriptor_; ///< For internal use by FLTK + int p_size; + typedef struct { float x; float y; } XPOINT; + XPOINT *xpoint; + virtual void global_gc(); + virtual void cache(Fl_Pixmap *img); + virtual void cache(Fl_Bitmap *img); + virtual void cache(Fl_RGB_Image *img); + virtual void uncache(Fl_RGB_Image *img, fl_uintptr_t &id_, fl_uintptr_t &mask_); + // --- implementation is in src/drivers/xxx/Fl_xxx_Graphics_Driver_image.cxx + virtual void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); + virtual void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); + virtual void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); + virtual void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); + virtual void draw_rgb(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy); + virtual void draw_pixmap(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy); + virtual void draw_bitmap(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy); + virtual void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); + + /** For internal library use only */ + static void change_image_size(Fl_Image *img, int W, int H) { + img->w(W); + img->h(H); + } + // Support function for image drawing + virtual void uncache_pixmap(fl_uintptr_t p); + // accessor functions to protected image members + int start_image(Fl_Image *img, int XP, int YP, int WP, int HP, int &cx, int &cy, + int &X, int &Y, int &W, int &H); + /** Accessor to a private member variable of Fl_RGB_Image */ + static fl_uintptr_t* id(Fl_RGB_Image *rgb) {return &(rgb->id_);} + /** Accessor to a private member variable of Fl_Pixmap */ + static fl_uintptr_t* id(Fl_Pixmap *pm) {return &(pm->id_);} + /** Accessor to a private member variable of Fl_Bitmap */ + static fl_uintptr_t* id(Fl_Bitmap *bm) {return &(bm->id_);} + /** Accessor to a private member variable of Fl_RGB_Image */ + static fl_uintptr_t* mask(Fl_RGB_Image *rgb) {return &(rgb->mask_);} + /** Accessor to a private member variable of Fl_Pixmap */ + static fl_uintptr_t* mask(Fl_Pixmap *pm) {return &(pm->mask_);} + /** Accessor to private member variables of Fl_Pixmap */ + static void cache_w_h(Fl_Pixmap *pm, int*& pwidth, int*& pheight) { + pwidth = &(pm->cache_w_); + pheight = &(pm->cache_h_); + } + /** Accessor to private member variables of Fl_Bitmap */ + static void cache_w_h(Fl_Bitmap *bm, int*& pwidth, int*& pheight) { + pwidth = &(bm->cache_w_); + pheight = &(bm->cache_h_); + } + /** Accessor to private member variables of Fl_RGB_Image */ + static void cache_w_h(Fl_RGB_Image *rgb, int*& pwidth, int*& pheight) { + pwidth = &(rgb->cache_w_); + pheight = &(rgb->cache_h_); + } + static Fl_Offscreen get_offscreen_and_delete_image_surface(Fl_Image_Surface*); + /** For internal library use only */ + static void draw_empty(Fl_Image* img, int X, int Y) {img->draw_empty(X, Y);} + + Fl_Graphics_Driver(); + virtual void cache_size(Fl_Image *img, int &width, int &height); + void cache_size_finalize(Fl_Image *img, int &width, int &height); + static unsigned need_pixmap_bg_color; +public: + virtual ~Fl_Graphics_Driver(); + static Fl_Graphics_Driver &default_driver(); + // support of "complex shapes" + void push_matrix(); + void pop_matrix(); + void load_identity(); + void load_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); + void rotate(double d); + void translate(double x,double y); + double transform_x(double x, double y); + double transform_y(double x, double y); + double transform_dx(double x, double y); + double transform_dy(double x, double y); + /** Return the current Fl_Font_Descriptor */ + inline Fl_Font_Descriptor *font_descriptor() { return font_descriptor_;} + /** Set the current Fl_Font_Descriptor */ + inline void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;} + /** Current scale factor between FLTK and drawing units: drawing = FLTK * scale() */ + float scale() { return scale_; } + /** Sets the current value of the scaling factor */ + virtual void scale(float f); + /** Return whether the graphics driver can do alpha blending */ + virtual char can_do_alpha_blending(); + virtual void point(int x, int y); + virtual void rect(int x, int y, int w, int h); + virtual void focus_rect(int x, int y, int w, int h); + virtual void rectf(int x, int y, int w, int h); + virtual void _rbox(int fill, int x, int y, int w, int h, int r); + virtual void rounded_rect(int x, int y, int w, int h, int r); + virtual void rounded_rectf(int x, int y, int w, int h, int r); + // the default implementation is most likely enough + virtual void colored_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b); + virtual void line(int x, int y, int x1, int y1); + /** see fl_line(int, int, int, int, int, int) */ + virtual void line(int x, int y, int x1, int y1, int x2, int y2); + /** see fl_xyline(int, int, int) */ + virtual void xyline(int x, int y, int x1); + /** see fl_xyline(int, int, int, int) */ + virtual void xyline(int x, int y, int x1, int y2); + /** see fl_xyline(int, int, int, int, int) */ + virtual void xyline(int x, int y, int x1, int y2, int x3); + /** see fl_yxline(int, int, int) */ + virtual void yxline(int x, int y, int y1); + /** see fl_yxline(int, int, int, int) */ + virtual void yxline(int x, int y, int y1, int x2); + /** see fl_yxline(int, int, int, int, int) */ + virtual void yxline(int x, int y, int y1, int x2, int y3); + /** see fl_loop(int, int, int, int, int, int) */ + virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2); + /** see fl_loop(int, int, int, int, int, int, int, int) */ + virtual void loop(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); + /** see fl_polygon(int, int, int, int, int, int, int, int) */ + virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + // --- clipping + virtual void push_clip(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); + virtual int not_clipped(int x, int y, int w, int h); + /** see fl_push_no_clip() */ + virtual void push_no_clip(); // has default implementation + /** see fl_pop_clip() */ + virtual void pop_clip(); // has default implementation + virtual Fl_Region clip_region(); // has default implementation + virtual void clip_region(Fl_Region r); // has default implementation + virtual void restore_clip(); + virtual void begin_points(); + virtual void begin_line(); + virtual void begin_loop(); + virtual void begin_polygon(); + virtual void begin_complex_polygon(); + virtual void transformed_vertex(double xf, double yf); + virtual void transformed_vertex0(float x, float y); + virtual void vertex(double x, double y); + virtual void end_points(); + virtual void end_line(); + virtual void end_loop(); + virtual void fixloop(); + virtual void end_polygon(); + virtual void end_complex_polygon(); + // default implementation is most probably enough + virtual bool can_fill_non_convex_polygon() { return true; } + virtual void gap(); + virtual void circle(double x, double y, double r); + virtual void arc(double x, double y, double r, double start, double end); + virtual void arc(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); + // To support fl_draw_circle(int x, int y, int d, Fl_Color color), + // the default implementation is most probably enough. + virtual void draw_circle(int x, int y, int d, Fl_Color c); + virtual void curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3); + virtual void line_style(int style, int width=0, char* dashes=0); + virtual void color(Fl_Color c); + virtual void set_color(Fl_Color i, unsigned int c); + virtual void free_color(Fl_Color i, int overlay); + virtual Fl_Color color(); + virtual void color(uchar r, uchar g, uchar b); + virtual void draw(const char *str, int nChars, int x, int y); + virtual void draw(const char *str, int nChars, float x, float y); + virtual void draw(int angle, const char *str, int nChars, int x, int y); + virtual void rtl_draw(const char *str, int nChars, int x, int y); + virtual int has_feature(driver_feature feature); + virtual void font(Fl_Font face, Fl_Fontsize fsize); + virtual Fl_Font font(); + virtual Fl_Fontsize size(); + virtual double width(const char *str, int nChars); + virtual double width(unsigned int c); + virtual void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h); + virtual int height(); + virtual int descent(); + virtual void gc(void*); + virtual void *gc(void); + virtual uchar **mask_bitmap(); + // default implementation may be enough + virtual float scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s); + // default implementation may be enough + virtual float scale_bitmap_for_PostScript(); + // each platform implements these 3 functions its own way + virtual void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h); + virtual Fl_Region XRectangleRegion(int x, int y, int w, int h); + virtual void XDestroyRegion(Fl_Region r); + virtual const char* get_font_name(Fl_Font fnum, int* ap); + virtual int get_font_sizes(Fl_Font fnum, int*& sizep); + virtual Fl_Font set_fonts(const char *name); + virtual Fl_Fontdesc* calc_fl_fonts(void); + virtual unsigned font_desc_size(); + virtual const char *font_name(int num); + virtual void font_name(int num, const char *name); + // Defaut implementation may be enough + virtual void overlay_rect(int x, int y, int w , int h); + virtual float override_scale(); + virtual void restore_scale(float); + virtual PangoFontDescription* pango_font_description() { return NULL; } + virtual void antialias(int state); + virtual int antialias(); + virtual void delete_bitmask(fl_uintptr_t bm); +}; + +#ifndef FL_DOXYGEN + +/* This class is not part of FLTK's public API. + Platforms usually define a derived class called Fl_XXX_Font_Descriptor + containing extra platform-specific data/functions. + This is a class for an actual system font, with junk to + help choose it and info on character sizes. Each Fl_Fontdesc has a + linked list of these. These are created the first time each system + font/size combination is used. + */ +class Fl_Font_Descriptor { +public: + /** linked list for this Fl_Fontdesc */ + Fl_Font_Descriptor *next; + Fl_Fontsize size; /**< font size */ + Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size); + virtual FL_EXPORT ~Fl_Font_Descriptor() {} + int ascent, descent; + unsigned int listbase;// base of display list, 0 = none +}; + +// This struct is not part of FLTK's public API. +struct Fl_Fontdesc { + const char *name; + char fontname[128]; // "Pretty" font name + Fl_Font_Descriptor *first; // linked list of sizes of this style +}; + +/* Abstract class Fl_Scalable_Graphics_Driver is platform-independent. + It supports the scaling of all graphics coordinates by a + float factor helpful to support HiDPI displays. + This class does : + - compute scaled coordinates + - scale the cached offscreen of image objects + - scale the pixel arrays used when performing direct image draws + - call the member functions of a platform-specific, + Fl_Scalable_Graphics_Driver-derived class that do the drawings with adequately + scaled coordinates. The member functions are named with the _unscaled suffix. + - scale and unscale the clipping region. + + This class is presently used by the X11 and Windows platforms to support HiDPI displays. + In the future, it may also be used by other platforms. + */ +class FL_EXPORT Fl_Scalable_Graphics_Driver : public Fl_Graphics_Driver { + Fl_Fontsize fontsize_; // scale-independent font size value +public: + Fl_Scalable_Graphics_Driver(); + static int floor(int x, float s); + inline int floor(int x) { return Fl_Scalable_Graphics_Driver::floor(x, scale()); } +protected: + int line_width_; + virtual Fl_Region scale_clip(float f); + void unscale_clip(Fl_Region r); + void point(int x, int y) FL_OVERRIDE; + virtual void point_unscaled(float x, float y); + void rect(int x, int y, int w, int h) FL_OVERRIDE; + void rectf(int x, int y, int w, int h) FL_OVERRIDE; + virtual void rect_unscaled(int x, int y, int w, int h); + virtual void rectf_unscaled(int x, int y, int w, int h); + void line(int x, int y, int x1, int y1) FL_OVERRIDE; + virtual void line_unscaled(int x, int y, int x1, int y1); + void line(int x, int y, int x1, int y1, int x2, int y2) FL_OVERRIDE; + virtual void line_unscaled(int x, int y, int x1, int y1, int x2, int y2); + void xyline(int x, int y, int x1) FL_OVERRIDE; + virtual void xyline_unscaled(int x, int y, int x1); + void xyline(int x, int y, int x1, int y2) FL_OVERRIDE {Fl_Graphics_Driver::xyline(x, y, x1, y2);} + void xyline(int x, int y, int x1, int y2, int x3) FL_OVERRIDE {Fl_Graphics_Driver::xyline(x, y, x1, y2, x3);} + void yxline(int x, int y, int y1) FL_OVERRIDE; + virtual void yxline_unscaled(int x, int y, int y1); + void yxline(int x, int y, int y1, int x2) FL_OVERRIDE {Fl_Graphics_Driver::yxline(x, y, y1, x2);} + void yxline(int x, int y, int y1, int x2, int y3) FL_OVERRIDE {Fl_Graphics_Driver::yxline(x, y, y1, x2, y3);} + void loop(int x0, int y0, int x1, int y1, int x2, int y2) FL_OVERRIDE; + virtual void loop_unscaled(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) FL_OVERRIDE; + virtual void loop_unscaled(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) FL_OVERRIDE; + virtual void polygon_unscaled(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) FL_OVERRIDE; + virtual void polygon_unscaled(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + void circle(double x, double y, double r) FL_OVERRIDE; + virtual void ellipse_unscaled(double xt, double yt, double rx, double ry); + void font(Fl_Font face, Fl_Fontsize size) FL_OVERRIDE; + Fl_Font font() FL_OVERRIDE; + virtual void font_unscaled(Fl_Font face, Fl_Fontsize size); + double width(const char *str, int n) FL_OVERRIDE; + double width(unsigned int c) FL_OVERRIDE; + virtual double width_unscaled(const char *str, int n); + virtual double width_unscaled(unsigned int c); + Fl_Fontsize size() FL_OVERRIDE; + virtual Fl_Fontsize size_unscaled(); + void text_extents(const char *str, int n, int &dx, int &dy, int &w, int &h) FL_OVERRIDE; + virtual void text_extents_unscaled(const char *str, int n, int &dx, int &dy, int &w, int &h); + int height() FL_OVERRIDE; + int descent() FL_OVERRIDE; + virtual int height_unscaled(); + virtual int descent_unscaled(); + void draw(const char *str, int n, int x, int y) FL_OVERRIDE; + virtual void draw_unscaled(const char *str, int n, int x, int y); + void draw(int angle, const char *str, int n, int x, int y) FL_OVERRIDE; + virtual void draw_unscaled(int angle, const char *str, int n, int x, int y); + void draw(const char *str, int nChars, float x, float y) FL_OVERRIDE; + void rtl_draw(const char* str, int n, int x, int y) FL_OVERRIDE; + virtual void rtl_draw_unscaled(const char* str, int n, int x, int y); + void arc(double x, double y, double r, double start, double end) FL_OVERRIDE; + void arc(int x, int y, int w, int h, double a1, double a2) FL_OVERRIDE; + virtual void arc_unscaled(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) FL_OVERRIDE; + virtual void pie_unscaled(int x, int y, int w, int h, double a1, double a2); + void draw_circle(int x, int y, int d, Fl_Color c) FL_OVERRIDE; + void line_style(int style, int width=0, char* dashes=0) FL_OVERRIDE; + virtual void line_style_unscaled(int style, int width, char* dashes); + void draw_image_rescale(void *buf, Fl_Draw_Image_Cb cb, int X, int Y, int W, int H, int D, int L, bool mono); + virtual void draw_image_unscaled(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); + virtual void draw_image_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); + void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0) FL_OVERRIDE; + void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3) FL_OVERRIDE; + virtual void draw_image_mono_unscaled(const uchar* buf, int x, int y, int w, int h, int d, int l); + void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0) FL_OVERRIDE; + virtual void draw_image_mono_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); + void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1) FL_OVERRIDE; + + void transformed_vertex(double xf, double yf) FL_OVERRIDE; + void vertex(double x, double y) FL_OVERRIDE; + float override_scale() FL_OVERRIDE; + void restore_scale(float) FL_OVERRIDE; + virtual void *change_pen_width(int lwidth); + virtual void reset_pen_width(void *data); +}; +#endif // FL_DOXYGEN + +#endif // FL_GRAPHICS_DRIVER_H + +/** + \} + \endcond + */ diff --git a/include/linux/amd64/FL/Fl_Grid.H b/include/linux/amd64/FL/Fl_Grid.H new file mode 100644 index 0000000..3661977 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Grid.H @@ -0,0 +1,405 @@ +// +// Fl_Grid widget header for the Fast Light Tool Kit (FLTK). +// +// Copyright 2021-2022 by Albrecht Schlosser. +// Copyright 2022-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef _FL_FL_GRID_H_ +#define _FL_FL_GRID_H_ + +/** \file FL/Fl_Grid.H + Fl_Grid container widget. +*/ + +#include +#include + +/** Fl_Grid type for child widget alignment control. */ +typedef unsigned short Fl_Grid_Align; + +/** Align the widget in the middle of the cell (default). */ +const Fl_Grid_Align FL_GRID_CENTER = 0x0000; + +/** Align the widget at the top of the cell. */ +const Fl_Grid_Align FL_GRID_TOP = 0x0001; + +/** Align the widget at the bottom of the cell. */ +const Fl_Grid_Align FL_GRID_BOTTOM = 0x0002; + +/** Align the widget at the left side of the cell. */ +const Fl_Grid_Align FL_GRID_LEFT = 0x0004; + +/** Align the widget at the right side of the cell. */ +const Fl_Grid_Align FL_GRID_RIGHT = 0x0008; + +/** Stretch the widget horizontally to fill the cell. */ +const Fl_Grid_Align FL_GRID_HORIZONTAL = 0x0010; + +/** Stretch the widget vertically to fill the cell. */ +const Fl_Grid_Align FL_GRID_VERTICAL = 0x0020; + +/** Stretch the widget in both directions to fill the cell. */ +const Fl_Grid_Align FL_GRID_FILL = 0x0030; + +/** Stretch the widget proportionally. */ +const Fl_Grid_Align FL_GRID_PROPORTIONAL = 0x0040; + +const Fl_Grid_Align FL_GRID_TOP_LEFT = FL_GRID_TOP | FL_GRID_LEFT; +const Fl_Grid_Align FL_GRID_TOP_RIGHT = FL_GRID_TOP | FL_GRID_RIGHT; +const Fl_Grid_Align FL_GRID_BOTTOM_LEFT = FL_GRID_BOTTOM | FL_GRID_LEFT; +const Fl_Grid_Align FL_GRID_BOTTOM_RIGHT = FL_GRID_BOTTOM | FL_GRID_RIGHT; + +/** + Fl_Grid is a container (layout) widget with multiple columns and rows. + + This container widget features very flexible layouts in columns and rows + w/o the need to position each child widget in x/y coordinates. + + Widgets are assigned to grid cells (column, row) with their minimal sizes + in \p w() and \p h(). The \p x() and \p y() positions are ignored and can + be (0, 0). Fl_Grid calculates widget positions and resizes the widgets to + fit into the grid. It is possible to create a single row or column of + widgets with Fl_Grid. + + You should design your grid with the smallest possible sizes of all widgets + in mind. Fl_Grid will automatically assign additional space to cells + according to some rules (described later) when resizing the Fl_Grid widget. + + \b Hint: You should set a minimum window size to make sure the Fl_Grid is + never resized below its minimal sizes. Resizing below the given widget + sizes results in undefined behavior. + + Fl_Grid and other container widgets (e.g. Fl_Group) can be nested. One main + advantage of this usage is that widget coordinates in embedded Fl_Group + widgets become relative to the group and will be positioned as expected. + \todo This (relative group coordinates of nested groups of Fl_Grid) + needs explanation and maybe an example. + + Fl_Grid child widgets are handled by its base class Fl_Group but Fl_Grid + stores additional data corresponding to each widget in internal grid cells. + + Fl_Grid children are allowed to span multiple columns and rows like HTML + \ cells. Individual children can have fixed sizes or be aligned + inside their cells (left, right, top, bottom, and more) and/or follow + their cell sizes when the Fl_Grid container is resized. + + Note to resizing: since Fl_Grid uses its own layout algorithm the normal + Fl_Group::resizable() widget is ignored (if set). Calling init_sizes() + is not necessary. + + \note Fl_Grid is, as of FLTK 1.4.0, still in experimental state and + should be used with caution. The API can still be changed although it is + assumed to be almost stable - as stable as possible for a first release. + + Example: Simple 3x3 Fl_Grid with five buttons: + \n + \code + #include + #include + #include + #include + + int main(int argc, char **argv) { + Fl_Double_Window *win = new Fl_Double_Window(320, 180, "3x3 Fl_Grid with Buttons"); + // create the Fl_Grid container with five buttons + Fl_Grid *grid = new Fl_Grid(0, 0, win->w(), win->h()); + grid->layout(3, 3, 10, 10); + grid->color(FL_WHITE); + Fl_Button *b0 = new Fl_Button(0, 0, 0, 0, "New"); + Fl_Button *b1 = new Fl_Button(0, 0, 0, 0, "Options"); + Fl_Button *b3 = new Fl_Button(0, 0, 0, 0, "About"); + Fl_Button *b4 = new Fl_Button(0, 0, 0, 0, "Help"); + Fl_Button *b6 = new Fl_Button(0, 0, 0, 0, "Quit"); + // assign buttons to grid positions + grid->widget(b0, 0, 0); + grid->widget(b1, 0, 2); + grid->widget(b3, 1, 1); + grid->widget(b4, 2, 0); + grid->widget(b6, 2, 2); + grid->show_grid(0); // 1 to display grid helper lines + grid->end(); + win->end(); + win->resizable(grid); + win->size_range(300, 100); + win->show(argc, argv); + return Fl::run(); + } + \endcode + + \image html Fl_Grid.png + \image latex Fl_Grid.png "Simple 3x3 Fl_Grid" width=7cm + + \image html Fl_Grid_show_grid_1.png + \image latex Fl_Grid_show_grid_1.png "show_grid() set to 1" width=7cm + +*/ +class FL_EXPORT Fl_Grid : public Fl_Group { + friend class Fl_Grid_Type; + +public: + class Cell { + friend class Fl_Grid; + private: + Cell *next_; // next cell in the same row + short row_; // row number + short col_; // column number + short rowspan_; // row span (1 - n) + short colspan_; // column span (1 - n) + Fl_Grid_Align align_; // widget alignment in its cell + Fl_Widget *widget_; // assigned widget + int w_; // minimal widget width + int h_; // minimal widget height + + public: + + void Cell_() { // common initialization + next_ = NULL; + row_ = 0; + col_ = 0; + rowspan_ = 1; + colspan_ = 1; + widget_ = NULL; + w_ = 0; + h_ = 0; + align_ = 0; + } + + Cell(int row, int col) { // constructor + Cell_(); + row_ = row; + col_ = col; + } + + Cell(Fl_Widget *w, int row, int col) { // widget assignment + Cell_(); + widget_ = w; + row_ = row; + col_ = col; + } + + /** + The destructor deletes the cell. + + \todo Fl_Grid's cell destructor should remove the cell from the grid. + Currently it does nothing! + */ + ~Cell() {} + + /** + Returns the next widget cell of the same row of this cell. + */ + Cell *next() { + return next_; + } + + /** + Sets the \c next pointer of a grid's cell. + + \b Internal use only! + + Do not use this method, it may corrupt the allocated memory. + + \internal + This method is public due to issue #937 but should be private or + at least protected. For more info see GitHub issue #937. + */ + void next(Cell *c) { + next_ = c; + } + + Fl_Widget *widget() const { return widget_; } + + short row() const { return row_; } + short col() const { return col_; } + + void rowspan(short v) { rowspan_ = v; } + void colspan(short v) { colspan_ = v; } + short rowspan() const { return rowspan_; } + short colspan() const { return colspan_; } + + void align(Fl_Grid_Align align) { align_ = align; } + Fl_Grid_Align align() const { return align_; } + + void minimum_size(int w, int h) { if (w>=0) w_ = w; if (h>=0) h_ = h; } + void minimum_size(int *w, int *h) const { if (w) *w = w_; if (h) *h = h_; } + }; // class Cell + +private: + class Row; + class Col; + short rows_; + short cols_; + + short margin_left_; // left margin + short margin_top_; // top margin + short margin_right_; // right margin + short margin_bottom_; // bottom margin + short gap_row_; // gap between rows + short gap_col_; // gap between columns + Fl_Rect old_size; // only for resize callback (TBD) + Col *Cols_; // array of columns + Row *Rows_; // array of rows + bool need_layout_; // true if layout needs to be calculated + +protected: + Fl_Color grid_color; // color for drawing the grid lines (design helper) + bool draw_grid_; // draw the grid for testing / design + +protected: + void init(); + Cell *add_cell(int row, int col); + void remove_cell(int row, int col); + +public: + Fl_Grid(int X, int Y, int W, int H, const char *L = 0); + virtual ~Fl_Grid(); + + // define and manage the layout and resizing + + virtual void layout(int rows, int cols, int margin = -1, int gap = -1); + virtual void layout(); + virtual void clear_layout(); + virtual void resize(int X, int Y, int W, int H) FL_OVERRIDE; + + short rows() const { return rows_; } + short cols() const { return cols_; } + + /** + Request or reset the request to calculate the layout of children. + + If called with \p true (1) this calls redraw() to schedule a + full draw(). When draw is eventually called, the layout is + (re)calculated before actually drawing the widget. + + \param[in] set 1 to request layout calculation,\n + 0 to reset the request + */ + void need_layout(int set) { + if (set) { + need_layout_ = true; + redraw(); + } + else { + need_layout_ = false; + } + } + + /** + Return whether layout calculation is required. + */ + bool need_layout() const { + return need_layout_; + } + +protected: + virtual void draw() FL_OVERRIDE; + void on_remove(int) FL_OVERRIDE; + virtual void draw_grid(); // draw grid lines for debugging + +public: + + // get and set individual margins + + virtual void margin(int left, int top = -1, int right = -1, int bottom = -1); + int margin(int *left, int *top, int *right, int *bottom) const; + + // get and set default row and column gaps for all rows and columns, respectively + + virtual void gap(int row_gap, int col_gap = -1); // set default row and column gap(s) + void gap(int *row_gap, int *col_gap) const; + + // find cells, get cell pointers + + Fl_Grid::Cell* cell(int row, int col) const; + Fl_Grid::Cell* cell(Fl_Widget *widget) const; + + // assign a widget to a cell + + Fl_Grid::Cell* widget(Fl_Widget *wi, int row, int col, Fl_Grid_Align align = FL_GRID_FILL); + Fl_Grid::Cell* widget(Fl_Widget *wi, int row, int col, int rowspan, int colspan, Fl_Grid_Align align = FL_GRID_FILL); + + // set minimal column and row sizes (widths and heights, respectively), + // set row and column specific gaps and weights + + void col_width(int col, int value); + void col_width(const int *value, size_t size); + int col_width(int col) const; + + void col_weight(int col, int value); + void col_weight(const int *value, size_t size); + int col_weight(int col) const; + + void col_gap(int col, int value); + void col_gap(const int *value, size_t size); + int col_gap(int col) const; + + void row_height(int row, int value); + void row_height(const int *value, size_t size); + int row_height(int row) const; + + void row_weight(int row, int value); + void row_weight(const int *value, size_t size); + int row_weight(int row) const; + + void row_gap(int row, int value); + void row_gap(const int *value, size_t size); + int row_gap(int row) const; + + int computed_col_width(int col) const; + int computed_row_height(int row) const; + + /** + Enable or disable drawing of the grid helper lines for visualization. + + Use this method during the design stage of your Fl_Grid widget or + for debugging if widgets are not positioned as intended. + + The default is a light green color but you can change it for better + contrast if needed, see show_grid(int set, Fl_Color col). + + \note You can define the environment variable \c FLTK_GRID_DEBUG=1 + to set show_grid(1) for all Fl_Grid widgets at construction time. + This enables you to debug the grid layout w/o changing code. + + \param[in] set 1 (true) = draw, 0 = don't draw the grid + + \see show_grid(int set, Fl_Color col) + */ + void show_grid(int set) { + draw_grid_ = set ? true : false; + } + + /** + Enable or disable drawing of the grid helper lines for visualization. + + This method also sets the color used for the helper lines. + + The default is a light green color but you can change it to any color + for better contrast if needed. + + \param[in] set 1 (true) = draw, 0 = don't draw the grid + \param[in] col color to use for the grid helper lines + + \see show_grid(int set) + */ + void show_grid(int set, Fl_Color col) { + draw_grid_ = set ? true : false; + grid_color = col; + } + + void debug(int level = 127); + +}; // class Fl_Grid + +#endif // _FL_FL_GRID_H_ diff --git a/include/linux/amd64/FL/Fl_Group.H b/include/linux/amd64/FL/Fl_Group.H new file mode 100644 index 0000000..27c68ef --- /dev/null +++ b/include/linux/amd64/FL/Fl_Group.H @@ -0,0 +1,289 @@ +// +// Group header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file + \brief Fl_Group and Fl_End classes. +*/ + +#ifndef Fl_Group_H +#define Fl_Group_H + +#include "Fl_Widget.H" + +// Don't #include Fl_Rect.H because this would introduce lots +// of unnecessary dependencies on Fl_Rect.H +class Fl_Rect; + + +/** + The Fl_Group class is the main 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. + + The tab and arrow keys are used to move the focus between widgets of + this group, and to other groups. The only modifier grabbed is shift + (for shift-tab), so that ctrl-tab, alt-up, and such are free + for the app to use as shortcuts. + + To remove a widget from the group and destroy it, in 1.3.x (and up) + you can simply use: + \code + delete some_widget; + \endcode + ..and this will trigger proper scheduling of the widget's removal + from its parent group. + + If used as a child of \p Fl_Tabs, setting \p when(FL_WHEN_CLOSED) will + enable the Close button in the corresponding tab. If the user clicks the + Close button, the callback of this group will be called with the callback + reason \p FL_REASON_CLOSED. +*/ +class FL_EXPORT Fl_Group : public Fl_Widget { + + union { + Fl_Widget** array_; // used if group has two or more children or NULL + Fl_Widget* child1_; // used if group has one child or NULL + }; + Fl_Widget* savedfocus_; + Fl_Widget* resizable_; + int children_; + Fl_Rect *bounds_; // remembered initial sizes of children + int *sizes_; // remembered initial sizes of children (FLTK 1.3 compat.) + + 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() FL_OVERRIDE; + 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; + Fl_Rect *bounds(); + int *sizes(); // FLTK 1.3 compatibility + virtual int on_insert(Fl_Widget*, int); + virtual int on_move(int, int); + virtual void on_remove(int); + +public: + + int handle(int) FL_OVERRIDE; + 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 the n'th child. + + Returns \c NULL if \c n is out of range (since FLTK 1.4.0). + + No range checking was done in FLTK 1.3 and older versions! + + \param[in] n index of child (0 .. children() - 1) + \return pointer to the n'th child or NULL if out of range + */ + Fl_Widget *child(int n) const { + if (n < 0 || n > children() - 1) return NULL; + 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) FL_OVERRIDE; + /** + 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(); + + /* delete child n (by index) */ + virtual int delete_child(int n); + + /** + Sets the group's resizable widget. + See void Fl_Group::resizable(Fl_Widget *o) + */ + void resizable(Fl_Widget& o) {resizable_ = &o;} + /** + The resizable widget defines both the resizing box and the resizing + behavior of the group and its children. + + If the resizable is NULL the group's size is fixed and all of the widgets + in the group remain a fixed size and distance from the top-left corner. + This is the default for groups derived from Fl_Window and Fl_Pack. + + The resizable may be set to the group itself, in which case all of the + widgets that are its direct children are resized proportionally. + This is the default value for Fl_Group. + + The resizable widget defines the resizing box for the group, which could + be the group itself or one of the group's direct children. 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. + + \note The resizable of a group \b must be one of + - NULL + - the group itself + - a direct child of the group. + \note If you set any other widget that is not a direct child of the group as + its resizable then the behavior is undefined. This is \b not checked by + Fl_Group for historical reasons. + + 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=4.85cm + + 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 + Fl_Group widgets, each with their own resizing strategies. + + See the \ref resize chapter for more examples and detailed explanation. + + \note The resizable() widget of a window can also affect the window's + resizing behavior if Fl_Window::size_range() is not called. Please + see Fl_Window::default_size_range() for more information on how the + default size range is calculated. + + \see Fl_Window::size_range() + \see Fl_Window::default_size_range() + */ + void resizable(Fl_Widget* o) {resizable_ = o;} + /** + Returns the group's resizable widget. + See void Fl_Group::resizable(Fl_Widget *o) + */ + 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. + Fl_Group* as_group() FL_OVERRIDE { return this; } + Fl_Group const* as_group() const FL_OVERRIDE { 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) { + [..ctor code..] + } + \endcode +*/ +class FL_EXPORT Fl_End { +public: + /** All it does is calling Fl_Group::current()->end() */ + Fl_End() {Fl_Group::current()->end();} +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Help_Dialog.H b/include/linux/amd64/FL/Fl_Help_Dialog.H new file mode 100644 index 0000000..ed19ca2 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Help_Dialog.H @@ -0,0 +1,84 @@ +// +// Fl_Help_Dialog dialog for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2021 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// +// ======================================================================== +// DO NOT EDIT FL/Fl_Help_Dialog.H and src/Fl_Help_Dialog.cxx !!! +// ======================================================================== +// Please use fluid to change src/Fl_Help_Dialog.fl interactively +// and then use fluid to "write code" or edit and use fluid -c . +// ======================================================================== +// + +// generated by Fast Light User Interface Designer (fluid) version 1.0400 + +#ifndef Fl_Help_Dialog_H +#define Fl_Help_Dialog_H +#include +#include +#include +#include +#include +#include +#include + +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_; + inline void cb_back__i(Fl_Button*, void*); + static void cb_back_(Fl_Button*, void*); + Fl_Button *forward_; + inline void cb_forward__i(Fl_Button*, void*); + static void cb_forward_(Fl_Button*, void*); + Fl_Button *smaller_; + inline void cb_smaller__i(Fl_Button*, void*); + static void cb_smaller_(Fl_Button*, void*); + Fl_Button *larger_; + inline void cb_larger__i(Fl_Button*, void*); + static void cb_larger_(Fl_Button*, void*); + Fl_Input *find_; + inline void cb_find__i(Fl_Input*, void*); + static void cb_find_(Fl_Input*, void*); + Fl_Help_View *view_; + inline void cb_view__i(Fl_Help_View*, void*); + static void cb_view_(Fl_Help_View*, void*); +public: + ~Fl_Help_Dialog(); + int h(); + void hide(); + int 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 diff --git a/include/linux/amd64/FL/Fl_Help_View.H b/include/linux/amd64/FL/Fl_Help_View.H new file mode 100644 index 0000000..2c73926 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Help_View.H @@ -0,0 +1,396 @@ +// +// Help Viewer widget definitions. +// +// Copyright 1997-2010 by Easy Software Products. +// Image support by Matthias Melcher, Copyright 2000-2009. +// Copyright 2011-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Help_View widget . */ + +#ifndef Fl_Help_View_H +#define Fl_Help_View_H + +// +// Include necessary header files... +// + +#include "Fl.H" +#include "Fl_Group.H" +#include "Fl_Scrollbar.H" +#include "fl_draw.H" +#include "filename.H" + +class Fl_Shared_Image; +// +// 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 + int ol; // is ordered list

    element + int ol_num; // item number in ordered list +}; + +// +// 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_[MAX_FL_HELP_FS_ELTS]; ///< 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 + - dagger 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 permil 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 + + \note You can't effectively set the box() to FL_NO_BOX, this would result + in FL_DOWN_BOX being used as the boxtype of the widget. This is unexpected + but can't be changed for backwards compatibility. If you don't want a frame + around the widget you can use FL_FLAT_BOX instead. +*/ +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); +protected: + void draw() FL_OVERRIDE; +private: + 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); +public: + int handle(int) FL_OVERRIDE; +private: + + void hv_draw(const char *t, int x, int y, int entity_extra_length = 0); + 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: + + static const char *copy_menu_text; + + 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) FL_OVERRIDE; + /** 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 \p newSize, 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 newSize to the special value of 0 causes the widget to + track the global Fl::scrollbar_size(), which is the default. + + \param[in] newSize 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 newSize) { + scrollbar_size_ = newSize; + } + + // Check if the user selected text in this view. + int text_selected(); + + // If text is selected in this view, copy it to a clipboard. + int copy(int clipboard=1); +}; + +#endif // !Fl_Help_View_H diff --git a/include/linux/amd64/FL/Fl_Hold_Browser.H b/include/linux/amd64/FL/Fl_Hold_Browser.H new file mode 100644 index 0000000..cc0192c --- /dev/null +++ b/include/linux/amd64/FL/Fl_Hold_Browser.H @@ -0,0 +1,49 @@ +// +// Hold browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + \image html fl_hold_browser.png "Fl_Hold_Browser" + \image latex fl_hold_browser.png "Fl_Hold_Browser" width=4cm + + 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(). +

    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. + */ + Fl_Hold_Browser(int X,int Y,int W,int H,const char *L=0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Hor_Fill_Slider.H b/include/linux/amd64/FL/Fl_Hor_Fill_Slider.H new file mode 100644 index 0000000..c8890db --- /dev/null +++ b/include/linux/amd64/FL/Fl_Hor_Fill_Slider.H @@ -0,0 +1,30 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Hor_Nice_Slider.H b/include/linux/amd64/FL/Fl_Hor_Nice_Slider.H new file mode 100644 index 0000000..fdaeda1 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Hor_Nice_Slider.H @@ -0,0 +1,39 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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_Hor_Nice_Slider + + \brief Single thumb tab slider + + \image html fl_hor_nice_slider.png "Fl_Hor_Nice_Slider with various Fl::scheme() values" + \image latex fl_hor_nice_slider.png "Fl_Hor_Nice_Slider with various Fl::scheme() values" width=6cm + +**/ + +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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Hor_Slider.H b/include/linux/amd64/FL/Fl_Hor_Slider.H new file mode 100644 index 0000000..cfd2426 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Hor_Slider.H @@ -0,0 +1,39 @@ +// +// Horizontal slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + */ + Fl_Hor_Slider(int X,int Y,int W,int H,const char *l=0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Hor_Value_Slider.H b/include/linux/amd64/FL/Fl_Hor_Value_Slider.H new file mode 100644 index 0000000..88c6efe --- /dev/null +++ b/include/linux/amd64/FL/Fl_Hor_Value_Slider.H @@ -0,0 +1,30 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_ICO_Image.H b/include/linux/amd64/FL/Fl_ICO_Image.H new file mode 100644 index 0000000..c77cb25 --- /dev/null +++ b/include/linux/amd64/FL/Fl_ICO_Image.H @@ -0,0 +1,57 @@ +// +// ICO image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 2022-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// http://www.fltk.org/COPYING.php +// +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php +// + +// https://en.wikipedia.org/wiki/ICO_(file_format) +// http://www.daubnet.com/en/file-format-ico + +#ifndef Fl_ICO_Image_H +# define Fl_ICO_Image_H +# include "Fl_BMP_Image.H" + +/** + The Fl_ICO_Image class supports loading, caching, and drawing of Windows icon (.ico) files. + */ +class FL_EXPORT Fl_ICO_Image : public Fl_BMP_Image { + +public: + /** Windows ICONDIRENTRY structure */ + struct IconDirEntry { + int bWidth; ///< Image width + int bHeight; ///< Image height + int bColorCount; ///< Number of colors (0 if ≥ 8bpp) + int bReserved; ///< Reserved + int wPlanes; ///< Color Planes + int wBitCount; ///< Bits per pixel + int dwBytesInRes; ///< Resource size in bytes + int dwImageOffset; ///< Offset to the image + }; + + Fl_ICO_Image(const char *filename, int id = -1, const unsigned char *data = NULL, const size_t datasize = 0); + ~Fl_ICO_Image(); + + /** Returns the number of icons of various resolutions present in the ICO object. */ + int idcount() const { return idcount_; } + + /** Returns the array of idcount() loaded IconDirEntry structures. */ + const IconDirEntry * icondirentry() const { return icondirentry_; } + +private: + int idcount_; + struct IconDirEntry *icondirentry_; + void load_ico_(class Fl_Image_Reader &rdr, int id); +}; + +#endif // Fl_ICO_Image_H diff --git a/include/linux/amd64/FL/Fl_Image.H b/include/linux/amd64/FL/Fl_Image.H new file mode 100644 index 0000000..8b8b433 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Image.H @@ -0,0 +1,397 @@ +// +// Image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file + Fl_Image, Fl_RGB_Image classes. */ + +#ifndef Fl_Image_H +#define Fl_Image_H + +#include "Enumerations.H" +#include "Fl_Widget.H" // for fl_uintptr_t + +class Fl_Widget; +class Fl_Pixmap; +struct Fl_Menu_Item; +struct Fl_Label; +class Fl_RGB_Image; + + +/** \enum Fl_RGB_Scaling + The scaling algorithm to use for RGB images. +*/ +enum Fl_RGB_Scaling { + FL_RGB_SCALING_NEAREST = 0, ///< default RGB image scaling algorithm + FL_RGB_SCALING_BILINEAR ///< more accurate, but slower RGB image scaling algorithm +}; + + +/** + Base class for image caching, scaling and drawing. + + Fl_Image is the base class used for caching, scaling 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. + + Each image possesses two (width, height) pairs: + -# The width and height of the raw image data are returned by data_w() and + data_h(). These values are set when the image is created and remain unchanged. + -# The width and height of the area filled by the image when it gets drawn are + returned by w() and h(). These values are equal to data_w() and data_h() when + the image is created and can be changed by the scale() member function. + + Since the Fl_Image class does not support image drawing by itself, calling the + Fl_Image::draw() method results in a box with an X in it being drawn instead. +*/ +class FL_EXPORT Fl_Image { + friend class Fl_Graphics_Driver; +public: + static const int ERR_NO_IMAGE = -1; + static const int ERR_FILE_ACCESS = -2; + static const int ERR_FORMAT = -3; + static const int ERR_MEMORY_ACCESS = -4; + +private: + int w_, h_, d_, ld_, count_; + int data_w_, data_h_; + const char * const *data_; + static Fl_RGB_Scaling RGB_scaling_; // method used when copying RGB images + static Fl_RGB_Scaling scaling_algorithm_; // method used to rescale RGB source images before drawing + // Forbid use of copy constructor and assign operator + Fl_Image & operator=(const Fl_Image &); + Fl_Image(const Fl_Image &); + // Presently redefined in Fl_SVG_Image + virtual void cache_size_(int &/*width*/, int &/*height*/) {} + +protected: + + /** + Sets the width of the image data. + This protected function sets both image widths: the width of the image data returned by data_w() and + the image drawing width in FLTK units returned by w(). + */ + void w(int W) {w_ = W; data_w_ = W;} + /** + Sets the height of the image data. + This protected function sets both image heights: the height of the image data returned by data_h() and + the image drawing height in FLTK units returned by h(). + */ + void h(int H) {h_ = H; data_h_ = H;} + /** + Sets the current image depth. + */ + void d(int D) {d_ = D;} + /** + Sets the current line data size in bytes. + + Color images may contain extra data (padding) that is included after every + line of color image data and is normally not present. + + If \p LD is zero, then line data size is assumed to be data_w() * d() bytes. + + If \p LD is non-zero, then it must be positive and larger than data_w() * d() + to account for the extra data per line. + */ + void ld(int LD) {ld_ = LD;} + /** + Sets the current data pointer and count of pointers in the array. + + There can be 0, 1, or more pointers to actual image data in an image. + + \see const char* const* data(), count(), w(), h(), data_w(), data_h(), d(), ld() + */ + 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); + int draw_scaled(int X, int Y, int W, int H); + +public: + + /** + Returns the current image drawing width in FLTK units. + The values of w() and data_w() are identical unless scale() has been called + after which they may differ. + */ + int w() const {return w_;} + /** + Returns the current image drawing height in FLTK units. + The values of h() and data_h() are identical unless scale() has been called + after which they may differ. + */ + int h() const {return h_;} + /** + Returns the width of the image data. + */ + int data_w() const {return data_w_;} + /** + Returns the height of the image data. + */ + int data_h() const {return data_h_;} + /** + Returns the image depth. + The return value will be 0 for bitmaps, 1 for + pixmaps, and 1 to 4 for color images.

    + */ + int d() const {return d_;} + /** + Returns the current line data size in bytes. + \see ld(int) + */ + int ld() const {return ld_;} + /** + 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. + + \see data() + */ + int count() const {return count_;} + /** + Returns a pointer to the current image data array. + + There can be 0, 1, or more pointers to actual image data in an image. + + Use the count() method to find the size of the data array. You must + not dereference the data() pointer if count() equals zero. + + \note data() \b may return NULL. + + Example: + + Fl_RGB_Image has exactly one pointer which points at the R, G, B [, A] + data array of the image. The total size of this array depends on + several attributes like data_w(), data_h(), d() and ld() and is basically + data_w() * data_h() * d() but there are exceptions if ld() is non-zero: + see description of ld(). Since FLTK 1.4.0 w() and h() are no longer + significant for the image data size if scale() has been called on the + image to set a different display size. + + Other image types have different numbers and types of data pointers + which are implementation details and not documented here. + + \see count(), w(), h(), data_w(), data_h(), d(), ld() + */ + const char * const *data() const {return data_;} + int fail() const; + /** + Releases an Fl_Image - the same as '\p delete \p this'. + + This virtual method is for almost all image classes the same as calling + \code + delete image; + \endcode + where image is an \p Fl_Image \p * pointer. + + However, for subclass Fl_Shared_Image and its subclasses this virtual + method is reimplemented and maintains shared images. + + This virtual method makes it possible to \p destroy all image types in + the same way by calling + \code + image->release(); + \endcode + + Reasoning: If you have an 'Fl_Image *' base class pointer and don't know + if the object is one of the class Fl_Shared_Image or any other subclass + of Fl_Image (for instance Fl_RGB_Image) then you can't just use operator + delete since this is not appropriate for Fl_Shared_Image objects. + + The virtual method release() handles this properly. + + \since 1.4.0 in the base class Fl_Image and virtual in Fl_Shared_Image + */ + virtual void release() { + delete this; + } + + /** Returns whether an image is an Fl_Shared_Image or not. + + This virtual method returns a pointer to an Fl_Shared_Image if this + object is an instance of Fl_Shared_Image or NULL if not. This can be + used to detect if a given Fl_Image object is a shared image, i.e. + derived from Fl_Shared_Image. + + \since 1.4.0 + */ + virtual class Fl_Shared_Image *as_shared_image() { + return 0; + } + + Fl_Image(int W, int H, int D); + virtual ~Fl_Image(); + virtual Fl_Image *copy(int W, int H) const; + /** + Creates a copy of the image in the same size. + + The new image should be released when you are done with it. + + This does exactly the same as 'Fl_Image::copy(int W, int H) const' where + \p W and \p H are the width and height of the source image, respectively. + This applies also to all subclasses of Fl_Image in the FLTK library. + + The following two copy() calls are equivalent: + \code + Fl_Image *img1 = new Fl_Image(...); + // ... + Fl_Image *img2 = img1->copy(); + Fl_Image *img3 = img1->copy(img1->w(), img1->h()) + \endcode + + For details see 'Fl_Image::copy(int w, int h) const'. + \see Fl_Image::release() + + \note Since FLTK 1.4.0 this method is 'const'. If you derive your own class + from Fl_Image or any subclass your overridden methods of 'Fl_Image::copy() const' + and 'Fl_Image::copy(int, int) const' \b must also be 'const' for inheritance + to work properly. This is different than in FLTK 1.3.x and earlier where these + methods have not been 'const'. + */ + Fl_Image *copy() const { return copy(w(), h()); } + virtual void color_average(Fl_Color c, float i); + /** + The inactive() method calls + color_average(\ref FL_BACKGROUND_COLOR, 0.33f) to produce + an image that appears grayed out. + + An internal copy is made of the original image before + changes are applied, to avoid modifying the original image. + + \note The RGB color of \ref FL_BACKGROUND_COLOR may change when the + connection to the display is made. See fl_open_display(). + */ + 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 to the current drawing surface with a bounding box. + Arguments X,Y,W,H specify + a bounding box for the image, with the origin + (upper-left corner) of the image offset by the \c cx + and \c cy arguments. + + In other words: fl_push_clip(X,Y,W,H) is applied, + the image is drawn with its upper-left corner at X-cx,Y-cy and its own width and height, + fl_pop_clip() is applied. + */ + virtual void draw(int X, int Y, int W, int H, int cx=0, int cy=0); // platform dependent + /** + Draws the image to the current drawing surface. + \param X, Y specify 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(); + + // used by fl_define_FL_IMAGE_LABEL() to avoid 'friend' declaration + static Fl_Labeltype define_FL_IMAGE_LABEL(); + + // set RGB image scaling method + static void RGB_scaling(Fl_RGB_Scaling); + // get RGB image scaling method + static Fl_RGB_Scaling RGB_scaling(); + + // set the image drawing size + virtual void scale(int width, int height, int proportional = 1, int can_expand = 0); + /** Sets what algorithm is used when resizing a source image to draw it. + The default algorithm is FL_RGB_SCALING_BILINEAR. + Drawing an Fl_Image is sometimes performed by first resizing the source image + and then drawing the resized copy. This occurs, e.g., when drawing to screen under X11 + without Xrender support after having called scale(). + This function controls what method is used when the image to be resized is an Fl_RGB_Image. + \version 1.4 + */ + static void scaling_algorithm(Fl_RGB_Scaling algorithm) {scaling_algorithm_ = algorithm; } + /** Gets what algorithm is used when resizing a source image to draw it. */ + static Fl_RGB_Scaling scaling_algorithm() {return scaling_algorithm_;} + static bool register_images_done; +}; + +class Fl_SVG_Image; + +/** + 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. + + 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_Graphics_Driver; + static size_t max_size_; +public: + + /** Points to the start of the object's data array + \see class Fl_SVG_Image which delays initialization of this member variable. + */ + const uchar *array; + /** If non-zero, the object's data array is delete[]'d when deleting the object. + */ + int alloc_array; + +private: + // These two variables are used to cache the image and mask for the main display graphics driver + fl_uintptr_t id_; + fl_uintptr_t mask_; + int cache_w_, cache_h_; // size of image when cached +public: + + Fl_RGB_Image(const uchar *bits, int W, int H, int D=3, int LD=0); + Fl_RGB_Image(const uchar *bits, int bits_length, int W, int H, int D, int LD); + Fl_RGB_Image(const Fl_Pixmap *pxm, Fl_Color bg=FL_GRAY); + ~Fl_RGB_Image() FL_OVERRIDE; + Fl_Image *copy(int W, int H) const FL_OVERRIDE; + Fl_Image *copy() const { return Fl_Image::copy(); } + void color_average(Fl_Color c, float i) FL_OVERRIDE; + void desaturate() FL_OVERRIDE; + void draw(int X, int Y, int W, int H, int cx=0, int cy=0) FL_OVERRIDE; + void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} + void label(Fl_Widget*w) FL_OVERRIDE; + void label(Fl_Menu_Item*m) FL_OVERRIDE; + void uncache() FL_OVERRIDE; + int cache_w() {return cache_w_;} + int cache_h() {return cache_h_;} + /** Sets the maximum allowed image size in bytes when creating an Fl_RGB_Image object. + + The image size in bytes of an Fl_RGB_Image object is the value of the product w() * h() * d(). + If this product exceeds size, the created object of a derived class of Fl_RGB_Image + won't be loaded with the image data. + This does not apply to direct RGB image creation with + Fl_RGB_Image::Fl_RGB_Image(const uchar *bits, int W, int H, int D, int LD). + The default max_size() value is essentially infinite. + */ + static void max_size(size_t size) { max_size_ = size;} + /** Returns the maximum allowed image size in bytes when creating an Fl_RGB_Image object. + + \sa void Fl_RGB_Image::max_size(size_t) + */ + static size_t max_size() {return max_size_;} + /** Returns whether an image is an Fl_SVG_Image or not. + This virtual method returns a pointer to the Fl_SVG_Image if this object is an instance of Fl_SVG_Image or NULL if not. */ + virtual Fl_SVG_Image *as_svg_image() { return NULL; } + /** Makes sure the object is fully initialized. + In particular, makes sure member variable \ref array is non-null. */ + virtual void normalize() {} +}; + +#endif // !Fl_Image_H diff --git a/include/linux/amd64/FL/Fl_Image_Surface.H b/include/linux/amd64/FL/Fl_Image_Surface.H new file mode 100644 index 0000000..c9f0b22 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Image_Surface.H @@ -0,0 +1,135 @@ +// +// Draw-to-image code for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2016 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Image_Surface_H +#define Fl_Image_Surface_H + +#include +#include +#include +#include // for Fl_Offscreen + + +/** + \brief Directs all graphics requests to an Fl_Image. + + After creation of an Fl_Image_Surface object, make it the current drawing + surface calling Fl_Surface_Device::push_current(), and all + subsequent graphics requests will be recorded in the image. It's possible to + draw widgets (using Fl_Image_Surface::draw()) or to use any of the + \ref fl_drawings or the \ref fl_attributes. Finally, call image() on the object + to obtain a newly allocated Fl_RGB_Image object. + Fl_Gl_Window objects can be drawn in the image as well. + + Usage example: + \code + // this is the widget that you want to draw into an image + Fl_Widget *g = ...; + + // create an Fl_Image_Surface object + Fl_Image_Surface *image_surface = new Fl_Image_Surface(g->w(), g->h()); + + // direct all further graphics requests to the image + Fl_Surface_Device::push_current(image_surface); + + // draw a white background + fl_color(FL_WHITE); + fl_rectf(0, 0, g->w(), g->h()); + + // draw the g widget in the image + image_surface->draw(g); + + // get the resulting image + Fl_RGB_Image* image = image_surface->image(); + + // direct graphics requests back to their previous destination + Fl_Surface_Device::pop_current(); + + // delete the image_surface object, but not the image itself + delete image_surface; + \endcode +*/ +class FL_EXPORT Fl_Image_Surface : public Fl_Widget_Surface { + friend class Fl_Graphics_Driver; +private: + class Fl_Image_Surface_Driver *platform_surface; + Fl_Offscreen get_offscreen_before_delete_(); +protected: + void translate(int x, int y) FL_OVERRIDE; + void untranslate() FL_OVERRIDE; +public: + Fl_Image_Surface(int w, int h, int high_res = 0, Fl_Offscreen off = 0); + ~Fl_Image_Surface(); + void set_current() FL_OVERRIDE; + bool is_current() FL_OVERRIDE; + Fl_RGB_Image *image(); + Fl_Shared_Image *highres_image(); + void origin(int *x, int *y) FL_OVERRIDE; + void origin(int x, int y) FL_OVERRIDE; + int printable_rect(int *w, int *h) FL_OVERRIDE; + Fl_Offscreen offscreen(); + void rescale(); + void mask(const Fl_RGB_Image *); +}; + + +/** + \cond DriverDev + \addtogroup DriverDeveloper + \{ + */ + +/** A base class describing the interface between FLTK and draw-to-image operations. + This class is only for internal use by the FLTK library. + A supported platform should implement the virtual methods of this class + in order to support drawing to an Fl_RGB_Image through class Fl_Image_Surface. + */ +class Fl_Image_Surface_Driver : public Fl_Widget_Surface { + friend class Fl_Image_Surface; +private: + Fl_Image_Surface *image_surface_; +protected: + int width; + int height; + Fl_Offscreen offscreen; + int external_offscreen; + Fl_Image_Surface_Driver(int w, int h, int /*high_res*/, Fl_Offscreen off) : Fl_Widget_Surface(NULL), width(w), height(h), offscreen(off) {external_offscreen = (off != 0);} + virtual ~Fl_Image_Surface_Driver() {} + static void copy_with_mask(Fl_RGB_Image* mask, uchar *dib_dst, uchar *dib_src, + int line_size, bool bottom_to_top); + static Fl_RGB_Image *RGB3_to_RGB1(const Fl_RGB_Image *rgb3, int W, int H); + void set_current() FL_OVERRIDE = 0; + void translate(int x, int y) FL_OVERRIDE = 0; + void untranslate() FL_OVERRIDE = 0; + int printable_rect(int *w, int *h) FL_OVERRIDE; + virtual Fl_RGB_Image *image() = 0; + virtual void mask(const Fl_RGB_Image *) {} + /** Each platform implements this function its own way. + It returns an object implementing all virtual functions + of class Fl_Image_Surface_Driver for the plaform. + */ + static Fl_Image_Surface_Driver *newImageSurfaceDriver(int w, int h, int high_res, Fl_Offscreen off); +public: + /** Returns pointer to the associated Fl_Image_Surface object */ + Fl_Image_Surface *image_surface() { return image_surface_; } +}; + +/** + \} + \endcond + */ + +#endif // Fl_Image_Surface_H diff --git a/include/linux/amd64/FL/Fl_Input.H b/include/linux/amd64/FL/Fl_Input.H new file mode 100644 index 0000000..970a414 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Input.H @@ -0,0 +1,270 @@ +// +// Input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 Windows 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. +

    + + + +
    Keyboard and mouse bindings.
    + Mouse button 1 + + 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. +
    + Mouse button 2 + + 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. +
    + Mouse button 3 + + Currently acts like button 1. +
    + Backspace + + Deletes one character to the left, or deletes the selected region. +
    + Delete + + Deletes one character to the right, or deletes the selected region. + Combine with Shift for equivalent of ^X (copy+cut). +
    + Enter + + May cause the callback, see when(). +
    + +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Platform specific keyboard bindings.
    Windows/Linux Mac Function
    ^A Command-A + Selects all text in the widget. + +
    ^C Command-C + Copy the current selection to the clipboard. + +
    ^I ^I + Insert a tab. + +
    ^J ^J + Insert a Line Feed.
    + (Similar to literal 'Enter' character) + +
    ^L ^L + Insert a Form Feed. + +
    ^M ^M + Insert a Carriage Return. + +
    ^V,
    Shift-Insert
    Command-V + Paste the clipboard.
    + (Macs keyboards don't have "Insert" keys, + but if they did, Shift-Insert would work) + +
    ^X,
    Shift-Delete
    Command-X,
    Shift-Delete
    + Cut.
    + Copy the selection to the clipboard and delete it. + (If there's no selection, Shift-Delete acts like Delete) + +
    ^Z Command-Z + Undo.
    + 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. + +
    Shift-^Z Shift-Command-Z + Redo.
    + Currently same behavior as ^Z. + Reserved for future multilevel undo/redo. + +
    Arrow Keys Arrow Keys + Standard cursor movement.
    + Can be combined with Shift to extend selection. + +
    Home Command-Up,
    Command-Left
    + Move to start of line.
    + Can be combined with Shift to extend selection. + +
    End Command-Down,
    Command-Right
    + Move to end of line.
    + Can be combined with Shift to extend selection. + +
    Ctrl-HomeCommand-Up,
    Command-PgUp,
    Ctrl-Left
    + Move to top of document/field.
    + 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. + +
    Ctrl-End Command-End,
    Command-PgDn,
    Ctrl-Right
    + Move to bottom of document/field.
    + 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. + +
    Ctrl-Left Alt-Left + Word left.
    + Can be combined with Shift to extend selection. + +
    Ctrl-Right Alt-Right + Word right.
    + Can be combined with Shift to extend selection. + +
    Ctrl-Backspace Alt-Backspace + Delete word left. + +
    Ctrl-Delete Alt-Delete + Delete word right. + +
    + */ +class FL_EXPORT Fl_Input : public Fl_Input_ { + friend class Fl_Screen_Driver; + friend class Fl_Cocoa_Screen_Driver; // Not ideal, but probably no other platform will use it + 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() FL_OVERRIDE; + int handle_key(); + int handle_rmb(); + +public: + int handle(int) FL_OVERRIDE; + Fl_Input(int,int,int,int,const char * = 0); + static const char *cut_menu_text; + static const char *copy_menu_text; + static const char *paste_menu_text; +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Input_.H b/include/linux/amd64/FL/Fl_Input_.H new file mode 100644 index 0000000..2e87b11 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Input_.H @@ -0,0 +1,536 @@ +// +// Input base class header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2015 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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) + +class Fl_Input_Undo_Action; +class Fl_Input_Undo_Action_List; + +/** + 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, counting from 0 (at or before the first character) + to size() (at the end of the buffer, after the last byte). 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 + \see Fl_Widget::shortcut_label(int) + + \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 Current size of internal value() buffer in bytes. */ + 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 number of (UTF-8) characters a user can input. */ + 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 local undo event */ + Fl_Input_Undo_Action* undo_; + Fl_Input_Undo_Action_List* undo_list_; + Fl_Input_Undo_Action_List* redo_list_; + + /** \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); + + /* Draw the text in the passed bounding box. */ + void drawtext(int, int, int, int, bool draw_active); + + /* 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(Fl_Callback_Reason reason = FL_REASON_UNKNOWN); + + /** \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 yOffset) { yscroll_ = yOffset; damage(FL_DAMAGE_EXPOSE);} + + /* Return the number of lines displayed on a single page. */ + int linesPerPage(); + + /* Apply the current undo/redo operation, called from undo() or redo() */ + int apply_undo(); + +public: + + /* Change the size of the widget. */ + void resize(int, int, int, int) FL_OVERRIDE; + + /* 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 value(int value); + + /* Changes the widget text. */ + int value(double value); + + /* 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_;} + + int ivalue() const; + + double dvalue() const; + + /* Returns the Unicode character at index \p i. */ + unsigned int index(int i) const; + + /** + Returns the number of bytes in value(). + + This may be greater than strlen(value()) 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 in characters. + \see maximum_size(int). */ + int maximum_size() const {return maximum_size_;} + + /** Sets the maximum length of the input field in characters. + + This limits the number of characters that can be inserted + in the widget. + + Since FLTK 1.3 this is different than the buffer size, since one + character can be more than one byte in UTF-8 encoding. In FLTK 1.1 + this was the same (one byte = one character). + */ + void maximum_size(int m) {maximum_size_ = m;} + + /** Gets the position of the text cursor. + \return the cursor position as an index in the range 0..size() + \see insert_position(int, int) + */ + int insert_position() const { return position_; } + FL_DEPRECATED("since 1.4.0 - use insert_position() instead", + int position() const ) { return insert_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 insert_position(int p, int m); + FL_DEPRECATED("since 1.4.0 - use insert_position(p, m) or Fl_Widget::position(x, y) instead", + int position(int p, int m)) { return insert_position(p, m); } + + /** Sets the cursor position and mark. + position(n) is the same as position(n, n). + \param p new index for cursor and mark + \return 0 if no positions changed + \see insert_position(int, int), insert_position(), mark(int) + */ + int insert_position(int p) { return insert_position(p, p); } + FL_DEPRECATED("since 1.4.0 - use insert_position(p) instead", + int position(int p)) { return insert_position(p); } + + /** Sets the current selection mark. + mark(n) is the same as insert_position(insert_position(),n). + \param m new index of the mark + \return 0 if the mark did not change + \see insert_position(), insert_position(int, int) */ + int mark(int m) {return insert_position(insert_position(), m);} + + /* Deletes text from \p b to \p e and inserts the new string \p text. */ + int replace(int b, int e, const char *text, int ilen=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(insert_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(insert_position(), insert_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);} + + /* Append text at the end. */ + int append(const char* t, int l=0, char keep_selection=0); + + /* Put the current selection into the clipboard. */ + int copy(int clipboard); + + /* Undo previous changes to the text buffer. */ + int undo(); + + /* Return true if the last operation can be undone. */ + bool can_undo() const; + + /* Redo previous undo operations. */ + int redo(); + + /* Return true if there is a redo action in the list. */ + bool can_redo() const; + + /* 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).
    + If \p val is 0, Tab inserts a tab character (old FLTK behavior). + + \see tab_nav(), Fl::OPTION_ARROW_FOCUS. + */ + 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), Fl::OPTION_ARROW_FOCUS. + */ + int tab_nav() const { + return tab_nav_; + } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Input_Choice.H b/include/linux/amd64/FL/Fl_Input_Choice.H new file mode 100644 index 0000000..4c840b6 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Input_Choice.H @@ -0,0 +1,199 @@ +// +// An input/chooser widget. +// ______________ ____ +// | || __ | +// | input area || \/ | +// |______________||____| +// +// Copyright 2004 by Greg Ercolano. +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Input_Choice widget . */ + +#ifndef Fl_Input_Choice_H +#define Fl_Input_Choice_H + +#include +#include +#include +#include + +/* + 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 to choose an item which loads + the input area with the selected text. + + Note: doxygen docs in src/Fl_Input_Choice.cxx +*/ + +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() FL_OVERRIDE; + const Fl_Menu_Item* popup(); + public: + InputMenuButton(int X, int Y, int W, int H, const char *L=0); + int handle(int e) FL_OVERRIDE; + }; + + Fl_Input *inp_; + InputMenuButton *menu_; + + // note: this is used by the Fl_Input_Choice ctor. + static void menu_cb(Fl_Widget*, void *data); + + // note: this is used by the Fl_Input_Choice ctor. + static void inp_cb(Fl_Widget*, void *data); + +protected: + // Custom resize behavior -- input stretches, menu button doesn't + + /** The methods inp_x(), inp_y(), inp_w() and inp_h() return the + desired position and size of the internal Fl_Input widget. + These can be overridden by a subclass to redefine positioning. + See code example in the Description for subclassing details. + */ + virtual int inp_x() const { return(x() + Fl::box_dx(box())); } + /** See inp_x() for info. */ + virtual int inp_y() const { return(y() + Fl::box_dy(box())); } + /** See inp_x() for info. */ + virtual int inp_w() const { return(w() - Fl::box_dw(box()) - menu_w()); } + /** See inp_x() for info. */ + virtual int inp_h() const { return(h() - Fl::box_dh(box())); } + + /** The methods menu_x(), menu_y(), menu_w() and menu_h() return the + desired position and size of the internal Fl_Menu_Button widget. + These can be overridden by a subclass to redefine positioning. + See code example in the Description for subclassing details. + */ + virtual int menu_x() const { return x() + w() - menu_w() - Fl::box_dx(box()); } + /** See menu_x() for info. */ + virtual int menu_y() const { return y() + Fl::box_dy(box()); } + /** See menu_x() for info. */ + virtual int menu_w() const { return 20; } + /** See menu_x() for info. */ + virtual int menu_h() const { return h() - Fl::box_dh(box()); } + + void draw() FL_OVERRIDE; + +public: + + Fl_Input_Choice(int X, int Y, int W, int H, const char *L=0); + + void resize(int X, int Y, int W, int H) FL_OVERRIDE; + + /** Adds an item to the menu. + When any item is selected, the Fl_Input_Choice callback() is invoked, + which can do something with the selected item. + + You can access the more complex Fl_Menu_Button::add() methods + (setting item-specific callbacks, userdata, etc), via menubutton(). Example: + \code + Fl_Input_Choice *choice = new Fl_Input_Choice(100,10,120,25,"Fonts"); + Fl_Menu_Button *mb = choice->menubutton(); // use Fl_Input_Choice's Fl_Menu_Button + mb->add("Helvetica", 0, MyFont_CB, (void*)mydata); // use Fl_Menu_Button's add() methods + mb->add("Courier", 0, MyFont_CB, (void*)mydata); + mb->add("More..", 0, FontDialog_CB, (void*)mydata); + \endcode + */ + void add(const char *s) { menu_->add(s); } + + /** Returns the combined changed() state of the input and menu button widget. */ + int changed() const { return inp_->changed() | Fl_Widget::changed(); } + + // Clears the changed() state of both input and menu button widgets. + void clear_changed(); + + // Sets the changed() state of both input and menu button widgets. + void 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); } + + /// Gets the Fl_Input text field's text color. + Fl_Color textcolor() const { return (inp_->textcolor());} + + /// Sets the Fl_Input text field's text color to \p c. + void textcolor(Fl_Color c) { inp_->textcolor(c);} + + /// Gets the Fl_Input text field's font style. + Fl_Font textfont() const { return (inp_->textfont());} + + /// Sets the Fl_Input text field's font style to \p f. + void textfont(Fl_Font f) { inp_->textfont(f);} + + /// Gets the Fl_Input text field's font size + Fl_Fontsize textsize() const { return (inp_->textsize()); } + + /// Sets the Fl_Input text field's font size to \p s. + void textsize(Fl_Fontsize s) { inp_->textsize(s); } + + /// Returns the Fl_Input text field's current contents. + const char* value() const { return (inp_->value()); } + + /** Sets the Fl_Input text field's contents to \p val. + + Note it is possible to set the value() to one that is not + in the menubutton's list of choices. + + Setting the value() does NOT affect the menubutton's selection. + If that's needed, call update_menubutton() after setting value(). + + \see void value(int val), update_menubutton() + */ + void value(const char *val) { inp_->value(val); } + + /* Chooses item# \p val in the menu, and sets the Fl_Input text field + to that value. Any previous text is cleared. */ + void value(int val); + + int update_menubutton(); + + /** Returns a pointer to the internal Fl_Menu_Button widget. + This can be used to access any of the methods of the menu button, e.g. + \code + Fl_Input_Choice *choice = new Fl_Input_Choice(100,10,120,25,"Choice:"); + [..] + // Print all the items in the choice menu + for ( int t=0; tmenubutton()->size(); t++ ) { + const Fl_Menu_Item &item = choice->menubutton()->menu()[t]; + printf("item %d -- label=%s\n", t, item.label() ? item.label() : "(Null)"); + } + \endcode + */ + Fl_Menu_Button *menubutton() { return menu_; } + + /** Returns a pointer to the internal Fl_Input widget. + This can be used to directly access all of the Fl_Input widget's methods. + */ + Fl_Input *input() { return inp_; } +}; + +#endif // !Fl_Input_Choice_H diff --git a/include/linux/amd64/FL/Fl_Int_Input.H b/include/linux/amd64/FL/Fl_Int_Input.H new file mode 100644 index 0000000..508a2f8 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Int_Input.H @@ -0,0 +1,40 @@ +// +// Integer input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + */ + Fl_Int_Input(int X,int Y,int W,int H,const char *l = 0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_JPEG_Image.H b/include/linux/amd64/FL/Fl_JPEG_Image.H new file mode 100644 index 0000000..4e74148 --- /dev/null +++ b/include/linux/amd64/FL/Fl_JPEG_Image.H @@ -0,0 +1,43 @@ +// +// JPEG image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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, int data_length=-1); + +protected: + + void load_jpg_(const char *filename, const char *sharename, const unsigned char *data, int data_length=-1); + +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Light_Button.H b/include/linux/amd64/FL/Fl_Light_Button.H new file mode 100644 index 0000000..a03ec2e --- /dev/null +++ b/include/linux/amd64/FL/Fl_Light_Button.H @@ -0,0 +1,44 @@ +// +// Lighted button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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(). + \image html Fl_Light_Button.png + \image latex Fl_Light_Button.png "Fl_Light_Button" width=4cm +*/ +class FL_EXPORT Fl_Light_Button : public Fl_Button { +protected: + void draw() FL_OVERRIDE; +public: + int handle(int) FL_OVERRIDE; + Fl_Light_Button(int x,int y,int w,int h,const char *l = 0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Line_Dial.H b/include/linux/amd64/FL/Fl_Line_Dial.H new file mode 100644 index 0000000..873e82b --- /dev/null +++ b/include/linux/amd64/FL/Fl_Line_Dial.H @@ -0,0 +1,30 @@ +// +// Line dial header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Menu.H b/include/linux/amd64/FL/Fl_Menu.H new file mode 100644 index 0000000..eb6caf7 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Menu.H @@ -0,0 +1,18 @@ +// +// Old menu header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// this include file is for back compatibility only +#include "Fl_Menu_Item.H" diff --git a/include/linux/amd64/FL/Fl_Menu_.H b/include/linux/amd64/FL/Fl_Menu_.H new file mode 100644 index 0000000..b89949c --- /dev/null +++ b/include/linux/amd64/FL/Fl_Menu_.H @@ -0,0 +1,254 @@ +// +// Menu base class header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + 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_. + + When the user clicks a menu item, value() is set to that item + and then: + + - If the Fl_Menu_Item has a callback set, that callback + is invoked with any userdata configured for it. + (The Fl_Menu_ widget's callback is NOT invoked.) + + - For any Fl_Menu_Items that \b don't have a callback set, + the Fl_Menu_ widget's callback is invoked with any userdata + configured for it. The callback can determine which item + was picked using value(), mvalue(), item_pathname(), etc. + + The line spacing between menu items can be controlled with the global setting + Fl::menu_linespacing(). + \see Fl_Widget::shortcut_label(int) +*/ +class FL_EXPORT Fl_Menu_ : public Fl_Widget { + + Fl_Menu_Item *menu_; + const Fl_Menu_Item *value_; + const Fl_Menu_Item *prev_value_; + +protected: + + uchar alloc; // flag indicates if menu_ is a dynamic copy (=1) or not (=0) + uchar down_box_; + Fl_Boxtype menu_box_; + Fl_Font textfont_; + Fl_Fontsize textsize_; + Fl_Color textcolor_; + + int item_pathname_(char *name, int namelen, const Fl_Menu_Item *finditem, + const Fl_Menu_Item *menu=0) const; +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*); + const Fl_Menu_Item* find_item_with_user_data(void*); + const Fl_Menu_Item* find_item_with_argument(long); + 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 or an internal + (temporary) location (see note below). + + \note Implementation details - may be changed in the future. + All modifications of the menu array are done by copying the entire + menu array to an internal storage for optimization of memory + allocations, for instance when using add() or insert(). While this + is done, menu() returns the pointer to this internal location. The + entire menu will be copied back to private storage when needed, + i.e. when \b another Fl_Menu_ is modified. You can force this + reallocation after you're done with all menu modifications by calling + Fl_Menu_::menu_end() to make sure menu() returns a permanent pointer + to private storage (until the menu is modified again). + Note also that some menu methods (e.g. Fl_Menu_Button::popup()) call + menu_end() internally to ensure a consistent menu array while the + menu is open. + + \see size() -- returns the size of the Fl_Menu_Item array. + \see menu_end() -- finish %menu modifications (optional) + + \b Example: How to walk the array: + \code + for ( int t=0; tsize(); t++ ) { // walk array of items + const Fl_Menu_Item &item = menubar->menu()[t]; // get each item + fprintf(stderr, "item #%d -- label=%s, value=%s type=%s\n", + t, + item.label() ? item.label() : "(Null)", // menu terminators have NULL labels + (item.flags & FL_MENU_VALUE) ? "set" : "clear", // value of toggle or radio items + (item.flags & FL_SUBMENU) ? "Submenu" : "Item"); // see if item is a submenu or actual item + } + \endcode + + */ + const Fl_Menu_Item *menu() const {return menu_;} + const Fl_Menu_Item *menu_end(); // in src/Fl_Menu_add.cxx + 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 src/Fl_Menu_add.cxx + /** 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); + /** Change the shortcut of item \p i to \p s. */ + void shortcut(int i, int s) {menu_[i].shortcut(s);} + /** Set 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;} + /** Get the flags of item i. For a list of the flags, see Fl_Menu_Item. */ + int mode(int i) const {return menu_[i].flags;} + + /** Return a pointer to the last menu item that was picked. */ + const Fl_Menu_Item *mvalue() const {return value_;} + + /** Return a pointer to the menu item that was picked before the current one was picked. + This call gives developers additional details how a user changed a choice in the Fl_Choice widget. + */ + const Fl_Menu_Item *prev_mvalue() const {return prev_value_;} + // Return the index into the menu() of the last item chosen by the user or -1. + int value() const; + // Set the internal value_ of the menu to the given Fl_Menu_Item. + int value(const Fl_Menu_Item*); + /** + Set the value of the menu to index \c i. + + The \e value of the menu is the index into the menu() of the last + item chosen by the user or -1. + + It is \c -1 initially (if no item has been chosen) or if the chosen + menu item is part of a submenu addressed by an FL_SUBMENU_POINTER. + + \note All menu items are located in a contiguous array of Fl_Menu_Item's + unless an item has the FL_SUBMENU_POINTER flag which redirects the + submenu to an independent submenu array. This submenu array is not + counted in the size() of the menu, and menu items in this submenu can't + return a valid index into the \b main menu. Therefore menu items that + are located in such a submenu return -1 when value() is called. + This may be changed in a future version. + + You can set the value as an integer or with a pointer to a menu item. + The integer value is restricted to the main menu array (0..size()-1) + whereas the menu item can be any menu item, even one in a detached + submenu (see note about FL_SUBMENU_POINTER above). + + \param[in] i Index of the menu item in the main menu array.\n + Values outside 0..size()-1 are ignored (return 0). + + \return Whether the new value is different than the old one. + \retval 0 The value didn't change. + \retval 1 The value was changed. + + \see int value(const Fl_Menu_Item*) + \see int value() + \see const Fl_Menu_Item *mvalue() + */ + int value(int i) { + if (!menu_ || i < 0 || i >= size()) + return 0; + 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. + */ + Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;} + /** Sets the box type used to surround the currently-selected items in the menus. */ + void down_box(Fl_Boxtype b) {down_box_ = b;} + + /** Get the box type for the menu popup windows. + \return the box type, or FL_NO_BOX if Fl_Menu_::box() is to be used instead + */ + Fl_Boxtype menu_box() const { return menu_box_; } + /** Set the box type for the menu popup windows. + If menu_box set to FL_NO_BOX, the menu window will use Fl_Menu_::box() instead. + \param[in] b new box type or FL_NO_BOX + */ + void menu_box(Fl_Boxtype b) { menu_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);} + void setonly(Fl_Menu_Item* item); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Menu_Bar.H b/include/linux/amd64/FL/Fl_Menu_Bar.H new file mode 100644 index 0000000..26c0853 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Menu_Bar.H @@ -0,0 +1,101 @@ +// +// Menu bar header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2017 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + 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. + + \image html menubar.png + \image latex menubar.png " menubar" width=12cm + + 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. + + When the user clicks a menu item, value() is set to that item + and then: + + - The item's callback is done if one has been set; the + Fl_Menu_Bar is passed as the Fl_Widget* argument, + along with any userdata configured for the callback. + + - If the item does not have a callback, the Fl_Menu_Bar's callback + is done instead, along with any userdata configured for the callback. + The callback can determine which item was picked using + value(), mvalue(), item_pathname(), etc. + + 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. + + 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_ { + friend class Fl_Sys_Menu_Bar_Driver; +protected: + void draw() FL_OVERRIDE; +public: + int handle(int) FL_OVERRIDE; + /** + Creates a new Fl_Menu_Bar widget using the given position, + size, and label string. The default boxtype is FL_UP_BOX. + + The constructor sets menu() to NULL. See + Fl_Menu_ for the methods to set or change the menu. + + 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. + + label() is ignored unless you change align() to + put it outside the menubar. + + 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); + /** Updates the menu bar after any change to its items. + This is useful when the menu bar can be an Fl_Sys_Menu_Bar object. + */ + virtual void update() {} + /** + Opens the 1st level submenu of the menubar corresponding to \c item. + \since 1.4.0 + */ + virtual void play_menu(const Fl_Menu_Item *item); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Menu_Button.H b/include/linux/amd64/FL/Fl_Menu_Button.H new file mode 100644 index 0000000..0e10364 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Menu_Button.H @@ -0,0 +1,80 @@ +// +// Menu button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + \image html menu_button.png + \image latex menu_button.png " menu_button" width=5cm +

    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).

    +

    The menu will also pop up in response to shortcuts indicated by + putting a '&' character in the label().

    +

    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.

    + + When the user clicks a menu item, value() is set to that item + and then: + + - The item's callback is done if one has been set; the + Fl_Menu_Button is passed as the Fl_Widget* argument, + along with any userdata configured for the callback. + + - If the item does not have a callback, the Fl_Menu_Button's callback + is done instead, along with any userdata configured for it. + The callback can determine which item was picked using + value(), mvalue(), item_pathname(), etc. +*/ +class FL_EXPORT Fl_Menu_Button : public Fl_Menu_ { +protected: + void draw() FL_OVERRIDE; + static Fl_Menu_Button* pressed_menu_button_; +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) FL_OVERRIDE; + const Fl_Menu_Item* popup(); + Fl_Menu_Button(int,int,int,int,const char * =0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Menu_Item.H b/include/linux/amd64/FL/Fl_Menu_Item.H new file mode 100644 index 0000000..3073dd2 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Menu_Item.H @@ -0,0 +1,561 @@ +// +// Menu item header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Menu_Item_H +#define Fl_Menu_Item_H + +#include +#include +#include +#include // for FL_COMMAND and FL_CONTROL + +// doxygen needs the following line to enable e.g. ::FL_MENU_TOGGLE to link to the enums +/// @file + +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, ///< 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, internal (do not use) + ///< Note: \b ALL other bits in \p flags are reserved: do not use them for your own purposes! +}; + +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() + int 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, internal (do not use) + }; + \endcode + + \note \b All other bits in \p flags are reserved for FLTK usage, do not use any bits of the + \p flags variable for your own purposes. Even \b undocumented bits can be used for internal + purposes in this or any future FLTK version. + + Some \p flags bits may be changed during runtime by user code, particularly if you need to change + the value of a menu item (ON/OFF) or make it active or inactive. Such changes must be done with + caution so they don't affect other (maybe undocumented) bits, i.e. you need to make proper bit + operations to set or clear only these particular bits. + + 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. + + \note Adding menu items with insert(), add(), or any of its overloaded + variants copies the entire menu to internal storage. Using the + memory of a static menu array after that would access unused (but not + released) memory and thus have no effect. +*/ +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 (label) of the menu 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. + + The returned value depends on the labeltype() that has been used + to store the label. + + \returns A pointer to the label cast to (const char *) + + \retval (a) A pointer to text (const char *) + \retval (b) A pointer to an image (Fl_Image *) + \retval (c) A pointer to a "multi label" (Fl_Multi_Label *) + \retval NULL End of menu or submenu + + \see Fl_Menu_Item::label(const char *) + \see Fl_Menu_Item::label(Fl_Labeltype, const char *) + \see Fl_Menu_Item::image_label(const Fl_Image *) + \see Fl_Menu_Item::multi_label(const Fl_Multi_Label *) + \see Fl_Multi_Label::label(Fl_Menu_Item *) + */ + const char* label() const { return text; } + + /** + Sets the title (label) of the menu item. + + \note This does \b not change the labeltype() for backwards compatibility. + Take care to assign the correct labeltype() if you assign different + label types to the same menu item sequentially. + + The default labeltype() is FL_NORMAL_LABEL. + + \see label(Fl_Labeltype, const char*) + \see const char* Fl_Menu_Item::label() const + */ + void label(const char* a) { text = a; } + + /** + Sets the title (label) and the label type of the menu item. + + The default Fl_Labeltype when using Fl_Menu_Item::label(const char* a) + is FL_NORMAL_LABEL but you can set any other label type, for instance + FL_EMBOSSED_LABEL. + + Special labeltypes are: + + - FL_ICON_LABEL: draws the icon (Fl_Image) associated with the text + - FL_IMAGE_LABEL: draws the image (Fl_Image) associated with the text + - FL_MULTI_LABEL: draws multiple parts side by side, see Fl_Multi_Label + + \see const char* Fl_Menu_Item::label() const + */ + void label(Fl_Labeltype a, const char* b) { + labeltype_ = a; + text = b; + } + + /** + Sets the title (label()) and labeltype() to an Fl_Multi_Label. + + This sets the labeltype() to \_FL_MULTI_LABEL (note the leading + underscore). + + \see const char* Fl_Menu_Item::label() const + + \since 1.4.0 + + \internal Overloading Fl_Menu_Item::image() would lead to ambiguities + when used like `item->label(0)`, hence we need our own method name. + Otherwise existing programs might not compile w/o error (e.g. fluid). + */ + void multi_label(const Fl_Multi_Label *ml) { + label(FL_MULTI_LABEL, (const char *)ml); + } + + /** + Sets the title (label()) to an icon or image. + + This sets the labeltype() to \_FL_IMAGE_LABEL (note the leading + underscore). + + \see const char* Fl_Menu_Item::label() const + + \since 1.4.0 + + \internal Overloading Fl_Menu_Item::image() would lead to ambiguities + when used like `item->label(0)`, hence we need our own method name. + Otherwise existing programs might not compile w/o error (e.g. fluid). + */ + void image_label(const Fl_Image *image) { + label(FL_IMAGE_LABEL, (const char *)image); + } + + /** + 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 *)(void *)c; + } + + /** + Sets the menu item's callback function and 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 *)(void *)c; + user_data_ = (void *)(fl_intptr_t)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*)(fl_intptr_t)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. + This is zero (0) if the menu item is not checked and non-zero otherwise. + \since 1.4.0 this method returns 1 if the item is checked but you + should not rely on a particular value, only zero or non-zero. + \note The returned value for a checked menu item was FL_MENU_VALUE (4) + before FLTK 1.4.0. + */ + int value() const {return (flags & FL_MENU_VALUE) ? 1 : 0;} + + /** Sets the current value of the check or radio item. */ + void value(int v) { v ? set() : clear(); } + + /** + Turns the check or radio item "on" for the menu item. Note that this + does not turn off any adjacent radio items like setonly() 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(Fl_Menu_Item const* first = NULL); + + /** 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 image->label(this). + + \note This method is intended for internal use by fluid and may + not do what you expect. + */ + void image(Fl_Image* image) {image->label(this);} + + /** Compatibility API for FLUID, same as image.label(this). + + \note This method is intended for internal use by fluid and may + not do what you expect. + */ + void image(Fl_Image& image) {image.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 {Fl::callback_reason_=FL_REASON_SELECTED; 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 {Fl::callback_reason_=FL_REASON_SELECTED; 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 {Fl::callback_reason_=FL_REASON_SELECTED; callback_(o, (void*)(fl_intptr_t)arg);} + + /** Back compatibility only. + \deprecated + Please use Fl_Menu_Item::value() instead. + This method will be removed in FLTK 1.5.0 or later. + \see value() + */ + inline int checked() const {return value();} + + /** Back compatibility only. + \deprecated + Please use Fl_Menu_Item::set() instead. + This method will be removed in FLTK 1.5.0 or later. + \see set() + */ + inline void check() {set();} + + /** Back compatibility only. + \deprecated + Please use Fl_Menu_Item::clear() instead. + This method will be removed in FLTK 1.5.0 or later. + \see clear() + */ + inline void uncheck() {clear();} + + 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 diff --git a/include/linux/amd64/FL/Fl_Menu_Window.H b/include/linux/amd64/FL/Fl_Menu_Window.H new file mode 100644 index 0000000..dbd9cae --- /dev/null +++ b/include/linux/amd64/FL/Fl_Menu_Window.H @@ -0,0 +1,40 @@ +// +// Menu window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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: + ~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); + /** 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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Multi_Browser.H b/include/linux/amd64/FL/Fl_Multi_Browser.H new file mode 100644 index 0000000..69a6395 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Multi_Browser.H @@ -0,0 +1,52 @@ +// +// Multi browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + \image html fl_multi_browser.png "Fl_Multi_Browser" + \image latex fl_multi_browser.png "Fl_Multi_Browser" width=4cm + + 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 ctrl + click (Cmd+click on the Mac OS platform) toggles the items. + Shift + click extends the selection until the clicked item. + This is different from how forms did it. + Normally the callback is done when the user releases the + mouse, but you can change this with when(). +

    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. + */ + Fl_Multi_Browser(int X,int Y,int W,int H,const char *L=0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Multi_Label.H b/include/linux/amd64/FL/Fl_Multi_Label.H new file mode 100644 index 0000000..7c7f60a --- /dev/null +++ b/include/linux/amd64/FL/Fl_Multi_Label.H @@ -0,0 +1,103 @@ +// +// Multi-label header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Multi_Label_H +#define Fl_Multi_Label_H + +class Fl_Widget; +struct Fl_Menu_Item; + +/** Allows a mixed text and/or graphics label to be applied to an Fl_Menu_Item or Fl_Widget. + + Most regular FLTK widgets now support the ability to associate both images and text + with a label but some special cases, notably the non-widget Fl_Menu_Item objects, do not. + Fl_Multi_Label may be used to create menu items that have an icon and text, which would + not normally be possible for an Fl_Menu_Item. + For example, Fl_Multi_Label is used in the New->Code submenu in fluid, and others. + + \image html Fl_Multi_Label-menu-item.png "Menu items with icons using Fl_Multi_Label" + \image latex Fl_Multi_Label-menu-item.png "Menu items with icons using Fl_Multi_Label" width=4cm + + Each Fl_Multi_Label holds two elements, \p labela and \p labelb; each may hold either a + text label (const char*) or an image (Fl_Image*). When displayed, \p labela is drawn first + and \p labelb is drawn immediately to its right. + + More complex labels can be constructed by setting labelb as another Fl_Multi_Label and + thus chaining up a series of label elements. + + When assigning a label element to one of \p labela or \p labelb, they should be + explicitly cast to (const char*) if they are not of that type already. + + \note An Fl_Multi_Label object and all its components (label text, images, chained + Fl_Multi_Label's and their linked objects) must exist during the lifetime of the + widget or menu item they are assigned to. It is the responsibility of the user's + code to release these linked objects if necessary after the widget or menu is deleted. + + Example Use: Fl_Menu_Bar + \code + Fl_Pixmap *image = new Fl_Pixmap(..); // image for menu item; any Fl_Image based widget + Fl_Menu_Bar *menu = new Fl_Menu_Bar(..); // can be any Fl_Menu_ oriented widget (Fl_Choice, Fl_Menu_Button..) + + // Create a menu item + int i = menu->add("File/New", ..); + Fl_Menu_Item *item = (Fl_Menu_Item*)&(menu->menu()[i]); + + // Create a multi label, assign it an image + text + Fl_Multi_Label *ml = new Fl_Multi_Label; + + // Left side of label is an image + ml->typea = FL_IMAGE_LABEL; + ml->labela = (const char*)image; // any Fl_Image widget: Fl_Pixmap, Fl_PNG_Image, etc.. + + // Right side of label is label text + ml->typeb = FL_NORMAL_LABEL; + ml->labelb = item->label(); + + // Assign the multilabel to the menu item + // ml->label(item); // deprecated since 1.4.0; backwards compatible with 1.3.x + item->label(ml); // new method since 1.4.0 + \endcode + + \see Fl_Label and Fl_Labeltype and examples/howto-menu-with-images.cxx +*/ +struct FL_EXPORT Fl_Multi_Label { + /** Holds the "leftmost" of the two elements in the composite label. + Typically this would be assigned either a text string (const char*), + a (Fl_Image*) or a (Fl_Multi_Label*). */ + const char* labela; + /** Holds the "rightmost" of the two elements in the composite label. + Typically this would be assigned either a text string (const char*), + a (Fl_Image*) or a (Fl_Multi_Label*). */ + const char* labelb; + /** Holds the "type" of labela. + Typically this is set to FL_NORMAL_LABEL for a text label, + FL_IMAGE_LABEL for an image (based on Fl_image) or FL_MULTI_LABEL + if "chaining" multiple Fl_Multi_Label elements together. */ + uchar typea; + /** Holds the "type" of labelb. + Typically this is set to FL_NORMAL_LABEL for a text label, + FL_IMAGE_LABEL for an image (based on Fl_image) or FL_MULTI_LABEL + if "chaining" multiple Fl_Multi_Label elements together. */ + uchar typeb; + + // This method is used to associate a Fl_Multi_Label with a Fl_Widget. + void label(Fl_Widget*); + + // This method is used to associate a Fl_Multi_Label with a Fl_Menu_Item. + void label(Fl_Menu_Item*); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Multiline_Input.H b/include/linux/amd64/FL/Fl_Multiline_Input.H new file mode 100644 index 0000000..5527210 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Multiline_Input.H @@ -0,0 +1,54 @@ +// +// Multiline input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + */ + Fl_Multiline_Input(int X,int Y,int W,int H,const char *l = 0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Multiline_Output.H b/include/linux/amd64/FL/Fl_Multiline_Output.H new file mode 100644 index 0000000..480fc8f --- /dev/null +++ b/include/linux/amd64/FL/Fl_Multiline_Output.H @@ -0,0 +1,59 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + A caret cursor (^) shows the keyboard navigation mark + for keyboard selection of the output text, e.g. Arrow Keys + to move the cursor, Shift + Arrow Keys to create a text + selection, and '^C' to copy the selected text to the paste buffer. + The caret cursor can be disabled by disabling the widget's + "visible focus" using clear_visible_focus(), inherited from the + Fl_Widget base class. Doing this also disables the widget's + keyboard navigation. +*/ +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. + */ + Fl_Multiline_Output(int X,int Y,int W,int H,const char *l = 0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Native_File_Chooser.H b/include/linux/amd64/FL/Fl_Native_File_Chooser.H new file mode 100644 index 0000000..726a346 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Native_File_Chooser.H @@ -0,0 +1,283 @@ +// +// FLTK native OS file chooser widget +// +// Copyright 2004 Greg Ercolano. +// Copyright 2005-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file + Fl_Native_File_Chooser widget. */ + +/* Implementation note: + + class Fl_Native_File_Chooser <== public API used by applications + + class Fl_Native_File_Chooser_Driver <== virtual API that a platform may implement + this API has a do-nothing default implementation + + class Fl_Native_File_Chooser_FLTK_Driver <== this API implementation is the default FLTK file chooser + class Fl_GTK_Native_File_Chooser_Driver <== this API implementation runs a GTK file chooser + class Fl_Kdialog_Native_File_Chooser_Driver <== this API implementation runs a KDE file chooser + it is determined at run-time if the GTK dynamic libraries are available + and the KDE file chooser runs under the KDE desktop + + class Fl_Quartz_Native_File_Chooser_Driver <== this API implementation runs a Mac OS X file chooser + + class Fl_WinAPI_Native_File_Chooser_Driver <== this API implementation runs a Windows file chooser + + + Each platform must implement the constructor of the Fl_Native_File_Chooser class. + This particular implementation: + + Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) { + platform_fnfc = new Fl_Native_File_Chooser_FLTK_Driver(val); + } + + can be used by any platform. + No more code is required. The cross-platform Fl_Native_File_Chooser_FLTK.cxx file must be compiled in libfltk, + and the default FLTK file chooser will be used. + + This other implementation: + Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) { + platform_fnfc = 0; + } + can be used by a platform that needs no file chooser. + */ + +#ifndef FL_NATIVE_FILE_CHOOSER_H +#define FL_NATIVE_FILE_CHOOSER_H + +#include +#include + +class Fl_Native_File_Chooser_Driver; + +/** + 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 + \endcode + + The following example shows how to pick a single file: + \code + // Create and post the local native file chooser + #include + [..] + 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 + + The Fl_Native_File_Chooser widget transmits UTF-8 encoded filenames to its user. It is + recommended to open files that may have non-ASCII names with the fl_fopen() or + fl_open() utility functions that handle these names in a cross-platform way + (whereas the standard fopen()/open() functions fail on the Windows platform + to open files with a non-ASCII name). + + Platform Specific Caveats + + - Under X11/Wayland the dialog is chosen as follows: + -# If command \p zenity is available at run-time and if \p Fl::option(OPTION_FNFC_USES_ZENITY) is + turned on, the \p zenity -based dialog opens. This is expected to be more appropriate + than other dialog forms for sandboxed apps, but member function filter_value() is not effective. + -# Else if the app runs under the KDE desktop + and if \p Fl::option(OPTION_FNFC_USES_KDIALOG) is turned on, + and if command \p kdialog is available at run-time, the \p kdialog -based dialog opens. + Member function filter_value() is not effective with this dialog. + -# Else if the GTK library is available at run-time on the computer and if \p Fl::option(OPTION_FNFC_USES_GTK) is + not turned off, the GTK-styled dialog opens. Call fl_register_images() to add a "Preview" button to this dialog. + Use the static public attributes of class Fl_File_Chooser to localize the browser. + -# Otherwise, FLTK's own dialog produced by the Fl_File_Chooser class opens. + Call fl_register_images() to add a "Preview" button to it. + It's best if you also 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 { +private: + Fl_Native_File_Chooser_Driver *platform_fnfc; +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 + NEW_FOLDER = 0x0002, ///< Show 'New Folder' icon (if supported) + PREVIEW = 0x0004, ///< enable preview mode (if supported) + USE_FILTER_EXT = 0x0008 ///< Chooser filter presets the output file extension (if supported) + }; + static const char *file_exists_message; + + /** + The constructor. Internally allocates the native widgets. + Optional \p val presets the type of browser this will be, + which can also be changed with type(). + */ + Fl_Native_File_Chooser(int val = BROWSE_FILE); // each platorm implements it + ~Fl_Native_File_Chooser(); + void type(int t); + int type() const ; + void options(int o); + 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 *t); + const char* title() const; + const char *filter() const ; + void filter(const char *f); + int filters() const ; + void filter_value(int i) ; + int filter_value() const ; + void preset_file(const char*f) ; + const char* preset_file() const; + const char *errmsg() const ; + int show() ; + }; + +/** + \cond DriverDev + \addtogroup DriverDeveloper + \{ + */ + +/** Represents the interface between FLTK and a native file chooser. + This class is only for internal use by the FLTK library. + A platform that wants to provide a native file chooser implements all virtual methods + of this class. Each platform supported by FLTK must also implement the constructor of the + Fl_Native_File_Chooser class. + */ +class Fl_Native_File_Chooser_Driver { +protected: + static void chrcat(char *s, char c); + static char *strapp(char *s, const char *val); + static char *strfree(char *val); + static char *strnew(const char *val); +public: + Fl_Native_File_Chooser_Driver(int) {} + virtual ~Fl_Native_File_Chooser_Driver() {} + virtual void type(int) {} + virtual int type() const {return 0;} + virtual void options(int) {} + virtual int options() const {return 0;} + virtual int count() const {return 0;} + virtual const char *filename() const {return 0;} + virtual const char *filename(int) const {return 0;} + virtual void directory(const char *) {} + virtual const char *directory() const {return 0;} + virtual void title(const char *) {} + virtual const char* title() const {return 0;} + virtual const char *filter() const {return 0;} + virtual void filter(const char *) {} + virtual int filters() const {return 0;} + virtual void filter_value(int) {} + virtual int filter_value() const {return 0;} + virtual void preset_file(const char*) {} + virtual const char* preset_file() const {return 0;} + virtual const char *errmsg() const {return 0;} + virtual int show() {return 1;} +}; + +/** A cross-platform implementation of Fl_Native_File_Chooser_Driver. + This implementation uses a Fl_File_Chooser object as file chooser. + + Any platform can support the Fl_Native_File_Chooser class by implementing + its constructor as follows: + \code + Fl_Native_File_Chooser::Fl_Native_File_Chooser(int type) { + platform_fnfc = new Fl_Native_File_Chooser_FLTK_Driver(type); + } +\endcode + */ +class Fl_Native_File_Chooser_FLTK_Driver : public Fl_Native_File_Chooser_Driver { +private: + void errmsg(const char *msg); + int type_fl_file(int val); + int exist_dialog(); + void parse_filter(); +protected: + 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; +public: + Fl_Native_File_Chooser_FLTK_Driver(int val); + virtual ~Fl_Native_File_Chooser_FLTK_Driver(); + void type(int t) FL_OVERRIDE; + int type() const FL_OVERRIDE; + void options(int o) FL_OVERRIDE; + int options() const FL_OVERRIDE; + int count() const FL_OVERRIDE; + const char *filename() const FL_OVERRIDE; + const char *filename(int i) const FL_OVERRIDE; + void directory(const char *val) FL_OVERRIDE; + const char *directory() const FL_OVERRIDE; + void title(const char *t) FL_OVERRIDE; + const char* title() const FL_OVERRIDE; + const char *filter() const FL_OVERRIDE; + void filter(const char *f) FL_OVERRIDE; + int filters() const FL_OVERRIDE; + void filter_value(int i) FL_OVERRIDE; + int filter_value() const FL_OVERRIDE; + void preset_file(const char*f) FL_OVERRIDE; + const char* preset_file() const FL_OVERRIDE; + const char *errmsg() const FL_OVERRIDE; + int show() FL_OVERRIDE; +}; + +/** + \} + \endcond + */ + + +#endif /*FL_NATIVE_FILE_CHOOSER_H*/ diff --git a/include/linux/amd64/FL/Fl_Nice_Slider.H b/include/linux/amd64/FL/Fl_Nice_Slider.H new file mode 100644 index 0000000..1887eac --- /dev/null +++ b/include/linux/amd64/FL/Fl_Nice_Slider.H @@ -0,0 +1,30 @@ +// +// "Nice" slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Object.H b/include/linux/amd64/FL/Fl_Object.H new file mode 100644 index 0000000..8098dd2 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Object.H @@ -0,0 +1,21 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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" diff --git a/include/linux/amd64/FL/Fl_Output.H b/include/linux/amd64/FL/Fl_Output.H new file mode 100644 index 0000000..099afbe --- /dev/null +++ b/include/linux/amd64/FL/Fl_Output.H @@ -0,0 +1,57 @@ +// +// Output header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + \image html text.png + \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. + */ + + Fl_Output(int X,int Y,int W,int H, const char *l = 0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Overlay_Window.H b/include/linux/amd64/FL/Fl_Overlay_Window.H new file mode 100644 index 0000000..b030375 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Overlay_Window.H @@ -0,0 +1,78 @@ +// +// Overlay window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. +

    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 { +#ifndef FL_DOXYGEN + friend class _Fl_Overlay; + friend class Fl_Window_Driver; +#endif +public: + /** + You must subclass Fl_Overlay_Window and provide this method. + It is just like a draw() method, except it draws the overlay. + The overlay will have already been "cleared" when this is called. You + can use any of the routines described in <FL/fl_draw.H>. + */ + virtual void draw_overlay() = 0; +private: + Fl_Window *overlay_; +public: + void show() FL_OVERRIDE; + void hide() FL_OVERRIDE; + void flush() FL_OVERRIDE; + void resize(int,int,int,int) FL_OVERRIDE; + ~Fl_Overlay_Window(); + /** Returns non-zero if there's hardware overlay support */ + int can_do_overlay(); + void redraw_overlay(); +protected: + /** + See Fl_Overlay_Window::Fl_Overlay_Window(int X, int Y, int W, int H, const char *l=0) + */ + Fl_Overlay_Window(int W, int H, const char *l=0); + /** + 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 X, int Y, int W, int H, const char *l=0); +public: + /** Same as Fl_Window::show(int a, char **b) */ + void show(int a, char **b) {Fl_Double_Window::show(a,b);} + Fl_Overlay_Window *as_overlay_window() FL_OVERRIDE {return this; } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_PDF_File_Surface.H b/include/linux/amd64/FL/Fl_PDF_File_Surface.H new file mode 100644 index 0000000..7fd2ed5 --- /dev/null +++ b/include/linux/amd64/FL/Fl_PDF_File_Surface.H @@ -0,0 +1,89 @@ +// +// Declaration of class Fl_PDF_File_Surface for the Fast Light Tool Kit (FLTK). +// +// Copyright 2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef PDF_FILE_SURFACE_H +#define PDF_FILE_SURFACE_H + +#include + +/** + To send graphical output to a PDF file. + Class Fl_PDF_File_Surface is used exactly as the Fl_Printer class except for its 2 member functions begin_job() and begin_document(). +

    Platform notes: + - Windows: requires "Microsoft Print to PDF" available in Windows 10 and later. + - Wayland/X11: requires the FLTK library was built with FLTK_USE_PANGO=1. + - macOS: requires macOS 10.9 or later. +

    If the running platform doesn't fulfill the requirement above, the program runs but doesn't output any PDF. +*/ +class FL_EXPORT Fl_PDF_File_Surface : public Fl_Paged_Device { +private: + const char **out_filename_; + Fl_Paged_Device *platform_surface_; + static Fl_Paged_Device *new_platform_pdf_surface_(const char ***); +public: + /** \name These attributes are useful for the Wayland/X11 platform only. + \{ + */ + static const char * format_dialog_title; + static const char * format_dialog_page_size; + static const char * format_dialog_orientation; + static const char * format_dialog_default; + /** \} */ + Fl_PDF_File_Surface(); + ~Fl_PDF_File_Surface(); + /** Prepare to draw to a PDF document identified with a file chooser. + A dialog opens to select the location and name of the output PDF document + as well as its page format and orientation. + \param defaultfilename Default name for the PDF document + \param perr NULL or address of a string that receives a message in case of error. + To be deleted[] after use. + \return 0 for success, 1 when the user cancelled the operation, 2 when an error occurred. + */ + int begin_job(const char* defaultfilename, char **perr = NULL); + /** Don't use for this class */ + int begin_job(int, int *, int *, char **) FL_OVERRIDE {return 1;} + /** Prepare to draw to a PDF document identified by its pathname. + \param pathname Path name for the PDF document + \param format The paper format for the PDF document + \param layout The orientation for the PDF document + \param perr NULL or address of a string that receives a message in case of error. + To be deleted[] after use. + \return 0 for success, 2 when an error occurred. + */ + int begin_document(const char* pathname, + enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, + enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT, + char **perr = NULL); + int printable_rect(int *w, int *h) FL_OVERRIDE { return platform_surface_->printable_rect(w,h); } + void margins(int *left, int *top, int *right, int *bottom) FL_OVERRIDE { + platform_surface_->margins(left,top,right,bottom); + } + void origin(int x, int y) FL_OVERRIDE {platform_surface_->origin(x, y);} + void origin(int *x, int *y) FL_OVERRIDE {platform_surface_->origin(x, y);} + void scale(float s_x, float s_y = 0) FL_OVERRIDE {platform_surface_->scale(s_x, s_y);} + void rotate(float angle) FL_OVERRIDE {platform_surface_->rotate(angle);} + void translate(int x, int y) FL_OVERRIDE {platform_surface_->translate(x, y);} + void untranslate() FL_OVERRIDE {platform_surface_->untranslate();}; + int begin_page(void) FL_OVERRIDE {return platform_surface_->begin_page();} + int end_page(void) FL_OVERRIDE {return platform_surface_->end_page();} + void end_job(void) FL_OVERRIDE {return platform_surface_->end_job();} + /** Returns the name of the PDF document */ + inline const char *pdf_filename() { return *out_filename_; } + void set_current() FL_OVERRIDE { if (platform_surface_) platform_surface_->set_current(); } + bool is_current() FL_OVERRIDE { return surface() == platform_surface_; } +}; + +#endif // PDF_FILE_SURFACE_H diff --git a/include/linux/amd64/FL/Fl_PNG_Image.H b/include/linux/amd64/FL/Fl_PNG_Image.H new file mode 100644 index 0000000..41b9de5 --- /dev/null +++ b/include/linux/amd64/FL/Fl_PNG_Image.H @@ -0,0 +1,47 @@ +// +// PNG image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 color-mapped and full-color images and handles color- + and alpha-based transparency. +*/ +class FL_EXPORT Fl_PNG_Image : public Fl_RGB_Image { + friend class Fl_ICO_Image; +public: + + Fl_PNG_Image(const char* filename); + Fl_PNG_Image (const char *name_png, const unsigned char *buffer, int datasize); +private: + Fl_PNG_Image(const char *filename, int offset); // used by Fl_ICO_Image + void load_png_(const char *name_png, int offset, const unsigned char *buffer_png, int datasize); +}; + +// Support functions to write PNG image files (since 1.4.0) + +FL_EXPORT int fl_write_png(const char *filename, Fl_RGB_Image *img); +FL_EXPORT int fl_write_png(const char *filename, const char *pixels, int w, int h, int d=3, int ld=0); +FL_EXPORT int fl_write_png(const char *filename, const unsigned char *pixels, int w, int h, int d=3, int ld=0); + +#endif diff --git a/include/linux/amd64/FL/Fl_PNM_Image.H b/include/linux/amd64/FL/Fl_PNM_Image.H new file mode 100644 index 0000000..ff0b637 --- /dev/null +++ b/include/linux/amd64/FL/Fl_PNM_Image.H @@ -0,0 +1,37 @@ +// +// PNM image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 diff --git a/include/linux/amd64/FL/Fl_Pack.H b/include/linux/amd64/FL/Fl_Pack.H new file mode 100644 index 0000000..3da236b --- /dev/null +++ b/include/linux/amd64/FL/Fl_Pack.H @@ -0,0 +1,101 @@ +// +// Pack header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2020 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Pack widget . */ + +#ifndef Fl_Pack_H +#define Fl_Pack_H + +#include + +/** + This widget was designed to add the functionality of compressing and + aligning widgets. + + 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. + + You may want to put the Fl_Pack inside an Fl_Scroll. + + The \p 'resizable()' for Fl_Pack is set to NULL by default. Its behavior + is slightly different than in a normal Fl_Group widget: only if the + resizable() widget is the last widget in the group it is extended to take + the full available width or height, respectively, of the Fl_Pack group. + + \note You can nest Fl_Pack widgets or put them inside Fl_Scroll widgets + or inside other group widgets but their behavior can sometimes be + "surprising". This is partly due to the fact that Fl_Pack widgets + resize themselves during their draw() operation, trying to react on + their child widgets resizing themselves during \b their draw() operations + which can be confusing. If you want to achieve special resize behavior + of nested group widgets it can sometimes be easier to derive your own + specialized group widget than to try to make nested Fl_Pack widgets + behave as expected. + + \see 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() FL_OVERRIDE; + +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;} + + /** Returns non-zero if Fl_Pack alignment is horizontal. + + \returns non-zero if Fl_Pack alignment is horizontal (Fl_Pack::HORIZONTAL) + + \note Currently the return value is the same as Fl_Group::type(), but + this may change in the future. Do not set any other values than the + following with Fl_Pack::type(): + - Fl_Pack::VERTICAL (Default) + - Fl_Pack::HORIZONTAL + + See class Fl_Pack documentation for details. + */ + uchar horizontal() const {return type();} + + void resize(int X, int Y, int W, int H) FL_OVERRIDE; + /** Deletes all child widgets with Fl_Group::clear(). + And sets to NULL the resizable() widget. */ + void clear() { Fl_Group::clear(); resizable(NULL); } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Paged_Device.H b/include/linux/amd64/FL/Fl_Paged_Device.H new file mode 100644 index 0000000..59f84ce --- /dev/null +++ b/include/linux/amd64/FL/Fl_Paged_Device.H @@ -0,0 +1,126 @@ +// +// Printing support for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file Fl_Paged_Device.H + \brief declaration of class Fl_Paged_Device. + */ + +#ifndef Fl_Paged_Device_H +#define Fl_Paged_Device_H + +#include + + +/** \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_Widget_Surface { +protected: + /** \brief The constructor */ + Fl_Paged_Device() : Fl_Widget_Surface(NULL) {} +public: + /** + Possible page formats. + All paper formats with pre-defined width and height. The Fl_Paged_Device::page_formats array gives these widths and heights. + */ + enum Page_Format { + A0 = 0, /**< A0 format */ + A1, /**< A1 format */ + A2, /**< A2 format */ + A3, /**< A3 format */ + A4, /**< A4 format */ + A5, /**< A5 format */ + A6, /**< A6 format */ + A7, /**< A7 format */ + A8, /**< A8 format */ + A9, /**< A9 format */ + B0, /**< B0 format */ + B1, /**< B1 format */ + B2, /**< B2 format */ + B3, /**< B3 format */ + B4, /**< B4 format */ + B5, /**< B5 format */ + B6, /**< B6 format */ + B7, /**< B7 format */ + B8, /**< B8 format */ + B9, /**< B9 format */ + B10, /**< B10 format */ + C5E, + DLE, + EXECUTIVE, /**< Executive format */ + FOLIO, /**< Folio format */ + LEDGER, /**< Ledger format */ + LEGAL, /**< Legal format */ + LETTER, /**< Letter format */ + TABLOID, /**< Tabloid format */ + 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]; + /** \brief The destructor */ + virtual ~Fl_Paged_Device() {} + virtual int begin_job(int pagecount = 0, int *frompage = NULL, int *topage = NULL, char **perr_message = NULL); + /** Synonym of begin_job(int pagecount, int *frompage, int *topage, char **perr_message). + For API compatibility with FLTK 1.3.x */ + int start_job(int pagecount = 0, int *frompage = NULL, int *topage = NULL, char **perr_message = NULL) { + return begin_job(pagecount, frompage, topage, perr_message); + } + virtual int begin_page(void); + /** Synonym of begin_page(). + For API compatibility with FLTK 1.3.x */ + int start_page() {return begin_page();} + virtual void margins(int *left, int *top, int *right, int *bottom); + virtual void scale(float scale_x, float scale_y = 0.); + virtual void rotate(float angle); + /** Synonym of draw(Fl_Widget*, int, int) */ + void print_widget(Fl_Widget* widget, int delta_x = 0, int delta_y = 0) {draw(widget, delta_x, delta_y);} + /** Synonym of draw_decorated_window(Fl_Window*, int, int) */ + void print_window(Fl_Window *win, int x_off = 0, int y_off = 0) { + draw_decorated_window(win, x_off, y_off); + } + virtual int end_page (void); + virtual void end_job (void); +}; + +#endif // Fl_Paged_Device_H diff --git a/include/linux/amd64/FL/Fl_Pixmap.H b/include/linux/amd64/FL/Fl_Pixmap.H new file mode 100644 index 0000000..0efdb84 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Pixmap.H @@ -0,0 +1,79 @@ +// +// Pixmap header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2017 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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_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: + // for internal use + fl_uintptr_t id_; + fl_uintptr_t mask_; + int cache_w_, cache_h_; // size of pixmap when cached + +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(); + Fl_Image *copy(int W, int H) const FL_OVERRIDE; + Fl_Image *copy() const { return Fl_Image::copy(); } + void color_average(Fl_Color c, float i) FL_OVERRIDE; + void desaturate() FL_OVERRIDE; + void draw(int X, int Y, int W, int H, int cx=0, int cy=0) FL_OVERRIDE; + void draw(int X, int Y) {draw(X, Y, w(), h(), 0, 0);} + void label(Fl_Widget*w) FL_OVERRIDE; + void label(Fl_Menu_Item*m) FL_OVERRIDE; + void uncache() FL_OVERRIDE; + int cache_w() {return cache_w_;} + int cache_h() {return cache_h_;} +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Plugin.H b/include/linux/amd64/FL/Fl_Plugin.H new file mode 100644 index 0000000..6342c7e --- /dev/null +++ b/include/linux/amd64/FL/Fl_Plugin.H @@ -0,0 +1,89 @@ +// +// A Plugin system for FLTK, implemented in Fl_Preferences.cxx. +// +// Copyright 2002-2023 by Matthias Melcher. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 initialization 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; ido_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 *dirpath, const char *pattern=0); +}; + + +#endif // !Fl_Preferences_H diff --git a/include/linux/amd64/FL/Fl_Positioner.H b/include/linux/amd64/FL/Fl_Positioner.H new file mode 100644 index 0000000..ce1a798 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Positioner.H @@ -0,0 +1,88 @@ +// +// Positioner header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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(). + \image html positioner.png + \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() FL_OVERRIDE; + +public: + + int handle(int) FL_OVERRIDE; + /** + 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 diff --git a/include/linux/amd64/FL/Fl_PostScript.H b/include/linux/amd64/FL/Fl_PostScript.H new file mode 100644 index 0000000..b03a0a0 --- /dev/null +++ b/include/linux/amd64/FL/Fl_PostScript.H @@ -0,0 +1,214 @@ +// +// Support for graphics output to PostScript file for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010-2020 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file Fl_PostScript.H + \brief declaration of classes Fl_PostScript_File_Device and Fl_EPS_File_Surface. + */ + +#ifndef Fl_PostScript_H +#define Fl_PostScript_H + +#include +#include +#include + +/** Signature of functions FLTK may use to close FILE variables after PostScript/EPS output. + A non-null return value indicates output error. + \see Fl_PostScript_File_Device::close_command() and Fl_EPS_File_Surface::Fl_EPS_File_Surface(). + */ +extern "C" { + typedef int (*Fl_PostScript_Close_Command)(FILE *); +} + +class Fl_PostScript_Graphics_Driver; + +/** + To send graphical output to a PostScript file. + This class is used exactly as the Fl_Printer class except for the begin_job() call, + two variants of which are usable and allow to specify what page format and layout are desired. + +
    Processing of text: Text uses vectorial fonts under the X11 + Pango and the Wayland platforms. + With other platforms, only text restricted to the Latin alphabet (and a few other characters + listed in the table below) and to FLTK standard fonts is vectorized. All other unicode characters + or all other fonts (FL_FREE_FONT and above) are output as a bitmap. + FLTK standard fonts are output using the corresponding PostScript standard fonts. + The latin alphabet means all unicode characters between U+0020 and U+017F, or, in other words, + the ASCII, Latin-1 Supplement and Latin Extended-A charts. + \htmlonly + + + + + + + + + + + + + + + + +
    Extra characters supported by standard PostScript fonts
    CharCodepointName CharCodepointName CharCodepointName
    ƒU+0192florinU+201AquotesinglbaseU+2122trademark
    ˆU+02C6circumflexU+201CquotedblleftU+2202partialdiff
    ˇU+02C7caronU+201DquotedblrightΔU+2206Delta
    ˘U+02D8breveU+201EquotedblbaseU+2211summation
    ˙U+02D9dotaccentU+2020daggerU+221Aradical
    ˚U+02DAringU+2021daggerdblU+221Einfinity
    ˛U+02DBogonekU+2022bulletU+2260notequal
    ˜U+02DCtildeU+2026ellipsisU+2264lessequal
    ˝U+02DDhungarumlautU+2030perthousandU+2265greaterequal
    U+2013endashU+2039guilsinglleftU+25CAlozenge
    U+2014emdashU+203AguilsinglrightU+FB01fi
    U+2018quoteleft/U+2044fractionU+FB02fl
    U+2019quoterightU+20ACEuroU+F8FFapple (macOS only)
    + \endhtmlonly + + \image latex extraPSchars.png "Extra characters supported by standard PostScript fonts" width=16cm + + Processing of transparent Fl_RGB_Image objects: Under the X11 + Pango and the Wayland platforms, + these objects are output with their exact transparency. With other platforms, these objects + are drawn blended to white color. Class Fl_EPS_File_Surface 's constructor allows to set another + background color for blending. + + */ +class FL_EXPORT Fl_PostScript_File_Device : public Fl_Paged_Device { +private: + // memorize the display's current font to restore it when the object ceases being current + Fl_Font display_font_; + Fl_Fontsize display_size_; +protected: + /** + \brief Returns the PostScript driver of this drawing surface. + */ + inline Fl_PostScript_Graphics_Driver *driver() { return (Fl_PostScript_Graphics_Driver*)Fl_Surface_Device::driver(); } +public: + /** The constructor. */ + Fl_PostScript_File_Device(); + /** The destructor. */ + ~Fl_PostScript_File_Device(); + /** Don't use with this class. */ + int begin_job(int pagecount, int* from, int* to, char **perr_message) FL_OVERRIDE; + /** Begins the session where all graphics requests will go to a local PostScript file. + Opens a file dialog to select an output PostScript file. + This member function makes end_job() close the resulting PostScript file and display an + alert message with fl_alert() in case of any output error. + @param pagecount The total number of pages to be created. Use 0 if this number is unknown when this function is called. + @param format Desired page format. + @param layout Desired page layout. + @return 0 if OK, 1 if user cancelled the file dialog, 2 if fopen failed on user-selected output file. + */ + int begin_job(int pagecount = 0, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, + enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT); + /** Synonym of begin_job(). + For API compatibility with FLTK 1.3.x */ + int start_job(int pagecount = 0, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, + enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT) { + return begin_job(pagecount, format, layout); + } + /** Begins the session where all graphics requests will go to FILE pointer. + This member function prevents end_job() from closing \p ps_output, so the user can check with \p ferror(ps_output) + for output errors. + @param ps_output A writable FILE pointer that will receive PostScript output and that should not be closed + until after end_job() has been called. + @param pagecount The total number of pages to be created. Use 0 if this number is unknown when this function is called. + @param format Desired page format. + @param layout Desired page layout. + @return always 0. + */ + int begin_job(FILE *ps_output, int pagecount = 0, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, + enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT); + /** Synonym of begin_job(). + For API compatibility with FLTK 1.3.x */ + int start_job(FILE *ps_output, int pagecount = 0, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, + enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT) { + return begin_job(ps_output, pagecount, format, layout); + } + + int begin_page (void) FL_OVERRIDE; + int printable_rect(int *w, int *h) FL_OVERRIDE; + void margins(int *left, int *top, int *right, int *bottom) FL_OVERRIDE; + void origin(int *x, int *y) FL_OVERRIDE; + void origin(int x, int y) FL_OVERRIDE; + void scale (float scale_x, float scale_y = 0.) FL_OVERRIDE; + void rotate(float angle) FL_OVERRIDE; + void translate(int x, int y) FL_OVERRIDE; + void untranslate(void) FL_OVERRIDE; + int end_page (void) FL_OVERRIDE; + /** Completes all PostScript output. + This also closes with \p fclose() the underlying file() unless close_command() was used to set another function. + */ + void end_job(void) FL_OVERRIDE; + /** Label of the PostScript file chooser window */ + static const char *file_chooser_title; + /** Returns the underlying FILE* receiving all PostScript data */ + FILE *file(); + /** Sets the function end_job() calls to close the file() */ + void close_command(Fl_PostScript_Close_Command cmd); + void set_current() FL_OVERRIDE; + void end_current() FL_OVERRIDE; +}; + +/** Encapsulated PostScript drawing surface. + This drawing surface allows to store any FLTK graphics in vectorial form in an "Encapsulated PostScript" file. + \n Usage example: + \code + Fl_Window *win = ...// Window to draw to an .eps file + int ww = win->decorated_w(); + int wh = win->decorated_h(); + FILE *eps = fl_fopen("/path/to/mywindow.eps", "w"); + if (eps) { + Fl_EPS_File_Surface *surface = new Fl_EPS_File_Surface(ww, wh, eps, win->color()); + Fl_Surface_Device::push_current(surface); + surface->draw_decorated_window(win); + Fl_Surface_Device::pop_current(); + delete surface; // the .eps file is not complete until the destructor was run + } + \endcode + */ +class FL_EXPORT Fl_EPS_File_Surface : public Fl_Widget_Surface { +protected: + /** Returns the PostScript driver of this drawing surface. */ + inline Fl_PostScript_Graphics_Driver *driver() { return (Fl_PostScript_Graphics_Driver*)Fl_Surface_Device::driver(); } +public: + /** + Constructor. + \param width,height Width and height of the EPS drawing area + \param eps_output A writable FILE pointer where the Encapsulated PostScript data will be sent + \param background Color expected to cover the background of the EPS drawing area. + This parameter affects only the drawing of transparent Fl_RGB_Image objects: + transparent areas of RGB images are blended with the \p background color. + Under the X11 + pango platform, transparent RGB images are correctly blended to their background, + thus this parameter has no effect. + \param closef If not NULL, the destructor or close() will call \p closef(eps_output) after all + EPS data has been sent. If NULL, \p fclose(eps_output) is called instead. This allows to close the FILE + pointer by, e.g., \p pclose, or, using a function such as \p "int keep_open(FILE*){return 0;}", to keep it open after + completion of all output to \p eps_output. Function \p closef should return non zero to indicate an error. + */ + Fl_EPS_File_Surface(int width, int height, FILE *eps_output, + Fl_Color background = FL_WHITE, Fl_PostScript_Close_Command closef = NULL); + /** + Destructor. + By default, the destructor closes with function \p fclose() the underlying FILE. See the constructor for how + to close it differently or to keep it open. Use close() before object destruction to receive the status code + of output operations. If close() is not used and if EPS output results in error, the destructor displays an alert message + with fl_alert(). + */ + ~Fl_EPS_File_Surface(); + int printable_rect(int *w, int *h) FL_OVERRIDE; + /** Returns the underlying FILE pointer */ + FILE *file(); + void origin(int x, int y) FL_OVERRIDE; + void origin(int *px, int *py) FL_OVERRIDE; + void translate(int x, int y) FL_OVERRIDE; + void untranslate() FL_OVERRIDE; + /** Completes all EPS output. + The only operation possible with the Fl_EPS_File_Surface object after calling close() is its destruction. + \return The status code of output operations to the FILE object. 0 indicates success. */ + int close(); +}; + +#endif // Fl_PostScript_H diff --git a/include/linux/amd64/FL/Fl_Preferences.H b/include/linux/amd64/FL/Fl_Preferences.H new file mode 100644 index 0000000..6c6407a --- /dev/null +++ b/include/linux/amd64/FL/Fl_Preferences.H @@ -0,0 +1,408 @@ +// +// Preferences implementation for the Fast Light Tool Kit (FLTK). +// +// Copyright 2002-2023 by Matthias Melcher. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Preferences class . */ + +#ifndef Fl_Preferences_H +# define Fl_Preferences_H + +# include +# include "Fl_Export.H" +# include "fl_attr.h" + +//class Fl_String; +#if (FLTK_USE_STD) +#include +#endif + +/** + \brief Fl_Preferences store user settings between application starts. + + FLTK Preferences are similar to the Registry on Windows and Preferences on + MacOS, providing a simple method to store customizable user settings between + application launches. A typical use is storing the last window position or a + history of previously used documents. + + Preferences are organized in a hierarchy of groups. Every group can contain + more groups and any number of key/value pairs. Keys can be text strings + containing ASCII letters, digits, periods, and underscores. Forward slashes + in a key name are treated as subgroups, i.e. the key 'window/width' would + actually refer to the key 'width' inside the group 'window'. + + Keys have a unique name within their group. A value can be any string including + control characters 0x00 to 0x1f, 0x7f, and UTF-8 octets. + + Several methods allow setting and getting numerical values and binary data. + + Preferences files are the same across platforms. User comments in preference + files are preserved. Filenames are unique for each application by using a + vendor/application naming scheme. The developer app must provide default values + for all entries to ensure proper operation should preferences be corrupted + or not yet exist. + + \note The format of preferences files is not part of the FLTK specification + and intentionally undocumented. The only valid way to read or write prefs + files is via the API from your app. The fact that the current + implementation looks like human-readable text is purely coincidental and + may change at any time. Preferences files are not meant to be created + or edited "by hand." + + FLTK preferences are not meant to replace a fully featured database. No merging + of data takes place. If several instances of an app access the same database at + the same time, only the most recent changes will persist. + + Preferences should not be used to store document data. The .prefs 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 \a Fl_Preferences::get_userdata_path() . + + Fl_Preferences are not thread-safe. They can temporarily change the locale + on some platforms during read and write access, which also changes it + temporarily in other threads of the same app. + + Typically a preferences database is read at startup, and then reopened and + written at app shutdown: + ``` + int appWindowWidth, appWindowHeight; + + void launch() { + Fl_Preferences app(Fl_Preferences::USER_L, "matthiasm.com", "hello"); + // 'app' constructor will be called, reading data from .prefs file + Fl_Preferences window(app, "window"); + window.get("width", appWindowWidth, 800); + window.get("height", appWindowHeight, 600); + // 'app' destructor will be called. This will write data to the + // .prefs file if any preferences were changed or added + } + + void quit() { + Fl_Preferences app(Fl_Preferences::USER_L, "matthiasm.com", "hello"); + Fl_Preferences window(app, "window"); + window.set("width", appWindowWidth); + window.set("height", appWindowHeight); + } + ``` + + \see Fl_Preferences::Fl_Preferences(Root root, const char *vendor, const char *application) + + \see As a special case, Fl_Preferences can be memory mapped and not be associated + with a file on disk. See + Fl_Preferences::Fl_Preferences(Fl_Preferences *parent, const char *group) + and Fl_Preferences::MEMORY for more details on memory mapped preferences. + + \note Starting with FLTK 1.3, preferences databases are expected to + be in UTF-8 encoding. Previous databases were stored in the + current character set or code page which renders them incompatible + for text entries using international characters. + + \note Starting with FLTK 1.4, searching a valid path to store + the preference files has changed slightly. Please see + Fl_Preferences::Fl_Preferences(Root, const char*, const char*) + for details. + + \note Starting with FLTK 1.4, preference files should be created with + `SYSTEM_L` or `USER_L` to be interchangeable between computers with + differing locale settings. The legacy modes, `LOCAL` and `SYSTEM`, will + read and write floating point values using the decimal point of the + current locale. As a result, a fp-value would be written '3,1415' on a + German machine, and would be read back as '3.0' on a US machine because + the comma would not be recognized as an alternative decimal point. + */ +class FL_EXPORT Fl_Preferences { + +public: + /** + Define the scope of the preferences. + */ + enum Root { + UNKNOWN_ROOT_TYPE = -1, ///< Returned if storage could not be determined. + SYSTEM = 0, ///< Preferences are used system-wide. Deprecated, see SYSTEM_L + USER, ///< Preferences apply only to the current user. Deprecated, see USER_L + MEMORY, ///< Returned if querying memory mapped preferences + ROOT_MASK = 0x00FF, ///< Mask for the values above + CORE = 0x0100, ///< OR'd by FLTK to read and write core library preferences and options + C_LOCALE = 0x1000, ///< This flag should always be set to ensure that floating point values + ///< are written and read correctly independently of the current locale + CLEAR = 0x2000, ///< Don't read a possibly existing database. Instead, start with an empty set of preferences. + SYSTEM_L = SYSTEM | C_LOCALE, ///< Preferences are used system-wide, locale independent + USER_L = USER | C_LOCALE, ///< Preferences apply only to the current user, locale independent + CORE_SYSTEM_L = CORE | SYSTEM_L, ///< Same as CORE | SYSTEM | C_LOCALE + CORE_USER_L = CORE | USER_L, ///< Same as CORE | USER | C_LOCALE + CORE_SYSTEM = CORE | SYSTEM, ///< Deprecated, same as CORE | SYSTEM. Use CORE_SYSTEM_L instead. + CORE_USER = CORE | USER ///< Deprecated, same as CORE | USER. Use CORE_USER_L instead. + }; + + /** + Every Fl_Preferences-Group has a unique 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 *new_UUID(); + + /** Set this if no call to Fl_Preferences shall access the file system. + @see Fl_Preferences::file_access(unsigned int) + @see Fl_Preferences::file_access() + */ + static const unsigned int NONE = 0x0000; + /** Set this if it is OK for applications to read user preference files. */ + static const unsigned int USER_READ_OK = 0x0001; + /** Set this if it is OK for applications to create and write user preference files. */ + static const unsigned int USER_WRITE_OK = 0x0002; + /** Set this if it is OK for applications to read, create, and write user preference files. */ + static const unsigned int USER_OK = USER_READ_OK | USER_WRITE_OK; + /** Set this if it is OK for applications to read system wide preference files. */ + static const unsigned int SYSTEM_READ_OK = 0x0004; + /** Set this if it is OK for applications to create and write system wide preference files. */ + static const unsigned int SYSTEM_WRITE_OK = 0x0008; + /** Set this if it is OK for applications to read, create, and write system wide preference files. */ + static const unsigned int SYSTEM_OK = SYSTEM_READ_OK | SYSTEM_WRITE_OK; + /** Set this if it is OK for applications to read, create, and write any kind of preference files. */ + static const unsigned int APP_OK = SYSTEM_OK | USER_OK; + /** Set this if it is OK for FLTK to read preference files. USER_READ_OK and/or SYSTEM_READ_OK must also be set. */ + static const unsigned int CORE_READ_OK = 0x0010; + /** Set this if it is OK for FLTK to create or write preference files. USER_WRITE_OK and/or SYSTEM_WRITE_OK must also be set. */ + static const unsigned int CORE_WRITE_OK = 0x0020; + /** Set this if it is OK for FLTK to read, create, or write preference files. */ + static const unsigned int CORE_OK = CORE_READ_OK | CORE_WRITE_OK; + /** Set this to allow FLTK and applications to read preference files. */ + static const unsigned int ALL_READ_OK = USER_READ_OK | SYSTEM_READ_OK | CORE_READ_OK; + /** Set this to allow FLTK and applications to create and write preference files. */ + static const unsigned int ALL_WRITE_OK = USER_WRITE_OK | SYSTEM_WRITE_OK | CORE_WRITE_OK; + /** Set this to give FLTK and applications permission to read, write, and create preference files. */ + static const unsigned int ALL = ALL_READ_OK | ALL_WRITE_OK; + + static void file_access(unsigned int flags); + static unsigned int file_access(); + static Root filename( char *buffer, size_t buffer_size, Root root, const char *vendor, const char *application ); + + Fl_Preferences( Root root, const char *vendor, const char *application ); + Fl_Preferences( const char *path, const char *vendor, const char *application, Root flags ); + 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(); + + FL_DEPRECATED("since 1.4.0 - use Fl_Preferences(path, vendor, application, flags) instead", + Fl_Preferences( const char *path, const char *vendor, const char *application ) ); + + Root filename( char *buffer, size_t buffer_size); + + /** 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 full path to this entry. + */ + const char *path() { return node->path(); } + + int groups(); + const char *group( int num_group ); + char group_exists( const char *key ); + char delete_group( const char *group ); + char delete_all_groups(); + + int entries(); + const char *entry( int index ); + char entry_exists( const char *key ); + char delete_entry( const char *entry ); + char delete_all_entries(); + + 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 ); + char get( const char *entry, void *value, const void *defaultValue, int defaultSize, int *size ); + +// char set( const char *entry, const Fl_String &value ); +// char get( const char *entry, Fl_String &value, const Fl_String &defaultValue ); + +#if (FLTK_USE_STD) + char set( const char *entry, const std::string &value ); + char get( const char *entry, std::string &value, const std::string &defaultValue ); +#endif + + int size( const char *entry ); + + char get_userdata_path( char *path, int pathlen ); + + int flush(); + + int dirty(); + + /** \cond PRIVATE */ + static const char *newUUID() { return new_UUID(); } + char groupExists( const char *key ) { return group_exists(key); } + char deleteGroup( const char *group ) { return delete_group(group); } + char deleteAllGroups() { return delete_all_groups(); } + char entryExists( const char *key ) { return entry_exists(key); } + char deleteEntry( const char *entry ) { return delete_entry(entry); } + char deleteAllEntries() { return delete_all_entries(); } + char getUserdataPath( char *path, int pathlen ) { return get_userdata_path(path, pathlen); } + /** \endcond */ + + /** + '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. + + '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; + static unsigned int fileAccess_; + +public: // older Sun compilers need this (public definition of the following classes) + class RootNode; + + class FL_EXPORT Node { // a node contains a list to all its entries + // and all means to manage the tree structure + Node *first_child_, *next_; + union { // these two are mutually exclusive + Node *parent_; // top_ bit clear + RootNode *root_node_; // 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_node_ = r; top_ = 1; } + RootNode *findRoot(); + char remove(); + char dirty(); + void clearDirtyFlags(); + 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_; + Root root_type_; + public: + RootNode( Fl_Preferences *, Root root, const char *vendor, const char *application ); + RootNode( Fl_Preferences *, const char *path, const char *vendor, const char *application, Root flags ); + RootNode( Fl_Preferences * ); + ~RootNode(); + int read(); + int write(); + char getPath( char *path, int pathlen ); + char *filename() { return filename_; } + Root root() { return root_type_; } + }; + friend class RootNode; + +protected: + Node *node; + RootNode *rootNode; +}; + +#endif // !Fl_Preferences_H diff --git a/include/linux/amd64/FL/Fl_Printer.H b/include/linux/amd64/FL/Fl_Printer.H new file mode 100644 index 0000000..3efa5f7 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Printer.H @@ -0,0 +1,151 @@ +// +// Printing support for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010-2016 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file Fl_Printer.H + \brief declaration of class Fl_Printer. + */ + +#ifndef Fl_Printer_H +#define Fl_Printer_H + +#include + +/** + \brief OS-independent print support. + Fl_Printer allows to use all drawing, color, text, image, and clip FLTK functions, and to have them operate + on printed page(s). There are two main, non exclusive, ways to use it. +

    • 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(), + print_window() or print_window_part(). +
    • Use a series of FLTK graphics commands (e.g., font, text, lines, colors, clip, image) to + compose a page appropriately shaped for printing. +
    + In both cases, begin by begin_job(), begin_page(), printable_rect() and origin() calls + and finish by end_page() and end_job() calls. +

    Example of use: print a widget centered in a page + \code + #include + #include + int width, height; + Fl_Widget *widget = ... // a widget we want printed + Fl_Printer *printer = new Fl_Printer(); + if (printer->begin_job(1) == 0) { + printer->begin_page(); + printer->printable_rect(&width, &height); + fl_color(FL_BLACK); + fl_line_style(FL_SOLID, 2); + fl_rect(0, 0, width, height); + fl_font(FL_COURIER, 12); + time_t now; time(&now); fl_draw(ctime(&now), 0, fl_height()); + printer->origin(width/2, height/2); + printer->print_widget(widget, -widget->w()/2, -widget->h()/2); + printer->end_page(); + printer->end_job(); + } + delete printer; + \endcode +

    Recommended method to refresh GUI while printing : + \code + printer->begin_job(0); + …… + Fl_Surface_Device::push_current(Fl_Display_Device::display_device()); + Fl::check(); // or any operation that draws to display + Fl_Surface_Device::pop_current(); + …… + printer->end_job(); + \endcode + Platform specifics +

      +
    • X11 and Wayland platforms: +
      • FLTK expresses all graphics data using (Level 2) PostScript and sends that to the selected printer. + See class Fl_PostScript_File_Device for a description of how text and transparent images appear in print. +
      • If the GTK library is available at run-time, class Fl_Printer runs GTK's printer dialog which allows to set + printer, paper size and orientation. +
      • If the GTK library is not available, or if Fl::option(Fl::OPTION_PRINTER_USES_GTK) has been turned off, + class Fl_Printer runs FLTK's print dialog. +
          +
        • Unless it has been previously changed, the default paper size is A4. + To change that, press the "Properties" button of the "Print" dialog window + opened by an Fl_Printer::begin_job() call. This opens a "Printer Properties" window where it's + possible to select the adequate paper size. Finally press the "Save" button therein to assign + the chosen paper size to the chosen printer for this and all further print operations. +
        • 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. +
        +
      +
    • Windows platform: Transparent Fl_RGB_Image 's don't print with exact transparency on most printers + (a workaround is to use print_window_part() ). + Fl_RGB_Image 's don't rotate() well. +
    • Mac OS X platform: all graphics requests print as on display and accept rotation and scaling. +
    + */ +class FL_EXPORT Fl_Printer : public Fl_Paged_Device { +private: + Fl_Paged_Device *printer; + /** Each platform implements this function its own way */ + static Fl_Paged_Device* newPrinterDriver(void); +public: + /** The constructor */ + Fl_Printer(void); + int begin_job(int pagecount = 0, int *frompage = NULL, int *topage = NULL, char **perr_message = NULL) FL_OVERRIDE; + int begin_page(void) FL_OVERRIDE; + int printable_rect(int *w, int *h) FL_OVERRIDE; + void margins(int *left, int *top, int *right, int *bottom) FL_OVERRIDE; + void origin(int *x, int *y) FL_OVERRIDE; + void origin(int x, int y) FL_OVERRIDE; + void scale(float scale_x, float scale_y = 0.) FL_OVERRIDE; + void rotate(float angle) FL_OVERRIDE; + void translate(int x, int y) FL_OVERRIDE; + void untranslate(void) FL_OVERRIDE; + int end_page (void) FL_OVERRIDE; + void end_job (void) FL_OVERRIDE; + void set_current(void) FL_OVERRIDE; + bool is_current() FL_OVERRIDE; + + /** \name These attributes are useful for the Linux/Unix 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; + /** \} */ + /** The destructor */ + ~Fl_Printer(void); +}; + +#endif // Fl_Printer_H diff --git a/include/linux/amd64/FL/Fl_Progress.H b/include/linux/amd64/FL/Fl_Progress.H new file mode 100644 index 0000000..81c4f82 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Progress.H @@ -0,0 +1,66 @@ +// +// Progress bar widget definitions. +// +// Copyright 2000-2010 by Michael Sweet. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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: + + void draw() FL_OVERRIDE; + + 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_ diff --git a/include/linux/amd64/FL/Fl_RGB_Image.H b/include/linux/amd64/FL/Fl_RGB_Image.H new file mode 100644 index 0000000..1584c2f --- /dev/null +++ b/include/linux/amd64/FL/Fl_RGB_Image.H @@ -0,0 +1,20 @@ +// +// RGB Image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_RGB_Image_H +# define Fl_RGB_Image_H +# include "Fl_Image.H" +#endif // !Fl_RGB_Image_H diff --git a/include/linux/amd64/FL/Fl_Radio_Button.H b/include/linux/amd64/FL/Fl_Radio_Button.H new file mode 100644 index 0000000..9cfc316 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Radio_Button.H @@ -0,0 +1,30 @@ +// +// Radio button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2014 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Radio_Light_Button.H b/include/linux/amd64/FL/Fl_Radio_Light_Button.H new file mode 100644 index 0000000..0877377 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Radio_Light_Button.H @@ -0,0 +1,30 @@ +// +// Radio light button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2014 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Radio_Round_Button.H b/include/linux/amd64/FL/Fl_Radio_Round_Button.H new file mode 100644 index 0000000..ab0dc55 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Radio_Round_Button.H @@ -0,0 +1,30 @@ +// +// Radio round button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2014 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Rect.H b/include/linux/amd64/FL/Fl_Rect.H new file mode 100644 index 0000000..386deb4 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Rect.H @@ -0,0 +1,159 @@ +// +// Fl_Rect header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Rect_H +#define Fl_Rect_H + +#include // for c'tor based on Fl_Widget + +/** + Rectangle with standard FLTK coordinates (X, Y, W, H). + + This may be used internally, for overloaded widget constructors and other + overloaded methods like fl_measure(), fl_text_extents(), fl_rect(), + fl_rectf(), and maybe more. +*/ + +class FL_EXPORT Fl_Rect { + + int x_; + int y_; + int w_; + int h_; + +public: + + /** The default constructor creates an empty rectangle (x = y = w = h = 0). */ + Fl_Rect() + : x_(0), y_(0), w_(0), h_(0) {} + + /** This constructor creates a rectangle with x = y = 0 and + the given width and height. */ + Fl_Rect(int W, int H) + : x_(0), y_(0), w_(W), h_(H) {} + + /** This constructor creates a rectangle with the given x,y coordinates + and the given width and height. */ + Fl_Rect(int X, int Y, int W, int H) + : x_(X), y_(Y), w_(W), h_(H) {} + + /** This constructor creates a rectangle with the given x,y coordinates + and the given width and height reduced by the box frame size. + + This is the same as using the constructor w/o \p bt and subsequently + calling inset(\p bt). + */ + Fl_Rect(int X, int Y, int W, int H, Fl_Boxtype bt) + : x_(X), y_(Y), w_(W), h_(H) { + inset(bt); + } + + /** This constructor creates a rectangle based on a widget's position and size. */ + Fl_Rect (const Fl_Widget& widget) + : x_(widget.x()), y_(widget.y()), w_(widget.w()), h_(widget.h()) {} + + /** This constructor creates a rectangle based on a widget's position and size. */ + Fl_Rect (const Fl_Widget* const widget) + : x_(widget->x()), y_(widget->y()), w_(widget->w()), h_(widget->h()) {} + + int x() const { return x_; } ///< gets the x coordinate (left edge) + int y() const { return y_; } ///< gets the y coordinate (top edge) + int w() const { return w_; } ///< gets the width + int h() const { return h_; } ///< gets the height + + /** gets the right edge (x + w). + \note r() and b() are coordinates \b outside the area of the rectangle. + */ + int r() const { return x_ + w_; } + /** gets the bottom edge (y + h). + \note r() and b() are coordinates \b outside the area of the rectangle. + */ + int b() const { return y_ + h_; } + + void x(int X) { x_ = X; } ///< sets the x coordinate (left edge) + void y(int Y) { y_ = Y; } ///< sets the y coordinate (top edge) + void w(int W) { w_ = W; } ///< sets the width + void h(int H) { h_ = H; } ///< sets the height + + void r(int R) { w_ = R - x_; } ///< sets the width based on R and x + void b(int B) { h_ = B - y_; } ///< sets the height based on B and y + + /** Move all edges in by \p d. + + Shrinks the rectangle by \p d at all sides keeping the center of the + rectangle at the same spot. + + If \p d is negative, the rectangle is enlarged. + + If \p d \>= w() or h() the result is undefined, i.e. an + invalid or empty rectangle. + */ + void inset(int d) { + x_ += d; + y_ += d; + w_ -= 2 * d; + h_ -= 2 * d; + } + + /** Move all edges in by the frame size of box type \p bt. + + Shrinks the rectangle at all sides by the frame width or height of the + given box type \p bt. + + This method uses the frame sizes given by the box type \p bt using + - Fl::box_dx(bt) + - Fl::box_dy(bt) + - Fl::box_dw(bt) + - Fl::box_dh(bt) + + If the rectangle is smaller than the frame sizes the result is undefined, + i.e. an invalid or empty rectangle. + */ + void inset(Fl_Boxtype bt) { + x_ += Fl::box_dx(bt); + y_ += Fl::box_dy(bt); + w_ -= Fl::box_dw(bt); + h_ -= Fl::box_dh(bt); + } + + /** Move all edges in by \p left, \p top, \p right, \p bottom. + + Shrinks the rectangle on all sides keeping the center of the + rectangle at the same spot. + + If any value is negative, the rectangle is enlarged. + + Values are not range checked; it is possible to create + an invalid or empty rectangle. + */ + void inset(int left, int top, int right, int bottom) { + x_ += left; + y_ += top; + w_ -= (left + right); + h_ -= (top + bottom); + } + + friend bool operator==(const Fl_Rect& lhs, const Fl_Rect& rhs) { + return (lhs.x_==rhs.x_) && (lhs.y_==rhs.y_) && (lhs.w_==rhs.w_) && (lhs.h_==rhs.h_); + } + + friend bool operator!=(const Fl_Rect& lhs, const Fl_Rect& rhs) { + return !(lhs==rhs); + } + +}; // class Fl_Rect + +#endif // Fl_Rect_H diff --git a/include/linux/amd64/FL/Fl_Repeat_Button.H b/include/linux/amd64/FL/Fl_Repeat_Button.H new file mode 100644 index 0000000..f80008e --- /dev/null +++ b/include/linux/amd64/FL/Fl_Repeat_Button.H @@ -0,0 +1,48 @@ +// +// Repeat button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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) FL_OVERRIDE; + /** + 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); + + void deactivate() { + Fl::remove_timeout(repeat_callback,this); + Fl_Button::deactivate(); + } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Return_Button.H b/include/linux/amd64/FL/Fl_Return_Button.H new file mode 100644 index 0000000..81ce478 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Return_Button.H @@ -0,0 +1,44 @@ +// +// Return button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + \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() FL_OVERRIDE; +public: + int handle(int) FL_OVERRIDE; + /** + Creates a new Fl_Return_Button widget using the given + position, size, and label string. The default boxtype is FL_UP_BOX. +

    The inherited destructor deletes the button. + */ + Fl_Return_Button(int X, int Y, int W, int H,const char *l=0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Roller.H b/include/linux/amd64/FL/Fl_Roller.H new file mode 100644 index 0000000..dc9aa43 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Roller.H @@ -0,0 +1,46 @@ +// +// Roller header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + The roller can be controlled by clicking and dragging the mouse, by the + corresponding arrow keys when the roller has the keyboard focus, or by the + mouse wheels when the mouse pointer is positioned over the roller widget. + + \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() FL_OVERRIDE; +public: + int handle(int) FL_OVERRIDE; + Fl_Roller(int X,int Y,int W,int H,const char* L=0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Round_Button.H b/include/linux/amd64/FL/Fl_Round_Button.H new file mode 100644 index 0000000..4994f56 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Round_Button.H @@ -0,0 +1,39 @@ +// +// Round button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#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(). + \image html Fl_Round_Button.png + \image latex Fl_Round_Button.png "Fl_Round_Button" width=4cm + The Fl_Round_Button 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_ROUND_DOWN_BOX. The color of the light + when on is controlled with selection_color(), which defaults to + FL_FOREGROUND_COLOR. +*/ +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 diff --git a/include/linux/amd64/FL/Fl_Round_Clock.H b/include/linux/amd64/FL/Fl_Round_Clock.H new file mode 100644 index 0000000..5d9bf90 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Round_Clock.H @@ -0,0 +1,32 @@ +// +// Round clock header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_SVG_File_Surface.H b/include/linux/amd64/FL/Fl_SVG_File_Surface.H new file mode 100644 index 0000000..2a8061e --- /dev/null +++ b/include/linux/amd64/FL/Fl_SVG_File_Surface.H @@ -0,0 +1,80 @@ +// +// Declaration of Fl_SVG_File_Surface in the Fast Light Tool Kit (FLTK). +// +// Copyright 2020 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_SVG_File_Surface_H +#define Fl_SVG_File_Surface_H + +#include +#include + +/** A drawing surface producing a Scalable Vector Graphics (SVG) file. + This drawing surface allows to store any FLTK graphics in vectorial form in a "Scalable Vector Graphics" file. + \n Usage example: + \code + Fl_Window *win = ...// Window to draw to a .svg file + int ww = win->decorated_w(); + int wh = win->decorated_h(); + FILE *svg = fl_fopen("/path/to/mywindow.svg", "w"); + if (svg) { + Fl_SVG_File_Surface *surface = new Fl_SVG_File_Surface(ww, wh, svg); + Fl_Surface_Device::push_current(surface); + fl_color(FL_WHITE); + fl_rectf(0, 0, ww, wh); + surface->draw_decorated_window(win); + Fl_Surface_Device::pop_current(); + delete surface; // the .svg file is not complete until the destructor was run + fclose(svg); + } + \endcode + \note FLTK uses the PNG and JPEG libraries to encode images to the SVG format. + For this reason, class Fl_SVG_File_Surface is placed in the fltk_images library. + If JPEG is not available at application build time, PNG is enough (but produces a quite larger output). + If PNG isn't available either, images don't appear in the SVG output. +*/ +class FL_EXPORT Fl_SVG_File_Surface : public Fl_Widget_Surface { + int width_, height_; + int (*closef_)(FILE*); +public: + /** + Constructor of the SVG drawing surface. + \param width,height Width and height of the graphics area in FLTK drawing units + \param svg A writable FILE pointer where the SVG data are to be sent. The resulting SVG data are not complete until after destruction of the Fl_SVG_File_Surface object or after calling close(). + \param closef If not NULL, the destructor and close() will call \p closef(svg) after all + SVG data has been sent. If NULL, \p fclose(svg) is called instead. This allows to close the FILE + pointer by, e.g., \p pclose, or, using a function such as \p "int keep_open(FILE*){return 0;}", to keep it open after + completion of all output to \p svg. Function \p closef should return non zero to indicate an error. + */ + Fl_SVG_File_Surface(int width, int height, FILE *svg, int (*closef)(FILE*) = NULL); + /** + Destructor. + The underlying FILE pointer is processed as by close(). + */ + ~Fl_SVG_File_Surface(); + /** Returns the underlying FILE pointer */ + FILE *file(); + void origin(int x, int y) FL_OVERRIDE; + void origin(int *x, int *y) FL_OVERRIDE; + void translate(int x, int y) FL_OVERRIDE; + void untranslate() FL_OVERRIDE; + int printable_rect(int *w, int *h) FL_OVERRIDE; + /** Closes the FILE pointer where SVG data is output. + The underlying FILE is closed by function fclose() unless another function was set at object's construction time. + The only operation possible after this on the Fl_SVG_File_Surface object is its destruction. + \return The value returned by the closing function call. */ + int close(); +}; + +#endif /* Fl_SVG_File_Surface_H */ diff --git a/include/linux/amd64/FL/Fl_SVG_Image.H b/include/linux/amd64/FL/Fl_SVG_Image.H new file mode 100644 index 0000000..6d9f777 --- /dev/null +++ b/include/linux/amd64/FL/Fl_SVG_Image.H @@ -0,0 +1,173 @@ +// +// SVG Image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 2017-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_SVG_IMAGE_H +#define FL_SVG_IMAGE_H + +#include + +struct NSVGimage; + +/** The Fl_SVG_Image class supports loading, caching and drawing of scalable vector graphics (SVG) images. + The FLTK library performs parsing and rasterization of SVG data using a modified version + of the \c nanosvg software (https://github.com/memononen/nanosvg). + The software modification allows the option to change the image ratio + while performing rasterization. + + Use Fl_Image::fail() to check if the Fl_SVG_Image failed to load. fail() returns ERR_FILE_ACCESS + if the file could not be opened or read, and ERR_FORMAT if the SVG format could not be decoded. + If the image has loaded correctly, w(), h(), and d() should return values greater than zero. + + Rasterization is not done until the image is first drawn or resize() or normalize() is called. Therefore, + \ref array is NULL until then. The delayed rasterization ensures an Fl_SVG_Image is always rasterized + to the exact screen resolution at which it is drawn. + + The Fl_SVG_Image class draws images computed by \c nanosvg with the following known limitations + + - text between \c and marks, + - \c image elements, and + - statements + + are not rendered. + + The FLTK library can optionally be built without SVG support; in that case, + class Fl_SVG_Image is unavailable. + + Example of displaying a hard-coded svg file: + \code + #include + #include + #include + #include + + // A black rotated rectangle + const char *svg_data = "\n" + " \n"; + + int main(int argc, char **argv) { + Fl_SVG_Image *svg = new Fl_SVG_Image(0, svg_data); // create SVG object + Fl_Window *win = new Fl_Window(720, 486, "svg test"); + Fl_Box *box = new Fl_Box(0, 0, win->w(), win->h()); + box->image(svg); // assign svg object to Fl_Box + win->end(); + win->show(argc,argv); + return(Fl::run()); + } + \endcode + + Example of displaying an svg image from a file: + \code + #include // errno + #include // strerror + #include + #include + #include + #include + #include + int main(int argc, char **argv) { + Fl_Window *win = new Fl_Window(720, 486, "svg test"); + Fl_Box *box = new Fl_Box(0, 0, win->w(), win->h()); + + // Load svg image from disk, assign to a box + const char *svgpath = "/var/tmp/simple.svg"; + Fl_SVG_Image *svg = new Fl_SVG_Image(svgpath); // load SVG object from disk + switch (svg->fail()) { + case Fl_Image::ERR_FILE_ACCESS: + // File couldn't load? show path + os error to user + fl_alert("%s: %s", svgpath, strerror(errno)); + return 1; + case Fl_Image::ERR_FORMAT: + // Parsing error + fl_alert("%s: couldn't decode image", svgpath); + return 1; + } + box->image(svg); // assign svg object to box + + win->end(); + win->show(argc,argv); + return(Fl::run()); + } + \endcode + + Example of fitting an svg image to a resizable Fl_Box: + \code + #include + #include + #include + + class resizable_box : public Fl_Box { + public: + resizable_box(int w, int h) : Fl_Box(0, 0, w, h, NULL) {} + virtual void resize(int x, int y, int w, int h) { + image()->scale(w, h, 1, 1); // p3 = proportional, p4 = can_expand + Fl_Box::resize(x, y, w, h); + } + }; + + int main(int argc, char **argv) { + Fl_Window *win = new Fl_Window(130, 130); + resizable_box *box = new resizable_box(win->w(), win->h()); + Fl_SVG_Image *svg = new Fl_SVG_Image("/path/to/image.svg"); + box->image(svg); + svg->scale(box->w(), box->h()); + win->end(); + win->resizable(win); + win->show(argc, argv); + return Fl::run(); + } + \endcode + + */ +class FL_EXPORT Fl_SVG_Image : public Fl_RGB_Image { +private: + typedef struct { + NSVGimage* svg_image; + int ref_count; + } counted_NSVGimage; + counted_NSVGimage* counted_svg_image_; + bool rasterized_; + int raster_w_, raster_h_; + bool to_desaturate_; + Fl_Color average_color_; + float average_weight_; + float svg_scaling_(int W, int H); + void rasterize_(int W, int H); + void cache_size_(int &width, int &height) FL_OVERRIDE; + void init_(const char *name, const unsigned char *filedata, size_t length); + Fl_SVG_Image(const Fl_SVG_Image *source); +public: + /** Set this to \c false to allow image re-scaling that alters the image aspect ratio. + Upon object creation, proportional is set to \c true, and the aspect ratio is kept constant.*/ + bool proportional; + Fl_SVG_Image(const char *filename); + Fl_SVG_Image(const char *sharedname, const char *svg_data); + Fl_SVG_Image(const char *sharedname, const unsigned char *svg_data, size_t length); + virtual ~Fl_SVG_Image(); + Fl_Image *copy(int W, int H) const FL_OVERRIDE; + Fl_Image *copy() const { + return Fl_Image::copy(); + } + void resize(int width, int height); + void desaturate() FL_OVERRIDE; + void color_average(Fl_Color c, float i) FL_OVERRIDE; + void draw(int X, int Y, int W, int H, int cx = 0, int cy = 0) FL_OVERRIDE; + void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); } + Fl_SVG_Image *as_svg_image() FL_OVERRIDE { return this; } + void normalize() FL_OVERRIDE; +}; + +#endif // FL_SVG_IMAGE_H diff --git a/include/linux/amd64/FL/Fl_Scheme.H b/include/linux/amd64/FL/Fl_Scheme.H new file mode 100644 index 0000000..9a0f3cb --- /dev/null +++ b/include/linux/amd64/FL/Fl_Scheme.H @@ -0,0 +1,64 @@ +// +// Scheme header for the Fast Light Tool Kit (FLTK). +// +// Copyright 2022-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_Fl_Scheme_H_ +#define FL_Fl_Scheme_H_ + +#include + +class Fl_Scheme { + +private: + + static const char **names_; // registered scheme names + static int num_schemes_; // number of registered schemes + static int alloc_size_; // number of allocated scheme name entries + +protected: + + // const char *name_; // the scheme's name + + // protected constructor - not yet implemented + // Fl_Scheme(const char *name); + +public: + + // Static methods. + + // Some of these methods will replace the scheme related methods of class Fl, + // for instance Fl::scheme() and Fl::is_scheme(). + // Backwards compatibility must be kept though. + + static const char **names(); + + /** + Return the number of currently registered schemes. + + \return Number of registered schemes. + */ + static int num_schemes() { + if (!names_) names(); // force initialization + return num_schemes_; + } + + // Adding a scheme name must be a public static method in FLTK 1.4.0. + // This will later be protected or replaced by another method name. + + static int add_scheme_name(const char *name); + +}; // class Fl_Scheme + +#endif // FL_Fl_Scheme_H_ diff --git a/include/linux/amd64/FL/Fl_Scheme_Choice.H b/include/linux/amd64/FL/Fl_Scheme_Choice.H new file mode 100644 index 0000000..336d43f --- /dev/null +++ b/include/linux/amd64/FL/Fl_Scheme_Choice.H @@ -0,0 +1,38 @@ +// +// Scheme Choice header for the Fast Light Tool Kit (FLTK). +// +// Copyright 2022-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_Fl_Scheme_Choice_H_ +#define FL_Fl_Scheme_Choice_H_ + +#include +#include +#include + +class FL_EXPORT Fl_Scheme_Choice : public Fl_Choice { + +protected: + static void scheme_cb_(Fl_Widget *w, void *); + +public: + Fl_Scheme_Choice(int X, int Y, int W, int H, const char *L = 0); + int handle(int event) FL_OVERRIDE; + + // set the current value according to the active scheme + virtual void init_value(); + +}; // class Fl_Scheme_Choice + +#endif // FL_Fl_Scheme_Choice_H_ diff --git a/include/linux/amd64/FL/Fl_Scroll.H b/include/linux/amd64/FL/Fl_Scroll.H new file mode 100644 index 0000000..0331c83 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Scroll.H @@ -0,0 +1,223 @@ +// +// Fl_Scroll header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + The Fl_Scroll widget calculates the bounding box of all its children + by using their widget positions and sizes (x, y, w, h). Outside labels + are not considered. If you need outside labels of any widgets or free + space outside of this bounding box you can add a tiny invisible Fl_Box + at the relevant corner(s) of the Fl_Scroll widget, for instance: + \code + Fl_Scroll scroll(100, 100, 200, 200); // Fl_Scroll at (100, 100) + Fl_Box(100, 100, 1, 1); // Fl_Box in top left corner + Fl_Input(150, 120, 60, 30, "Input:"); // left most widget with label + // ... more widgets ... + scroll.end(); + \endcode + + 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 : + + - 0 - No scrollbars + - Fl_Scroll::HORIZONTAL - Only a horizontal scrollbar. + - Fl_Scroll::VERTICAL - Only a vertical scrollbar. + - Fl_Scroll::BOTH - The default is both scrollbars. + - Fl_Scroll::HORIZONTAL_ALWAYS - Horizontal scrollbar always on, vertical always off. + - Fl_Scroll::VERTICAL_ALWAYS - Vertical scrollbar always on, horizontal always off. + - Fl_Scroll::BOTH_ALWAYS - Both always on. + + Use scrollbar.align(int) ( see void Fl_Widget::align(Fl_Align) ) : + 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_not_clipped(int x,int y,int w,int h) + to find out if a particular area of the widget must be drawn. + + 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. + + 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. +*/ +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*); + static void draw_clip(void*,int,int,int,int); + +protected: // (STR#1895) + + /// A local struct to manage a region defined by xywh + typedef struct { int x,y,w,h; } Fl_Region_XYWH; + + /// A local struct to manage a region defined by left/right/top/bottom + typedef struct { + int l; ///< (l)eft "x" position, aka x1 + int r; ///< (r)ight "x" position, aka x2 + int t; ///< (t)op "y" position, aka y1 + int b; ///< (b)ottom "y" position, aka y2 + } Fl_Region_LRTB; + + /// A local struct to manage a scrollbar's xywh region and tab values + typedef struct { + int x,y,w,h; + int pos; ///< scrollbar tab's "position of first line displayed" + int size; ///< scrollbar tab's "size of window in lines" + int first; ///< scrollbar tab's "number of first line" + int total; ///< scrollbar tab's "total number of lines" + } Fl_Scrollbar_Data; + + /** + Structure to manage scrollbar and widget interior sizes. + This is filled out by recalc_scrollbars() for use in calculations + that need to know the visible scroll area size, etc. + \version 1.3.3 + */ + typedef struct { + int scrollsize; ///< the effective scrollbar thickness (local or global) + Fl_Region_XYWH innerbox; ///< widget's inner box, excluding scrollbars + Fl_Region_XYWH innerchild; ///< widget's inner box, including scrollbars + Fl_Region_LRTB child; ///< child bounding box: left/right/top/bottom + int hneeded; ///< horizontal scrollbar visibility + int vneeded; ///< vertical scrollbar visibility + Fl_Scrollbar_Data hscroll; ///< horizontal scrollbar region + values + Fl_Scrollbar_Data vscroll; ///< vertical scrollbar region + values + } ScrollInfo; + void recalc_scrollbars(ScrollInfo &si) const; + +protected: + + int on_insert(Fl_Widget*, int) FL_OVERRIDE; + int on_move(int, int) FL_OVERRIDE; + void fix_scrollbar_order(); + void bbox(int&,int&,int&,int&) const; + void draw() FL_OVERRIDE; + +public: + + Fl_Scrollbar scrollbar; + Fl_Scrollbar hscrollbar; + + void resize(int X, int Y, int W, int H) FL_OVERRIDE; + int handle(int) FL_OVERRIDE; + + Fl_Scroll(int X, int Y, int W, int H, const char *L = 0); + virtual ~Fl_Scroll(); + + 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(); + + /* delete child n (by index) */ + int delete_child(int n) FL_OVERRIDE; + + /** + 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 \p newSize, 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 newSize to the special value of 0 causes the widget to + track the global Fl::scrollbar_size(), which is the default. + + \param[in] newSize 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 newSize) { + if ( newSize != scrollbar_size_ ) redraw(); + scrollbar_size_ = newSize; + } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Scrollbar.H b/include/linux/amd64/FL/Fl_Scrollbar.H new file mode 100644 index 0000000..8e7a45e --- /dev/null +++ b/include/linux/amd64/FL/Fl_Scrollbar.H @@ -0,0 +1,105 @@ +// +// Scroll bar header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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() FL_OVERRIDE; + +public: + + Fl_Scrollbar(int X,int Y,int W,int H, const char *L = 0); + ~Fl_Scrollbar(); + int handle(int) FL_OVERRIDE; + + /** + 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] windowSize number of lines displayed + \param[in] first_line number of first line + \param[in] total_lines 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 windowSize, int first_line, int total_lines) { + return scrollvalue(pos, windowSize, first_line, total_lines); + } + + /** + 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 diff --git a/include/linux/amd64/FL/Fl_Secret_Input.H b/include/linux/amd64/FL/Fl_Secret_Input.H new file mode 100644 index 0000000..bd4ca30 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Secret_Input.H @@ -0,0 +1,45 @@ +// +// Secret input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + */ + Fl_Secret_Input(int X,int Y,int W,int H,const char *l = 0); + int handle(int) FL_OVERRIDE; +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Select_Browser.H b/include/linux/amd64/FL/Fl_Select_Browser.H new file mode 100644 index 0000000..b4651a0 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Select_Browser.H @@ -0,0 +1,44 @@ +// +// Select browser header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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(). +

    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. + */ + Fl_Select_Browser(int X,int Y,int W,int H,const char *L=0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Shared_Image.H b/include/linux/amd64/FL/Fl_Shared_Image.H new file mode 100644 index 0000000..fec7700 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Shared_Image.H @@ -0,0 +1,206 @@ +// +// Shared image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file + Fl_Shared_Image class. */ + +#ifndef Fl_Shared_Image_H +# define Fl_Shared_Image_H + +# include "Fl_Image.H" + +#undef SHIM_DEBUG + +/** Test function (typedef) for adding new shared image formats. + + This defines the function type you can use to add a handler for unknown + image formats that can be opened and loaded as an Fl_Shared_Image. + + fl_register_images() adds all image formats known to FLTK. + Call Fl_Shared_Image::add_handler() to add your own check function to + the list of known image formats. + + Your function will be passed the filename (\p name), some \p header + bytes already read from the image file and the size \p headerlen of the + data read. The max value of size is implementation dependent. If your + handler function needs to check more bytes you must open the image file + yourself. + + The provided buffer \p header must not be overwritten. + + If your handler function can identify the file type you must open the + file and return a valid Fl_Image or derived type, otherwise you must + return \c NULL. + Example: + \code + static Fl_Image *check_my_image(const char *name, + uchar *header, + int headerlen) { + // (test image type using header and headerlen) + if (known) { + // (load image data from file \p name) + return new Fl_RGB_Image(data, ...); + } else + return 0; + } + // add your handler: + Fl_Shared_Image::add_handler(check_my_image); + \endcode + + \param[in] name filename to be checked and opened if applicable + \param[in] header portion of the file that has already been read + \param[in] headerlen length of provided \p header data + + \returns valid Fl_Image or \c NULL. + + \see Fl_Shared_Image::add_handler() +*/ +typedef Fl_Image *(*Fl_Shared_Handler)(const char *name, + uchar *header, + int headerlen); + +/** + 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, PNG, and SVG (unless the library was built + with the option removing SVG support). + + Images can be requested (loaded) with Fl_Shared_Image::get(), find(), + and some other methods. All images are cached in an internal list of + shared images and should be released when they are no longer needed. + A refcount is used to determine if a released image is to be destroyed + with delete. + + \see fl_register_image() + \see Fl_Shared_Image::get() + \see Fl_Shared_Image::find() + \see Fl_Shared_Image::release() +*/ +class FL_EXPORT Fl_Shared_Image : public Fl_Image { + + friend class Fl_JPEG_Image; + friend class Fl_PNG_Image; + friend class Fl_SVG_Image; + friend class Fl_Graphics_Driver; + +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(); + Fl_Shared_Image *copy_(int W, int H) const; + +public: +#ifdef SHIM_DEBUG + static void print_pool(); +#endif + + /** 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_; } + + /** Returns whether this is an original image. + Images loaded from a file or from memory are marked \p original as + opposed to images created as a copy of another image with different + size (width or height). + \note This is useful for debugging (rarely used in user code). + \since FLTK 1.4.0 + */ + int original() { return original_; } + + void release() FL_OVERRIDE; + virtual void reload(); + + Fl_Shared_Image *as_shared_image() FL_OVERRIDE { + return this; + } + + Fl_Image *copy(int W, int H) const FL_OVERRIDE; + Fl_Image *copy() const; + Fl_Image *copy(); + + void color_average(Fl_Color c, float i) FL_OVERRIDE; + void desaturate() FL_OVERRIDE; + void draw(int X, int Y, int W, int H, int cx = 0, int cy = 0) FL_OVERRIDE; + void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); } + void uncache() FL_OVERRIDE; + + static Fl_Shared_Image *find(const char *name, int W = 0, int H = 0); + static Fl_Shared_Image *get(const char *name, int W = 0, int H = 0); + static Fl_Shared_Image *get(Fl_RGB_Image *rgb, int own_it = 1); + 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); + + /** + Returns a pointer to the internal Fl_Image object. + + The output is a pointer to the \p internal image ('Fl_Image' or subclass) + which can be used to inspect or copy the image. + + Do not try to modify the image! You can copy the image though + if you want or need to change any attributes, size etc. If all you + need to do is to resize the image you should use + Fl_Shared_Image::copy(int, int) instead. + + \note The internal image (pointer) is protected for good reasons, e.g. + to prevent access to the image so it can't be modified by user code. + \b DO \b NOT cast away the 'const' attribute to modify the image. + + User code should rarely need this method. Use with caution. + + \return const Fl_Image* image, the internal Fl_Image + + \since 1.4.0 + */ + const Fl_Image *image() const { return image_; } + +}; // class Fl_Shared_Image + +// +// 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 diff --git a/include/linux/amd64/FL/Fl_Shortcut_Button.H b/include/linux/amd64/FL/Fl_Shortcut_Button.H new file mode 100644 index 0000000..8e95112 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Shortcut_Button.H @@ -0,0 +1,45 @@ +// +// Shortcut Button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Shortcut_Button_H +#define Fl_Shortcut_Button_H + +#include + +class FL_EXPORT Fl_Shortcut_Button : public Fl_Button { +private: + bool hot_, pre_hot_, default_set_, handle_default_button_; + Fl_Shortcut pre_esc_; + Fl_Shortcut default_shortcut_; +protected: + Fl_Shortcut shortcut_value; + void do_end_hot_callback(); + int handle(int) FL_OVERRIDE; + void draw() FL_OVERRIDE; +public: + Fl_Shortcut_Button(int X,int Y,int W,int H, const char* l = 0); + void value(Fl_Shortcut shortcut); + Fl_Shortcut value(); +#if 0 + // Default shortcut settings are disabled until successful review of the UI + void default_value(Fl_Shortcut shortcut); + Fl_Shortcut default_value(); + void default_clear(); +#endif +}; + +#endif // Fl_Shortcut_Button_H + diff --git a/include/linux/amd64/FL/Fl_Simple_Counter.H b/include/linux/amd64/FL/Fl_Simple_Counter.H new file mode 100644 index 0000000..a91f349 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Simple_Counter.H @@ -0,0 +1,34 @@ +// +// Simple counter header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 + \image html counter.png + \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); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Single_Window.H b/include/linux/amd64/FL/Fl_Single_Window.H new file mode 100644 index 0000000..7cbb387 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Single_Window.H @@ -0,0 +1,61 @@ +// +// Single-buffered window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 subclass can 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() FL_OVERRIDE; + /** Same as Fl_Window::show(int argc, char **argv) */ + void show(int argc, char **argv) { Fl_Window::show(argc, argv);} + + /** + 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); + + /** + 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); + + /** + Same as Fl_Window::make_current() + */ + void make_current() { Fl_Window::make_current(); } + + /** + Same as Fl_Window::flush() + */ + void flush() FL_OVERRIDE { Fl_Window::flush(); } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Slider.H b/include/linux/amd64/FL/Fl_Slider.H new file mode 100644 index 0000000..0714238 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Slider.H @@ -0,0 +1,105 @@ +// +// Slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 is + 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() FL_OVERRIDE; + +public: + + int handle(int) FL_OVERRIDE; + 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 diff --git a/include/linux/amd64/FL/Fl_Spinner.H b/include/linux/amd64/FL/Fl_Spinner.H new file mode 100644 index 0000000..cad68a3 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Spinner.H @@ -0,0 +1,209 @@ +// +// Spinner widget for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Spinner widget . */ + +#ifndef Fl_Spinner_H +#define Fl_Spinner_H + +#include +#include +#include +#include + +/** + This widget is a combination of a numerical input widget and repeat buttons. + + The user can either type into the input area or use the buttons to + change the value. + + \image html Fl_Spinner.png "Fl_Spinner widget" + \image latex Fl_Spinner.png "Fl_Spinner widget" width=6cm +*/ +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 for input field + int wrap_; // wrap around at bounds (1/0) + +private: + + static void sb_cb(Fl_Widget *w, Fl_Spinner *sb); // internal callback + void update(); // update input field + +protected: + + // This class works like Fl_Input but ignores FL_Up and FL_Down key + // presses so they are handled by its parent, the Fl_Spinner widget. + // See STR #2989. + + class FL_EXPORT Fl_Spinner_Input : public Fl_Input { + public: + Fl_Spinner_Input(int X, int Y, int W, int H) + : Fl_Input(X, Y, W, H) {} + int handle(int event) FL_OVERRIDE; // implemented in src/Fl_Spinner.cxx + }; + + Fl_Spinner_Input input_; // Input field for the value + Fl_Repeat_Button + up_button_, // Up button + down_button_; // Down button + + void draw() FL_OVERRIDE; + +public: + + // Constructor + Fl_Spinner(int X, int Y, int W, int H, const char *L = 0); + // Event handling + int handle(int event) FL_OVERRIDE; + // Resize group and subwidgets + void resize(int X, int Y, int W, int H) FL_OVERRIDE; + + /** Returns the format string for the value. */ + const char *format() const { return (format_); } + + /** Sets the format string for the value. */ + void format(const char *f) { format_ = f; update(); } + + /** 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; } + + /** 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; } + + // Sets the amount to change the value when the user clicks a button. + // Docs in src/Fl_Spinner.cxx + void step(double s); + + /** + Gets the amount to change the value when the user clicks a button. + \see Fl_Spinner::step(double) + */ + double step() const { return (step_); } + + /** Sets whether the spinner wraps around at upper and lower bounds. + + If wrap mode is on the spinner value is set to the minimum() or + maximum() if the value exceeds the upper or lower bounds, resp., if + it was changed by one of the buttons or the FL_Up or FL_Down keys. + + The spinner stops at the upper and lower bounds if wrap mode is off. + + The default wrap mode is on for backwards compatibility with + FLTK 1.3.x and older versions. + + \note Wrap mode does not apply to the input field if the input value + is edited directly as a number. The input value is always + clipped to the allowed range as if wrap mode was off when the + input field is left (i.e. loses focus). + + \see minimum(), maximum() + + \param[in] set non-zero sets wrap mode, zero resets wrap mode + + \since 1.4.0 + */ + void wrap(int set) { wrap_ = set ? 1 : 0; } + + /** Gets the wrap mode of the Fl_Spinner widget. + \see void wrap(int) + \since 1.4.0 + */ + int wrap() const { return wrap_; } + + /** 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); } + + // Sets the numeric representation in the input field. + // Docs see src/Fl_Spinner.cxx + void type(uchar v); + + /** Gets the numeric representation in the input field. + \see Fl_Spinner::type(uchar) + */ + uchar type() const { return (input_.type()); } + + /** Gets the current value of the widget. */ + double value() const { return (value_); } + + /** + Sets the current value of the input 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(); } + + /** + Sets the background color of the spinner widget's input field. + */ + void color(Fl_Color v) { input_.color(v); } + + /** + Returns the background color of the spinner widget's input field. + */ + Fl_Color color() const { return(input_.color()); } + + /** + Sets the selection color of the spinner widget's input field. + */ + void selection_color(Fl_Color val) { input_.selection_color(val); } + + /** + Returns the selection color of the spinner widget's input field. + */ + Fl_Color selection_color() const { return input_.selection_color(); } + + /** + Sets the maximum width of the input field. + */ + void maximum_size(int m) { if (m > 0) input_.maximum_size(m); } + + /** + Returns the maximum width of the input field. + */ + int maximum_size() const { return input_.maximum_size(); } +}; + +#endif // !Fl_Spinner_H diff --git a/include/linux/amd64/FL/Fl_Sys_Menu_Bar.H b/include/linux/amd64/FL/Fl_Sys_Menu_Bar.H new file mode 100644 index 0000000..aff118c --- /dev/null +++ b/include/linux/amd64/FL/Fl_Sys_Menu_Bar.H @@ -0,0 +1,151 @@ +// +// MacOS system menu bar header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2017 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file + Definition of class Fl_Sys_Menu_Bar. + */ + + +#ifndef Fl_Sys_Menu_Bar_H +#define Fl_Sys_Menu_Bar_H + +#include + +class Fl_Sys_Menu_Bar_Driver; + +/** + A class to create and modify menus that appear on macOS in the menu bar at the top of the screen. + + On other than macOS platforms, Fl_Sys_Menu_Bar is a synonym of class Fl_Menu_Bar. + + On the macOS platform, replace Fl_Menu_Bar with Fl_Sys_Menu_Bar, and + a system menu at the top of the screen will be available. This menu will match an array + of Fl_Menu_Item's exactly as in all other FLTK menus (except for the submenu with the + application's own name and the 'Window' menu; see below). There is, though, an important difference between + an Fl_Sys_Menu_Bar object under macOS and under other platforms: only a single object + from this class can be created, because macOS uses a single system menu bar. Therefore, + porting to macOS an app that creates, on other platforms, several Fl_Menu_Bar objects, one for each of several windows, + is more complex that just replacing Fl_Menu_Bar by Fl_Sys_Menu_Bar. + + On the macOS platform, the system menu bar of any FLTK app begins with the Application + menu which the FLTK library automatically constructs. Functions + Fl_Mac_App_Menu::custom_application_menu_items() and Fl_Sys_Menu_Bar::about() can be used to further customize + the Application menu. The FLTK library also automatically constructs and handles a Window menu which can be + further customized (or even removed) calling + Fl_Sys_Menu_Bar::window_menu_style(window_menu_style_enum style). + Other member functions of this class allow the app to generate the rest of the system menu bar. + It is recommended to localize the system menu bar using the standard Mac OS X localization procedure + (see \ref osissues_localize). + + Changes to the menu state are immediately visible in the menubar when they are made + using member functions of the Fl_Sys_Menu_Bar class. Other changes (e.g., by a call to + Fl_Menu_Item::set()) should be followed by a call to update() to be + visible in the menubar across all platforms. macOS global variable \ref fl_sys_menu_bar points to + the unique, current system menu bar. + + A few FLTK menu features are not supported by the Mac System menu: + \li no symbolic labels + \li no embossed labels + \li no font sizes + + As described above, the submenu with the application's own name (usually + the second submenu from the left, immediately following the "Apple" submenu) + is a special case, and can be managed with + Fl_Mac_App_Menu::custom_application_menu_items(). + For example, to make your own "Appname -> Preferences" dialog, you might use: + + \code + #include // for Fl_Mac_App_Menu class + #include // for Fl_Menu_Item + : + void prefs_cb(Fl_Widget *w, void *data) { + // ..Open your preferences dialog here.. + } + : + int main(..) { + : + // Items to add to the application menu + static Fl_Menu_Item appitems[] = { + { "Preferences", 0, prefs_cb, 0, 0 }, + { 0 }, { 0 } + }; + Fl_Mac_App_Menu::custom_application_menu_items(appitems); // adds it + } + \endcode + + ..the result being: + + \image html mac-app-menu-preferences.png "Mac Application submenu" + \image latex mac-app-menu-preferences.png "Mac Application submenu" width=4cm + + */ +class FL_EXPORT Fl_Sys_Menu_Bar : public Fl_Menu_Bar { + static Fl_Sys_Menu_Bar_Driver *driver(); +protected: + void draw() FL_OVERRIDE; +public: + /** Possible styles of the Window menu in the system menu bar */ + typedef enum { + no_window_menu = 0, ///< No Window menu in the system menu bar + tabbing_mode_none, ///< No tabbed windows, but the system menu bar contains a Window menu + tabbing_mode_automatic, ///< Windows are created by themselves but can be tabbed later + tabbing_mode_preferred ///< Windows are tabbed when created + } window_menu_style_enum; + Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l=0); + virtual ~Fl_Sys_Menu_Bar(); + /** Return the system menu's array of Fl_Menu_Item's + */ + const Fl_Menu_Item *menu() const {return Fl_Menu_::menu();} + void menu(const Fl_Menu_Item *m); + void update() FL_OVERRIDE; + void play_menu(const Fl_Menu_Item *) FL_OVERRIDE; + int add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0); + /** Adds a new menu item. + \see Fl_Menu_::add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0) + */ + int add(const char* label, const char* shortcut, Fl_Callback* cb, void *user_data=0, int flags=0) { + return add(label, fl_old_shortcut(shortcut), cb, user_data, flags); + } + int add(const char* str); + int insert(int index, const char* label, int shortcut, Fl_Callback *cb, void *user_data=0, int flags=0); + /** Insert a new menu item. + \see Fl_Menu_::insert(int index, const char* label, const char* shortcut, Fl_Callback *cb, void *user_data=0, int flags=0) + */ + int insert(int index, const char* label, const char* shortcut, Fl_Callback *cb, void *user_data=0, int flags=0) { + return insert(index, label, fl_old_shortcut(shortcut), cb, user_data, flags); + } + void remove(int n); + void replace(int index, const char *name); + void clear(); + int clear_submenu(int index); + void mode (int i, int fl); + /** Gets the flags of item i. + */ + int mode(int i) const { return Fl_Menu_::mode(i); } + void shortcut (int i, int s); + void setonly (Fl_Menu_Item *item); + static void about(Fl_Callback *cb, void *data); + + static window_menu_style_enum window_menu_style(); + static void window_menu_style(window_menu_style_enum style); + static void create_window_menu(); +}; + +/** The system menu bar. + */ +extern Fl_Sys_Menu_Bar *fl_sys_menu_bar; + +#endif // Fl_Sys_Menu_Bar_H diff --git a/include/linux/amd64/FL/Fl_Table.H b/include/linux/amd64/FL/Fl_Table.H new file mode 100644 index 0000000..746b3a3 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Table.H @@ -0,0 +1,1101 @@ +// +// Fl_Table -- A table widget for the Fast Light Tool Kit (FLTK). +// +// Copyright 2002 by Greg Ercolano. +// Copyright (c) 2004 O'ksi'D +// Copyright 2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef _FL_TABLE_H +#define _FL_TABLE_H + +#include +#include + +// EXPERIMENTAL +// We use either std::vector or the private class Fl_Int_Vector +// depending on the build option FLTK_OPTION_STD or --enable-use_std. +// This option allows to use std::string and std::vector in FLTK 1.4.x + +#if (FLTK_USE_STD) +#include +typedef std::vector Fl_Int_Vector; +#else +class Fl_Int_Vector; // private class declared in src/Fl_Int_Vector.H +#endif + +/** + 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: + + \anchor table_dimensions_diagram + \image html table-dimensions.png + \image latex table-dimensions.png "Fl_Table Dimensions" width=6cm + + + + + + + + + + + + +
    x()/y()/w()/h()Fl_Table widget's outer dimension. The outer edge of the border of the + Fl_Table. (Red in the diagram above)
    wix/wiy/wiw/wihFl_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)
    tox/toy/tow/tohThe 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) +
    tix/tiy/tiw/tihThe 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/toy/tow/toh. (Blue in the diagram above) +
    + + 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 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. [updated by Greg, 04/26/17] +*/ +class FL_EXPORT Fl_Table : public Fl_Group { +public: + /** + The context bit flags for Fl_Table related callbacks. + + Should be used in draw_cell() to determine what's being drawn, + or in a callback() to determine where a recent event occurred. + */ + enum TableContext { + CONTEXT_NONE = 0, ///< no known context + CONTEXT_STARTPAGE = 0x01, ///< before the table is redrawn + CONTEXT_ENDPAGE = 0x02, ///< after the table is redrawn + CONTEXT_ROW_HEADER = 0x04, ///< drawing or event occurred in the row header + CONTEXT_COL_HEADER = 0x08, ///< drawing or event occurred in the col header + CONTEXT_CELL = 0x10, ///< drawing or event occurred in a cell + CONTEXT_TABLE = 0x20, ///< drawing or event occurred in a dead zone of table + CONTEXT_RC_RESIZE = 0x40 ///< column or row is 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; + int _scrollbar_size; + enum { + TABCELLNAV = 1<<0 ///> tab cell navigation flag + }; + unsigned int flags_; + + Fl_Int_Vector *_colwidths; // column widths in pixels + Fl_Int_Vector *_rowheights; // row heights in pixels + + // number of columns and rows == size of corresponding vectors + int col_size(); // size of the column widths vector + int row_size(); // size of the row heights vector + + 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's virtual width (in pixels) + int table_h; ///< table's virtual height (in pixels) + int toprow; ///< top row# of currently visible table on screen + int botrow; ///< bottom row# of currently visible table on screen + int leftcol; ///< left column# of currently visible table on screen + int rightcol; ///< right column# of currently visible table on screen + + // selection + int current_row; ///< selection cursor's current row (-1 if none) + int current_col; ///< selection cursor's current column (-1 if none) + int select_row; ///< extended selection row (-1 if none) + int select_col; ///< extended selection column (-1 if none) + + // OPTIMIZATION: Precomputed scroll positions for the toprow/leftcol + int toprow_scrollpos; ///< precomputed scroll position for top row + int leftcol_scrollpos; ///< precomputed scroll position for left column + + // Data table's inner dimension + int tix; ///< Data table's inner x dimension, inside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int tiy; ///< Data table's inner y dimension, inside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int tiw; ///< Data table's inner w dimension, inside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int tih; ///< Data table's inner h dimension, inside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + + // Data table's outer dimension + int tox; ///< Data table's outer x dimension, outside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int toy; ///< Data table's outer y dimension, outside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int tow; ///< Data table's outer w dimension, outside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int toh; ///< Data table's outer h dimension, outside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + + // Table widget's inner dimension + int wix; ///< Table widget's inner x dimension, inside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int wiy; ///< Table widget's inner y dimension, inside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int wiw; ///< Table widget's inner w dimension, inside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + int wih; ///< Table widget's inner h dimension, inside bounding box. See \ref table_dimensions_diagram "Table Dimension Diagram" + + Fl_Scroll *table; ///< child Fl_Scroll widget container for child fltk widgets (if any) + Fl_Scrollbar *vscrollbar; ///< child vertical scrollbar widget + Fl_Scrollbar *hscrollbar; ///< child horizontal scrollbar widget + + // Fltk + int handle(int e) FL_OVERRIDE; // fltk handle() FL_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); + 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: + + + + + + + + + + + + + + + + + + + + + +
    \p Fl_Table::CONTEXT_STARTPAGEWhen table, or parts of the table, are about to be redrawn.
    + Use to initialize static data, such as font selections.

    + R/C will be zero,
    + X/Y/W/H will be the dimensions of the table's entire data area.
    + (Useful for locking a database before accessing; see + also visible_cells())

    \p Fl_Table::CONTEXT_ENDPAGEWhen table has completed being redrawn.
    + R/C will be zero, X/Y/W/H dimensions of table's data area.
    + (Useful for unlocking a database after accessing)
    \p Fl_Table::CONTEXT_ROW_HEADERWhenever a row header cell needs to be drawn.
    + R will be the row number of the header being redrawn,
    + C will be zero,
    + X/Y/W/H will be the fltk drawing area of the row header in the window
    \p Fl_Table::CONTEXT_COL_HEADERWhenever a column header cell needs to be drawn.
    + R will be zero,
    + C will be the column number of the header being redrawn,
    + X/Y/W/H will be the fltk drawing area of the column header in the window
    \p Fl_Table::CONTEXT_CELLWhenever a data cell in the table needs to be drawn.
    + R/C will be the row/column of the cell to be drawn,
    + X/Y/W/H will be the fltk drawing area of the cell in the window
    \p Fl_Table::CONTEXT_RC_RESIZEWhenever table or row/column is resized or scrolled, + either interactively or via col_width() or row_height().
    + R/C/X/Y/W/H will all be zero. +

    + Useful for fltk containers that need to resize or move + the child fltk widgets.

    + + \p R and \p C will be set to the row and column number + of the cell being drawn. In the case of row headers, \p C will be \a 0. + In the case of column headers, \p R will be \a 0. + + X/Y/W/H 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 it's starting to draw page + fl_font(FL_HELVETICA, 16); + return; + + case CONTEXT_ROW_HEADER: // Fl_Table telling us to 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) + { (void)context; (void)R; (void)C; (void)X; (void)Y; (void)W; (void)H;} // 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) + + /** + Does the table contain any child fltk widgets? + */ + 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); + + /** + Define region of cells to be redrawn by specified range of rows/cols, + and then sets damage(DAMAGE_CHILD). Extends any previously defined range to redraw. + */ + 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); + } + + // draw() has to be protected per FLTK convention (was public in 1.3.x) + void draw() FL_OVERRIDE; + +public: + Fl_Table(int X, int Y, int W, int H, const char *l=0); + ~Fl_Table(); + + /** + Clears the table to zero rows (rows(0)), zero columns (cols(0)), and clears + any widgets (table->clear()) that were added with begin()/end() or add()/insert()/etc. + \see rows(int), cols(int) + */ + virtual void clear() { + rows(0); + cols(0); + table->clear(); + } + + // \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()); + } + + virtual void rows(int val); // set number of rows + + /** + Returns the number of rows in the table. + */ + inline int rows() { + return(_rows); + } + + virtual void cols(int val); // set 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 if row resizing by the user is allowed. + */ + 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 if column resizing by the user is allowed. + */ + 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; + } + + /** + Returns the current column minimum resize value. + */ + inline int col_resize_min() { // column minimum resizing width + return(_col_resize_min); + } + + /** + 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. + */ + 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 if row headers are enabled or not. + */ + 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); + } + + void row_height(int row, int height); // set row height in pixels + + // Returns the current height of the specified row as a value in pixels. + int row_height(int row); + + void col_width(int col, int width); // set a column's width in pixels + + // Returns the current width of the specified column in pixels. + int col_width(int 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; rinit_sizes(); + table->redraw(); + } + + /** + The specified widget is removed from its current group (if any) + and added to the end of Fl_Table's group. + */ + void add(Fl_Widget& wgt) { + table->add(wgt); + if ( table->children() > 2 ) { + table->show(); + } else { + table->hide(); + } + } + + /** + The specified widget is removed from its current group (if any) + and added to the end of Fl_Table's group. + */ + void add(Fl_Widget* wgt) { + add(*wgt); + } + + /** + The specified widget is removed from its current group (if any) + and inserted into the Fl_Table's group at position 'n'. + */ + void insert(Fl_Widget& wgt, int n) { + table->insert(wgt,n); + } + + /** + The specified widget is removed from its current group (if any) + and inserted into Fl_Table's group before widget 'w2'. + This will append if 'w2' is not in Fl_Table's group. + */ + void insert(Fl_Widget& wgt, Fl_Widget* w2) { + table->insert(wgt,w2); + } + + /** + The specified widget is removed from Fl_Table's group. + */ + void remove(Fl_Widget& wgt) { + table->remove(wgt); + } + + // (doxygen will substitute Fl_Group's docs here) + void begin() { + table->begin(); + } + + // (doxygen will substitute Fl_Group's docs here) + 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()); + } + + /** + Returns a pointer to the array of children. This pointer is only + valid until the next time a child is added or removed. + */ + 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; ichild(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 + } + + // (doxygen will substitute Fl_Group's docs here) + int find(const Fl_Widget *wgt) const { + return(table->find(wgt)); + } + + // (doxygen will substitute Fl_Group's docs here) + int find(const Fl_Widget &wgt) const { + return(table->find(wgt)); + } + + // 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); + } + + /** + Calls the widget callback. + + Saves the specified 'context', 'row', and 'col' values, so that the user's + callback can then access them with the member functions + callback_context(), callback_row() and callback_col(). + */ + void do_callback(TableContext context, int row, int col) { + _callback_context = context; + _callback_row = row; + _callback_col = col; + Fl_Widget::do_callback(); + } + +#ifdef FL_DOXYGEN + /** + The Fl_Widget::when() function is used to set a group of flags, determining + when the widget callback is called: + + + + + + + + + +
    \p FL_WHEN_CHANGED + 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(). +
    \p FL_WHEN_RELEASE + callback() will be called during FL_RELEASE events, such as when someone + releases a mouse button somewhere on the 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::event_button()) to determine what kind of event is occurring. + */ + void when(Fl_When flags); +#endif + +#ifdef 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: + + + + + + + + + + + + + + +
    Fl_Table::CONTEXT_ROW_HEADERSomeone clicked on a row header. Excludes resizing.
    Fl_Table::CONTEXT_COL_HEADERSomeone clicked on a column header. Excludes resizing.
    Fl_Table::CONTEXT_CELL + Someone clicked on a cell. + + To receive callbacks for FL_RELEASE events, you must set + when(FL_WHEN_RELEASE). +
    Fl_Table::CONTEXT_RC_RESIZE + 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). +
    + + \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 + + /** + 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 \p newSize, 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 newSize to the special value of 0 causes the widget to + track the global Fl::scrollbar_size(), which is the default. + + \param[in] newSize 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 newSize) { + if ( newSize != _scrollbar_size ) redraw(); + _scrollbar_size = newSize; + } + + /** + Flag to control if Tab navigates table cells or not. + + If on, Tab key navigates table cells. + If off, Tab key navigates fltk widget focus. (default) + + As of fltk 1.3, the default behavior of the Tab key is to navigate focus off + of the current widget, and on to the next one. But in some applications, + it's useful for Tab to be used to navigate cells in the Fl_Table. + + \param [in] val If \p val is 1, Tab key navigates cells in table, not fltk widgets.
    + If \p val is 0, Tab key will advance focus to the next fltk widget (default), and does not navigate cells in table. + */ + void tab_cell_nav(int val) { + if ( val ) flags_ |= TABCELLNAV; + else flags_ &= ~TABCELLNAV; + } + + /** + Get state of table's 'Tab' key cell navigation flag. + + \returns 1 if Tab configured to navigate cells in table
    0 to navigate widget focus (default) + + \see tab_cell_nav(int) + */ + int tab_cell_nav() const { + return(flags_ & TABCELLNAV ? 1 : 0); + } +}; + +#endif /*_FL_TABLE_H*/ diff --git a/include/linux/amd64/FL/Fl_Table_Row.H b/include/linux/amd64/FL/Fl_Table_Row.H new file mode 100644 index 0000000..ac35f33 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Table_Row.H @@ -0,0 +1,187 @@ +// + +#ifndef _FL_TABLE_ROW_H +#define _FL_TABLE_ROW_H + +// +// Fl_Table_Row -- A row oriented table widget for the Fast Light Tool Kit (FLTK). +// +// A class specializing in a table of rows. +// Handles row-specific selection behavior. +// +// Copyright 2002 by Greg Ercolano. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#include + +/** + 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 = 0; + _size = 0; + } + void copy(char *newarr, int newsize); + public: + CharVector() { // CTOR + init(); + } + ~CharVector(); // DTOR + 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); + 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) FL_OVERRIDE; + 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) FL_OVERRIDE; // 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() FL_OVERRIDE { + rows(0); // implies clearing selection + cols(0); + Fl_Table::clear(); // clear the table + } +}; + +#endif /*_FL_TABLE_ROW_H*/ diff --git a/include/linux/amd64/FL/Fl_Tabs.H b/include/linux/amd64/FL/Fl_Tabs.H new file mode 100644 index 0000000..8fe21da --- /dev/null +++ b/include/linux/amd64/FL/Fl_Tabs.H @@ -0,0 +1,334 @@ +// +// Tab header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Tabs widget . */ + +#ifndef Fl_Tabs_H +#define Fl_Tabs_H + +#include "Fl_Group.H" + +struct Fl_Menu_Item; + +/** + The Fl_Tabs widget is a container widget that displays a set of tabs, with + each tab representing a different child widget. The user can select a tab by + clicking on it, and the corresponding child widget will be displayed. + The Fl_Tabs widget is useful for organizing a large number of controls or + other widgets into a compact space, allowing the user to switch between + different sets of controls as needed. + + \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. + '&' in labels are used to prefix a shortcut that is drawn underlined and + that activates the corresponding tab; repeated '&&' avoids that. + + 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. + + The background area behind and to the right of the tabs is + "transparent", exposing the background detail of the parent. The + value of Fl_Tabs::box() does not affect this area. So if Fl_Tabs is + resized by itself without the parent, force the appropriate parent + (visible behind the tabs) to redraw() to prevent artifacts. + + See "Resizing Caveats" below on how to keep tab heights constant. + See "Callback's Use Of when()" on how to control the details + of how clicks invoke the callback(). + + A typical use of the Fl_Tabs widget: + + \par + \code + // Typical use of Fl_Tabs + Fl_Tabs *tabs = new Fl_Tabs(10,10,300,200); + { + Fl_Group *grp1 = new Fl_Group(20,30,280,170,"Tab1"); + { + ..widgets that go in tab#1.. + } + grp1->end(); + Fl_Group *grp2 = new Fl_Group(20,30,280,170,"Tab2"); + { + ..widgets that go in tab#2.. + } + grp2->end(); + } + tabs->end(); + \endcode + + \b Default \b Appearance + + The appearance of each "tab" is taken from the label() and color() of the + child group corresponding to that "tab" and panel. Where the "tabs" appear + depends on the position and size of the child groups that make up the + panels within the Fl_Tabs widget, i.e. whether there is more space above + or below them. The height of the "tabs" depends on how much free space + is available. + + \image html tabs_default.png "Fl_Tabs Default Appearance" + \image latex tabs_default.png "Fl_Tabs Default Appearance" width=8cm + + \b Highlighting \b The \b Selected \b Tab + + The selected "tab" can be highlighted further by setting the + selection_color() of the Fl_Tab itself, e.g. + + \par + \code + .. + tabs = new Fl_Tabs(..); + tabs->selection_color(FL_DARK3); + .. + \endcode + + The result of the above looks like: + \image html tabs_selection.png "Highlighting the selected tab" + \image latex tabs_selection.png "Highlighting the selected tab" width=8cm + + \b Uniform \b Tab \b and \b Panel \b Appearance + + In order to have uniform tab and panel appearance, not only must the color() + and selection_color() for each child group be set, but also the + selection_color() of the Fl_Tab itself any time a new "tab" is selected. + This can be achieved within the Fl_Tab callback, e.g. + + \par + \code + void MyTabCallback(Fl_Widget *w, void*) { + Fl_Tabs *tabs = (Fl_Tabs*)w; + // When tab changed, make sure it has same color as its group + tabs->selection_color( (tabs->value())->color() ); + } + .. + int main(..) { + // Define tabs widget + tabs = new Fl_Tabs(..); + tabs->callback(MyTabCallback); + + // Create three tabs each colored differently + grp1 = new Fl_Group(.. "One"); + grp1->color(9); + grp1->selection_color(9); + grp1->end(); + + grp2 = new Fl_Group(.. "Two"); + grp2->color(10); + grp2->selection_color(10); + grp2->end(); + + grp3 = new Fl_Group(.. "Three"); + grp3->color(14); + grp3->selection_color(14); + grp3->end(); + .. + // Make sure default tab has same color as its group + tabs->selection_color( (tab->value())->color() ); + .. + return Fl::run(); + } + \endcode + + The result of the above looks like: + \image html tabs_uniform.png "Fl_Tabs with uniform colors" + \image latex tabs_uniform.png "Fl_Tabs with uniform colors" width=8cm + + If Fl_Tabs has no children, the widget will be drawn as a flat rectangle + in the background color set by \ref color(). + + \b Close \b Button \b on \b Tabs + + The Fl_Tabs widget allows you to specify that a child widget should display + a close button in its tab. If the \ref FL_WHEN_CLOSED flag is set for the + child widget, an "X" symbol will be displayed to the left of the label text + in the tab. When the close button is clicked, the child widget's callback + function will be called with the \ref FL_REASON_CLOSED reason. It is then + the responsibility of the child widget to remove itself from the + Fl_Tabs container. + + Tabs that are in a compressed state will not display a close button until + they are fully expanded. + + \b Overflowing \b Tabs + + When the combined width of the tabs exceeds that of the Fl_Tabs widget, the + tabs will overflow. Fl_Tabs provides four options for managing tabs overflow: + + - Fl_Tabs::OVERFLOW_COMPRESS: proportionally compress the tabs to the left and right + of the selected tab until they all fit within the widget. + - Fl_Tabs::OVERFLOW_CLIP: clips any tabs that extend beyond the right edge of the + Fl_Tabs widget, making some tabs unreachable. + - Fl_Tabs::OVERFLOW_PULLDOWN: doesn't compress the tabs but instead generates a + pulldown menu at the right end of the tabs area, displaying + all available tabs. + - Fl_Tabs::OVERFLOW_DRAG: maintains the tabs' original sizes, allowing horizontal + dragging of the tabs area using the mouse, a horizontal mouse wheel, + or the horizontal scrolling gesture on touchpads. + + \b Resizing \b Caveats + + When Fl_Tabs is resized vertically, the default behavior scales the + tab's height as well as its children. To keep the tab height constant + during resizing, set the tab widget's resizable() to one of the tab's + child groups, i.e. + + \par + \code + tabs = new Fl_Tabs(..); + grp1 = new Fl_Group(..); + .. + grp2 = new Fl_Group(..); + .. + tabs->end(); + tabs->resizable(grp1); // keeps tab height constant + \endcode + + \par Callback's Use Of when() + + As of FLTK 1.3.3, Fl_Tabs() supports the following flags for when(): + + - \ref FL_WHEN_NEVER -- callback never invoked (all flags off) + - \ref FL_WHEN_CHANGED -- if flag set, invokes callback when a tab has been changed (on click or keyboard navigation) + - \ref FL_WHEN_NOT_CHANGED -- if flag set, invokes callback when the tabs remain unchanged (on click or keyboard navigation) + - \ref FL_WHEN_RELEASE -- if flag set, invokes callback on RELEASE of mouse button or keyboard navigation + + Notes: + + -# The above flags can be logically OR-ed (|) or added (+) to combine behaviors. + -# The default value for when() is \ref FL_WHEN_RELEASE (inherited from Fl_Widget). + -# If \ref FL_WHEN_RELEASE is the \em only flag specified, + the behavior will be as if (\ref FL_WHEN_RELEASE|\ref FL_WHEN_CHANGED) was specified. + -# The value of changed() will be valid during the callback. + -# If both \ref FL_WHEN_CHANGED and \ref FL_WHEN_NOT_CHANGED are specified, + the callback is invoked whether the tab has been changed or not. + The changed() method can be used to determine the cause. + -# \ref FL_WHEN_NOT_CHANGED can happen if someone clicks on an already selected tab, + or if a keyboard navigation attempt results in no change to the tabs, + such as using the arrow keys while at the left or right end of the tabs. + -# \ref Fl::callback_reason() returns FL_REASON_SELECTED or FL_REASON_RESELECTED +*/ +class FL_EXPORT Fl_Tabs : public Fl_Group { + + Fl_Widget *push_; + +protected: + + int overflow_type; ///< \see OVERFLOW_COMPRESS, OVERFLOW_CLIP, etc. + int tab_offset; ///< for pulldown and drag overflow, this is the horizontal offset when the tabs bar is dragged by the user + int *tab_pos; ///< Array of x-offsets of tabs per child + 1 \see tab_positions() + int *tab_width; ///< Array of widths of tabs per child \see tab_positions() + int *tab_flags; ///< Array of tab flag of tabs per child \see tab_positions() + int tab_count; ///< Array size of tab positions etc. \see tab_positions() + Fl_Align tab_align_; ///< tab label alignment + int has_overflow_menu;///< set in OVERFLOW_PULLDOWN mode if tabs overflow. The actual menu array is created only on demand + + void take_focus(Fl_Widget *o); + int maybe_do_callback(Fl_Widget *o); + void check_overflow_menu(); + void handle_overflow_menu(); + void draw_overflow_menu_button(); + + int on_insert(Fl_Widget*, int) FL_OVERRIDE; + int on_move(int, int) FL_OVERRIDE; + void on_remove(int) FL_OVERRIDE; + + virtual void redraw_tabs(); + virtual int tab_positions(); // allocate and calculate tab positions + virtual void clear_tab_positions(); + virtual void draw_tab(int x1, int x2, int W, int H, Fl_Widget* o, int flags, int sel); + virtual int tab_height(); + virtual int hit_close(Fl_Widget *o, int event_x, int event_y); + virtual int hit_overflow_menu(int event_x, int event_y); + virtual int hit_tabs_area(int event_x, int event_y); + + void draw() FL_OVERRIDE; + +public: + + Fl_Tabs(int X, int Y, int W, int H, const char *L = 0); + ~Fl_Tabs() FL_OVERRIDE; + + void resize(int, int, int, int) FL_OVERRIDE; + void show() FL_OVERRIDE; + + int handle(int) FL_OVERRIDE; + Fl_Widget *value(); + int value(Fl_Widget *); + + /** + Returns the tab group for the tab the user has currently down-clicked on + and remains over until FL_RELEASE. Otherwise, returns NULL. + + While the user is down-clicked on a tab, the return value is the tab group + for that tab. But as soon as the user releases, or drags off the tab with + the button still down, the return value will be NULL. + + \see push(Fl_Widget*). + */ + Fl_Widget *push() const { return push_; } + int push(Fl_Widget *); + + virtual Fl_Widget *which(int event_x, int event_y); + void client_area(int &rx, int &ry, int &rw, int &rh, int tabh=0); + + /** + Sets the tab label alignment. + + The default is FL_ALIGN_CENTER so tab labels are centered, but since + the label space is measured (per label) to fit the labels, there + wouldn't be any difference if labels were aligned left or right. + + If you want to show an image (icon) next to the group's label you can + set a different label alignment. FL_ALIGN_IMAGE_NEXT_TO_TEXT is the + recommended alignment to show the icon left of the text. + */ + void tab_align(Fl_Align a) { tab_align_ = a; } + + /** + Gets the tab label alignment. + + \see tab_align(Fl_Align) + */ + Fl_Align tab_align() const { return tab_align_; } + + enum { + OVERFLOW_COMPRESS = 0, ///< Tabs will be compressed and overlaid on top of each other. + OVERFLOW_CLIP, ///< Only the first tabs that fit will be displayed. + OVERFLOW_PULLDOWN, ///< Tabs that do not fit will be placed in a pull-down menu. + OVERFLOW_DRAG ///< The tab bar can be dragged horizontally to reveal additional tabs. + }; + + void handle_overflow(int ov); + +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Terminal.H b/include/linux/amd64/FL/Fl_Terminal.H new file mode 100644 index 0000000..dc11e31 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Terminal.H @@ -0,0 +1,1202 @@ +// +// Fl_Terminal - A terminal widget for Fast Light Tool Kit (FLTK). +// +// Copyright 2022 by Greg Ercolano. +// Copyright 2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file + Fl_Terminal widget. +*/ + +#ifndef Fl_Terminal_H +#define Fl_Terminal_H + +#include +#include +#include +#include +#include + +#include // va_list (MinGW) + +/** \class Fl_Terminal + + \brief Terminal widget supporting Unicode/utf-8, ANSI/xterm escape codes with full RGB color control. + + \section Fl_Terminal + + \image html Fl_Terminal-demo.png "Fl_Terminal widget showing a linux manual page" + \image latex Fl_Terminal-demo.png "Fl_Terminal widget showing a linux manual page" width=6cm + + Fl_Terminal is an output-only text widget supporting ASCII and UTF-8/Unicode. + It supports most terminal text features, such as most VT100/xterm style escape sequences + (see \ref Fl_Terminal_escape_codes), text colors/attributes, scrollback history, mouse selection, etc. + + It is recommended that accessing features such as setting text colors and cursor positioning + is best done with ANSI/XTERM escape sequences. But if one sets ansi(false) then this is + not possible, so the public API can be used for common operations, e.g. + \par + Public API | ESC code equivalent | Description | + ------------------------|--------------------------|-----------------------------| + clear_screen_home() | ESC [ H ESC [ 2 J | Clear screen, home cursor | + cursor_home() | ESC [ H | Home the cursor | + clear_history() | ESC [ 3 J | Clear scrollback history | + reset_terminal() | ESC [ c | Reset terminal | + + To access more advanced API calls, one can derive a class from Fl_Terminal to + access protected methods manipulate the terminal more directly, e.g. + \par + Protected API | ESC code equiv. | Description | + -----------------------------|------------------|-----------------------------------------| + current_style() | ESC [ # m | Set text attributes | + clear_eod() | ESC [ 0 J | Clear from cursor to end of display | + clear_sod() | ESC [ 1 J | Clear from cursor to start of display | + clear_eol() | ESC [ 0 K | Clear from cursor to end of line | + clear_sol() | ESC [ 1 K | Clear from cursor to start of line | + clear_line() | ESC [ 2 K | Clear line cursor is on | + scroll(int) // >0 for up | ESC [ 1 S | Scroll up one line | + scroll(int) // <0 for down | ESC [ 1 T | Scroll down one line | + cursor_left() | ESC [ 1 D | Move cursor left (no wrap) | + cursor_right() | ESC [ 1 C | Move cursor right (no wrap) | + cursor_up() | ESC [ 1 B | Move cursor up (no scroll or wrap) | + cursor_down() | ESC [ 1 A | Move cursor down (no scroll or wrap) | + cursor_row() cursor_col() | ESC [ # ; # H | Move cursor to row# / column# | + insert_char() | ESC [ # @ | Insert a char at cursor position | + delete_chars() | ESC [ # P | Delete chars at cursor position | + insert_rows() | ESC [ # L | Insert rows at cursor position | + delete_rows() | ESC [ # M | Delete rows at cursor position | + etc... | etc... | etc... | + + Many commonly used API functions are public, such as textfgcolor() for setting + text colors. Others, such as cursor_up() are protected to prevent common misuse, and are + available only to subclasses. + + Some common operations: + - Set the terminal's background color, see color(Fl_Color) + - Set the terminal's default text color, see textfgcolor_default(Fl_Color) + - Printing text to the terminal, see Fl_Terminal::printf() and Fl_Terminal::append() + - Clearing the screen, see clear() + - Getting the terminal's buffer contents, see text() + - Getting single utf8 characters by row/col from the terminal display, see utf8_char_at_disp() + - Getting the text from a text selection, see get_selection() + + For applications that need input support, the widget can be subclassed to provide + keyboard input, and advanced features like pseudo ttys, termio, serial port I/O, etc., + as such features are beyond the scope of FLTK. + + \subsection Fl_Terminal_Examples Examples + + \par + \code + // + // Fl_Terminal: Simple Use + // + Fl_Terminal *tty = new Fl_Terminal(...); + : + tty->append("Hello world.\n"); // simple strings + tty->append("\033[31mThis text is red.\033[0m\n"); // colored text + tty->append("\033[32mThis text is green.\033[0m\n"); + tty->printf("The value of x is %.02f\n", x); // printf() formatting + \endcode + \par + There are also public methods for doing what most "\033[" escape codes do, + so that if ansi(bool) is set to "false", one can still change text colors + or clear the screen via application control, e.g. + \par + \code + tty->home(); // home the cursor + tty->clear_screen(); // clear the screen + tty->textfgcolor(0xff000000); // change the text color to RED + tty->textbgcolor(0x0000ff00); // change the background color to BLUE + // ├┘├┘├┘ + // R G B + \endcode + \par + When creating the widget, the width/height determine the default column + and row count for the terminal's display based on the current font size. + The column width determines where text will wrap. + \par + You can specify wider column sizes than the screen using + display_columns(colwidth). When this value is larger than + the widget's width, text will wrap off-screen, and can be revealed by + resizing the widget wider. + + \subsection Fl_Terminal_Writing Writing To Terminal From Applications + + \par + An application needing terminal output as part of its user interface + can instance Fl_Terminal, and write text strings with: + \par + - append() to append strings + - printf() to append formatted strings + \par + Single character output can be done with: + \par + - print_char() to print a single ASCII/UTF-8 char at the cursor + - plot_char() to put single ASCII/UTF-8 char at an x,y position + \par + + \subsection Fl_Terminal_Attributes Text Attributes + \par + The terminal's text supports these attributes: + \par + - Italic - italicized text: \\033[3m + - Bold - brighter/thicker text: \\033[1m + - Dim - lower brightness text: \\033[2m + - Underline - text that is underlined: \\033[4m + - Strikeout - text that has a line through the text: \\033[9m + - Inverse - text whose background and foreground colors are swapped: \\033[7m + - Normal - normal text: \\033[0m + \par + \image html Fl_Terminal-utf8-demo.png "Fl_Terminal screen" + \image latex Fl_Terminal-utf8-demo.png "Fl_Terminal screen" width=6cm + + \subsection Fl_Terminal_Colors Text and Background Colors + + \par + There's at least two ways to specify colors for text and background colors: + \par + - 3 bit / 8 Color Values + - Full 24 bit R/G/B colors + \par + Example of 3 bit colors: + \image html Fl_Terminal-3bit-colors.png "Fl_Terminal 3 bit colors" + \image latex Fl_Terminal-3bit-colors.png "Fl_Terminal 3 bit colors" width=6cm + \par + Example application source code using 3 bit colors: + \code + // + // Text colors + // + tty->append("\033[31m Red text.\033[0m\n"); // Print red text.. + tty->append("\033[32m Green text.\033[0m\n"); + : + tty->append("\033[36m Cyan text.\033[0m\n"); + tty->append("\033[37m White text.\033[0m\n"); + // + // Background colors + // + tty->append("\033[41m Red Background.\033[0m\n"); // background will be red + tty->append("\033[42m Green Background.\033[0m\n"); + : + tty->append("\033[46m Cyan Background.\033[0m\n"); + tty->append("\033[47m White Background.\033[0m\n"); + \endcode + \par + Example of 24 bit colors: + \image html Fl_Terminal-24bit-colors.png "Fl_Terminal 24 bit colors" + \image latex Fl_Terminal-24bit-colors.png "Fl_Terminal 24 bit colors" width=6cm + \par + Example application source code using 24 bit colors: + \code + // + // 24 bit Text Color + // + tty->append("\033[38;2;0;0;255m Text is BLUE.\033[0m\n"); // RGB: R=0, G=0, B=255 + tty->append("\033[38;2;255;0;0m Text is RED.\033[0m\n"); // RGB: R=255, G=0, B=0 + tty->append("\033[38;2;127;64;0m Text is DARK ORANGE.\033[0m\n"); // RGB: R=127, G=64, B=0 + // + // 24 bit Background Color + // + tty->append("\033[48;2;0;0;255m Background is BLUE.\033[0m\n"); // RGB: R=0, G=0, B=255 + tty->append("\033[48;2;255;0;0m Background is RED.\033[0m\n"); // RGB: R=255, G=0, B=0 + tty->append("\033[48;2;127;64;0m Background is DARK ORANGE.\033[0m\n"); // RGB: R=127, G=64, B=0 + \endcode + \par + For more on the ANSI escape codes, see \ref Fl_Terminal_escape_codes. + + \subsection Fl_Terminal_Features Features + + \par + Most standard terminal behaviors are supported, e.g. + \par + - ASCII + UTF-8/Unicode + - scrollback history management + - mouse selection + copy/paste (^C, ^A) + - autoscroll during selection + \par + Most popular ANSI/DEC VT100/Xterm escape sequences are supported (see \ref Fl_Terminal_escape_codes), including: + - per-character colors for text and background + - per-character text attributes: bold/dim, underline, strikeout + - scrolling up/down + - character insert/delete for characters/rows/screen + - clearing characters/rows/screen + \par + Does not (yet) support: + - programmable regions (scroll regions and attribute blocks) + - dynamic line wrap (where resizing display dynamically re-wraps long lines) + \par + Will likely never implement as part of this widget: + - pty/termio management (such features should be _subclassed_) + - Different per-character font family + sizes (font family/size is global only) + - variable width fonts + \par + Regarding the font family+size; the way the terminal is currently designed, + the font family and size must not vary within text; rows have to be consistent + height. Varying widths are tricky too, esp. when it comes to moving the cursor + up/down within a column; varying *widths* are supported (due to Unicode characters + sometimes being "wide", but not heights. + + \subsection Fl_Terminal_Margins Margins + + \par + The margins define the amount of space (in pixels) around the outside of the + text display area, the space between the widget's inner edge (inside the box()) + and the text display area's outer edge. The margins can be inspected and changed + with the margin_left(), margin_right(), margin_top() and margin_bottom() methods. + \par + \code +· + TERMINAL WIDGET (Fl_Terminal) + ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━┓ + ┃ ↑ margin_top ┃ ┃ + ┃ TEXT DISPLAY AREA ↓ ┃ ┃ + ┃ ┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬─▴─┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┐ ┃ ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ S ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ c ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ display_rows ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ r ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ o ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ l ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ l ┃ + ┃ │◄── display_columns ─────────┼───────────────────────────►│ ┃ ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ B ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ a ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ r ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ ┃ + ┃ ├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤ ┃ ┃ + ┃◄─┬─►├┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼ │ ┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┼┤◄─┬─►┃ ┃ + ┃ │ └┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴─▾─┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┘ │ ┃ ┃ + ┃ margin_left ↑ margin_right ┃ ┃ + ┃ ↓ margin_bottom ┃ ┃ + ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━┛ + Fl_Terminal Margins + + + ░░░░░░░░░░░░░░░░░░░░░░░░░ + ░░░░░░░░░░░░░░░░░░░░░░░░░ + ░░░░░░:::::::::::::░░░░░◉ + ░░░░░░::##:::::##:◉░░░░░░╲ + ░░░░░░::###:::###::╲░░░░░ ╲ + ░░░░░░::####:####::░╲░░░░ Fl_Terminal::color() + ░░░░░░::##:###:##::░░╲░░░ + ░░░░░░::##::#::##::░░░╲░░ + ░░░░░░::##:.:::##::░░░░╲░ + ░░░░░░::##:::::#◉::░░░░░╲ + ░░░░░░:::::::::::╲:░░░░░░╲ + ░░░░░░░░░░░░░░░░░░╲░░░░░░ Fl_Terminal::textbgcolor() + ░░░░░░░░░░░░░░░░░░░╲░░░░░ + ╲ + Fl_Terminal::textfgcolor() +· + \endcode + + \subsection Fl_Terminal_Caveats Caveats + + \par + - This widget is not a full terminal emulator; it does not do stdio redirection, + pseudo ttys/termios/character cooking, keyboard input processing, full + curses(3) support. However, such features CAN be implemented with subclassing. + \par + - The printf() and vprintf() functions are limited to strings no longer than + 1024 characters (including NULL). For printing longer strings, use append() + which has no string limits. + \par + - For background colors textbgcolor() and textbgcolor_default(), the special + color value 0xffffffff lets the widget's box() color() show through behind + the text. +**/ + +class FL_EXPORT Fl_Terminal : public Fl_Group { + ////////////////////////////////////// + ////// Fl_Terminal Public Enums ////// + ////////////////////////////////////// +public: + /** + \enum RedrawStyle + Determines when Fl_Terminal calls redraw() if new text is added. + RATE_LIMITED is the recommended setting, using redraw_rate(float) to determine + the maximum rate of redraws. + \see redraw_style(), redraw_rate() + */ + enum RedrawStyle { + NO_REDRAW=0, ///< app must call redraw() as needed to update text to screen + RATE_LIMITED, ///< timer controlled redraws. (DEFAULT) + PER_WRITE ///< redraw triggered after *every* append() / printf() / etc. operation + }; + + /** + \enum Attrib + Bits for the per-character attributes, which control text features + such as italic, bold, underlined text, etc. + + NOTE: enum names with a leading underbar must not be used, and are + reserved for future use. + */ + enum Attrib { + NORMAL = 0x00, ///< all attributes off + BOLD = 0x01, ///< bold text: uses bold font, color brighter than normal + DIM = 0x02, ///< dim text; color slightly darker than normal + ITALIC = 0x04, ///< italic font text + UNDERLINE = 0x08, ///< underlined text + _RESERVED_1 = 0x10, ///< (reserved for internal future use) + INVERSE = 0x20, ///< inverse text; fg/bg color are swapped + _RESERVED_2 = 0x40, ///< (reserved for internal future use) + STRIKEOUT = 0x80 ///< strikeout text + }; + + /** + \enum CharFlags + Per-character 8 bit flags (uchar) used to manage special states for characters. + */ + enum CharFlags { + FG_XTERM = 0x01, ///< this char's fg color is an XTERM color; can be affected by Dim+Bold + BG_XTERM = 0x02, ///< this char's bg color is an XTERM color; can be affected by Dim+Bold + EOL = 0x04, ///< TODO: char at EOL, used for line re-wrap during screen resizing + RESV_A = 0x08, + RESV_B = 0x10, + RESV_C = 0x20, + RESV_D = 0x40, + RESV_E = 0x80, + COLORMASK = (FG_XTERM | BG_XTERM) + }; + + /** + \enum OutFlags + Output translation flags for special control character translations. + */ + enum OutFlags { + OFF = 0x00, ///< no output translation + CR_TO_LF = 0x01, ///< carriage return generates a vertical line-feed (\\r -> \\n) + LF_TO_CR = 0x02, ///< line-feed generates a carriage return (\\n -> \\r) + LF_TO_CRLF = 0x04 ///< line-feed generates a carriage return line-feed (\\n -> \\r\\n) + }; + + /** + \enum ScrollbarStyle + Behavior of scrollbars + */ + enum ScrollbarStyle { + SCROLLBAR_OFF = 0x00, ///< scrollbar always invisible + SCROLLBAR_AUTO = 0x01, ///< scrollbar visible if widget resized in a way that hides columns (default) + SCROLLBAR_ON = 0x02 ///< scrollbar always visible + }; + + /////////////////////////////////////////////////////////////// + ////// + ////// Fl_Terminal Protected Classes + ////// + /////////////////////////////////////////////////////////////// +protected: + // Margin Class //////////////////////////////////////////// + // + // Class to manage the terminal's margins + // + class FL_EXPORT Margin { + int left_, right_, top_, bottom_; + public: + Margin(void) { left_ = right_ = top_ = bottom_ = 3; } + int left(void) const { return left_; } + int right(void) const { return right_; } + int top(void) const { return top_; } + int bottom(void) const { return bottom_; } + void left(int val) { left_ = val; } + void right(int val) { right_ = val; } + void top(int val) { top_ = val; } + void bottom(int val) { bottom_ = val; } + }; + + // CharStyle Class //////////////////////////////////////////// + // + // Class to manage the terminal's character style + // This includes the font, color, and some cached internal + // info for optimized drawing speed. + // + class FL_EXPORT CharStyle { + uchar attrib_; // bold, underline.. + uchar charflags_; // CharFlags (xterm color management) + Fl_Color fgcolor_; // foreground color for text + Fl_Color bgcolor_; // background color for text + Fl_Color defaultfgcolor_; // default fg color used by ESC[0m + Fl_Color defaultbgcolor_; // default bg color used by ESC[0m + Fl_Font fontface_; // font face + Fl_Fontsize fontsize_; // font size + int fontheight_; // font height (in pixels) + int fontdescent_; // font descent (pixels below font baseline) + int charwidth_; // width of a fixed width ASCII character + public: + CharStyle(bool fontsize_defer); + uchar attrib(void) const { return attrib_; } + uchar charflags(void) const { return charflags_; } + // Colors - All access to colors are by Fl_Color only. + // There are three ways to SET colors: Fl_Color, rgb, xterm(uchar) + // + Fl_Color fltk_fg_color(uchar ci); + Fl_Color fltk_bg_color(uchar ci); + Fl_Color fgcolor(void) const; + Fl_Color bgcolor(void) const; + Fl_Color defaultfgcolor(void) const { return defaultfgcolor_; } + Fl_Color defaultbgcolor(void) const { return defaultbgcolor_; } + Fl_Font fontface(void) const { return fontface_; } + Fl_Fontsize fontsize(void) const { return fontsize_; } + int fontheight(void) const { return fontheight_; } + int fontdescent(void) const { return fontdescent_; } + int charwidth(void) const { return charwidth_; } + uchar colorbits_only(uchar inflags) const; + void attrib(uchar val) { attrib_ = val; } + void charflags(uchar val) { charflags_ = val; } + void set_charflag(uchar val) { charflags_ |= val; } + void clr_charflag(uchar val) { charflags_ &= ~val; } + // Non-xterm colors + void fgcolor(int r,int g,int b) { fgcolor_ = (r<<24) | (g<<16) | (b<<8); clr_charflag(FG_XTERM); } + void bgcolor(int r,int g,int b) { bgcolor_ = (r<<24) | (g<<16) | (b<<8); clr_charflag(BG_XTERM); } + void fgcolor(Fl_Color val) { fgcolor_ = val; clr_charflag(FG_XTERM); } + void bgcolor(Fl_Color val) { bgcolor_ = val; clr_charflag(BG_XTERM); } + // Xterm colors + void fgcolor_xterm(Fl_Color val) { fgcolor_ = val; set_charflag(FG_XTERM); } + void bgcolor_xterm(Fl_Color val) { bgcolor_ = val; set_charflag(BG_XTERM); } + void fgcolor_xterm(uchar val); + void bgcolor_xterm(uchar val); + // + void defaultfgcolor(Fl_Color val) { defaultfgcolor_ = val; } + void defaultbgcolor(Fl_Color val) { defaultbgcolor_ = val; } + void fontface(Fl_Font val) { fontface_ = val; update(); } + void fontsize(Fl_Fontsize val) { fontsize_ = val; update(); } + void update(void); + void update_fake(void); + // SGR MODES: Set Graphics Rendition + void sgr_reset(void) { // e.g. ESC[0m + attrib(Fl_Terminal::NORMAL); + if (charflags() & FG_XTERM) fgcolor_xterm(defaultfgcolor_); + else fgcolor(defaultfgcolor_); + if (charflags() & BG_XTERM) bgcolor_xterm(defaultbgcolor_); + else bgcolor(defaultbgcolor_); + } + int onoff(bool flag, Attrib a) { return (flag ? (attrib_ | a) : (attrib_ & ~a)); } + void sgr_bold(bool val) { attrib_ = onoff(val, Fl_Terminal::BOLD); } // e.g. ESC[1m + void sgr_dim(bool val) { attrib_ = onoff(val, Fl_Terminal::DIM); } // e.g. ESC[2m + void sgr_italic(bool val) { attrib_ = onoff(val, Fl_Terminal::ITALIC); } // e.g. ESC[3m + void sgr_underline(bool val) { attrib_ = onoff(val, Fl_Terminal::UNDERLINE); } // e.g. ESC[3m + void sgr_dbl_under(bool val) { attrib_ = onoff(val, Fl_Terminal::UNDERLINE); } // e.g. ESC[21m (TODO!) + void sgr_blink(bool val) { (void)val; /* NOT IMPLEMENTED */ } // e.g. ESC[5m + void sgr_inverse(bool val) { attrib_ = onoff(val, Fl_Terminal::INVERSE); } // e.g. ESC[7m + void sgr_strike(bool val) { attrib_ = onoff(val, Fl_Terminal::STRIKEOUT); } // e.g. ESC[9m + }; + +protected: + // Cursor Class /////////////////////////////////////////////////////////// + // + // Class to manage the terminal's cursor position, color, etc. + // + class FL_EXPORT Cursor { + int col_; // cursor's current col (x) position on display + int row_; // cursor's current row (y) position on display + int h_; // cursor's height (affected by font size) + Fl_Color fgcolor_; // cursor's fg color (color of text, if any) + Fl_Color bgcolor_; // cursor's bg color + public: + Cursor(void) { + col_ = 0; + row_ = 0; + h_ = 10; + fgcolor_ = 0xfffff000; // wht + bgcolor_ = 0x00d00000; // grn + } + int col(void) const { return col_; } + int row(void) const { return row_; } + int h(void) const { return h_; } + Fl_Color fgcolor(void) const { return fgcolor_; } + Fl_Color bgcolor(void) const { return bgcolor_; } + void col(int val) { col_ = val >= 0 ? val : 0; } + void row(int val) { row_ = val >= 0 ? val : 0; } + void h(int val) { h_ = val; } + void fgcolor(Fl_Color val) { fgcolor_ = val; } + void bgcolor(Fl_Color val) { bgcolor_ = val; } + int left(void) { col_ = (col_>0) ? (col_-1) : 0; return col_; } + int right(void) { return ++col_; } + int up(void) { row_ = (row_>0) ? (row_-1) : 0; return row_; } + int down(void) { return ++row_; } + bool is_rowcol(int drow,int dcol) const; + void scroll(int nrows); + void home(void) { row_ = 0; col_ = 0; } + }; + + // Utf8Char Class /////////////////////////////////////////////////////////// + // + // Class to manage the terminal's individual UTF-8 characters. + // Includes fg/bg color, attributes (BOLD, UNDERLINE..) + // + class FL_EXPORT Utf8Char { + static const int max_utf8_ = 4; // RFC 3629 paraphrased: In UTF-8, chars are encoded with 1 to 4 octets + char text_[max_utf8_]; // memory for actual ASCII or UTF-8 byte contents + uchar len_; // length of bytes in text_[] buffer; 1 for ASCII, >1 for UTF-8 + uchar attrib_; // attribute bits for this char (bold, underline..) + uchar charflags_; // CharFlags (xterm colors management) + Fl_Color fgcolor_; // fltk fg color (supports 8color or 24bit color set w/ESC[37;;;m) + Fl_Color bgcolor_; // fltk bg color (supports 8color or 24bit color set w/ESC[47;;;m) + // Private methods + void text_utf8_(const char *text, int len); + Fl_Color attr_color_(Fl_Color col, const Fl_Widget *grp) const; + public: + // Public methods + Utf8Char(void); // ctor + Utf8Char(const Utf8Char& o); // copy ctor + ~Utf8Char(void); // dtor + Utf8Char& operator=(const Utf8Char& o); // assignment + inline int max_utf8() const { return max_utf8_; } + void text_utf8(const char *text, int len, const CharStyle& style); + void text_ascii(char c, const CharStyle& style); + void fl_font_set(const CharStyle& style) const; + + // Return the UTF-8 text string for this character. + // Use length() to get number of bytes in string, which will be 1 for ASCII chars. + // + const char* text_utf8(void) const { return text_; } + // Return the attribute for this char + uchar attrib(void) const { return attrib_; } + uchar charflags(void) const { return charflags_; } + Fl_Color fgcolor(void) const; + Fl_Color bgcolor(void) const; + // Return the length of this character in bytes (UTF-8 can be multibyte..) + int length(void) const { return int(len_); } + double pwidth(void) const; + int pwidth_int(void) const; + // Clear the character to a 'space' + void clear(const CharStyle& style) { text_utf8(" ", 1, style); charflags_ = 0; attrib_ = 0; } + bool is_char(char c) const { return *text_ == c; } + void show_char(void) const { ::printf("%.*s", len_, text_); } + void show_char_info(void) const { ::fprintf(stderr, "UTF-8('%.*s', len=%d)\n", len_, text_, len_); } + Fl_Color attr_fg_color(const Fl_Widget *grp) const; + Fl_Color attr_bg_color(const Fl_Widget *grp) const; + }; + + // RingBuffer Class /////////////////////////////////////////////////// + // + // Manages ring with indexed row/col and "history" vs. "display" concepts. + // + class FL_EXPORT RingBuffer { + Utf8Char *ring_chars_; // the ring UTF-8 char buffer + int ring_rows_; // #rows in ring total + int ring_cols_; // #columns in ring/hist/disp + int nchars_; // #chars in ring (ring_rows*ring_cols) + int hist_rows_; // #rows in history + int hist_use_; // #rows in use by history + int disp_rows_; // #rows in display + int offset_; // index offset (used for 'scrolling') + +private: + void new_copy(int drows, int dcols, int hrows, const CharStyle& style); + //DEBUG void write_row(FILE *fp, Utf8Char *u8c, int cols) const { + //DEBUG cols = (cols != 0) ? cols : ring_cols(); + //DEBUG for ( int col=0; collength(), u8c->text_utf8()); + //DEBUG } + //DEBUG } + public: + void clear(void); + void clear_hist(void); + RingBuffer(void); + RingBuffer(int drows, int dcols, int hrows); + ~RingBuffer(void); + + // Methods to access ring + // + // The 'offset' concept allows the 'history' and 'display' + // to be scrolled indefinitely. The 'offset' is applied + // to all the row accesses, and are clamped to within their bounds. + // + // For 'raw' access to the ring (without the offset concept), + // use the ring_chars() method, and walk from 0 - ring_rows(). + // + // _____________ + // | | <- hist_srow() <- ring_srow() + // | H i s t | + // | | + // |_____________| <- hist_erow() + // | | <- disp_srow() + // | D i s p | + // | | + // |_____________| <- disp_erow() <- ring_erow() + // + // \___________/ + // ring_cols() + // hist_cols() + // disp_cols() + // + inline int ring_rows(void) const { return ring_rows_; } + inline int ring_cols(void) const { return ring_cols_; } + inline int ring_srow(void) const { return(0); } + inline int ring_erow(void) const { return(ring_rows_ - 1); } + inline int hist_rows(void) const { return hist_rows_; } + inline int hist_cols(void) const { return ring_cols_; } + inline int hist_srow(void) const { return((offset_ + 0) % ring_rows_); } + inline int hist_erow(void) const { return((offset_ + hist_rows_ - 1) % ring_rows_); } + inline int disp_rows(void) const { return disp_rows_; } + inline int disp_cols(void) const { return ring_cols_; } + inline int disp_srow(void) const { return((offset_ + hist_rows_) % ring_rows_); } + inline int disp_erow(void) const { return((offset_ + hist_rows_ + disp_rows_ - 1) % ring_rows_); } + inline int offset(void) const { return offset_; } + void offset_adjust(int rows); + void hist_rows(int val) { hist_rows_ = val; } + void disp_rows(int val) { disp_rows_ = val; } + + // History use + inline int hist_use(void) const { return hist_use_; } + inline void hist_use(int val) { hist_use_ = val; } + inline int hist_use_srow(void) const { return((offset_ + hist_rows_ - hist_use_) % ring_rows_); } + inline Utf8Char *ring_chars(void) { return ring_chars_; } // access ring buffer directly + inline Utf8Char *ring_chars(void) const { return ring_chars_; } // access ring buffer directly + + bool is_hist_ring_row(int grow) const; + bool is_disp_ring_row(int grow) const; + //DEBUG void show_ring_info(void) const; + void move_disp_row(int src_row, int dst_row); + void clear_disp_rows(int sdrow, int edrow, const CharStyle& style); + void scroll(int rows, const CharStyle& style); + + const Utf8Char* u8c_ring_row(int row) const; + const Utf8Char* u8c_hist_row(int hrow) const; + const Utf8Char* u8c_hist_use_row(int hurow) const; + const Utf8Char* u8c_disp_row(int drow) const; + // Non-const versions of the above methods + // Using "Effective C++" ugly-as-hell syntax technique. + // + Utf8Char* u8c_ring_row(int row); + Utf8Char* u8c_hist_row(int hrow); + Utf8Char* u8c_hist_use_row(int hurow); + Utf8Char* u8c_disp_row(int drow); + + void create(int drows, int dcols, int hrows); + void resize(int drows, int dcols, int hrows, const CharStyle& style); + + void change_disp_rows(int drows, const CharStyle& style); + void change_disp_cols(int dcols, const CharStyle& style); + }; + + // Selection Class /////////////////////////////////////////////////// + // + // Class to manage mouse selection + // + class FL_EXPORT Selection { + Fl_Terminal *terminal_; + int srow_, scol_, erow_, ecol_; // selection start/end. NOTE: start *might* be > end + int push_row_, push_col_; // global row/col for last FL_PUSH + bool push_char_right_; + Fl_Color selectionbgcolor_; + Fl_Color selectionfgcolor_; + int state_ ; // 0=none, 1=started, 2=extended, 3=done + bool is_selection_; // false: no selection + public: + Selection(Fl_Terminal *terminal); + int srow(void) const { return srow_; } + int scol(void) const { return scol_; } + int erow(void) const { return erow_; } + int ecol(void) const { return ecol_; } + void push_clear() { push_row_ = push_col_ = -1; push_char_right_ = false; } + void push_rowcol(int row,int col,bool char_right) { + push_row_ = row; push_col_ = col; push_char_right_ = char_right; } + void start_push() { start(push_row_, push_col_, push_char_right_); } + bool dragged_off(int row,int col,bool char_right) { + return (push_row_ != row) || (push_col_+push_char_right_ != col+char_right); } + void selectionfgcolor(Fl_Color val) { selectionfgcolor_ = val; } + void selectionbgcolor(Fl_Color val) { selectionbgcolor_ = val; } + Fl_Color selectionfgcolor(void) const { return selectionfgcolor_; } + Fl_Color selectionbgcolor(void) const { return selectionbgcolor_; } + bool is_selection(void) const { return is_selection_; } + bool get_selection(int &srow,int &scol,int &erow,int &ecol) const; // guarantees return (start < end) + bool start(int row, int col, bool char_right); + bool extend(int row, int col, bool char_right); + void end(void); + void select(int srow, int scol, int erow, int ecol); + bool clear(void); + int state(void) const { return state_; } + void scroll(int nrows); + }; + + // EscapeSeq Class /////////////////////////////////////////////////// + // + // Class to handle parsing ESC sequences + // + // Holds all state information for parsing esc sequences, + // so sequences can span multiple block read(2) operations, etc. + // Handling of parsed sequences is NOT handled in this class, + // just the parsing of the sequences and managing generic integers. + // + class FL_EXPORT EscapeSeq { + public: + // EscapeSeq Constants + // Maximums + static const int maxbuff = 80; // character buffer + static const int maxvals = 20; // integer value buffer + // Return codes + static const int success = 0; // operation succeeded + static const int fail = -1; // operation failed + static const int completed = 1; // multi-step operation completed successfully + private: + char esc_mode_; // escape parsing mode state + char csi_; // This is an ESC[.. sequence (Ctrl Seq Introducer) + char buff_[maxbuff]; // escape sequence being parsed + char *buffp_; // parsing ptr into buff[] + char *buffendp_; // end of buff[] (ptr to last valid buff char) + char *valbuffp_; // pointer to first char in buff of integer being parsed + int vals_[maxvals]; // value array for parsing #'s in ESC[#;#;#.. + int vali_; // parsing index into vals_[], 0 if none + int save_row_, save_col_; // used by ESC[s/u for save/restore + + int append_buff(char c); + int append_val(void); + + public: + EscapeSeq(void); + void reset(void); + char esc_mode(void) const; + void esc_mode(char val); + int total_vals(void) const; + int val(int i) const; + int defvalmax(int dval, int max) const; + bool parse_in_progress(void) const; + bool is_csi(void) const; + int parse(char c); + void save_cursor(int row, int col); + void restore_cursor(int &row, int &col); + }; + + // Partial UTF-8 Buffer Class //////////////////////////////////////////// + // + // Class to manage buffering partial UTF-8 characters between write calls. + // + class FL_EXPORT PartialUtf8Buf { + char buf_[10]; // buffer partial UTF-8 encoded char + int buflen_; // length of buffered UTF-8 encoded char + int clen_; // final byte length of a UTF-8 char + public: + void clear(void) { buflen_ = clen_ = 0; } // clear the buffer + PartialUtf8Buf(void) { clear(); } // Ctor + // Is byte 'c' in the middle of a UTF-8 encoded byte sequence? + bool is_continuation(char c) { + // Byte 1 Byte 2 Byte 3 ..etc.. + // ASCII: 0xxxxxxx + // UTF8(2): 110xxxxx 10xxxxxx + // UTF8(3): 1110xxxx 10xxxxxx 10xxxxxx + // UTF8(4): 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + // UTF8(5): 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + // UTF8(6): 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx + // \______/ \______________________________________________/ + // Start byte Continuation bytes + // (c & 0xc0) == 0x80 + return ((c & 0xc0) == 0x80); + } + // Access buffer + const char* buf(void) const { return buf_; } + // Access buffer length + int buflen(void) const { return buflen_; } + // Append bytes of a partial UTF-8 string to the buffer. + // + // Returns: + // - true if done OK. Use is_complete() to see if a complete char received. + // - false if buffer overrun occurred, class is clear()ed. + // + // An appropriate response to 'false' would be to print the + // "unknown character" and skip all subsequent UTF-8 continuation chars. + // + bool append(const char* p, int len) { + if (len <= 0) return true; // ignore silly requests: say we did but dont + if (buflen_ + len >= (int)sizeof(buf_)) // overrun check + { clear(); return false; } // clear self, return false + if (!buflen_) clen_ = fl_utf8len(*p); // first byte? save char len for later + while (len>0) { buf_[buflen_++] = *p++; len--; } // append byte to buffer + return true; + } + bool is_complete(void) const { return (buflen_ && (buflen_ == clen_)); } + }; + + /////////////////////////////////////////////////////////////// + ////// + ////// Fl_Terminal members + methods + ////// + /////////////////////////////////////////////////////////////// +public: + /** + Vertical scrollbar. This is public so it can be accessed directly, e.g. + + - \ref Fl_Scrollbar::value(void) "scrollbar->value(void)" returns the row offset + from the bottom of the display, 0 being the bottom (default). + - \ref Fl_Scrollbar::value(int) "scrollbar->value(int)" similarly sets the row offset, + which should be in the range [0 .. Fl_Scrollbar::maximum()]. + - \ref Fl_Scrollbar::step(double) "scrollbar->step(double)" sets the smoothness + of scrolling, default is 0.25 for 4 steps of motion per column. + + \todo Support scrollbar_left/right() - See Fl_Browser_::scrollbar docs + \todo Support new ScrollbarStyle + */ + Fl_Scrollbar *scrollbar; // vertical scrollbar (value: rows above disp_chars[]) + /** + Horizontal scrollbar. This is public so it can be accessed directly, e.g. + + - \ref Fl_Scrollbar::value(void) "hscrollbar->value(void)" returns the column offset + position from the left edge of the display; 0 being the left edge (default). + - \ref Fl_Scrollbar::value(int) "hscrollbar->value(int)" similarly sets the column offset, + which should be in the range [0 .. Fl_Scrollbar::maximum()]. + - \ref Fl_Scrollbar::step(double) "hscrollbar->step(double)" sets the smoothness + of scrolling, default is 0.25 for 4 steps of motion per column. + */ + Fl_Scrollbar *hscrollbar; // horizontal scrollbar +private: + // Special utf8 symbols + const char *error_char_; // utf8 string shown for invalid utf8, bad ANSI, etc + bool fontsize_defer_; // flag defers font calcs until first draw() (issue 837) + int scrollbar_size_; // local preference for scrollbar size + ScrollbarStyle hscrollbar_style_; + CharStyle *current_style_; // current font, attrib, color.. + OutFlags oflags_; // output translation flags (CR_TO_LF, LF_TO_CR, LF_TO_CRLF) + + // A ring buffer is used for the terminal's history (hist) and display (disp) buffer. + // See README-Fl_Terminal.txt, section "RING BUFFER DESCRIPTION" for diagrams/info. + // + // Ring buffer + RingBuffer ring_; // terminal history/display ring buffer + Cursor cursor_; // terminal cursor (position, color, etc) + Margin margin_; // terminal margins (top,left,bottom,right) + Selection select_; // mouse selection + EscapeSeq escseq; // Escape sequence parsing (ESC[ xterm/vt100) + bool show_unknown_; // if true, show unknown chars as '¿' (default off) + bool ansi_; // if true, parse ansi codes (default on) + char *tabstops_; // array of tab stops (0|1) \__ TODO: This should probably + int tabstops_size_; // size of tabstops[] array / be a class "TabStops". + Fl_Rect scrn_; // terminal screen xywh inside box(), margins, and scrollbar + int autoscroll_dir_; // 0=autoscroll timer off, 3=scrolling up, 4=scrolling down + int autoscroll_amt_; // #pixels above or below edge, used for autoscroll speed + RedrawStyle redraw_style_; // NO_REDRAW, RATE_LIMITED, PER_WRITE + float redraw_rate_; // maximum redraw rate in seconds, default=0.10 + bool redraw_modified_; // display modified; used by update_cb() to rate limit redraws + bool redraw_timer_; // if true, redraw timer is running + PartialUtf8Buf pub_; // handles Partial Utf8 Buffer (pub) + +protected: + // Ring buffer management + const Utf8Char* u8c_ring_row(int grow) const; + const Utf8Char* u8c_hist_row(int hrow) const; + const Utf8Char* u8c_hist_use_row(int hrow) const; + const Utf8Char* u8c_disp_row(int drow) const; + // Non-const versions of the above. + // "Effective C++" says: implement non-const method to cast away const + // + Utf8Char* u8c_ring_row(int grow); + Utf8Char* u8c_hist_row(int hrow); + Utf8Char* u8c_hist_use_row(int hurow); + Utf8Char* u8c_disp_row(int drow); + Utf8Char* u8c_cursor(void); +private: + void create_ring(int drows, int dcols, int hrows); + void init_(int X,int Y,int W,int H,const char*L,int rows,int cols,int hist,bool fontsize_defer); + // Tabstops + void init_tabstops(int newsize); + void default_tabstops(void); + void clear_all_tabstops(void); + void set_tabstop(void); + void clear_tabstop(void); + // Updates + void update_screen_xywh(void); + void update_screen(bool font_changed); + void set_scrollbar_params(Fl_Scrollbar* scroll, int min, int max); + void update_scrollbar(void); + // Resize + void resize_display_rows(int drows); + void resize_display_columns(int dcols); + void refit_disp_to_screen(void); + // Callbacks + static void scrollbar_cb(Fl_Widget*, void*); // scrollbar manipulation + static void autoscroll_timer_cb(void*); // mouse drag autoscroll + void autoscroll_timer_cb2(void); + static void redraw_timer_cb(void*); // redraw rate limiting timer + void redraw_timer_cb2(void); + + // Screen management +protected: + CharStyle& current_style(void) const; + void current_style(const CharStyle& sty); +private: + int x_to_glob_col(int X, int grow, int &gcol, bool &gcr) const; + int xy_to_glob_rowcol(int X, int Y, int &grow, int &gcol, bool &gcr) const; +protected: + int w_to_col(int W) const; + int h_to_row(int H) const; + // API: Display clear operations + void clear_sod(void); + void clear_eod(void); + void clear_eol(void); + void clear_sol(void); + void clear_line(int row); + void clear_line(void); + const Utf8Char* walk_selection(const Utf8Char *u8c, int &row, int &col) const; + bool get_selection(int &srow,int &scol,int &erow,int &ecol) const; + bool is_selection(void) const; + bool is_inside_selection(int row,int col) const; +private: + bool is_hist_ring_row(int grow) const; + bool is_disp_ring_row(int grow) const; +public: + int selection_text_len(void) const; + const char* selection_text(void) const; +protected: + void clear_mouse_selection(void); + bool selection_extend(int X,int Y); + void select_word(int grow, int gcol); + void select_line(int grow); + void scroll(int rows); + void insert_rows(int count); + void delete_rows(int count); + void insert_char_eol(char c, int drow, int dcol, int rep); + void insert_char(char c, int rep); + void delete_chars(int drow, int dcol, int rep); + void delete_chars(int rep); +public: + // API: Terminal operations + void clear(void); + void clear(Fl_Color val); + void clear_screen(bool scroll_to_hist=true); // ESC [ 2 J + void clear_screen_home(bool scroll_to_hist=true); // ESC [ H ESC [ 2 J + void clear_history(void); // ESC [ 3 J + void reset_terminal(void); // ESC c + void cursor_home(void); // ESC [ 0 H + // API: Cursor + void cursorfgcolor(Fl_Color val); + void cursorbgcolor(Fl_Color val); + Fl_Color cursorfgcolor(void) const; + Fl_Color cursorbgcolor(void) const; +protected: + void cursor_row(int row); + void cursor_col(int col); +public: + int cursor_row(void) const; + int cursor_col(void) const; +protected: + void cursor_up(int count=1, bool do_scroll=false); + void cursor_down(int count=1, bool do_scroll=false); + void cursor_left(int count=1); + void cursor_right(int count=1, bool do_scroll=false); + void cursor_eol(void); + void cursor_sol(void); + void cursor_cr(void); + void cursor_crlf(int count=1); + void cursor_tab_right(int count=1); + void cursor_tab_left(int count=1); + void save_cursor(void); + void restore_cursor(void); + // Output translation +public: + void output_translate(Fl_Terminal::OutFlags val); + Fl_Terminal::OutFlags output_translate(void) const; +private: + void handle_lf(void); + void handle_cr(void); + void handle_esc(void); + // Printing + void handle_ctrl(char c); + bool is_printable(char c); + bool is_ctrl(char c); + void handle_SGR(void); + void handle_DECRARA(void); + void handle_escseq(char c); + // -- + void display_modified(void); + void display_modified_clear(void); + void clear_char_at_disp(int drow, int dcol); + const Utf8Char* utf8_char_at_disp(int drow, int dcol) const; + const Utf8Char* utf8_char_at_glob(int grow, int gcol) const; + void repeat_char(char c, int rep); + void utf8_cache_clear(void); + void utf8_cache_flush(void); + // API: Character display output +public: + void plot_char(const char *text, int len, int drow, int dcol); + void plot_char(char c, int drow, int dcol); + void print_char(const char *text, int len=-1); + void print_char(char c); + // API: String display output + void append_utf8(const char *buf, int len=-1); + void append_ascii(const char *s); + void append(const char *s, int len=-1); +protected: + int handle_unknown_char(void); + int handle_unknown_char(int drow, int dcol); + // Drawing + void draw_row_bg(int grow, int X, int Y) const; + void draw_row(int grow, int Y) const; + void draw_buff(int Y) const; +private: + void handle_selection_autoscroll(void); + int handle_selection(int e); +public: + // FLTK: draw(), resize(), handle() + void draw(void) FL_OVERRIDE; + void resize(int X,int Y,int W,int H) FL_OVERRIDE; + int handle(int e) FL_OVERRIDE; + const char* text(bool lines_below_cursor=false) const; + +protected: + // Internal short names + // Don't make these public, but allow internals and + // derived classes to maintain brevity. + // + /// Return the number of rows in the ring buffer. + inline int ring_rows(void) const { return ring_.ring_rows(); } + /// Return the number of columns in the ring buffer. + inline int ring_cols(void) const { return ring_.ring_cols(); } + /// Return the starting row# in the ring buffer. (Always 0) + inline int ring_srow(void) const { return ring_.ring_srow(); } + /// Return the ending row# in the ring buffer (Always ring_rows()-1) + inline int ring_erow(void) const { return ring_.ring_erow(); } + /// Return the number of rows in the scrollback history. + inline int hist_rows(void) const { return ring_.hist_rows(); } + /// Return the number of columns in the scrollback history. + inline int hist_cols(void) const { return ring_.hist_cols(); } + /// Return the starting row# of the scrollback history. + inline int hist_srow(void) const { return ring_.hist_srow(); } + /// Return the ending row# of the scrollback history. + inline int hist_erow(void) const { return ring_.hist_erow(); } + /// Return number of rows in use by the scrollback history. + inline int hist_use(void) const { return ring_.hist_use(); } + /// Return the starting row of the "in use" scrollback history. + inline int hist_use_srow(void) const { return ring_.hist_use_srow(); } + /// Return the number of rows in the display area. + inline int disp_rows(void) const { return ring_.disp_rows(); } + /// Return the number of columns in the display area. + inline int disp_cols(void) const { return ring_.disp_cols(); } + /// Return the starting row# in the display area. + inline int disp_srow(void) const { return ring_.disp_srow(); } + /// Return the ending row# in the display area. + inline int disp_erow(void) const { return ring_.disp_erow(); } + /// Returns the current offset into the ring buffer. + inline int offset(void) const { return ring_.offset(); } + + // TODO: CLEAN UP WHAT'S PUBLIC, AND WHAT SHOULD BE 'PROTECTED' AND 'PRIVATE' + // Some of the public stuff should, quite simply, "not be". + + // API: Terminal features +public: + // API: Scrollbar + int scrollbar_size(void) const; + void scrollbar_size(int val); + int scrollbar_actual_size(void) const; + void hscrollbar_style(ScrollbarStyle val); + ScrollbarStyle hscrollbar_style(void) const; + // API: History + int history_rows(void) const; + void history_rows(int val); + int history_use(void) const; + // API: Display + int display_rows(void) const; + void display_rows(int val); + int display_columns(void) const; + void display_columns(int val); + // API: Box + /// Sets the box type, updates terminal margins et al. Default is FL_DOWN_FRAME. + /// + /// FL_XXX_FRAME types are handled in a special way by this widget, and guarantee + /// the background is a flat field. + /// + /// FL_XXX_BOX may draw gradients as inherited by Fl::scheme(). + /// + void box(Fl_Boxtype val) { Fl_Group::box(val); update_screen(false); } + /// Returns the current box type. + Fl_Boxtype box(void) const { return Fl_Group::box(); } + // API: Margins + /// Return the left margin; see \ref Fl_Terminal_Margins. + int margin_left(void) const { return margin_.left(); } + /// Return the right margin; see \ref Fl_Terminal_Margins. + int margin_right(void) const { return margin_.right(); } + /// Return the top margin; see \ref Fl_Terminal_Margins. + int margin_top(void) const { return margin_.top(); } + /// Return the bottom margin; see \ref Fl_Terminal_Margins. + int margin_bottom(void) const { return margin_.bottom(); } + void margin_left(int val); + void margin_right(int val); + void margin_top(int val); + void margin_bottom(int val); + // API: Text font/size/color + void textfont(Fl_Font val); + void textsize(Fl_Fontsize val); + void textcolor(Fl_Color val); + void color(Fl_Color val); + void textfgcolor(Fl_Color val); + void textbgcolor(Fl_Color val); + void textfgcolor_default(Fl_Color val); + void textbgcolor_default(Fl_Color val); + /// Return text font used to draw all text in the terminal. + Fl_Font textfont(void) const { return current_style_->fontface(); } + /// Return text font size used to draw all text in the terminal. + Fl_Fontsize textsize(void) const { return current_style_->fontsize(); } + /// Return base widget Fl_Group's box() color() + Fl_Color color(void) const { return Fl_Group::color(); } + /// Return textcolor(). This is a convenience method that returns textfgcolor_default() + Fl_Color textcolor(void) const { return textfgcolor_default(); } + /// Return text's current foreground color. + Fl_Color textfgcolor(void) const { return current_style_->fgcolor(); } + /// Return text's current background color. + Fl_Color textbgcolor(void) const { return current_style_->bgcolor(); } + /// Return text's default foreground color. \see textfgcolor() + Fl_Color textfgcolor_default(void) const { return current_style_->defaultfgcolor(); } + /// Return text's default background color. \see textbgcolor() + Fl_Color textbgcolor_default(void) const { return current_style_->defaultbgcolor(); } + void textfgcolor_xterm(uchar val); + void textbgcolor_xterm(uchar val); + /// Set mouse selection foreground color. + void selectionfgcolor(Fl_Color val) { select_.selectionfgcolor(val); } + /// Set mouse selection background color. + void selectionbgcolor(Fl_Color val) { select_.selectionbgcolor(val); } + /// Get mouse selection foreground color. + Fl_Color selectionfgcolor(void) const { return select_.selectionfgcolor(); } + /// Get mouse selection background color. + Fl_Color selectionbgcolor(void) const { return select_.selectionbgcolor(); } + // API: Text attrib + void textattrib(uchar val); + uchar textattrib() const; + // API: Redraw style/rate + RedrawStyle redraw_style(void) const; + void redraw_style(RedrawStyle val); +private: + bool is_redraw_style(RedrawStyle val) { return redraw_style_ == val; } +public: + float redraw_rate(void) const; + void redraw_rate(float val); + // API: Show unknown/invalid utf8/ANSI sequences with an error character (¿). + bool show_unknown(void) const; + void show_unknown(bool val); + /// Sets the "error character" utf8 string shown for invalid utf8 + /// or bad ANSI sequences if show_unknown() is true. Default: "¿". + /// \see show_unknown(bool) + void error_char(const char* val) { error_char_ = val; } + /// Returns the "error character" utf8 string, which is shown for invalid utf8 + /// or bad ANSI sequences if show_unknown() is true. \see show_unknown(bool) + const char* error_char(void) const { return error_char_; } + // API: ANSI sequences + bool ansi(void) const; + void ansi(bool val); + // Fl_Simple_Terminal API compatibility + int history_lines(void) const; + void history_lines(int val); + // API: printf() + void printf(const char *fmt, ...); + void vprintf(const char *fmt, va_list ap); + // Ctor + Fl_Terminal(int X,int Y,int W,int H,const char*L=0); + Fl_Terminal(int X,int Y,int W,int H,const char*L,int rows,int cols,int hist); + // Dtor + ~Fl_Terminal(void); + // Debugging features +//DEBUG void show_ring_info() const { ring_.show_ring_info(); } +//DEBUG void write_row(FILE *fp, Utf8Char *u8c, int cols) const; +//DEBUG void show_buffers(RingBuffer *a, RingBuffer *b=0) const; +}; +#endif diff --git a/include/linux/amd64/FL/Fl_Text_Buffer.H b/include/linux/amd64/FL/Fl_Text_Buffer.H new file mode 100644 index 0000000..f548f1e --- /dev/null +++ b/include/linux/amd64/FL/Fl_Text_Buffer.H @@ -0,0 +1,886 @@ +// +// Header file for Fl_Text_Buffer class. +// +// Copyright 2001-2023 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Text_Buffer, Fl_Text_Selection widget . */ + +#ifndef FL_TEXT_BUFFER_H +#define FL_TEXT_BUFFER_H + +#include /* va_list */ +#include "fl_attr.h" /* Doxygen can't find */ + +#undef ASSERT_UTF8 + +#ifdef ASSERT_UTF8 +# include +# define IS_UTF8_ALIGNED(a) if (a && *a) assert(fl_utf8len(*(a))>0); +# define IS_UTF8_ALIGNED2(a, b) if (b>=0 && blength()) 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 originally 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 characters 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_Undo_Action_List; +class Fl_Text_Undo_Action; + +/** + \class Fl_Text_Selection + \brief This is an internal class for Fl_Text_Buffer to manage text selections. + + All methods use byte (not UTF-8 character) offsets and start at 0. This + class works correctly with UTF-8 strings assuming that the parameters + for all calls are on character boundaries. + + If the selection is inactive (not currently used), then selected() + returns \p false and start() and end() return 0 (zero). + + The stored offsets are in ascending order, hence the following conditions + are true (pseudo code): + \code + if ( !selected() ) : (start() == 0) && (end() == 0) && (start() == end()) + if ( selected() ) : start() < end() + always : 0 <= start() <= end() + always : length() == end() - start() + \endcode + + The selection size in bytes can always (unconditionally) be computed by + \code + int size = sel->end() - sel->start(); + \endcode + + \see length() + + \note + The \b protected member variables \p mStart and \p mEnd are not + necessarily 0 (zero) if mSelected == \p false because they are + not cleared when \p selected(false) is called (as of Jul 2017). + This may be changed in the future. +*/ +class FL_EXPORT Fl_Text_Selection { + friend class Fl_Text_Buffer; + +public: + + // Sets the selection range and selected(). + void set(int startpos, int endpos); + + // Updates a selection after text was modified. + void update(int pos, int nDeleted, int nInserted); + + /** + \brief Returns the byte offset to the first selected character. + + The returned offset is only valid if selected() returns true. + If the selection is not valid the returned offset is 0 since FLTK 1.4.0. + + \note In FLTK 1.3.x the returned offset could be non-zero even if + selected() would have returned 0. + + \return byte offset or 0 if not selected. + */ + int start() const { return mSelected ? mStart : 0; } + + /** + \brief Returns the byte offset to the character after the last selected character. + + The returned offset is only valid if selected() returns true (non-zero). + The offset is 0 if no text is selected (since FLTK 1.4.0). + + \note In FLTK 1.3.x the returned offset could be non-zero even if + selected() would have returned 0. + + \return byte offset or 0 if not selected. + */ + int end() const { return mSelected ? mEnd : 0; } + + /** + \brief Returns true if any text is selected. + \return \p true if any text has been selected, or \p false + if no text is selected. + */ + bool selected() const { return mSelected; } + + /** + \brief Modifies the 'selected' flag. + \param b new flag + */ + void selected(bool b) { mSelected = b; } + + /** + \brief Returns the size in bytes of the selection. + + This is a convenience method. It always returns the same as + \code + end() - start() + \endcode + and it returns 0 if selected() == false. + + \return size in bytes or 0 if not selected. + + \since FLTK 1.4.0 + */ + int length() const { return mSelected ? mEnd - mStart : 0; } + + // Returns true if position \p pos is in this Fl_Text_Selection. + int includes(int pos) const; + + // Returns true if selected() and the positions of this selection. + int selected(int *startpos, int *endpos) const; + FL_DEPRECATED("since 1.4.0 - use selected(startpos, endpos) instead", + int position(int *startpos, int *endpos) const) { return selected(startpos, endpos); } + +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); + + +/** + This class manages Unicode text displayed in one or more Fl_Text_Display widgets. + + All text in Fl_Text_Buffer must 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 unsigned 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 https://sourceforge.net/projects/nedit/. + */ +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 characters) + */ + 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 UTF-8 + */ + char* text() const; + + /** + Replaces the entire contents of the text buffer. + \param text Text must be valid UTF-8. If null, an empty string is substituted. + */ + 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 UTF-8 + */ + char* text_range(int start, int end) const; + + /** + Returns the character at the specified position \p pos in the buffer. + Positions start at 0. + \param pos byte offset into buffer, \p pos must be at a UTF-8 character 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 text + \param insertedLength number of bytes to insert, or -1 to indicate \p text is null-terminated + */ + void insert(int pos, const char* text, int insertedLength = -1); + + /** + Appends the text string to the end of the buffer. + \param t UTF-8 encoded text + \param addedLength number of bytes to append, or -1 to indicate \p t is null-terminated + */ + void append(const char* t, int addedLength = -1) { insert(length(), t, addedLength); } + + void vprintf(const char *fmt, va_list ap); + void printf(const char* fmt, ...); + + /** + Deletes a range of characters in the buffer. + \param start byte offset to first character to be removed + \param end byte offset to character 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 character after last character to be removed + \param text UTF-8 encoded text + \param insertedLength number of bytes to insert, or -1 to indicate \p text is null-terminated + */ + void replace(int start, int end, const char *text, int insertedLength = -1); + + /** + Copies text from another Fl_Text_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); + + /** + Check if undo is enabled and if the last action can be undone. + \see canUndo() + */ + bool can_undo() const; + + /** + Redo previous undo action. + */ + int redo(int *cp=0); + + /** + Check if undo is enabled and if the last undo action can be redone. + \see canUndo() + */ + bool can_redo() const; + + /** + Enable or disable undo actions for this text buffer. + Undo actions are enable for text buffer by default. If used as a style buffer + in Fl_Text_Display, undo actions are disabled as they are handled by the + text buffer. + \see can_undo() + */ + 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 data transcoded to UTF-8. 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 text buffer 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) + + \see savefile(const char *file, int buflen) + */ + int outputfile(const char *file, int start, int end, int buflen = 128*1024); + + /** + Saves a text file from the current buffer. + 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) + + \see outputfile(const char *file, int start, int end, int buflen) + */ + int savefile(const char *file, int buflen = 128*1024) + { return outputfile(file, 0, length(), buflen); } + + /** + Gets the tab width. + + The tab width is measured in characters. The pixel position is + calculated using an average character 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-zero 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-zero 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 a non-zero value if text has been highlighted, 0 otherwise. + */ + 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 UTF-8 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; + + /** + Estimate the number of newlines between \p startPos and \p endPos in buffer. + This call takes line wrapping into account. It assumes a line break at every + `lineLen` characters after the beginning of a line. + */ + int estimate_lines(int startPos, int endPos, int lineLen) 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 search_forward() 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 \e before \p startPos, returning the result in \p foundPos. + + Returns 1 if found, 0 if not. The difference between this and + search_backward() 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 UTF-8 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 \p searchString, starting with + the character \e at \p startPos, returning the result in \p foundPos. + + Returns 1 if found, 0 if not. + \param startPos byte offset to start position + \param searchString UTF-8 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 character + */ + 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 character + */ + int next_char(int ix) const; + int next_char_clipped(int ix) const; + + /** + Align an index into the buffer to the current or previous UTF-8 boundary. + */ + int utf8_align(int) const; + + /** + \brief true if 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*); + bool is_word_separator(int pos) const; + +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 insert(). + + Returns the length of text inserted (this is just strlen(\p text) if + \p insertedLength == -1, 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, int insertedLength = -1); + + /** + Internal (non-redisplaying) version of remove(). + + Removes the contents of the buffer between \p start and \p 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); + + /** + Apply the current undo/redo operation, called from undo() or redo(). + */ + int apply_undo(Fl_Text_Undo_Action* action, int* cursorPos); + + 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 character 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 */ + Fl_Text_Undo_Action* mUndo; /**< local undo event */ + Fl_Text_Undo_Action_List* mUndoList; /**< List of undo event */ + Fl_Text_Undo_Action_List* mRedoList; /**< List of redo event */ +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Text_Display.H b/include/linux/amd64/FL/Fl_Text_Display.H new file mode 100644 index 0000000..533839a --- /dev/null +++ b/include/linux/amd64/FL/Fl_Text_Display.H @@ -0,0 +1,669 @@ +// +// Header file for Fl_Text_Display class. +// +// Copyright 2001-2023 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Text_Display widget . */ + +#ifndef FL_TEXT_DISPLAY_H +#define FL_TEXT_DISPLAY_H + +#include // Fl::scrollbar_size() +#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, word wrap, mixes + of font faces and colors, line numbers 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. + + \image html editor.png "Fl_Text_Display widget" + \image latex editor.png "Fl_Text_Display widget" width=10cm +

    + \image html editor-linenumbers.png "Fl_Text_Display widget with line numbers enabled" + \image latex editor-linenumbers.png "Fl_Text_Display widget with line numbers enabled" width=10cm + + \b Example \b Use + \code + #include + .. + int main() { + .. + Fl_Text_Buffer *buff = new Fl_Text_Buffer(); + Fl_Text_Display *disp = new Fl_Text_Display(10, 10, 640, 480); + disp->buffer(buff); // attach text buffer to display widget + buff->text("line one\nline two"); // add some text to buffer + .. + } + \endcode + + \b Features + + - Word wrap: wrap_mode(), wrapped_column(), wrapped_row() + - Font control: textfont(), textsize(), textcolor() + - Font styling: highlight_data() + - Cursor: cursor_style(), show_cursor(), hide_cursor(), cursor_color() + - Line numbers: linenumber_width(), linenumber_font(), + linenumber_size(), linenumber_fgcolor(), linenumber_bgcolor(), + linenumber_align(), linenumber_format() + + Note that other features may be available via Fl_Text_Editor + and Fl_Text_Buffer classes. + + \note Line numbers were added in FLTK 1.3.3. + \see Fl_Widget::shortcut_label(int) + */ +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 */ + SIMPLE_CURSOR /**< as cursor as Fl_Input cursor */ + }; + + /** + 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 int fl_text_drag_prepare(int pos, int key, Fl_Text_Display* d); + 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, and font size of a string to draw + with an attribute mask matching attr. + + There must be one entry for each style that can be used in an + Fl_Text_Display for displaying text. The style table is an array of + struct Style_Table_Entry. + + The style table is associated with an Fl_Text_Display by using + Fl_Text_Display::highlight_data(). + + \see Fl_Text_Display::highlight_data() + */ + struct Style_Table_Entry { + Fl_Color color; ///< text color + Fl_Font font; ///< text font + Fl_Fontsize size; ///< text font size + unsigned attr; ///< further attributes for the text style (see `ATTR_BGCOLOR`, etc.) + Fl_Color bgcolor; ///< text background color if `ATTR_BGCOLOR` or `ATTR_BGCOLOR_EXT` is set + }; + + /** + attribute flags in `Style_Table_Entry.attr` + */ + enum { + ATTR_BGCOLOR = 0x0001, ///< use the background color in the `bgcolor` field + ATTR_BGCOLOR_EXT_ = 0x0002, ///< (internal use) + ATTR_BGCOLOR_EXT = 0x0003, ///< extend background color to the end of the line + ATTR_UNDERLINE = 0x0004, ///< a single underline, underline types are mutually exclusive + ATTR_GRAMMAR = 0x0008, ///< grammar suggestion (blue dotted underline) + ATTR_SPELLING = 0x000C, ///< spelling suggestion (red dotted underline) + ATTR_STRIKE_THROUGH = 0x0010, ///< line through the middle of the text + ATTR_LINES_MASK = 0x001C ///< the mask for all underline and strike through types + }; + + Fl_Text_Display(int X, int Y, int W, int H, const char *l = 0); + ~Fl_Text_Display(); + + int handle(int e) FL_OVERRIDE; + + 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 + \see Fl_Text_Display::buffer(Fl_Text_Buffer* buf) + */ + 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 + \see Fl_Text_Display::buffer(Fl_Text_Buffer* buf) + \see Fl_Text_Display::buffer(Fl_Text_Buffer& buf) + */ + Fl_Text_Buffer* buffer() const { return mBuffer; } + /** + Gets the current style buffer associated with the text widget. + Multiple text widgets can be associated with the same style buffer. + \return current style buffer + \see Fl_Text_Display::highlight_data() + */ + Fl_Text_Buffer* style_buffer() const { return mStyleBuffer; } + + 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. + + The insert position is the byte count (offset) from the beginning + of the text buffer (starting with 0). Returns 0 (zero) if no buffer + is associated to the text display. Returns buffer()->length() if the + insert position is at the end of the buffer. + + \returns insert position index into text buffer + \see insert_position(int) + */ + 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); + int cursor_style() const { return mCursorStyle; } + + /** + 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;} + + /** + Returns the global value Fl::scrollbar_size() unless a specific scrollbar_width_ has been set. + \deprecated Use scrollbar_size() instead. + \todo This method should eventually be removed. + */ + int scrollbar_width() const { + return scrollbar_width_ ? scrollbar_width_ : Fl::scrollbar_size(); + } + + /** + Sets the global Fl::scrollbar_size(), and forces this instance of the widget to use it. + \deprecated Use scrollbar_size() instead. + \todo This method should eventually be removed + */ + void scrollbar_width(int width) { + Fl::scrollbar_size(width); + scrollbar_width_ = 0; + } + + /** + 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_width_); + } + + /** + Sets the pixel size of the scrollbars' troughs to \p newSize, 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 newSize to the special value of 0 causes the widget to + track the global Fl::scrollbar_size(), which is the default. + + \param[in] newSize 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 newSize) { + scrollbar_width_ = newSize; + } + + /** + 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;} + + /** + Sets the underline color for style attribute ATTR_GRAMMAR. + \param color underline color + */ + void grammar_underline_color(Fl_Color color) { grammar_underline_color_ = color; } + + /** + Gets the underline color for style attribute ATTR_GRAMMAR. + \return underline color + */ + Fl_Color grammar_underline_color() const { return grammar_underline_color_;} + + /** + Sets the underline color for style attribute ATTR_SPELLING. + \param color underline color + */ + void spelling_underline_color(Fl_Color color) { spelling_underline_color_ = color; } + + /** + Gets the underline color for style attribute ATTR_SPELLING. + \return underline color + */ + Fl_Color spelling_underline_color() const { return spelling_underline_color_;} + + /** + Sets the background color for the secondary selection block. + \param color background color + */ + void secondary_selection_color(Fl_Color color) { secondary_selection_color_ = color; } + + /** + Gets the background color for the secondary selection block. + \return background color color + */ + Fl_Color secondary_selection_color() const { return secondary_selection_color_;} + + int wrapped_column(int row, int column) const; + int wrapped_row(int row) const; + void wrap_mode(int wrap, int wrap_margin); + + virtual void recalc_display(); + virtual void display_needs_recalc(); + void resize(int X, int Y, int W, int H) FL_OVERRIDE; + + /** + 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; + + void linenumber_width(int width); + int linenumber_width() const; + void linenumber_font(Fl_Font val); + Fl_Font linenumber_font() const; + void linenumber_size(Fl_Fontsize val); + Fl_Fontsize linenumber_size() const; + void linenumber_fgcolor(Fl_Color val); + Fl_Color linenumber_fgcolor() const; + void linenumber_bgcolor(Fl_Color val); + Fl_Color linenumber_bgcolor() const; + void linenumber_align(Fl_Align val); + Fl_Align linenumber_align() const; + void linenumber_format(const char* val); + const char* linenumber_format() 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. + + void draw() FL_OVERRIDE; + 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, + FIND_CURSOR_INDEX // STR #2788 + }; + + int handle_vline(int mode, + int lineStart, int lineLen, int leftChar, int rightChar, + int topClip, int bottomClip, + int leftClip, int rightClip) const; + + int handle_rmb(int readonly); + + 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. This is + also the size of the mLineStarts[] array. */ + int mNBufferLines; /* # of newlines in the buffer, or number of + wraps if line wrapping is enabled. Note that + partial lines at the end of the buffer are + not counted, so you may want to add 1. */ + 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; /* Array of the size mNVisibleLines. + This array only keeps track of lines + within the display area. Each entry + contains the starting character offset + (from the beginning of the text buffer) + for each /visible/ line. + If wrap enabled, points to the beginning + of each wrap. So a long line wrapping + into 3 separate lines in the display + will take up 3 separate array entries. */ + 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 XXX: UNUSED */ + + 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" */ + + bool display_needs_recalc_; /* Set to true when the display needs + to be recalculated. */ + + Fl_Color mCursor_color; + + Fl_Scrollbar* mHScrollBar; + Fl_Scrollbar* mVScrollBar; + int scrollbar_width_; // size of scrollbar trough (behavior changed in 1.4) + 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_; + Fl_Color grammar_underline_color_; + Fl_Color spelling_underline_color_; + Fl_Color secondary_selection_color_; + + // Line number margin and width + int mLineNumLeft, mLineNumWidth; + + // Line number font/colors + Fl_Font linenumber_font_; + Fl_Fontsize linenumber_size_; + Fl_Color linenumber_fgcolor_; + Fl_Color linenumber_bgcolor_; + Fl_Align linenumber_align_; + const char* linenumber_format_; +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Text_Editor.H b/include/linux/amd64/FL/Fl_Text_Editor.H new file mode 100644 index 0000000..16af254 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Text_Editor.H @@ -0,0 +1,139 @@ +// +// Header file for Fl_Text_Editor class. +// +// Copyright 2001-2023 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 item 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(); } + int handle(int e) FL_OVERRIDE; + /** + 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 tab_nav(int val); + int tab_nav() const; + void add_key_binding(int key, int state, Key_Func f, Key_Binding** list); + /** Adds a \p key of state \p state with the function \p f. */ + 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) const; + /** Returns the function associated with a key binding. */ + Key_Func bound_key_function(int key, int state) const + { 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); + static int kf_redo(int c, Fl_Text_Editor* e); + + protected: + int handle_key(); + void maybe_do_callback(Fl_Callback_Reason reason = FL_REASON_CHANGED); + +#ifndef FL_DOXYGEN + int insert_mode_; + Key_Binding* key_bindings; +#endif + + /** Global key binding list. + + Derived classes can add key bindings for all Fl_Text_Editor widgets + by adding a Key_Binding to this list. + + \see add_key_binding(int key, int state, Key_Func f, Key_Binding** list); + */ + static Key_Binding* global_key_bindings; + +#ifndef FL_DOXYGEN + Key_Func default_key_function_; +#endif +}; + +#endif + diff --git a/include/linux/amd64/FL/Fl_Tile.H b/include/linux/amd64/FL/Fl_Tile.H new file mode 100644 index 0000000..189e0f6 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Tile.H @@ -0,0 +1,75 @@ +// +// Tile header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Tile_H +#define Fl_Tile_H + +#include "Fl_Group.H" + +/* + The Fl_Tile class lets you resize its children by dragging + the border between them. +*/ + +class FL_EXPORT Fl_Tile : public Fl_Group { +public: + int handle(int event) FL_OVERRIDE; + Fl_Tile(int X, int Y, int W, int H, const char *L=0); + ~Fl_Tile() FL_OVERRIDE; + void resize(int X, int Y, int W, int H) FL_OVERRIDE; + virtual void move_intersection(int oldx, int oldy, int newx, int newy); + virtual void drag_intersection(int oldx, int oldy, int newx, int newy); + FL_DEPRECATED("since 1.4.0 - use move_intersection(p) instead", + void position(int oldx, int oldy, int newx, int newy)) { move_intersection(oldx, oldy, newx, newy); } + void position(int x, int y) { Fl_Group::position(x, y); } + void size_range(int index, int minw, int minh, int maxw=0x7FFFFFFF, int maxh=0x7FFFFFFF); + void size_range(Fl_Widget *w , int minw, int minh, int maxw=0x7FFFFFFF, int maxh=0x7FFFFFFF); + void init_size_range(int default_min_w = -1, int default_min_h = -1); + +protected: + int cursor_; ///< current cursor index (0..3) + Fl_Cursor *cursors_; ///< points at the array of 4 cursors (may be overridden) + + /** Returns the cursor for cursor index n. + \see Fl_Tile::set_cursor(int) + */ + + Fl_Cursor cursor(int n) { + return cursors_[n]; + } + + void set_cursor(int n); // set one of n (0..3) cursors + + typedef struct { int minw, minh, maxw, maxh; } Size_Range; + + Size_Range *size_range_; + int size_range_size_, size_range_capacity_; + int default_min_w_, default_min_h_; + void request_shrink_l(int old_l, int &new_l, Fl_Rect *final_size); + void request_shrink_r(int old_r, int &new_r, Fl_Rect *final_size); + void request_shrink_t(int old_t, int &new_t, Fl_Rect *final_size); + void request_shrink_b(int old_b, int &new_b, Fl_Rect *final_size); + void request_grow_l(int old_l, int &new_l, Fl_Rect *final_size); + void request_grow_r(int old_r, int &new_r, Fl_Rect *final_size); + void request_grow_t(int old_t, int &new_t, Fl_Rect *final_size); + void request_grow_b(int old_b, int &new_b, Fl_Rect *final_size); + + int on_insert(Fl_Widget*, int) FL_OVERRIDE; + int on_move(int, int) FL_OVERRIDE; + void on_remove(int) FL_OVERRIDE; +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Tiled_Image.H b/include/linux/amd64/FL/Fl_Tiled_Image.H new file mode 100644 index 0000000..10015aa --- /dev/null +++ b/include/linux/amd64/FL/Fl_Tiled_Image.H @@ -0,0 +1,54 @@ +// +// Tiled image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2015 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 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 tiled + 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(); + + Fl_Image *copy(int W, int H) const FL_OVERRIDE; + Fl_Image *copy() const { + return Fl_Image::copy(); + } + void color_average(Fl_Color c, float i) FL_OVERRIDE; + void desaturate() FL_OVERRIDE; + void draw(int X, int Y, int W, int H, int cx = 0, int cy = 0) FL_OVERRIDE; + void draw(int X, int Y) { draw(X, Y, w(), h(), 0, 0); } + /** Gets The image that is tiled */ + Fl_Image *image() { return image_; } +}; + +#endif // !Fl_Tiled_Image_H diff --git a/include/linux/amd64/FL/Fl_Timer.H b/include/linux/amd64/FL/Fl_Timer.H new file mode 100644 index 0000000..b79bbeb --- /dev/null +++ b/include/linux/amd64/FL/Fl_Timer.H @@ -0,0 +1,72 @@ +// +// Timer header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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() FL_OVERRIDE; +public: + int handle(int) FL_OVERRIDE; + 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 + diff --git a/include/linux/amd64/FL/Fl_Toggle_Button.H b/include/linux/amd64/FL/Fl_Toggle_Button.H new file mode 100644 index 0000000..b2e0eda --- /dev/null +++ b/include/linux/amd64/FL/Fl_Toggle_Button.H @@ -0,0 +1,44 @@ +// +// Toggle button header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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.

    +

    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. +

    The inherited destructor deletes the toggle button. + */ + Fl_Toggle_Button(int X,int Y,int W,int H,const char *l=0); +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Toggle_Light_Button.H b/include/linux/amd64/FL/Fl_Toggle_Light_Button.H new file mode 100644 index 0000000..60dacd8 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Toggle_Light_Button.H @@ -0,0 +1,22 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 diff --git a/include/linux/amd64/FL/Fl_Toggle_Round_Button.H b/include/linux/amd64/FL/Fl_Toggle_Round_Button.H new file mode 100644 index 0000000..7fe5e19 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Toggle_Round_Button.H @@ -0,0 +1,22 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 diff --git a/include/linux/amd64/FL/Fl_Tooltip.H b/include/linux/amd64/FL/Fl_Tooltip.H new file mode 100644 index 0000000..b79d931 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Tooltip.H @@ -0,0 +1,123 @@ +// +// Tooltip header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2011 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Tooltip widget . */ + +#ifndef Fl_Tooltip_H +#define Fl_Tooltip_H + +#include +#include + +/** + The Fl_Tooltip class provides tooltip support for + all FLTK widgets. It contains only static methods. + + \image html tooltip-options.png "Fl_Tooltip Options" + \image latex src/tooltip-options.png "Fl_Tooltip Options" width=6cm + +*/ +class FL_EXPORT Fl_Tooltip { + friend class Fl_TooltipBox; +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 time until an open tooltip hides again. The default delay is 12.0 seconds. */ + static float hidedelay() { return hidedelay_; } + /** Sets the time until an open tooltip hides again. The default delay is 12.0 seconds. */ + static void hidedelay(float f) { hidedelay_ = 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 b 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; } + /** Gets the amount of extra space left/right of the tooltip's text. Default is 3. */ + static int margin_width() { return margin_width_; } + /** Sets the amount of extra space left/right of the tooltip's text. Default is 3. */ + static void margin_width(int v) { margin_width_ = v; } + /** Gets the amount of extra space above and below the tooltip's text. Default is 3. */ + static int margin_height() { return margin_height_; } + /** Sets the amount of extra space above and below the tooltip's text. Default is 3. */ + static void margin_height(int v) { margin_height_ = v; } + /** Gets the maximum width for tooltip's text before it word wraps. Default is 400. */ + static int wrap_width() { return wrap_width_; } + /** Sets the maximum width for tooltip's text before it word wraps. Default is 400. */ + static void wrap_width(int v) { wrap_width_ = v; } + /** Returns the window that is used for tooltips */ + static Fl_Window* current_window(void); + + // 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 hidedelay_; //!< delay until tooltip is closed again + 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 + static int margin_width_; //!< distance around tooltip text left+right + static int margin_height_; //!< distance around tooltip text top+bottom + static int wrap_width_; //!< maximum width of tooltip text before it word wraps + static const int draw_symbols_; // 1 = draw @-symbols in tooltips, 0 = no +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Tree.H b/include/linux/amd64/FL/Fl_Tree.H new file mode 100644 index 0000000..6c2b7bf --- /dev/null +++ b/include/linux/amd64/FL/Fl_Tree.H @@ -0,0 +1,492 @@ +// + +#ifndef FL_TREE_H +#define FL_TREE_H + +#include +#include +#include +#include + +#include +#include + +////////////////////// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/// +/// \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 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: + \par + \code + #include + [..] + 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 + + \par FEATURES + 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 close(),
    + positioned on the screen with show_item_top(), show_item_middle() and + show_item_bottom(),
    + item children can be swapped around with Fl_Tree_Item::swap_children(),
    + items can be moved around with Fl_Tree_Item::move(),
    + an item's children can be walked with Fl_Tree_Item::first() and Fl_Tree_Item::next(), + an item's children can be indexed directly with Fl_Tree_Item::child() + and Fl_Tree_Item::children(),
    + items can be moved from one subtree to another with Fl_Tree_Item::deparent() + and Fl_Tree_Item::reparent(),
    + sorting can be controlled when items are add()ed via sortorder().
    + You can walk the entire tree with first() and next().
    + You can walk visible items with first_visible_item() + and next_visible_item().
    + 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).
    + A hook is provided to allow you to redefine how item's labels are drawn + via Fl_Tree::item_draw_callback().
    + Items can be interactively dragged using FL_TREE_SELECT_SINGLE_DRAGGABLE. + + \par SELECTION OF ITEMS + The tree can have different selection behaviors controlled by selectmode(). + The background color used for selected items is the Fl_Tree::selection_color(). + The foreground color for selected items is controlled internally with fl_contrast(). + + \par CHILD WIDGETS + FLTK widgets (including custom widgets) can be assigned to tree items via + Fl_Tree_Item::widget(). + \par + When an Fl_Tree_Item::widget() is defined, the default behavior is for the + widget() to be shown in place of the item's label (if it has one). + Only the widget()'s width will be used; the widget()'s x() and y() position + will be managed by the tree, and the h() will track the item's height. + This default behavior can be altered (ABI 1.3.1): + Setting Fl_Tree::item_draw_mode()'s FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET flag + causes the label + widget to be displayed together in that order, and + adding the FL_TREE_ITEM_HEIGHT_FROM_WIDGET flag causes widget's height + to define the widget()'s height. + + \par ICONS + The tree's open/close icons can be redefined with + Fl_Tree::openicon(), Fl_Tree::closeicon(). User icons + can either be changed globally with Fl_Tree::usericon(), + or on a per-item basis with Fl_Tree_Item::usericon(). + \par + Various default preferences can be globally manipulated via Fl_Tree_Prefs, + including colors, margins, icons, connection lines, etc. + + \par FONTS AND COLORS + When adding new items to the tree, the new items get the + defaults for fonts and colors from: + \par + - Fl_Tree::item_labelfont() -- The default item label font (default: FL_HELVETICA) + - Fl_Tree::item_labelsize() -- The default item label size (default: FL_NORMAL_SIZE) + - Fl_Tree::item_labelfgcolor() -- The default item label foreground color (default: FL_FOREGROUND_COLOR) + - Fl_Tree::item_labelbgcolor() -- The default item label background color (default: 0xffffffff, which tree uses as 'transparent') + \par + Each item (Fl_Tree_Item) inherits a copy of these font/color attributes when created, + and each item has its own methods to let the app change these values on a per-item basis + using methods of the same name: + \par + - Fl_Tree_Item::labelfont() -- The item's label font (default: FL_HELVETICA) + - Fl_Tree_Item::labelsize() -- The item's label size (default: FL_NORMAL_SIZE) + - Fl_Tree_Item::labelfgcolor() -- The item's label foreground color (default: FL_FOREGROUND_COLOR) + - Fl_Tree_Item::labelbgcolor() -- The item's label background color (default: 0xffffffff, which uses the tree's own bg color) + + \par CALLBACKS + 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. e.g. + \par + \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_RESELECTED: [..] + case FL_TREE_REASON_OPENED: [..] + case FL_TREE_REASON_CLOSED: [..] + } + : + } + \endcode + + \par SIMPLE EXAMPLES + To find all the selected items: + \par + \code + for ( Fl_Tree_Item *i=first_selected_item(); i; i=next_selected_item(i) ) + printf("Item %s is selected\n", i->label()); + \endcode + \par + To get an item's full menu pathname, use Fl_Tree::item_pathname(), e.g. + \par + \code + [..] + char pathname[256] = "???"; + tree->item_pathname(pathname, sizeof(pathname), item); // eg. "Parent/Child/Item" + [..] + \endcode + \par + To walk all the items of the tree from top to bottom: + \par + \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 + \par + To recursively walk all the children of a particular item, + define a function that uses recursion: + \par + \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; tchildren(); t++ ) { + printf("%*s Item: %s\n", indent, "", item->child(t)->label()); + my_print_all_children(item->child(t), indent+4); // recurse + } + } + \endcode + \par + To change the default label font and color when creating new items: + \par + \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 + \par + To change the font and color of all existing items in the tree: + \par + \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 + + \par DISPLAY DESCRIPTION + The following image shows the tree's various visual elements + and the methods that control them: + \par + \image html tree-elements.png + \image latex tree-elements.png "Fl_Tree elements" width=6cm + \par + The following shows the protected dimension variables 'tree inner' (tix..) + and 'tree outer' (tox..): + \image html tree-dimensions.png "Fl_Tree inner/outer dimensions" width=6cm + \image latex tree-dimensions.png "Fl_Tree inner/outer dimensions" width=6cm + + \par KEYBOARD BINDINGS + The following table lists keyboard bindings for navigating the tree: + \par + Keyboard | FL_TREE_SELECT_MULTI | FL_TREE_SELECT_SINGLE | FL_TREE_SELECT_NONE | + ------------------------|-----------------------------|-----------------------------|-----------------------------| + Ctrl-A (Linux/Windows) | Select all items | N/A | N/A | + Command-A (Mac) | Select all items | N/A | N/A | + Space | Selects item | Selects item | N/A | + Ctrl-Space | Toggle item | Toggle item | N/A | + Shift-Space | Extends selection | Selects item | N/A | + Enter | Toggles open/close | Toggles open/close | Toggles open/close | + Ctrl-Enter | Toggles open/close | Toggles open/close | Toggles open/close | + Shift-Enter | Toggles open/close | Toggles open/close | Toggles open/close | + Right / Left | Open/Close item | Open/Close item | Open/Close item | + Up / Down | Move focus box up/down | Move focus box up/down | N/A | + Shift-Up / Shift-Down | Extend selection up/down | Move focus up/down | N/A | + Home / End | Move to top/bottom of tree | Move to top/bottom of tree | Move to top/bottom of tree | + PageUp / PageDown | Page up/down | Page up/down | Page up/down | + +*/ + +/// \enum Fl_Tree_Reason +/// The reason the callback was invoked. +/// +enum Fl_Tree_Reason { + FL_TREE_REASON_NONE = FL_REASON_UNKNOWN, ///< unknown reason + FL_TREE_REASON_SELECTED = FL_REASON_SELECTED, ///< an item was selected + FL_TREE_REASON_DESELECTED = FL_REASON_DESELECTED, ///< an item was de-selected + FL_TREE_REASON_RESELECTED = FL_REASON_RESELECTED, ///< an item was re-selected (double-clicked). + ///< See ::Fl_Tree_Item_Reselect_Mode to enable this. + FL_TREE_REASON_OPENED = FL_REASON_OPENED, ///< an item was opened + FL_TREE_REASON_CLOSED = FL_REASON_CLOSED, ///< an item was closed + FL_TREE_REASON_DRAGGED = FL_REASON_DRAGGED ///< an item was dragged into a new place +}; + +class FL_EXPORT Fl_Tree : public Fl_Group { + friend class Fl_Tree_Item; + 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 + Fl_Tree_Item *_lastselect; // last selected item + char _lastpushed; // FL_PUSH occurred on: 0=nothing, 1=open/close, 2=usericon, 3=label + void fix_scrollbar_order(); + +protected: + Fl_Scrollbar *_vscroll; ///< Vertical scrollbar + Fl_Scrollbar *_hscroll; ///< Horizontal scrollbar + int _tox,_toy,_tow,_toh; ///< Tree widget outer xywh dimension: outside scrollbars, inside widget border + int _tix,_tiy,_tiw,_tih; ///< Tree widget inner xywh dimension: inside borders + scrollbars + + /// the calculated width of the entire tree hierarchy. See calc_tree() + int _tree_w; + /// the calculated height of the entire tree hierarchy. See calc_tree() + int _tree_h; + void item_clicked(Fl_Tree_Item* val); + void do_callback_for_item(Fl_Tree_Item* item, Fl_Tree_Reason reason); + + // next_visible_item() and extend_selection() moved to 'public' in ABI 1.3.3 + // undocmented draw_tree() dropped -- draw() does all the work now + + // draw() has to be protected per FLTK convention (was public in 1.3.x) + void draw() FL_OVERRIDE; + +public: + Fl_Tree(int X, int Y, int W, int H, const char *L=0); + ~Fl_Tree(); + int handle(int e) FL_OVERRIDE; + void show_self(); + void resize(int,int,int,int) FL_OVERRIDE; + + /////////////////////// + // root methods + /////////////////////// + void root_label(const char *new_label); + Fl_Tree_Item* root(); + void root(Fl_Tree_Item *newitem); + const Fl_Tree_Prefs& prefs() const { return _prefs; } + + //////////////////////////////// + // Item creation/removal methods + //////////////////////////////// + Fl_Tree_Item *add(const char *path, Fl_Tree_Item *newitem=0); + Fl_Tree_Item* add(Fl_Tree_Item *parent_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); + int remove(Fl_Tree_Item *item); + void clear(); + void clear_children(Fl_Tree_Item *item); + + //////////////////////// + // 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(int yonly=0) const; + Fl_Tree_Item* find_clicked(int yonly=0); + Fl_Tree_Item *item_clicked(); + Fl_Tree_Item *first(); + Fl_Tree_Item *first_visible(); // deprecated in ABI 10303 + Fl_Tree_Item *first_visible_item(); + 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 *last_visible(); // deprecated in ABI 10303 + Fl_Tree_Item *last_visible_item(); + Fl_Tree_Item *next_visible_item(Fl_Tree_Item *start, int dir); // made public in 1.3.3 ABI + Fl_Tree_Item *first_selected_item(); + Fl_Tree_Item *last_selected_item(); + Fl_Tree_Item *next_item(Fl_Tree_Item *item, int dir=FL_Down, bool visible=false); + Fl_Tree_Item *next_selected_item(Fl_Tree_Item *item=0, int dir=FL_Down); + int get_selected_items(Fl_Tree_Item_Array &items); + + ////////////////////////// + // Item open/close methods + ////////////////////////// + int open(Fl_Tree_Item *item, int docallback=1); + int open(const char *path, int docallback=1); + void open_toggle(Fl_Tree_Item *item, int docallback=1); + int close(Fl_Tree_Item *item, int docallback=1); + int close(const char *path, int docallback=1); + int is_open(Fl_Tree_Item *item) const; + int is_open(const char *path) const; + int is_close(Fl_Tree_Item *item) const; + int is_close(const char *path) const; + + ///////////////////////// + // Item selection methods + ///////////////////////// + int select(Fl_Tree_Item *item, int docallback=1); + int select(const char *path, int docallback=1); + void select_toggle(Fl_Tree_Item *item, int docallback=1); + int deselect(Fl_Tree_Item *item, int docallback=1); + int deselect(const char *path, int docallback=1); + 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); + int extend_selection_dir(Fl_Tree_Item *from, + Fl_Tree_Item *to, + int dir, + int val, + bool visible); + int extend_selection(Fl_Tree_Item *from, + Fl_Tree_Item *to, + int val=1, + bool visible=false); + void set_item_focus(Fl_Tree_Item *item); + Fl_Tree_Item *get_item_focus() const; + int is_selected(Fl_Tree_Item *item) const; + int is_selected(const char *path); + + ///////////////////////////////// + // Item attribute related methods + ///////////////////////////////// + Fl_Font item_labelfont() const; + void item_labelfont(Fl_Font val); + Fl_Fontsize item_labelsize() const; + void item_labelsize(Fl_Fontsize val); + Fl_Color item_labelfgcolor(void) const; + void item_labelfgcolor(Fl_Color val); + Fl_Color item_labelbgcolor(void) const; + void item_labelbgcolor(Fl_Color val); + Fl_Color connectorcolor() const; + void connectorcolor(Fl_Color val); + int marginleft() const; + void marginleft(int val); + int margintop() const; + void margintop(int val); + int marginbottom() const; + void marginbottom(int val); + int linespacing() const; + void linespacing(int val); + int openchild_marginbottom() const; + void openchild_marginbottom(int val); + int usericonmarginleft() const; + void usericonmarginleft(int val); + int labelmarginleft() const; + void labelmarginleft(int val); + int widgetmarginleft() const; + void widgetmarginleft(int val); + int connectorwidth() const; + void connectorwidth(int val); + Fl_Image* usericon() const; + void usericon(Fl_Image *val); + Fl_Image* openicon() const; + void openicon(Fl_Image *val); + Fl_Image* closeicon() const; + void closeicon(Fl_Image *val); + int showcollapse() const; + void showcollapse(int val); + int showroot() const; + void showroot(int val); + Fl_Tree_Connector connectorstyle() const; + void connectorstyle(Fl_Tree_Connector val); + Fl_Tree_Sort sortorder() const; + void sortorder(Fl_Tree_Sort val); + Fl_Boxtype selectbox() const; + void selectbox(Fl_Boxtype val); + Fl_Tree_Select selectmode() const; + void selectmode(Fl_Tree_Select val); + Fl_Tree_Item_Reselect_Mode item_reselect_mode() const; + void item_reselect_mode(Fl_Tree_Item_Reselect_Mode mode); + Fl_Tree_Item_Draw_Mode item_draw_mode() const; + void item_draw_mode(Fl_Tree_Item_Draw_Mode mode); + void item_draw_mode(int mode); + void calc_dimensions(); + void calc_tree(); + void recalc_tree(); + 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_top(Fl_Tree_Item *item); + void show_item_middle(Fl_Tree_Item *item); + void show_item_bottom(Fl_Tree_Item *item); + void display(Fl_Tree_Item *item); + int vposition() const; + void vposition(int pos); + int hposition() const; + void hposition(int pos); + + int is_scrollbar(Fl_Widget *w); + int scrollbar_size() const; + void scrollbar_size(int size); + int is_vscroll_visible() const; + int is_hscroll_visible() const; + + /////////////////////// + // callback related + /////////////////////// + void callback_item(Fl_Tree_Item* item); + Fl_Tree_Item* callback_item(); + void callback_reason(Fl_Tree_Reason reason); + Fl_Tree_Reason callback_reason() const; + + /// Load FLTK preferences + void load(class Fl_Preferences&); +}; + +#endif /*FL_TREE_H*/ diff --git a/include/linux/amd64/FL/Fl_Tree_Item.H b/include/linux/amd64/FL/Fl_Tree_Item.H new file mode 100644 index 0000000..b763953 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Tree_Item.H @@ -0,0 +1,488 @@ +// + +#ifndef FL_TREE_ITEM_H +#define FL_TREE_ITEM_H + +#include +#include +#include +#include + +#include +#include + +////////////////////// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/// +/// \file +/// \brief This file contains the definitions for Fl_Tree_Item +/// + +/// \class Fl_Tree_Item +/// \brief Tree widget 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. +/// +/// New 1.3.3 ABI feature: +/// You can define custom items by either adding a custom widget to the item +/// with Fl_Tree_Item::widget(), or override the draw_item_content() method +/// if you want to just redefine how the label is drawn. +/// +/// The following shows the Fl_Tree_Item's dimensions, useful when overriding +/// the draw_item_content() method: +/// +/// \image html Fl_Tree_Item-dimensions.png "Fl_Tree_Item's internal dimensions." width=6cm +/// \image latex Fl_Tree_Item-dimensions.png "Fl_Tree_Item's internal dimensions." width=6cm +/// +class Fl_Tree; +class FL_EXPORT Fl_Tree_Item { + Fl_Tree *_tree; // parent tree + 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 (0xffffffff is 'transparent') + /// \enum Fl_Tree_Item_Flags + enum Fl_Tree_Item_Flags { + OPEN = 1<<0, ///> item is open + VISIBLE = 1<<1, ///> item is visible + ACTIVE = 1<<2, ///> item is active + SELECTED = 1<<3 ///> item is selected + }; + unsigned short _flags; // misc flags + int _xywh[4]; // xywh of this widget (if visible) + int _collapse_xywh[4]; // xywh of collapse icon (if visible) + 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_Image *_userdeicon; // deactivated usericon + 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 + Fl_Tree_Item *_prev_sibling; // previous sibling (same level) + Fl_Tree_Item *_next_sibling; // next sibling (same level) + // Protected methods +protected: + void _Init(const Fl_Tree_Prefs &prefs, Fl_Tree *tree); + 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); + void recalc_tree(); + int calc_item_height(const Fl_Tree_Prefs &prefs) const; + Fl_Color drawfgcolor() const; + Fl_Color drawbgcolor() const; + +public: + Fl_Tree_Item(const Fl_Tree_Prefs &prefs); // CTOR -- backwards compatible + Fl_Tree_Item(Fl_Tree *tree); // CTOR -- ABI 1.3.3+ + virtual ~Fl_Tree_Item(); // DTOR -- ABI 1.3.3+ + Fl_Tree_Item(const Fl_Tree_Item *o); // COPY CTOR + /// The item's x position relative to the window + int x() const { return(_xywh[0]); } + /// The item's y position relative to the window + int y() const { return(_xywh[1]); } + /// The entire item's width to right edge of Fl_Tree's inner width + /// within scrollbars. + int w() const { return(_xywh[2]); } + /// The item's height + int h() const { return(_xywh[3]); } + /// The item's label x position relative to the window + /// \version 1.3.3 + int label_x() const { return(_label_xywh[0]); } + /// The item's label y position relative to the window + /// \version 1.3.3 + int label_y() const { return(_label_xywh[1]); } + /// The item's maximum label width to right edge of Fl_Tree's inner width + /// within scrollbars. + /// \version 1.3.3 + int label_w() const { return(_label_xywh[2]); } + /// The item's label height + /// \version 1.3.3 + int label_h() const { return(_label_xywh[3]); } + virtual int draw_item_content(int render); + void draw(int X, int &Y, int W, Fl_Tree_Item *itemfocus, + int &tree_item_xmax, int lastchild=1, int render=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; + recalc_tree(); // may change tree geometry + } + /// 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; + recalc_tree(); // may change tree geometry + } + /// 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; + } + /// Return item's label foreground text color. + Fl_Color labelfgcolor() const { + return(_labelfgcolor); + } + /// Set item's label text color. Alias for labelfgcolor(Fl_Color)). + void labelcolor(Fl_Color val) { + labelfgcolor(val); + } + /// Return item's label text color. Alias for labelfgcolor() const). + Fl_Color labelcolor() const { + return labelfgcolor(); + } + /// Set item's label background color. + /// A special case is made for color 0xffffffff which uses the parent tree's bg color. + void labelbgcolor(Fl_Color val) { + _labelbgcolor = val; + } + /// Return item's label background text color. + /// If the color is 0xffffffff, the default behavior is the parent tree's + /// bg color will be used. (An overloaded draw_item_content() can override + /// this behavior.) + Fl_Color labelbgcolor() const { + return(_labelbgcolor); + } + /// Assign an FLTK widget to this item. + void widget(Fl_Widget *val) { + _widget = val; + recalc_tree(); // may change tree geometry + } + /// 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(const char *name) const; + Fl_Tree_Item *find_child_item(const char *name); + const Fl_Tree_Item *find_child_item(char **arr) const; + Fl_Tree_Item *find_child_item(char **arr); + const Fl_Tree_Item *find_item(char **arr) const; + Fl_Tree_Item *find_item(char **arr); + ////////////////// + // Adding items + ////////////////// + Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs, + const char *new_label, + Fl_Tree_Item *newitem); + 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 *newitem); + Fl_Tree_Item *add(const Fl_Tree_Prefs &prefs, + char **arr); + Fl_Tree_Item *replace(Fl_Tree_Item *new_item); + Fl_Tree_Item *replace_child(Fl_Tree_Item *olditem, Fl_Tree_Item *newitem); + 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); + Fl_Tree_Item* deparent(int index); + int reparent(Fl_Tree_Item *newchild, int index); + int move(int to, int from); + int move(Fl_Tree_Item *item, int op=0, int pos=0); + int move_above(Fl_Tree_Item *item); + int move_below(Fl_Tree_Item *item); + int move_into(Fl_Tree_Item *item, int pos=0); + int depth() const; + Fl_Tree_Item *prev(); + Fl_Tree_Item *next(); + Fl_Tree_Item *next_sibling(); + Fl_Tree_Item *prev_sibling(); + void update_prev_next(int index); + Fl_Tree_Item *next_displayed(Fl_Tree_Prefs &prefs); // deprecated + Fl_Tree_Item *prev_displayed(Fl_Tree_Prefs &prefs); // deprecated + Fl_Tree_Item *next_visible(Fl_Tree_Prefs &prefs); + Fl_Tree_Item *prev_visible(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; + } + const Fl_Tree_Prefs& prefs() const; + /// Return the tree for this item. + /// \version 1.3.3 + const Fl_Tree *tree() const { + return(_tree); + } + /// Return the tree for this item. + /// \version 1.3.4 + Fl_Tree *tree() { + return(_tree); + } + ////////////////// + // State + ////////////////// + void open(); + void close(); + /// See if the item is 'open'. + int is_open() const { + return(is_flag(OPEN)); + } + /// See if the item is 'closed'. + int is_close() const { + return(is_flag(OPEN)?0:1); + } + /// Toggle the item's open/closed state. + void open_toggle() { + is_open()?close():open(); // handles calling recalc_tree() + } + /// 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) { + set_flag(SELECTED, val); + } + /// Toggle the item's selection state. + void select_toggle() { + if ( is_selected() ) { + deselect(); // deselect if selected + } else { + select(); // select if deselected + } + } + /// Select item and all its 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; tselect_all(); + } + return(count); + } + /// Disable the item's selection state. + void deselect() { + set_flag(SELECTED, 0); + } + /// Deselect item and all its 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; tdeselect_all(); + } + return(count); + } + /// See if the item is selected. + char is_selected() const { + return(is_flag(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 a widget() + /// is 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) { + set_flag(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(is_flag(ACTIVE)); + } + /// See if the item is activated. Alias for is_activated(). + char is_active() const { + return(is_activated()); + } + /// See if the item is visible. Alias for is_visible(). + int visible() const { + return(is_visible()); + } + /// See if the item is visible. + int is_visible() const { + return(is_flag(VISIBLE)); + } + /// See if item and all its parents are open() and visible(). + /// Alias for is_visible_r(). + /// \returns + /// 1 -- item and its parents are open() and visible() + /// 0 -- item (or one of its parents) are not visible or close()ed. + /// + int visible_r() const { + return(is_visible_r()); + } + int is_visible_r() const; + + /// Set the item's user icon to an Fl_Image. Use '0' to disable. + /// No internal copy is made, caller must manage icon's memory. + /// + /// Note, if you expect your items to be deactivated(), + /// use userdeicon(Fl_Image*) to set up a 'grayed out' version of your icon + /// to be used for display. + /// + /// \see userdeicon(Fl_Image*) + /// + void usericon(Fl_Image *val) { + _usericon = val; + recalc_tree(); // may change tree geometry + } + /// Get the item's user icon as an Fl_Image. Returns '0' if disabled. + Fl_Image *usericon() const { + return(_usericon); + } + /// Set the usericon to draw when the item is deactivated. Use '0' to disable. + /// No internal copy is made; caller must manage icon's memory. + /// + /// To create a typical 'grayed out' version of your usericon image, + /// you can do the following: + /// + /// \code + /// // Create tree + usericon for items + /// Fl_Tree *tree = new Fl_Tree(..); + /// Fl_Image *usr_icon = new Fl_Pixmap(..); // your usericon + /// Fl_Image *de_icon = usr_icon->copy(); // make a copy, and.. + /// de_icon->inactive(); // make it 'grayed out' + /// ... + /// for ( .. ) { // item loop.. + /// item = tree->add("..."); // create new item + /// item->usericon(usr_icon); // assign usericon to items + /// item->userdeicon(de_icon); // assign userdeicon to items + /// .. + /// } + /// \endcode + /// + /// In the above example, the app should 'delete' the two icons + /// when they're no longer needed (e.g. after the tree is destroyed) + /// + /// \version 1.3.4 + /// + void userdeicon(Fl_Image* val) { + _userdeicon = val; + } + /// Return the deactivated version of the user icon, if any. + /// Returns 0 if none. + Fl_Image* userdeicon() const { + return _userdeicon; + } + ////////////////// + // Events + ////////////////// + const Fl_Tree_Item* find_clicked(const Fl_Tree_Prefs &prefs, int yonly=0) const; + Fl_Tree_Item* find_clicked(const Fl_Tree_Prefs &prefs, int yonly=0); + int event_on_item(const Fl_Tree_Prefs &prefs) const; + int event_on_collapse_icon(const Fl_Tree_Prefs &prefs) const; + int event_on_user_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); + } + + // Protected methods + // TODO: move these to top 'protected:' section +protected: + /// Set a flag to an on or off value. val is 0 or 1. + inline void set_flag(unsigned short flag,int val) { + if ( flag==OPEN || flag==VISIBLE ) { + recalc_tree(); // may change tree geometry + } + if ( val ) _flags |= flag; else _flags &= ~flag; + } + /// See if flag set. Returns 0 or 1. + inline int is_flag(unsigned short val) const { + return(_flags & val ? 1 : 0); + } + +}; + +#endif /*FL_TREE_ITEM_H*/ diff --git a/include/linux/amd64/FL/Fl_Tree_Item_Array.H b/include/linux/amd64/FL/Fl_Tree_Item_Array.H new file mode 100644 index 0000000..78e71bb --- /dev/null +++ b/include/linux/amd64/FL/Fl_Tree_Item_Array.H @@ -0,0 +1,93 @@ +// + +#ifndef _FL_TREE_ITEM_ARRAY_H +#define _FL_TREE_ITEM_ARRAY_H + +#include +#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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/// +/// \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 manage the Fl_Tree_Item's internals (internal use only) + }; + char _flags; // flags to control behavior + 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); + int move(int to, int from); + int deparent(int pos); + int reparent(Fl_Tree_Item *item, Fl_Tree_Item *newparent, int pos); + void clear(); + void add(Fl_Tree_Item *val); + void insert(int pos, Fl_Tree_Item *new_item); + void replace(int pos, Fl_Tree_Item *new_item); + void remove(int index); + int remove(Fl_Tree_Item *item); + /// Option to control if Fl_Tree_Item_Array's destructor will also destroy the Fl_Tree_Item's. + /// If set: items and item array is destroyed. + /// If clear: only the item array is destroyed, not items themselves. + void manage_item_destroy(int val) { + if ( val ) _flags |= MANAGE_ITEM; else _flags &= ~MANAGE_ITEM; + } + int manage_item_destroy() const { + return _flags & MANAGE_ITEM ? 1 : 0; + } +}; + +#endif /*_FL_TREE_ITEM_ARRAY_H*/ diff --git a/include/linux/amd64/FL/Fl_Tree_Prefs.H b/include/linux/amd64/FL/Fl_Tree_Prefs.H new file mode 100644 index 0000000..be4e3e2 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Tree_Prefs.H @@ -0,0 +1,443 @@ +// + +#ifndef FL_TREE_PREFS_H +#define FL_TREE_PREFS_H + +#include // needed for ABI version features (via Enumerations.H) + +////////////////////// +// FL/Fl_Tree_Prefs.H +////////////////////// +// +// Fl_Tree_Prefs -- This file is part of the Fl_Tree widget for FLTK +// Copyright (C) 2009-2010 by Greg Ercolano. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/// +/// \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, CTRL or mouse drags. + FL_TREE_SELECT_SINGLE_DRAGGABLE=3 ///< Single items may be selected, and they may be + ///< reordered by mouse drag. +}; + +/// \enum Fl_Tree_Item_Reselect_Mode +/// Defines the ways an item can be (re) selected +/// via item_reselect_mode(). +/// +enum Fl_Tree_Item_Reselect_Mode { + FL_TREE_SELECTABLE_ONCE=0, ///< Item can only be selected once (default) + FL_TREE_SELECTABLE_ALWAYS ///< Enables FL_TREE_REASON_RESELECTED events for callbacks +}; + +/// \enum Fl_Tree_Item_Draw_Mode +/// Bit flags that control how item's labels and widget()s are drawn in the tree +/// via item_draw_mode(). +/// +enum Fl_Tree_Item_Draw_Mode { + FL_TREE_ITEM_DRAW_DEFAULT=0, ///< If widget() defined, draw in place of label, + ///< and widget() tracks item height (default) + FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET=1, ///< If widget() defined, include label to the left of the widget + FL_TREE_ITEM_HEIGHT_FROM_WIDGET=2 ///< If widget() defined, widget()'s height controls item's height +}; + +class Fl_Tree_Item; +typedef void (Fl_Tree_Item_Draw_Callback)(Fl_Tree_Item*, void*); + +/// \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 controllable margins + 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 _widgetmarginleft; // space to left of widget + 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; // label's 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 + Fl_Image *_opendeimage; // deactivated 'open' icon + Fl_Image *_closedeimage; // deactivated 'close' icon + Fl_Image *_userdeimage; // deactivated user 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 + Fl_Tree_Item_Reselect_Mode _itemreselectmode; // controls item selection callback() behavior + Fl_Tree_Item_Draw_Mode _itemdrawmode; // controls how items draw label + widget() + Fl_Tree_Item_Draw_Callback *_itemdrawcallback; // callback to handle drawing items (0=none) + void *_itemdrawuserdata; // data for drawing items (0=none) +public: + Fl_Tree_Prefs(); + ~Fl_Tree_Prefs(); + + //////////////////////////// + // Labels + //////////////////////////// + /// Return the label's font. + inline Fl_Font item_labelfont() const { return(_labelfont); } + /// Set the label's font to \p val. + inline void item_labelfont(Fl_Font val) { _labelfont = val; } + /// Return the label's size in pixels. + inline Fl_Fontsize item_labelsize() const { return(_labelsize); } + /// Set the label's size in pixels to \p val. + inline void item_labelsize(Fl_Fontsize val) { _labelsize = val; } + /// Get the default label foreground color + inline Fl_Color item_labelfgcolor() const { return(_labelfgcolor); } + /// Set the default label foreground color + inline void item_labelfgcolor(Fl_Color val) { _labelfgcolor = val; } + /// Get the default label background color. + /// This returns the Fl_Tree::color() unless item_labelbgcolor() + /// has been set explicitly. + /// + inline Fl_Color item_labelbgcolor() const { + return _labelbgcolor; + } + /// Set the default label background color. + /// Once set, overrides the default behavior of using Fl_Tree::color(). + /// + inline void item_labelbgcolor(Fl_Color val) { + _labelbgcolor = val; + } + + ///////////////// + // Obsolete names - for 1.3.0 backwards compat + ///////////////// + /// Obsolete: Return the label's font. Please use item_labelfont() instead. + inline Fl_Font labelfont() const { return(_labelfont); } + /// Obsolete: Set the label's font to \p val. Please use item_labelfont(Fl_Font) instead. + inline void labelfont(Fl_Font val) { _labelfont = val; } + /// Obsolete: Return the label's size in pixels. Please use item_labelsize() instead. + inline Fl_Fontsize labelsize() const { return(_labelsize); } + /// Obsolete: Set the label's size in pixels to \p val. Please use item_labelsize(Fl_Fontsize) instead. + inline void labelsize(Fl_Fontsize val) { _labelsize = val; } + /// Obsolete: Get the default label foreground color. Please use item_labelfgcolor() instead. + inline Fl_Color labelfgcolor() const { return(_labelfgcolor); } + /// Obsolete: Set the default label foreground color. Please use item_labelfgcolor(Fl_Color) instead. + inline void labelfgcolor(Fl_Color val) { _labelfgcolor = val; } + /// Obsolete: Get the default label background color. Please use item_labelbgcolor() instead. + inline Fl_Color labelbgcolor() const { return(item_labelbgcolor()); } + /// Obsolete: Set the default label background color. Please use item_labelbgcolor(Fl_Color) instead. + inline void labelbgcolor(Fl_Color val) { item_labelbgcolor(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 bottom margin's value in pixels. + /// This is the extra distance the vertical scroller lets you travel. + inline int marginbottom() const { + return(_marginbottom); + } + /// Set the bottom margin's value in pixels + /// This is the extra distance the vertical scroller lets you travel. + inline void marginbottom(int val) { + _marginbottom = 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; + } + /// 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 widget()'s left margin value in pixels + inline int widgetmarginleft() const { + return(_widgetmarginleft); + } + /// Set the widget's left margin value in pixels + inline void widgetmarginleft(int val) { + _widgetmarginleft = 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 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); + } + inline int openicon_w() const { return _openimage ? _openimage->w() : 11; } + inline int openicon_h() const { return _openimage ? _openimage->h() : 11; } + 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); + } + inline int closeicon_w() const { return _closeimage ? _closeimage->w() : 11; } + inline int closeicon_h() const { return _closeimage ? _closeimage->h() : 11; } + 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; + // Update deactivated version of icon.. + if ( _userdeimage ) delete _userdeimage; + if ( _userimage ) { + _userdeimage = _userimage->copy(); + _userdeimage->inactive(); + } else { + _userdeimage = 0; + } + } + + /// Return the deactivated version of the open icon, if any. + /// Returns 0 if none. + inline Fl_Image *opendeicon() const { + return _opendeimage; + } + /// Return the deactivated version of the close icon, if any. + /// Returns 0 if none. + inline Fl_Image *closedeicon() const { + return _closedeimage; + } + /// Return the deactivated version of the user icon, if any. + /// Returns 0 if none. + inline Fl_Image *userdeicon() const { + return _userdeimage; + } + + //////////////////////////// + // 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; + } + /// Returns the current item re/selection mode + Fl_Tree_Item_Reselect_Mode item_reselect_mode() const { + return _itemreselectmode; + } + /// Sets the item re/selection mode + void item_reselect_mode(Fl_Tree_Item_Reselect_Mode mode) { + _itemreselectmode = mode; + } + /// Get the 'item draw mode' used for the tree + inline Fl_Tree_Item_Draw_Mode item_draw_mode() const { + return(_itemdrawmode); + } + /// Set the 'item draw mode' used for the tree to \p val. + /// This affects how items in the tree are drawn, + /// such as when a widget() is defined. + /// See Fl_Tree_Item_Draw_Mode for possible values. + /// + inline void item_draw_mode(Fl_Tree_Item_Draw_Mode val) { + _itemdrawmode = val; + } + void item_draw_callback(Fl_Tree_Item_Draw_Callback *cb, void *data=0) { + _itemdrawcallback = cb; + _itemdrawuserdata = data; + } + Fl_Tree_Item_Draw_Callback* item_draw_callback() const { + return(_itemdrawcallback); + } + void* item_draw_user_data() const { + return(_itemdrawuserdata); + } + void do_item_draw_callback(Fl_Tree_Item *o) const { + _itemdrawcallback(o, _itemdrawuserdata); + } +}; + +#endif /*FL_TREE_PREFS_H*/ diff --git a/include/linux/amd64/FL/Fl_Valuator.H b/include/linux/amd64/FL/Fl_Valuator.H new file mode 100644 index 0000000..9eaf2ea --- /dev/null +++ b/include/linux/amd64/FL/Fl_Valuator.H @@ -0,0 +1,132 @@ +// +// Valuator header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + + There are probably more of these classes in FLTK than any others: + + \image html valuators.png + \image latex valuators.png "Valuators derived from Fl_Valuators" width=10cm + + In the above diagram each box surrounds an actual subclass. These + are further differentiated by setting the type() of the widget to + 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 after rounding to the step + value (this makes a difference if the range is not a multiple of + the step). + + 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. + + 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. + + 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 \e before clamping it to the range. For most widgets + the default step is zero. + + For precision the step is stored as the ratio of a double \p A and + an integer \p B = A/B. You can set these values 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 digits); + + /** 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 diff --git a/include/linux/amd64/FL/Fl_Value_Input.H b/include/linux/amd64/FL/Fl_Value_Input.H new file mode 100644 index 0000000..7aca4e9 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Value_Input.H @@ -0,0 +1,126 @@ +// +// Value input header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + +

    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).

    + +

    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.

    + + If step() is non-zero and integral, then the range + of numbers are limited to integers instead of floating point + values. + + \image html Fl_Value_Input.png + \image latex Fl_Value_Input.png "Fl_Value_Input" width=4cm + + \see Fl_Widget::shortcut_label(int) +*/ +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*); + void value_damage() FL_OVERRIDE; // cause damage() due to value() changing +public: + int handle(int) FL_OVERRIDE; +protected: + void draw() FL_OVERRIDE; +public: + void resize(int,int,int,int) FL_OVERRIDE; + 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 diff --git a/include/linux/amd64/FL/Fl_Value_Output.H b/include/linux/amd64/FL/Fl_Value_Output.H new file mode 100644 index 0000000..4e380ea --- /dev/null +++ b/include/linux/amd64/FL/Fl_Value_Output.H @@ -0,0 +1,80 @@ +// +// Value output header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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(). +

    This is much lighter-weight than + Fl_Value_Input because it contains no text editing code or + character buffer.

    + \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() FL_OVERRIDE; + +public: + int handle(int) FL_OVERRIDE; + 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 diff --git a/include/linux/amd64/FL/Fl_Value_Slider.H b/include/linux/amd64/FL/Fl_Value_Slider.H new file mode 100644 index 0000000..3d7e42c --- /dev/null +++ b/include/linux/amd64/FL/Fl_Value_Slider.H @@ -0,0 +1,121 @@ +// +// Value Slider header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + \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_; + short value_width_; + short value_height_; + +protected: + void draw() FL_OVERRIDE; + +public: + int handle(int) FL_OVERRIDE; + 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; } + + /** Sets the width of the value box in pixels (horizontal mode only). + + Limited range checking is applied but drawing errors may occur if + the size \p s is set too high or too low, particularly if the widget + is resized (later). + + The programmer is responsible for setting sensible values and + widget sizes. + + The default value set by the constructor is 35. + + \param[in] s new width of the value box + + \since 1.4.0 + */ + void value_width(int s) { + if (s > w() - 10) + s = w() - 10; + if (s < 10) + s = 10; + value_width_ = (short)s; + } + + /** Gets the width of the value box in pixels (horizontal mode only). + + \since 1.4.0 + */ + int value_width() const { return (value_width_); } + + /** Sets the height of the value box in pixels (vertical mode only). + + Limited range checking is applied but drawing errors may occur if + the size \p s is set too high or too low, particularly if the widget + is resized (later). + + The programmer is responsible for setting sensible values and + widget sizes. + + The default value set by the constructor is 25. + + \param[in] s new height of the value box + + \since 1.4.0 + */ + void value_height(int s) { + if (s > h() - 10) + s = h() - 10; + if (s < 10) + s = 10; + value_height_ = (short)s; + } + /** Gets the height of the value box in pixels (vertical mode only). + + \since 1.4.0 + */ + int value_height() const { return (value_height_); } +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Widget.H b/include/linux/amd64/FL/Fl_Widget.H new file mode 100644 index 0000000..c0ede95 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Widget.H @@ -0,0 +1,1290 @@ +// +// Widget header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** + \file FL/Fl_Widget.H + \brief Fl_Widget and Fl_Label classes. +*/ + +#ifndef Fl_Widget_H +#define Fl_Widget_H + +#include "Fl.H" + +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 There is an aspiration that 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. + However, this re-factoring is not in place in this release. + */ +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; + /** Spacing between label and the horizontally aligned side of the widget. */ + signed char h_margin_; + /** Spacing between label and the vertically aligned side of the widget. */ + signed char v_margin_; + /** Spacing between an image and the label text */ + uchar spacing; + + /** Draws the label aligned to the given box */ + void draw(int,int,int,int, Fl_Align) const ; + void measure(int &w, int &h) const ; +}; + + +/** A class prototype that allows for additional data in callbacks. + + Users can derive this class and pass objects of such derived classes to widget callbacks. + Widgets can take ownership of the callback data, deleting the data when the widget + itself is deleted. + + The destructor of this class is virtual, allowing for additional code to + deallocate resources when the user data is deleted. + + \see FL_FUNCTION_CALLBACK_3, FL_METHOD_CALLBACK_1, FL_INLINE_CALLBACK_2 + \see Fl_Widget::callback(Fl_Callback*, Fl_Callback_User_Data*, bool) + \see Fl_Widget::user_data(Fl_Callback_User_Data*, bool) + */ +class FL_EXPORT Fl_Callback_User_Data { +protected: + Fl_Callback_User_Data() {} ///< Protected constructor +public: + virtual ~Fl_Callback_User_Data() { } ///< Destructor +}; + + +/** 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 windows (Fl_Window) + NO_OVERLAY = 1<<15, ///< window not using a hardware overlay plane (Fl_Menu_Window) + GROUP_RELATIVE = 1<<16, ///< Reserved, not implemented. DO NOT USE. + COPIED_TOOLTIP = 1<<17, ///< the widget tooltip is internally copied, its destruction is handled by the widget + FULLSCREEN = 1<<18, ///< a fullscreen window (Fl_Window) + MAC_USE_ACCENTS_MENU = 1<<19, ///< On the macOS platform, pressing and holding a key on the keyboard opens an accented-character menu window (Fl_Input_, Fl_Text_Editor) + NEEDS_KEYBOARD = 1<<20, ///< set on touch screen devices if a widget needs a keyboard when it gets the focus. Reserved, not yet used in 1.4.0. \see Fl_Widget::needs_keyboard() + IMAGE_BOUND = 1<<21, ///< binding the image to the widget will transfer ownership, so that the widget will delete the image when it is no longer needed + DEIMAGE_BOUND = 1<<22, ///< bind the inactive image to the widget, so the widget deletes the image when it is no longer needed + AUTO_DELETE_USER_DATA = 1<<23, ///< automatically call `delete` on the user_data pointer when destroying this widget; if set, user_data must point to a class derived from the class Fl_Callback_User_Data + MAXIMIZED = 1<<24, ///< a maximized Fl_Window + POPUP = 1<<25, ///< popup window (i.e., positioned relatively to another mapped window) + // Note to devs: add new FLTK core flags above this line (up to 1<<28). + + // Three more flags, reserved for user code + + 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. + This method uses the widget's boxtype and coordinates and its + background color color(). + \see Fl_Widget::draw_focus(Fl_Boxtype, int, int, int, int, Fl_Color) const + */ + void draw_focus() const { + draw_focus(box(), x(), y(), w(), h(), color()); + } + + /** Draws a focus rectangle around the widget. + This method uses the given boxtype and coordinates and the widget's + background color color(). + \see Fl_Widget::draw_focus(Fl_Boxtype, int, int, int, int, Fl_Color) const + */ + void draw_focus(Fl_Boxtype t, int X, int Y, int W, int H) const { + draw_focus(t, X, Y, W, H, color()); + + } + // See documentation in Fl_Widget.cxx + void draw_focus(Fl_Boxtype t, int x, int y, int w, int h, Fl_Color bg) const; + + void draw_label() const; + void draw_label(int, int, int, int) const; + +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 from within your + own draw() method, e.g. for an embedded scrollbar, you can do it + (because draw() is virtual) like this: + + \code + Fl_Widget *s = &scrollbar; // scrollbar 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. + + One exception to the rule in the previous paragraph is if you really + want to \e override the behavior of the base class. This requires + knowledge of the details of the inherited class. + + In rare cases you may want to return 1 from your handle() method + although you don't really handle the event. The effect would be to + \e filter event processing, for instance if you want to dismiss + non-numeric characters (keypresses) in a numeric input widget. You + may "ring the bell" or show another visual indication or drop the + event silently. In such a case you must not call the handle() method + of the base class and tell FLTK that you \e consumed the event by + returning 1 even if you didn't \e do anything with it. + + \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 whether the current label was assigned with copy_label(). + + This can be useful for temporarily overwriting the widget's label + and restoring it later. + + \retval 0 current label was assigned with label(). + \retval 1 current label was assigned with copy_label(). + */ + int is_label_copied() const {return ((flags_ & COPIED_LABEL) ? 1 : 0);} + + /** + Sets whether this widget needs a keyboard. + + Set this on touch screen devices if a widget needs a keyboard when it gets the focus. + + \note This flag can be set but is not yet \b used in FLTK 1.4.0. It is intended to be + used in the future on real touch devices. + + \param[in] needs Set this to true or false + + \internal Needs implementations in screen driver methods: + \see Fl::screen_driver()->request_keyboard(); + \see Fl::screen_driver()->release_keyboard(); + */ + void needs_keyboard(bool needs) { + if (needs) set_flag(NEEDS_KEYBOARD); + else clear_flag(NEEDS_KEYBOARD); + } + + /** + Returns whether this widget needs a keyboard. + \return true or false + \see needs_keyboard(bool) + */ + bool needs_keyboard() const { + return (flags_ & NEEDS_KEYBOARD); + } + + /** 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 gives some information about the derived widget class + to which the object belongs. Noticeably, the condition type() >= FL_WINDOW indicates + a widget is an Fl_Window or derived object. + */ + uchar type() const {return type_;} + + /** Sets the widget type. + \see type() + */ + 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. + See \ref common_labels for details about what can be put in a label. + The passed pointer is stored unchanged in the widget (the string is \em not copied), so if + you need to set the label to a formatted value, make sure the buffer is + static, global, or allocated. The copy_label() method can be used + 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 when in the active state. + \return the current image + */ + Fl_Image* image() {return label_.image;} + + /** Gets the image that is used as part of the widget label when in the active state. + \return the current image + */ + const Fl_Image* image() const {return label_.image;} + + /** Sets the image to use as part of the widget label when in the active state. + + The caller is responsible for making sure \p img is not deleted while it's used by the widget, + and, if appropriate, for deleting it after the widget's deletion. + + Calling image() with a new image will delete the old image if it + was bound, and set the new image without binding it. If old and new are + the same, the image will not be deleted, but it will be unbound. + + Calling image() with NULL will delete the old image if + it was bound and not set a new image. + + \param[in] img the new image for the label + \see bind_image(Fl_Image* img) + */ + void image(Fl_Image* img); + + /** Sets the image to use as part of the widget label when in the active state. + \param[in] img the new image for the label + \see void image(Fl_Image* img) + */ + void image(Fl_Image& img); + + /** Sets the image to use as part of the widget label when in the active state. + + The image will be bound to the widget. When the widget is deleted, the + image will be deleted as well. + + Calling bind_image() with a new image will delete the old image if it + was bound, and then set the new image, and bind that. If old and new image + are the same, nothing happens. + + Calling bind_image() with NULL will delete the old image if + it was bound and not set a new image. + + \param[in] img the new image for the label + \see void image(Fl_Image* img) + */ + void bind_image(Fl_Image* img); + + /** Bind the image to the widget, so the widget will delete the image when it is no longer needed. + \param f 1: mark the image as bound, 0: mark the image as managed by the user + \see image_bound(), bind_deimage() + */ + void bind_image(int f) { if (f) set_flag(IMAGE_BOUND); else clear_flag(IMAGE_BOUND); } + + /** Returns whether the image is managed by the widget. + \retval 0 if the image is not bound to the widget + \retval 1 if the image will be deleted when the widget is deleted + \see deimage_bound(), bind_image() + */ + int image_bound() const {return ((flags_ & IMAGE_BOUND) ? 1 : 0);} + + /** Gets the image that is used as part of the widget label when in the inactive state. + \return the current image for the deactivated widget + */ + Fl_Image* deimage() {return label_.deimage;} + + /** Gets the image that is used as part of the widget label when in the inactive state. + \return the current image for the deactivated widget + */ + const Fl_Image* deimage() const {return label_.deimage;} + + /** Sets the image to use as part of the widget label when in the inactive state. + \param[in] img the new image for the deactivated widget + \note The caller is responsible for making sure \p img is not deleted while it's used by the widget, + and, if appropriate, for deleting it after the widget's deletion. + \see void bind_deimage(Fl_Image* img) + */ + void deimage(Fl_Image* img); + + /** Sets the image to use as part of the widget label when in the inactive state. + \param[in] img the new image for the deactivated widget + \see void deimage(Fl_Image* img) + */ + void deimage(Fl_Image& img); + + /** Sets the image to use as part of the widget label when in the inactive state. + \param[in] img the new image for the deactivated widget + \note The image will be bound to the widget. When the widget is deleted, the + image will be deleted as well. + \see void deimage(Fl_Image* img) + */ + void bind_deimage(Fl_Image* img); + + /** Returns whether the inactive image is managed by the widget. + \retval 0 if the image is not bound to the widget + \retval 1 if the image will be deleted when the widget is deleted + \see image_bound(), bind_deimage() + */ + int deimage_bound() const {return ((flags_ & DEIMAGE_BOUND) ? 1 : 0);} + + /** Bind the inactive image to the widget, so the widget will delete the image when it is no longer needed. + \param f 1: mark the image as bound, 0: mark the image as managed by the user + \see deimage_bound(), bind_image() + */ + void bind_deimage(int f) { if (f) set_flag(DEIMAGE_BOUND); else clear_flag(DEIMAGE_BOUND); } + + /** Set the gap between the label and the image in pixels. + This value is limited to 0..255. + \param[in] gap spacing in pixels + */ + void label_image_spacing(int gap) { label_.spacing = (uchar)gap; } + + /** Return the gap size between the label and the image. + \return spacing in pixels + */ + int label_image_spacing() { return label_.spacing; } + + /** Set the spacing between the label and the horizontal edge of the widget. + \param[in] px gap in pixels + */ + void horizontal_label_margin(int px) { label_.h_margin_ = (signed char)px; } + + /** Get the spacing between the label and the horizontal edge of the widget. + \return px gap in pixels + */ + int horizontal_label_margin() { return label_.h_margin_; } + + /** Set the spacing between the label and the vertical edge of the widget. + \param[in] px gap in pixels + */ + void vertical_label_margin(int px) { label_.v_margin_ = (signed char)px; } + + /** Get the spacing between the label and the vertical edge of the widget. + \return px gap in pixels + */ + int vertical_label_margin() { return label_.v_margin_; } + + /** 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 and data 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 and managed user data for the widget. + Setting auto_free will transfer ownership of the callback user data to the + widget. Deleting the widget will then also delete the user data. + \param[in] cb new callback + \param[in] p user data + \param[in] auto_free if set, the widget will free user data when destroyed + */ + void callback(Fl_Callback* cb, Fl_Callback_User_Data* p, bool auto_free) { + callback_ = cb; + user_data(p, auto_free); + } + + /** 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*)(fl_intptr_t)(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*)(fl_intptr_t)(cb); + user_data((void*)(fl_intptr_t)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_;} + + /** \brief Sets the user data for this widget. */ + void user_data(void* v); + + /** \brief Sets the user data for this widget. */ + void user_data(Fl_Callback_User_Data* v, bool auto_free); + + /** Gets the current user data (long) argument that is passed to the callback function. + + \note On platforms with sizeof(long) \< sizeof(void*), particularly + on Windows 64-bit platforms, this method can truncate stored addresses + \p (void*) to the size of a \p long value. Use with care and only + if you are sure that the stored user_data value fits in a \p long + value because it was stored with argument(long) or another method + using only \p long values. You may want to use user_data() instead. + + \see user_data() + */ + long argument() const {return (long)(fl_intptr_t)user_data_;} + + /** Sets the current user data (long) argument that is passed to the callback function. + + \see argument() + */ + void argument(long v) {user_data((void*)(fl_intptr_t)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, do_callback(), Fl::callback_reason() + */ + 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. + \li \ref FL_WHEN_CLOSED : If the user requests that the widget is closed, + the callback is called with \ref FL_REASON_CLOSED. The \ref Fl_Tabs + widget checks this flag on its children to determine whether to display + a close button on the tab of that widget. + + 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 + \see Fl_When, do_callback(), Fl::callback_reason() + */ + 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 and all of its parents. + + Changing it will send FL_SHOW or FL_HIDE events to the widget. + Do not change it if the parent is not visible, as this + will send false FL_SHOW or FL_HIDE events to the widget. + 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 and all of its parents. + + 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. + + \note do_callback() turns this flag off after the callback. + + \retval 0 if the value did not change + \see set_changed(), clear_changed() + \see do_callback(Fl_Widget *widget, void *data) + */ + 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;} + + /** Marks the widget as inactive without sending events or changing focus. + This is mainly for specialized use, for normal cases you want deactivate(). + \see deactivate() + */ + void clear_active() {flags_ |= INACTIVE;} + + /** Marks the widget as active without sending events or changing focus. + This is mainly for specialized use, for normal cases you want activate(). + \see activate() + */ + void set_active() {flags_ &= ~INACTIVE;} + + /** Gives the widget the keyboard focus. + Tries to make this widget be the Fl::focus() widget, by first sending + it an FL_FOCUS event, and if it returns non-zero, setting + Fl::focus() to this widget. You should use this method to + assign the focus to a widget. + \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() const { return flags_ & VISIBLE_FOCUS; } + + /** The default callback for all widgets that don't set a callback. + + This callback function puts a pointer to the widget on the queue + returned by Fl::readqueue(). This is the default for all widgets + if you don't set a callback. + + You can avoid the overhead of this default handling if you set the + callback to \p NULL explicitly. + + Relying on the default callback and reading the callback queue with + Fl::readqueue() is not recommended. If you need a callback, you should + set one with Fl_Widget::callback(Fl_Callback *cb, void *data) + or one of its variants. + + \param[in] widget the Fl_Widget given to the callback + \param[in] data user data associated with that callback + + \see callback(), Fl::readqueue() + \see do_callback(Fl_Widget *widget, void *data) + */ + static void default_callback(Fl_Widget *widget, void *data); + + /** Calls the widget callback function with default arguments. + + This is the same as calling + \code + do_callback(this, user_data(), reason); + \endcode + + \param[in] reason give a reason to why this callback was called, defaults to \ref FL_REASON_UNKNOWN + + \see callback() + \see do_callback(Fl_Widget *widget, void *data, Fl_Callback_Reason reason), Fl_Callback_Reason + */ + void do_callback(Fl_Callback_Reason reason=FL_REASON_UNKNOWN) {do_callback(this, user_data_, reason);} + + /** Calls the widget callback function with arbitrary arguments. + \param[in] widget call the callback with \p widget as the first argument + \param[in] arg call the callback with \p arg as the user data (second) argument + \param[in] reason give a reason to why this callback was called, defaults to \ref FL_REASON_UNKNOWN + \see callback() + \see do_callback(Fl_Widget *widget, void *data), Fl_Callback_Reason + */ + void do_callback(Fl_Widget *widget, long arg, Fl_Callback_Reason reason=FL_REASON_UNKNOWN) { + do_callback(widget, (void*)(fl_intptr_t)arg, reason); + } + + void do_callback(Fl_Widget *widget, void *arg = 0, Fl_Callback_Reason reason=FL_REASON_UNKNOWN); + + /* 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); + /* Internal use only. */ + void _set_fullscreen() {flags_ |= FULLSCREEN;} + void _clear_fullscreen() {flags_ &= ~FULLSCREEN;} + + /** 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 \p wgt. + Returns 1 if this widget is a child of \p wgt, or is + equal to \p wgt. Returns 0 if \p wgt is NULL. + \param[in] wgt the possible parent widget. + \see contains() + */ + int inside(const Fl_Widget *wgt) const {return wgt ? wgt->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 are set + 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. + + This calls fl_measure() internally. For more information about + the arguments \p ww and \p hh and word wrapping + \see fl_measure(const char*, int&, int&, int) + */ + void measure_label(int& ww, int& hh) const {label_.measure(ww, hh);} + + Fl_Window* window() const ; + Fl_Window* top_window() const; + Fl_Window* top_window_offset(int& xoff, int& yoff) 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 NULL; } + virtual Fl_Group const* as_group() const { return NULL; } + + /** 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; } + virtual Fl_Window const* as_window() const { return NULL; } + + /** 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 NULL; } + virtual class Fl_Gl_Window const* as_gl_window() const { return NULL; } + + /** Returns non zero if MAC_USE_ACCENTS_MENU flag is set, 0 otherwise. + */ + int use_accents_menu() { return flags() & MAC_USE_ACCENTS_MENU; } + + /** For back compatibility only. + \deprecated Use selection_color() instead. + */ + Fl_Color color2() const {return (Fl_Color)color2_;} + + /** For back compatibility only. + \deprecated Use selection_color(unsigned) instead. + */ + void color2(unsigned a) {color2_ = a;} + + /** Sets whether the widget's label uses '&' to indicate shortcuts. + By default, all objects of classes Fl_Menu_ (and derivatives), Fl_Button (and derivatives), + Fl_Text_Display, Fl_Value_Input, and Fl_Input_ (and derivatives) + use character '&' in their label, unless '&' is repeated, + to indicate shortcuts: '&' does not appear in the drawn label, + the next character after '&' in the label is drawn underlined, and typing this character + triggers the corresponding menu window, button, or other widget. If the label contains 2 consecutive '&', + only one is drawn and the next character is not underlined and not used as a shortcut. + If \p value is set to 0, all these labels don't process character '&' as indicating a shortcut: + '&' is drawn in the label, the next character is not underlined and does not define a shortcut. + */ + void shortcut_label(int value) { + if (value) + set_flag(SHORTCUT_LABEL); + else + clear_flag(SHORTCUT_LABEL); + } + + /** Returns whether the widget's label uses '&' to indicate shortcuts. + \see void shortcut_label(int value) */ + int shortcut_label() const { return flags_ & SHORTCUT_LABEL; } +}; + +/** + 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 diff --git a/include/linux/amd64/FL/Fl_Widget_Surface.H b/include/linux/amd64/FL/Fl_Widget_Surface.H new file mode 100644 index 0000000..f649062 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Widget_Surface.H @@ -0,0 +1,45 @@ +// +// Drivers code for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2016 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef Fl_Widget_Surface_h +#define Fl_Widget_Surface_h + +#include +#include + +/** A surface on which any FLTK widget can be drawn. + */ +class FL_EXPORT Fl_Widget_Surface : public Fl_Surface_Device { +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; + Fl_Widget_Surface(Fl_Graphics_Driver *d); +public: + virtual void translate(int x, int y); + virtual void untranslate(); + void draw(Fl_Widget* widget, int delta_x = 0, int delta_y = 0); + void draw_decorated_window(Fl_Window *win, int x_offset = 0, int y_offset = 0); + 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 printable_rect(int *w, int *h); + virtual void origin(int x, int y); + virtual void origin(int *x, int *y); +}; + +#endif /* Fl_Widget_Surface_h */ diff --git a/include/linux/amd64/FL/Fl_Window.H b/include/linux/amd64/FL/Fl_Window.H new file mode 100644 index 0000000..c684927 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Window.H @@ -0,0 +1,644 @@ +// +// Window header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file + Fl_Window widget . */ + +#ifndef Fl_Window_H +#define Fl_Window_H + +#include +#include +#include + +#define FL_WINDOW 0xF0 ///< window type id: all subclasses have type() >= this +#define FL_DOUBLE_WINDOW 0xF1 ///< double window type id + +class Fl_X; +class Fl_Window_Driver; +class Fl_RGB_Image; +class Fl_Double_Window; + +/** + 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(). + Callback reasons can be \p FL_REASON_CANCELLED if the Escape key was pressed, + or \p FL_REASON_CLOSED when the close button is clicked. \p FL_WHEN_... + flags are ignored. +*/ +class FL_EXPORT Fl_Window : public Fl_Group { + friend class Fl_X; + friend class Fl_Window_Driver; +private: + static char *default_xclass_; + static char show_next_window_iconic_; // 1 means create next window in iconic form + + int no_fullscreen_x; + int no_fullscreen_y; + int no_fullscreen_w; + int no_fullscreen_h; + int fullscreen_screen_top; + int fullscreen_screen_bottom; + int fullscreen_screen_left; + int fullscreen_screen_right; + + // TODO: it would make sense to merge the use of Fl_X and Fl_Window_Driver, maybe simply by + // TODO: deriving Fl_Window_Driver from Fl_X. However, there are a lot of historic kludges + // TODO: for some platforms around Fl_X. + Fl_X *flx_; // points at the system-specific stuff, but exists only after the window is mapped + Fl_Window_Driver *pWindowDriver; // points at the system-specific stuff at window creation time + + const char* iconlabel_; + char* xclass_; + + // private size_range stuff: + int minw_, minh_, maxw_, maxh_; + int dw_, dh_, aspect_; + uchar size_range_set_; // true (1) if size_range() has been set or calculated + + // cursor stuff + Fl_Cursor cursor_default; + + void _Fl_Window(); // constructor innards + + // unimplemented copy ctor and assignment operator + Fl_Window(const Fl_Window&); + Fl_Window& operator=(const Fl_Window&); + + void is_maximized_(bool b); + +protected: + + /** Stores the last window that was made current. See current() const */ + static Fl_Window *current_; + void draw() FL_OVERRIDE; + +public: + + /** Forces the window to be drawn, this window is also made current and calls draw(). */ + virtual void flush(); + +protected: + + /** + 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); } + + void free_icons(); + + void default_size_range(); // calculate size_range() if not set explicitly + int is_resizable(); // calculate size_range() and return whether this is resizable + +public: + + /** + Creates a window from the given width \p w, height \p h, and \p 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 (x, y), size (w, h) and title. + + On a multi-screen system, the values computed by + Fl::screen_xywh(int &X, int &Y, int &W, int &H, int n) can be used to + discover the coordinates of the area of screen \#n. + When these screens have various scale factor + values, an \p (x, y) pair may not be enough to specify the targeted screen + for the window, because the same \p (x,y) pair can belong to several screens. + In that situation, a call to Fl_Window::screen_num(int) is to be used to identify + unambiguously the targeted screen. + + \see Fl_Window(int w, int h, const char *title) + \see Fl::screen_xywh(int &X, int &Y, int &W, int &H, int n) + + \note Under Wayland, it's generally not possible for the client app to control + the position of a window in the system. It's possible to specify on what screen + should the compositor place a fullscreen window. It's also possible to make an + Fl_Window the child of another window or group and control with \p x and \p y + its screen position relatively to the enclosing window. Apply member function + Fl_Window::allow_expand_outside_parent() to the child window to allow it + to expand partially or totally outside its parent. + */ + Fl_Window(int x, int y, int w, int h, const char *title = 0); + /** + The destructor also deletes all the children. 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 first so + that it is destroyed last. + */ + virtual ~Fl_Window(); + + int handle(int) FL_OVERRIDE; + + /** + 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. + */ + void resize(int X,int Y,int W,int H) FL_OVERRIDE; + /** Sets whether or not the window manager border is around the window. + The default value is true. The macOS platform ignores requests to change the + border state of a fullscreen or maximized window. + With some X window + managers, this does not work after show() has been called. + */ + 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);} + /** Returns whether the window possesses a border */ + unsigned int border() const {return !(flags() & NOBORDER);} + /** Activates the flags NOBORDER|OVERRIDE */ + void set_override() {set_flag(NOBORDER|OVERRIDE);} + /** Returns non zero if 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 three 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);} + + /** + Clears the "modal" flags and converts a "modal" or "non-modal" + window back into a "normal" window. + + Note that there are three states for a window: modal, + non-modal, and normal. + + You can not change the "modality" of a window whilst + it is shown, so it is necessary to first hide() the window, + change its "modality" as required, then re-show the window + for the new state to take effect. + + This method can also be used to change a "modal" window into a + "non-modal" one. On several supported platforms, the "modal" state + over-rides the "non-modal" state, so the "modal" state must be + cleared before the window can be set into the "non-modal" + state. + In general, the following sequence should work: + + \code + win->hide(); + win->clear_modal_states(); + // Set win to new state as desired, or leave "normal", e.g... + win->set_non_modal(); + win->show(); + \endcode + + \note Under some window managers, the sequence of hiding the + window and changing its modality will often cause it to be + re-displayed at a different position when it is subsequently + shown. This is an irritating feature but appears to be + unavoidable at present. + As a result we would advise to use this method only when + absolutely necessary. + + \see void set_modal(), void set_non_modal() + */ + void clear_modal_states() {clear_flag(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);} + + void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0); + + uchar get_size_range(int *minw, int *minh, int *maxw=NULL, int *maxh=NULL, int *dw=NULL, int *dh=NULL, int *aspect=NULL); + + /** 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); + + static void default_icon(const Fl_RGB_Image*); + static void default_icons(const Fl_RGB_Image*[], int); + void icon(const Fl_RGB_Image*); + void icons(const Fl_RGB_Image*[], int); + +#if defined(_WIN32) || defined(FL_DOXYGEN) + typedef struct HICON__* HICON; + // These 2 member functions break the driver model but are kept for back compatibility. + // They are implemented in Fl_win32.cxx + + /** Sets the default window icons (Windows platform only). + + Convenience function to set the default icons using Windows' + native HICON icon handles. + + The given icons are copied. You can free the icons immediately after + this call. + + \param[in] big_icon default large icon for all windows + subsequently created + \param[in] small_icon default small icon for all windows + subsequently created + + \see Fl_Window::default_icon(const Fl_RGB_Image *) + \see Fl_Window::default_icons(const Fl_RGB_Image *[], int) + \see Fl_Window::icon(const Fl_RGB_Image *) + \see Fl_Window::icons(const Fl_RGB_Image *[], int) + \see Fl_Window::icons(HICON, HICON) + */ + static void default_icons(HICON big_icon, HICON small_icon); + + /** Sets the window icons using HICON handles (Windows platform only). + + The given icons are copied. You can free the icons immediately after + this call. + + \param[in] big_icon large window icon + \param[in] small_icon small window icon + */ + void icons(HICON big_icon, HICON small_icon); +#endif // defined(_WIN32) || defined(FL_DOXYGEN) + + /* for legacy compatibility */ + 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 flx_ != 0;} + /** + Puts the window on the screen. This has the side + effect of opening the display, if not done before. + + 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. + + \note For some obscure reasons Fl_Window::show() resets the current + group by calling Fl_Group::current(0). The comments in the code + say "get rid of very common user bug: forgot end()". Although + this is true it may have unwanted side effects if you show() an + unrelated window (maybe for an error message or warning) while + building a window or any other group widget. + + \todo Check if we can remove resetting the current group in a later + FLTK version (after 1.3.x). This may break "already broken" programs + though if they rely on this "feature". + + \see Fl_Window::show(int argc, char **argv) + */ + void show() FL_OVERRIDE; + /** + Removes the window from the screen. If the window is already hidden or + has not been shown then this does nothing and is harmless. + */ + void hide() FL_OVERRIDE; + /** + Puts the window on the screen with show() and parses command-line arguments. + + This call should be used for top-level windows, at least for the + first (main) window. It allows standard arguments to be parsed, as done by Fl::args(int, char **), + from the command-line. You can use \p argc and \p argv from + main(int argc, char **argv) for this call. + + This call also sets up some system-specific internal variables, that is, + it sets FL_SELECTION_COLOR and calls Fl::background(), Fl::background2(), Fl::foreground() + with default or X resources-given values, and calls Fl::scheme(const char *) for the current scheme. + On X11, it also calls Fl::dnd_text_ops(int), Fl_Tooltip::enable(int), + Fl::visible_focus(int) with X resources-given values. + + \param argc command-line argument count, usually from main() + \param argv command-line argument vector, usually from main() + + \see virtual void Fl_Window::show() + \see Fl::args(int, char **) + */ + void show(int argc, char **argv); + + // Enables synchronous show(), docs in Fl_Window.cxx + void wait_for_expose(); + + /** + Makes the window completely fill one or more screens, without any + window manager border visible. You must use fullscreen_off() to + undo this. + + \note On some platforms, this can result in the keyboard being + grabbed. The window may also be recreated, meaning hide() and + show() will be called. + + \see void Fl_Window::fullscreen_screens() + */ + void fullscreen(); + /** + Turns off any side effects of fullscreen() + */ + void fullscreen_off(); + /** + Turns off any side effects of fullscreen() and does + resize(x,y,w,h). + */ + void fullscreen_off(int X,int Y,int W,int H); + /** + Returns non zero if FULLSCREEN flag is set, 0 otherwise. + */ + unsigned int fullscreen_active() const { return flags() & FULLSCREEN; } + /** + Sets which screens should be used when this window is in fullscreen + mode. The window will be resized to the top of the screen with index + \p top, the bottom of the screen with index \p bottom, etc. + + If this method is never called, or if any argument is < 0, then the + window will be resized to fill the screen it is currently on. + + \see void Fl_Window::fullscreen() + */ + void fullscreen_screens(int top, int bottom, int left, int right); + + void maximize(); + void un_maximize(); + /** Returns whether the window is currently maximized */ + unsigned int maximize_active() const { return flags() & MAXIMIZED; } +public: + /** + 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 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. Danger: incremental update is very hard to + debug and maintain! + + This method only works for the Fl_Window and Fl_Gl_Window derived classes. + */ + void make_current(); + + void cursor(Fl_Cursor); + void cursor(const Fl_RGB_Image*, int, int); + void default_cursor(Fl_Cursor); + + /* for legacy compatibility */ + void cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE); + void default_cursor(Fl_Cursor c, Fl_Color, 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, or if window is not yet mapped. + \see decorated_h(). + */ + int decorated_w() const; + + /** 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, or if window is not yet mapped. + \note Under X11, FLTK is able to compute the size of window titlebars and borders + only if these decoration elements are strictly X11-based. When that's not the case, + decorated_h() returns the same value as h() and decorated_w() as w(), and FLTK + cannot access window decorations. + + \note Under X11 again, the values returned by decorated_h() and decorated_w() + may not be reliable during a resize operation. The size of decoration elements + of a window is best computed when the window is first mapped. + */ + int decorated_h() const; + + // Note: Doxygen docs in Fl_Widget.H to avoid redundancy. + Fl_Window* as_window() FL_OVERRIDE { return this; } + Fl_Window const* as_window() const FL_OVERRIDE { return this; } + + /** + Return non-null if this is an Fl_Overlay_Window object. + */ + virtual class Fl_Overlay_Window *as_overlay_window() {return 0L; } + + /** + Return non-null if this is an Fl_Double_Window object. + */ + virtual class Fl_Double_Window *as_double_window() {return 0L;} + + void shape(const Fl_Image* img); + void shape(const Fl_Image& b); + const Fl_Image *shape(); + void draw_backdrop(); + int screen_num(); + void screen_num(int screen_num); + static bool is_a_rescale(); + fl_uintptr_t os_id(); + + /** + Sets a static flag whether the next window should be opened iconified. + + \note This is an internal function, you should not use this in user code. + + Please use Fl_Window::iconize() instead. + */ + static void show_next_window_iconic(char stat) { + show_next_window_iconic_ = stat ? 1 : 0; + } + + /** + Returns the static flag whether the next window should be opened iconified. + + \note This is an internal function, you should not use this in user code. + + Please use Fl_Window::iconize() to iconify a window. + */ + static char show_next_window_iconic() { + return show_next_window_iconic_; + } + + void allow_expand_outside_parent(); + +}; + +#endif diff --git a/include/linux/amd64/FL/Fl_Wizard.H b/include/linux/amd64/FL/Fl_Wizard.H new file mode 100644 index 0000000..b45d218 --- /dev/null +++ b/include/linux/amd64/FL/Fl_Wizard.H @@ -0,0 +1,58 @@ +// +// Fl_Wizard widget definitions. +// +// Copyright 1999-2010 by Easy Software Products. +// Copyright 2011-2020 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/* \file + Fl_Wizard widget . */ + +// +// Include necessary header files... +// + +#ifndef _Fl_Wizard_H_ +#define _Fl_Wizard_H_ + +#include + +/** + 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. + + 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_; + +protected: + + void draw() FL_OVERRIDE; + +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_ diff --git a/include/linux/amd64/FL/Fl_XBM_Image.H b/include/linux/amd64/FL/Fl_XBM_Image.H new file mode 100644 index 0000000..2c4e1b0 --- /dev/null +++ b/include/linux/amd64/FL/Fl_XBM_Image.H @@ -0,0 +1,35 @@ +// +// XBM image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 diff --git a/include/linux/amd64/FL/Fl_XPM_Image.H b/include/linux/amd64/FL/Fl_XPM_Image.H new file mode 100644 index 0000000..a10a248 --- /dev/null +++ b/include/linux/amd64/FL/Fl_XPM_Image.H @@ -0,0 +1,36 @@ +// +// XPM image header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 diff --git a/include/linux/amd64/FL/filename.H b/include/linux/amd64/FL/filename.H new file mode 100644 index 0000000..92bf96f --- /dev/null +++ b/include/linux/amd64/FL/filename.H @@ -0,0 +1,145 @@ +/* + * Filename header file for the Fast Light Tool Kit (FLTK). + * + * Copyright 1998-2023 by Bill Spitzak and others. + * + * This library is free software. Distribution and use rights are outlined in + * the file "COPYING" which should have been included with this file. If this + * file is missing or damaged, see the license at: + * + * https://www.fltk.org/COPYING.php + * + * Please see the following page on how to report bugs and issues: + * + * https://www.fltk.org/bugs.php + */ + +/* + * Note to devs: + * Under Windows, we include filename.H from numericsort.c; this should probably change. + * This implies that we need C-style comments and '#ifdef __cplusplus ... #endif' + */ + +/** \file + File names and URI utility functions. +*/ + +#ifndef FL_FILENAME_H +# define FL_FILENAME_H + +#include "Fl_Export.H" +#include + +#ifdef __cplusplus + +// The following include is not (yet) used in FLTK 1.4 +// In FLTK 1.5 or 4.0 using std::string would be default. +// #include + +#endif /* __cplusplus */ + +/** \addtogroup filenames File names and URI utility functions + File names and URI functions defined in + @{ */ + +# 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 + [..] + 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) + +FL_EXPORT int fl_filename_absolute(char *to, int tolen, const char *from, const char *cwd); +FL_EXPORT int fl_filename_relative(char *to, int tolen, const char *from, const char *cwd); + + +// FIXME: We can't do this in 1.4.x - enable this block in 1.5 or higher. +// See fluid/fluid_filename.{h|cxx} for an implementation using Fl_String. + +// FL_EXPORT std::string fl_filename_name(const std::string &filename); +// FL_EXPORT std::string fl_filename_path(const std::string &filename); +// FL_EXPORT std::string fl_filename_ext(const std::string &filename); +// FL_EXPORT std::string fl_filename_setext(const std::string &filename, const std::string &new_extension); +// FL_EXPORT std::string fl_filename_expand(const std::string &from); +// FL_EXPORT std::string fl_filename_absolute(const std::string &from); +// FL_EXPORT std::string fl_filename_absolute(const std::string &from, const std::string &base); +// FL_EXPORT std::string fl_filename_relative(const std::string &from); +// FL_EXPORT std::string fl_filename_relative(const std::string &from, const std::string &base); +// FL_EXPORT std::string fl_getcwd(); + +# endif /* defined(__cplusplus) */ + +# if defined(__cplusplus) && !defined(FL_DOXYGEN) +/* + * Under Windows, 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); } +inline int fl_filename_relative(char *to, const char *from) { return fl_filename_relative(to, FL_PATH_MAX, from); } +# endif /* __cplusplus */ + +# 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); + +FL_EXPORT void fl_decode_uri(char *uri); + +# endif /* __cplusplus */ + +/* + * Note: FLTK 1.0.x compatibility definitions (FLTK_1_0_COMPAT) dropped in 1.4.0 + */ + +#endif /* FL_FILENAME_H */ + +/** @} */ diff --git a/include/linux/amd64/FL/fl_ask.H b/include/linux/amd64/FL/fl_ask.H new file mode 100644 index 0000000..2387a19 --- /dev/null +++ b/include/linux/amd64/FL/fl_ask.H @@ -0,0 +1,134 @@ +// +// Standard dialog header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** \file fl_ask.H + API for common dialogs. +*/ + +#ifndef _FL_fl_ask_H_ +#define _FL_fl_ask_H_ + +#include +#include + +#if (FLTK_USE_STD) +#include +#endif + +class Fl_Widget; + +/** Defines the different system beeps available. + + Some systems may play different sounds or use different sound volume + depending on the Fl_Beep value. The implementation is platform dependent. + + \sa fl_beep(int) +*/ +enum Fl_Beep { + FL_BEEP_DEFAULT = 0, ///< Default beep. + FL_BEEP_MESSAGE, ///< Message beep. + FL_BEEP_ERROR, ///< Error beep. + FL_BEEP_QUESTION, ///< Question beep. + FL_BEEP_PASSWORD, ///< Password beep. + FL_BEEP_NOTIFICATION ///< Notification beep. +}; + +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() or fl_choice_n() 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))); + +// since FLTK 1.3.8: +// - fl_choice_n() with extended return value (-2, -1, 0, 1, 2) + +FL_EXPORT int fl_choice_n(const char *q, const char *b0, const char *b1, const char *b2, ...) + __fl_attr((__format__(__printf__, 1, 5))); + +// since FLTK 1.4.0: with 'maxchar' to limit input size + +FL_EXPORT const char *fl_input(int maxchar, const char *label, const char *deflt = 0, ...) + __fl_attr((__format__(__printf__, 2, 4))); + +FL_EXPORT const char *fl_password(int maxchar, const char *label, const char *deflt = 0, ...) + __fl_attr((__format__(__printf__, 2, 4))); + +// since FLTK 1.4.0 -- only with option FLTK_USE_STD + +// - fl_input_str() with limited input size, returns std::string +// - fl_password_str() with limited input size, returns std::string + +#if (FLTK_USE_STD) + +FL_EXPORT std::string fl_input_str(int maxchar, const char *label, const char *deflt = 0, ...) + __fl_attr((__format__(__printf__, 2, 4))); + +FL_EXPORT std::string fl_input_str(int &ret, int maxchar, const char *label, const char *deflt = 0, ...) + __fl_attr((__format__(__printf__, 3, 5))); + +FL_EXPORT std::string fl_password_str(int maxchar, const char *label, const char *deflt = 0, ...) + __fl_attr((__format__(__printf__, 2, 4))); + +FL_EXPORT std::string fl_password_str(int &ret, int maxchar, const char *label, const char *deflt = 0, ...) + __fl_attr((__format__(__printf__, 3, 5))); + +#endif + +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); + +// since FLTK 1.4.0: fl_message_position() + +FL_EXPORT void fl_message_position(const int x, const int y, const int center = 0); +FL_EXPORT void fl_message_position(Fl_Widget *widget); +FL_EXPORT int fl_message_position(int *x = 0, int *y = 0); + +/** \see fl_message_position(Fl_Widget *widget). */ +inline void fl_message_position(Fl_Widget &widget) { + fl_message_position(&widget); +} + +FL_EXPORT void fl_message_title(const char *title); +FL_EXPORT void fl_message_title_default(const char *title); + +FL_EXPORT void fl_message_icon_label(const char *str); + +// pointers you can use to change FLTK to another 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_fl_ask_H_ diff --git a/include/linux/amd64/FL/fl_attr.h b/include/linux/amd64/FL/fl_attr.h new file mode 100644 index 0000000..73884ff --- /dev/null +++ b/include/linux/amd64/FL/fl_attr.h @@ -0,0 +1,213 @@ +/* + * Function attribute declarations for the Fast Light Tool Kit (FLTK). + * + * Copyright 1998-2024 by Bill Spitzak and others. + * + * This library is free software. Distribution and use rights are outlined in + * the file "COPYING" which should have been included with this file. If this + * file is missing or damaged, see the license at: + * + * https://www.fltk.org/COPYING.php + * + * Please see the following page on how to report bugs and issues: + * + * https://www.fltk.org/bugs.php + */ + +/** + \file fl_attr.h + This file defines compiler-specific macros +*/ + +#ifndef _FL_fl_attr_h_ +#define _FL_fl_attr_h_ + + +/** + This section lists macros for Doxygen documentation only. The next section + will define the actual macros based on the compile used and based on the + capabilities of the version of that compiler. + */ +#ifdef FL_DOXYGEN + + +/** To be used in prototypes with a variable list of arguments. + This macro helps detection of mismatches between format string and + argument list at compilation time. + + Usage example: FL/fl_ask.H + */ +#define __fl_attr(x) + +/** + This macro makes it safe to use the C++11 keyword \c override with + older compilers. +*/ +#define FL_OVERRIDE override + +/** + Enclosing a function or method in FL_DEPRECATED marks it as no longer + recommended. This macro syntax can not be used if the return type contains + a comma, which is not the case in FLTK. + + \code + FL_DEPRECATED("Outdated, don't use", int position()) { return position_; } + \endcode + */ +#define FL_DEPRECATED(msg, func) \ + /##*##* \deprecated msg *##/ \ + func + + +#else /* FL_DOXYGEN */ + +// If FL_NO_DEPRECATED is defined FLTK 1.4 can compile 1.3.x code without +// issuing several "deprecated" warnings (1.3 "compatibility" mode). +// FL_DEPRECATED will be defined as a no-op. + +// If FL_NO_DEPRECATED is not defined (default) FLTK 1.4 will issue several +// "deprecated" warnings depending on the compiler in use: FL_DEPRECATED +// will be defined according to the capabilities of the compiler (below). +// The definition below this comment must match the one at the end of this file. + +#if defined(FL_NO_DEPRECATED) +#define FL_DEPRECATED(msg, func) func +#endif + +#ifdef __cplusplus + +/* + Declare macros specific to Visual Studio. + + Visual Studio defines __cplusplus = '199711L' in all its versions which is + not helpful for us here. For VS version number encoding see: + https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros + + This document specifies that the macro _MSVC_LANG is defined since + "Visual Studio 2015 Update 3" as 201402L (default) and undefined in + earlier versions. It can be used to determine the C++ standard as + specified by the /std:c++ compiler option: + + - /std:c++14 201402L (also if /std:c++ is not used) + - /std:c++17 201703L + - /std:c++20 202002L + - /std:c++latest a "higher, unspecified value" (docs of VS 2022) + + As of this writing (02/2023) _MSVC_LANG is not yet used in this file + but it is documented for future use. +*/ + +#if defined(_MSC_VER) + +#if (_MSC_VER >= 1900) // Visual Studio 2015 (14.0) +#ifndef FL_OVERRIDE +#define FL_OVERRIDE override +#endif +#endif // Visual Studio 2015 (14.0) + +#if (_MSC_VER >= 1400) // Visual Studio 2005 (8.0) +#ifndef FL_DEPRECATED +#define FL_DEPRECATED(msg, func) __declspec(deprecated(msg)) func +#endif +#endif // Visual Studio 2005 (8.0) + +#if (_MSC_VER >= 1310) // Visual Studio .NET 2003 (7.1) +#ifndef FL_DEPRECATED +#define FL_DEPRECATED(msg, func) __declspec(deprecated) func +#endif +#endif // Visual Studio .NET 2003 (7.1) + +#endif // Visual Studio + + +/* + Declare macros specific to the C++ standard used. + + Macros may have been declared already in previous sections. + */ +#if (__cplusplus >= 202002L) // C++20 +#endif // C++20 + +#if (__cplusplus >= 201703L) // C++17 +#endif // C++17 + +#if (__cplusplus >= 201402L) // C++14 +#ifndef FL_DEPRECATED +#define FL_DEPRECATED(msg, func) [[deprecated(msg)]] func +#endif +#endif // C++14 + +#if (__cplusplus >= 201103L) // C++11 +#ifndef FL_OVERRIDE +#define FL_OVERRIDE override +#endif +#endif // C+11 + +#if (__cplusplus >= 199711L) // C++89 +#endif // C++89 + +#endif // __cplusplus + +/* + Declare macros specific to clang + + Macros may have been declared already in previous sections. + */ +#if defined(__clang__) + +#define FL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) + +// -- nothing yet -- + +#endif /* __clang__ */ + + +/* + Declare macros specific to gcc. + + Macros may have been declared already in previous sections. + */ +#if defined(__GNUC__) + +#define FL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + +#ifndef __fl_attr +#define __fl_attr(x) __attribute__ (x) +#endif + +#if FL_GCC_VERSION > 40500 /* gcc 4.5.0 */ +#ifndef FL_DEPRECATED +#define FL_DEPRECATED(msg, func) func __attribute__((deprecated(msg))) +#endif +#endif /* gcc 4.5.0 */ + +#if FL_GCC_VERSION >= 30400 /* gcc 3.4.0 */ +#ifndef FL_DEPRECATED +#define FL_DEPRECATED(msg, func) func __attribute__((deprecated)) +#endif +#endif /* gcc 3.4.0 */ + +#endif /* __GNUC__ */ + + +/* + If a macro was not defined in any of the sections above, set it to no-op here. + */ + +#ifndef __fl_attr +#define __fl_attr(x) +#endif + +#ifndef FL_OVERRIDE +#define FL_OVERRIDE +#endif + +#ifndef FL_DEPRECATED +#define FL_DEPRECATED(msg, func) func +#endif + + +#endif /* FL_DOXYGEN */ + + +#endif /* !_FL_fl_attr_h_ */ diff --git a/include/linux/amd64/FL/fl_callback_macros.H b/include/linux/amd64/FL/fl_callback_macros.H new file mode 100644 index 0000000..398d848 --- /dev/null +++ b/include/linux/amd64/FL/fl_callback_macros.H @@ -0,0 +1,607 @@ +/* + * Macros for easy callbacks for the Fast Light Tool Kit (FLTK). + * + * Copyright 2023 by Bill Spitzak and others. + * + * This library is free software. Distribution and use rights are outlined in + * the file "COPYING" which should have been included with this file. If this + * file is missing or damaged, see the license at: + * + * https://www.fltk.org/COPYING.php + * + * Please see the following page on how to report bugs and issues: + * + * https://www.fltk.org/bugs.php + */ + +#ifndef _FL_FL_CALLBACK_MACROS_H_ +#define _FL_FL_CALLBACK_MACROS_H_ + +#include + +/** + \file fl_callback_macros.H + This file provides macros for easy function and method callbacks + with multiple type safe arguments. +*/ + +#ifdef FL_DOXYGEN + +/** + \brief Declare a C function callback with custom parameters. + + You can declare a plain C function callback or a static method callback with + custom parameters using this macro. It simplifies the process of calling + arbitrary functions with up to five custom parameters. The macro generates + code that ensures type safety and expands FLTK's standard callbacks, which + are limited to a single `void*` or `long` argument. + + To use the macro, you provide the widget that will handle the callback as the + first argument. The second argument can be either a regular function or a + static method in any class. + + Following these arguments, you can include up to five pairs, where each + pair consists of a type and a value. For example, + `int, 3` specifies an integer parameter with a value of 3. If you need to + pass two arguments, you can use two pairs, like this: + `int, 3, int, 4`. The last digit of the macro name must be the same as + the number of pairs (0..5) + + Whenever the code generated by the macro is called, the custom parameters are + duplicated and marked for automatic deallocation using `delete` when the + callback widget is destroyed. + + \code{.cpp} + #include + ... + Fl_Button *btn1 = new Fl_Button(10, 10, 100, 20, "Beep"); + FL_FUNCTION_CALLBACK_0(btn1, fl_beep); + ... + Fl_Button *btn2 = new Fl_Button(10, 40, 100, 20, "Hello"); + FL_FUNCTION_CALLBACK_5(btn2, + fl_message, + const char *, "Hello\n%d %d %d %d", + int, 1, int, 2, int, 3, int, 4 + ); + \endcode + + You can find a small demonstration program showcasing the usage of + `FL_*_CALLBACK_*` in the `examples/callbacks.cxx` file. + + \param WIDGET the widget that will call the callback + \param FUNC a C/C++ function or a static class method + \param TYPE0, VALUE0, TYPE1, VALUE1, TYPE2, VALUE2 a list of zero to five type/value pairs, all separated by commas + + \see FL_METHOD_CALLBACK_1, FL_INLINE_CALLBACK_2 + */ +#define FL_FUNCTION_CALLBACK_3(WIDGET, FUNC, TYPE0, VALUE0, TYPE1, VALUE1, TYPE2, VALUE2) + +/** + \brief Declare a non-static class method callback with custom parameters. + + You can declare a callback for a non-static class method with custom parameters + using this macro. It provides a convenient way to call arbitrary methods in + any class, overcoming FLTK's limitation of passing only a single `void*` or + `long` argument. Furthermore, it ensures type safety. + + The first argument of the macro specifies the widget that will handle the + callback. The second argument indicates the class type to be called. The + third argument must be a pointer to an instance of that class. The + fourth argument is the name of the method within the class. That method must be + public and should not be static. + + Following these arguments, you can include up to five pairs, where each + pair consists of a type and a value. For example, + `int, 3` specifies an integer parameter with a value of 3. If you need to + pass two arguments, you can use two pairs, like this: + `int, 3, int, 4`. The last digit of the macro name must be the same as + the number of pairs (0..5) + + Whenever the code generated by the macro is called, the custom parameters are + duplicated and marked for automatic deallocation using `delete` when the + callback widget is destroyed. + + \code{.cpp} + #include + ... + Fl_Button *btn = new Fl_Button(10, 10, 100, 20, "Test"); + FL_METHOD_CALLBACK_1(btn, Fl_Button, btn, color, Fl_Color, FL_GREEN); + \endcode + + You can find a small demonstration program showcasing the usage of + `FL_*_CALLBACK_*` in the `examples/callbacks.cxx` file. + + \param WIDGET the widget that will call the callback + \param CLASS the class type + \param SELF a pointer to an instance of the class + \param METH a C++ class method that must be public and not static + \param TYPE0, VALUE0 a list of zero to five type/value pairs, all separated by commas + + \see FL_FUNCTION_CALLBACK_3, FL_INLINE_CALLBACK_2 + */ +#define FL_METHOD_CALLBACK_1(WIDGET, CLASS, SELF, METH, TYPE0, VALUE0) + +/** + \brief Creates code to declare a callback function in line with instantiating a widget. + + You can use this macro to create a function as a callback, allowing you to + define the callback function right where the widget and callback are declared, + similar to a Lambda function. + + The first argument of the macro specifies the widget that will handle the + callback. Next, you can include up to five triplets, where each triplet + consists of a type, a parameter name, and a value. For example, `int, x, 3` + specifies an integer parameter with a value of 3. If you need to pass two + arguments, you can use two triplets, such as `int, x, 3, int, y, 4`. The last + digit of the macro name must be the same as the number of triplets (0..5). + + The last argument is the actual function body itself. + + The function body is limited to a syntax that the macro preprocessor can + handle. It should include the leading '{' and trailing '}' and may contain + local variable declarations, use global variables and functions, and use also + the variables listed and initialized in the argument triples of the macro. + Very large function bodies should be avoided because they may exceed the + admissible size of a macro argument. + + Whenever the code generated by the macro is called, the custom parameters are + duplicated and marked for automatic deallocation using `delete` when the + callback widget is destroyed. + + \code{.cpp} + #include + ... + Fl_Button *btn = new Fl_Button(10, 10, 100, 20, "Test"); + FL_INLINE_CALLBACK_1(btn, + const char *, name, btn->label(), + { + fl_message("Greetings from the %s button", name); + } + ); + \endcode + + You can find a small demonstration program showcasing the usage of + `FL_*_CALLBACK_*` in the `examples/callbacks.cxx` file. + + \param WIDGET the widget that will call the callback + \param TYPE0 the type of the first parameter in the function call + \param NAME0 an arbitrary variable name that can be used as a parameter in the function body + \param VALUE0 a constant value or a variable; the value of the variable is copied when the callback is created + \param TYPE1, NAME1, VALUE1 as above; there are six macros that support 0 to 5 parameters + \param LAMBDA the function body within the limits of the C macro preprocessor + + \see FL_METHOD_CALLBACK_1, FL_FUNCTION_CALLBACK_3 + */ +#define FL_INLINE_CALLBACK_2(WIDGET, TYPE0, NAME0, VALUE0, TYPE1, NAME1, VALUE1, LAMBDA) + +#else // FL_DOXYGEN + +/* + These two macros make it possible to call macros with names that are created + by concatenating the name in x and (in this context) the number in y. + */ +#define _FL_CBD_CONCAT_IMPL(x, y) x##y +#define _FL_CBD_CONCAT(x, y) _FL_CBD_CONCAT_IMPL(x, y) + +/* + Create a unique name for the derived class based on the current source code + line number. + */ +#define _FL_CBD_CLASS_NAME _FL_CBD_CONCAT(Fl_Callback_User_Data_,__LINE__) + + +/* + These macros create boilerplate code for callbacks to functions and + static class methods with up to five arguments. + + This macro invocation for example + ``` + FL_FUNCTION_CALLBACK_2( func_cb_btn_2, hello_2_args_cb, + const char *, text, "FLTK", + int, number, 2 ); + ``` + will generate the following code: + + ``` + do { + class Fl_Callback_User_Data_92 : public Fl_Callback_User_Data { + public: + const char * p0_; + int p1_; + static void cb(Fl_Widget *w, void *user_data) { + Fl_Callback_User_Data_92 *d = (Fl_Callback_User_Data_92*)user_data; + hello_2_args_cb(d->p0_, d->p1_); + }; + Fl_Callback_User_Data_92(const char * p0, int p1) + : p0_(p0), + p1_(p1) + { } + }; + func_cb_btn_2->callback(Fl_Callback_User_Data_92::cb, + new Fl_Callback_User_Data_92("FLTK", 2), + true); + } while(0) + ``` + + Clicking the Fl_Button `func_cb_btn_2` will call `hello_2_args_cb("FLTK", 2)`. + Deleting the button will also delete the data that was created in our + boilerplate code. + */ +#define FL_FUNCTION_CALLBACK_5(WIDGET, FUNC, TYPE0, VALUE0, TYPE1, VALUE1, TYPE2, VALUE2, TYPE3, VALUE3, TYPE4, VALUE4) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; TYPE3 p3_; TYPE4 p4_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + FUNC(d->p0_, d->p1_, d->p2_, d->p3_, d->p4_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0, TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4) \ + : p0_(p0), p1_(p1), p2_(p2), p3_(p3), p4_(p4) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0, VALUE1, VALUE2, VALUE3, VALUE4), true); \ + } while(0) + +#define FL_FUNCTION_CALLBACK_4(WIDGET, FUNC, TYPE0, VALUE0, TYPE1, VALUE1, TYPE2, VALUE2, TYPE3, VALUE3) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; TYPE3 p3_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + FUNC(d->p0_, d->p1_, d->p2_, d->p3_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0, TYPE1 p1, TYPE2 p2, TYPE3 p3) \ + : p0_(p0), p1_(p1), p2_(p2), p3_(p3) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0, VALUE1, VALUE2, VALUE3), true); \ + } while(0) + +#define FL_FUNCTION_CALLBACK_3(WIDGET, FUNC, TYPE0, VALUE0, TYPE1, VALUE1, TYPE2, VALUE2) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + FUNC(d->p0_, d->p1_, d->p2_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0, TYPE1 p1, TYPE2 p2) \ + : p0_(p0), p1_(p1), p2_(p2) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0, VALUE1, VALUE2), true); \ + } while(0) + +#define FL_FUNCTION_CALLBACK_2(WIDGET, FUNC, TYPE0, VALUE0, TYPE1, VALUE1) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; TYPE1 p1_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + FUNC(d->p0_, d->p1_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0, TYPE1 p1) \ + : p0_(p0), p1_(p1) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0, VALUE1), true); \ + } while(0) + +#define FL_FUNCTION_CALLBACK_1(WIDGET, FUNC, TYPE0, VALUE0) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + FUNC(d->p0_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0) \ + : p0_(p0) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0), true); \ + } while(0) + +#define FL_FUNCTION_CALLBACK_0(WIDGET, FUNC) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + static void cb(Fl_Widget *w, void *user_data) { \ + FUNC(); \ + }; \ + _FL_CBD_CLASS_NAME() { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(), true); \ + } while(0) + +/* + These macros create boilerplate code for callbacks to class methods + with up to five arguments. + + This macro invocation for example + ``` + FL_METHOD_CALLBACK_4(btn, + MyWindow, win, resize, + int, test_x+10, + int, test_y+10, + int, 320, + int, 400); + ``` + will generate the following code: + + ``` + do { + class Fl_Callback_User_Data_73 : public Fl_Callback_User_Data { + public: + int p0_; + int p1_; + int p2_; + int p3_; + MyWindow *self_; + static void cb(Fl_Widget *w, void *user_data) { + Fl_Callback_User_Data_73 *d = (Fl_Callback_User_Data_73*)user_data; + d->self_->resize(d->p0_, d->p1_, d->p2_, d->p3_); + }; + Fl_Callback_User_Data_73(MyWindow *self, int p0, int p1, int p2, int p3) + : self_(self), p0_(p0), p1_(p1), p2_(p2), p3_(p3) { } + }; + btn->callback(Fl_Callback_User_Data_73::cb, + new Fl_Callback_User_Data_73(win, test_x+10, test_y+10, 320, 400), + true); + } while(0); + ``` + + Clicking the Fl_Button `btn` will call + `win->resize(test_x+10, test_y+10, 320, 400);`. + Deleting the button will also delete the data that was created in our + boilerplate code. + */ + +#define FL_METHOD_CALLBACK_5(WIDGET, CLASS, SELF, METHOD, TYPE0, VALUE0, TYPE1, VALUE1, TYPE2, VALUE2, TYPE3, VALUE3, TYPE4, VALUE4) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + CLASS *self_; \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; TYPE3 p3_; TYPE4 p4_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + d->self_->METHOD(d->p0_, d->p1_, d->p2_, d->p3_, d->p4_); \ + }; \ + _FL_CBD_CLASS_NAME(CLASS *self, TYPE0 p0, TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4) \ + : self_(self), p0_(p0), p1_(p1), p2_(p2), p3_(p3), p4_(p4) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(SELF, VALUE0, VALUE1, VALUE2, VALUE3, VALUE4), true); \ + } while(0) + +#define FL_METHOD_CALLBACK_4(WIDGET, CLASS, SELF, METHOD, TYPE0, VALUE0, TYPE1, VALUE1, TYPE2, VALUE2, TYPE3, VALUE3) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + CLASS *self_; \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; TYPE3 p3_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + d->self_->METHOD(d->p0_, d->p1_, d->p2_, d->p3_); \ + }; \ + _FL_CBD_CLASS_NAME(CLASS *self, TYPE0 p0, TYPE1 p1, TYPE2 p2, TYPE3 p3) \ + : self_(self), p0_(p0), p1_(p1), p2_(p2), p3_(p3) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(SELF, VALUE0, VALUE1, VALUE2, VALUE3), true); \ + } while(0) + +#define FL_METHOD_CALLBACK_3(WIDGET, CLASS, SELF, METHOD, TYPE0, VALUE0, TYPE1, VALUE1, TYPE2, VALUE2) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + CLASS *self_; \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + d->self_->METHOD(d->p0_, d->p1_, d->p2_); \ + }; \ + _FL_CBD_CLASS_NAME(CLASS *self, TYPE0 p0, TYPE1 p1, TYPE2 p2) \ + : self_(self), p0_(p0), p1_(p1), p2_(p2) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(SELF, VALUE0, VALUE1, VALUE2), true); \ + } while(0) + +#define FL_METHOD_CALLBACK_2(WIDGET, CLASS, SELF, METHOD, TYPE0, VALUE0, TYPE1, VALUE1) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + CLASS *self_; \ + TYPE0 p0_; TYPE1 p1_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + d->self_->METHOD(d->p0_, d->p1_); \ + }; \ + _FL_CBD_CLASS_NAME(CLASS *self, TYPE0 p0, TYPE1 p1) \ + : self_(self), p0_(p0), p1_(p1) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(SELF, VALUE0, VALUE1), true); \ + } while(0) + +#define FL_METHOD_CALLBACK_1(WIDGET, CLASS, SELF, METHOD, TYPE0, VALUE0) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + CLASS *self_; \ + TYPE0 p0_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + d->self_->METHOD(d->p0_); \ + }; \ + _FL_CBD_CLASS_NAME(CLASS *self, TYPE0 p0) \ + : self_(self), p0_(p0) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(SELF, VALUE0), true); \ + } while(0) + +#define FL_METHOD_CALLBACK_0(WIDGET, CLASS, SELF, METHOD) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + CLASS *self_; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + d->self_->METHOD(); \ + }; \ + _FL_CBD_CLASS_NAME(CLASS *self) \ + : self_(self) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(SELF), true); \ + } while(0) + +/* + These macros create boilerplate code for callback functions inlined into + the widget creation code (similar to lambda functions in C++11 and up) + with up to five arguments. + + This macro invocation for example + ``` + FL_INLINE_CALLBACK_2( // callback has two parameters + btn, // attach callback to this button + const char *, text, "FLTK", // first parameter (type, name, value) + int, number, 2, // second parameter + { // function body + fl_message("We received the message %s with %d!", text, number); + } + ); + ``` + will generate the following code: + ``` + do { + class Fl_Callback_User_Data_133 : public Fl_Callback_User_Data { + public: + const char * p0_; // store first parameter here + int p1_; // store second parameter here + // lambda style function + static void fn(const char * text, int number ) { + fl_message("We received the message %s with %d!", text, number); + }; + // FLTK style callback + static void cb(Fl_Widget *w, void *user_data) { + Fl_Callback_User_Data_133 *d = (Fl_Callback_User_Data_133*)user_data; + fn(d->p0_, d->p1_); + }; + // class constructor + Fl_Callback_User_Data_133(const char * p0, int p1) + : p0_(p0), // copy parameter 0 + p1_(p1) // copy parameter 1 + { } // constructor body + }; + // connect our class to the widget callback + btn->callback(Fl_Callback_User_Data_133::cb, + new Fl_Callback_User_Data_133("FLTK", 2), + true); + } while(0); // user code adds semicolon + ``` + + Clicking the Fl_Button `btn` will call + `fl_message("We received the message %s with %d!", "FLTK", 2);`. + Deleting the button will also delete the data that was created in our + boilerplate code. + */ + +#define FL_INLINE_CALLBACK_5(WIDGET, TYPE0, NAME0, VALUE0, TYPE1, NAME1, VALUE1, TYPE2, NAME2, VALUE2, TYPE3, NAME3, VALUE3, TYPE4, NAME4, VALUE4, LAMBDA) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; TYPE3 p3_; TYPE4 p4_; \ + static void fn(TYPE0 NAME0, TYPE1 NAME1, TYPE2 NAME2, TYPE3 NAME3, TYPE4 NAME4) \ + LAMBDA; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + _FL_CBD_CLASS_NAME::fn(d->p0_, d->p1_, d->p2_, d->p3_, d->p4_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0, TYPE1 p1, TYPE2 p2, TYPE3 p3, TYPE4 p4) \ + : p0_(p0), p1_(p1), p2_(p2), p3_(p3), p4_(p4) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0, VALUE1, VALUE2, VALUE3, VALUE4), true); \ + } while(0) + +#define FL_INLINE_CALLBACK_4(WIDGET, TYPE0, NAME0, VALUE0, TYPE1, NAME1, VALUE1, TYPE2, NAME2, VALUE2, TYPE3, NAME3, VALUE3, LAMBDA) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; TYPE3 p3_; \ + static void fn(TYPE0 NAME0, TYPE1 NAME1, TYPE2 NAME2, TYPE3 NAME3) \ + LAMBDA; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + _FL_CBD_CLASS_NAME::fn(d->p0_, d->p1_, d->p2_, d->p3_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0, TYPE1 p1, TYPE2 p2, TYPE3 p3) \ + : p0_(p0), p1_(p1), p2_(p2), p3_(p3) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0, VALUE1, VALUE2, VALUE3), true); \ + } while(0) + +#define FL_INLINE_CALLBACK_3(WIDGET, TYPE0, NAME0, VALUE0, TYPE1, NAME1, VALUE1, TYPE2, NAME2, VALUE2, LAMBDA) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; TYPE1 p1_; TYPE2 p2_; \ + static void fn(TYPE0 NAME0, TYPE1 NAME1, TYPE2 NAME2) \ + LAMBDA; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + _FL_CBD_CLASS_NAME::fn(d->p0_, d->p1_, d->p2_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0, TYPE1 p1, TYPE2 p2) \ + : p0_(p0), p1_(p1), p2_(p2) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0, VALUE1, VALUE2), true); \ + } while(0) + +#define FL_INLINE_CALLBACK_2(WIDGET, TYPE0, NAME0, VALUE0, TYPE1, NAME1, VALUE1, LAMBDA) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; TYPE1 p1_; \ + static void fn(TYPE0 NAME0, TYPE1 NAME1) \ + LAMBDA; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + _FL_CBD_CLASS_NAME::fn(d->p0_, d->p1_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0, TYPE1 p1) \ + : p0_(p0), p1_(p1) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0, VALUE1), true); \ + } while(0) + +#define FL_INLINE_CALLBACK_1(WIDGET, TYPE0, NAME0, VALUE0, LAMBDA) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + TYPE0 p0_; \ + static void fn(TYPE0 NAME0) \ + LAMBDA; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME *d = (_FL_CBD_CLASS_NAME*)user_data; \ + _FL_CBD_CLASS_NAME::fn(d->p0_); \ + }; \ + _FL_CBD_CLASS_NAME(TYPE0 p0) \ + : p0_(p0) { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(VALUE0), true); \ + } while(0) + +#define FL_INLINE_CALLBACK_0(WIDGET, LAMBDA) \ + do { \ + class _FL_CBD_CLASS_NAME : public Fl_Callback_User_Data { \ + public: \ + static void fn() \ + LAMBDA; \ + static void cb(Fl_Widget *w, void *user_data) { \ + _FL_CBD_CLASS_NAME::fn(); \ + }; \ + _FL_CBD_CLASS_NAME() { }; \ + }; \ + WIDGET->callback(_FL_CBD_CLASS_NAME::cb, new _FL_CBD_CLASS_NAME(), true); \ + } while(0) + +#endif // FL_DOXYGEN + +#endif /* !_FL_FL_CALLBACK_MACROS_H_ */ diff --git a/include/linux/amd64/FL/fl_casts.H b/include/linux/amd64/FL/fl_casts.H new file mode 100644 index 0000000..cb9a708 --- /dev/null +++ b/include/linux/amd64/FL/fl_casts.H @@ -0,0 +1,39 @@ +// +// Experimental inline "cast functions" for the Fast Light Toolkit (FLTK). +// See also issue #109: "VS2017 warnings when building fltk 1.4.x" +// +// Copyright 1998-2021 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef _FL_fl_casts_H_ +#define _FL_fl_casts_H_ + +#include + +inline char fl_char(void *v) { return (char)(fl_intptr_t)v; } +inline int fl_int(void *v) { return (int)(fl_intptr_t)v; } +inline long fl_long(void *v) { return (long)(fl_intptr_t)v; } + +inline unsigned char fl_uchar(void *v) { return (unsigned char)(fl_uintptr_t)v; } +inline unsigned int fl_uint(void *v) { return (unsigned int)(fl_uintptr_t)v; } +inline unsigned long fl_ulong(void *v) { return (unsigned long)(fl_uintptr_t)v; } + +// the following conversions can be used to silence MSVC warning C4312: +// 'type cast': conversion from '' to 'void *' of greater size + +inline void *fl_voidptr(int v) { return (void *)(fl_intptr_t)v; } +inline void *fl_voidptr(unsigned int v) { return (void *)(fl_uintptr_t)v; } +inline void *fl_voidptr(long v) { return (void *)(fl_intptr_t)v; } +inline void *fl_voidptr(unsigned long v) { return (void *)(fl_uintptr_t)v; } + +#endif /* _FL_fl_casts_H_ */ diff --git a/lib/linux/amd64/FL/fl_config.h b/include/linux/amd64/FL/fl_config.h similarity index 82% rename from lib/linux/amd64/FL/fl_config.h rename to include/linux/amd64/FL/fl_config.h index 08a49da..cef4590 100644 --- a/lib/linux/amd64/FL/fl_config.h +++ b/include/linux/amd64/FL/fl_config.h @@ -2,7 +2,7 @@ /* * Build configuration file for the Fast Light Tool Kit (FLTK). * - * Copyright 1998-2021 by Bill Spitzak and others. + * Copyright 1998-2024 by Bill Spitzak and others. * * This library is free software. Distribution and use rights are outlined in * the file "COPYING" which should have been included with this file. If this @@ -46,6 +46,15 @@ /* #undef FLTK_HAVE_CAIROEXT */ +/* + * FLTK_HAVE_FORMS + * + * Do we have the Forms compatibility library available? +*/ + +#define FLTK_HAVE_FORMS 1 + + /* * FLTK_USE_X11 * @@ -63,7 +72,7 @@ * */ -/* #undef FLTK_USE_CAIRO */ +#define FLTK_USE_CAIRO 1 /* @@ -73,7 +82,7 @@ * */ -/* #undef FLTK_USE_WAYLAND */ +#define FLTK_USE_WAYLAND 1 /* @@ -88,4 +97,15 @@ #define FLTK_USE_STD 0 + +/* + * FLTK_USE_SVG + * + * Do we want FLTK to read and write SVG-formatted files ? + * + */ + +#define FLTK_USE_SVG 1 + + #endif /* _FL_fl_config_h_ */ diff --git a/include/linux/amd64/FL/fl_draw.H b/include/linux/amd64/FL/fl_draw.H new file mode 100644 index 0000000..6535d03 --- /dev/null +++ b/include/linux/amd64/FL/fl_draw.H @@ -0,0 +1,1217 @@ +// +// Portable drawing function header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +/** + \file fl_draw.H + \brief utility header to pull drawing functions together +*/ + +#ifndef fl_draw_H +#define fl_draw_H + +#include // color names +#include // fl_graphics_driver + Fl_Region +#include + +// Image class... +class Fl_Image; +class Fl_Window; + +// Label flags... +FL_EXPORT extern char fl_draw_shortcut; + +/** \addtogroup fl_attributes + @{ +*/ + +// Colors: +/** + Set the color for all subsequent drawing operations. + For color-mapped 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); +} +/** + Set 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); +} +/** + Return 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: +/** + Intersect the current clip region with a rectangle and push 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); +} +/** + Intersect the current clip region with a rectangle and push this + new region onto the stack (deprecated). + \param[in] x,y,w,h position and size + \deprecated + Please use fl_push_clip(int x, int y, int w, int h) instead. + fl_clip(int, int, int, int) will be removed in FLTK 1.5. +*/ +inline void fl_clip(int x, int y, int w, int h) { + fl_graphics_driver->push_clip(x, y, w, h); +} +/** + Push an empty clip region onto the stack so nothing will be clipped. +*/ +inline void fl_push_no_clip() { + fl_graphics_driver->push_no_clip(); +} +/** + Restore 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. + + \see fl_clip_box() +*/ +inline int fl_not_clipped(int x, int y, int w, int h) { + return fl_graphics_driver->not_clipped(x, y, w, h); +} + +/** + Intersect a rectangle with the current clip region and return the + bounding box of the result. + + Returns non-zero if the resulting rectangle is different to the original. + The given rectangle (x, y, w, h) \e should be entirely inside its + window, otherwise the result may be unexpected, i.e. this function \e may + not clip the rectangle to the window coordinates and size. In particular + \p x and \p y \e should not be negative. + + The resulting bounding box can be used to limit the necessary drawing to + this rectangle. + + Example: + \code + void MyGroup::draw() { + int X = 0, Y = 0, W = 0, H = 0; + int ret = fl_clip_box(x(), y(), w(), h(), X, Y, W, H); + if (ret == 0) { // entire group is visible (not clipped) + // full drawing code here + } else { // parts of this group are clipped + // partial drawing code here (uses X, Y, W, and H to test) + } + } + \endcode + + \p W and \p H are set to zero if the rectangle is completely outside the + clipping region. In this case \p X and \p Y are undefined and should + not be used. Possible values are (0, 0), (x, y), + or anything else (platform dependent). + + \note This function is platform-dependent. If the given rectangle is not + entirely inside the window, the results are not guaranteed to be the + same on all platforms. + + \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. + + \see fl_not_clipped() +*/ +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); +} + +/** Undo any clobbering of the clip region done by your program. */ +inline void fl_restore_clip() { + fl_graphics_driver->restore_clip(); +} + +/** + Replace the top of the clipping stack with a clipping region of any shape. + + Fl_Region is an operating system specific type. + \note This function is mostly intended for internal use by the FLTK library + when drawing to the display. + Its effect can be null if the current drawing surface is not the display. + \param[in] r clipping region +*/ +inline void fl_clip_region(Fl_Region r) { + fl_graphics_driver->clip_region(r); +} + +/** + Return the current clipping region. + \note This function is mostly intended for internal use by the FLTK library + when drawing to the display. + Its return value can be always NULL if the current drawing surface is not the display. +*/ +inline Fl_Region fl_clip_region() { + return fl_graphics_driver->clip_region(); +} + + +// points: +/** + Draw a single pixel at the given coordinates +*/ +inline void fl_point(int x, int y) { + fl_graphics_driver->point(x, y); +} + +// line type: +/** + Set 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). + + \image html fl_line_style.png "fl_line_style() styles" + \image latex fl_line_style.png "fl_line_style() styles" width=12cm + + \param[in] style A bitmask which is a bitwise-OR of \ref LineStyles "Line Styles", + 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 the (unsupported!) operating + systems 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); +} + +/// \anchor LineStyles +/// +/// \image html fl_line_style.png "fl_line_style() styles" +/// \image latex fl_line_style.png "fl_line_style() styles" width=12cm +/// +enum { + FL_SOLID = 0, ///< line style: solid line + FL_DASH = 1, ///< line style: 75% dashed line + FL_DOT = 2, ///< line style: 50% pixel dotted + FL_DASHDOT = 3, ///< line style: dash / dot pattern + FL_DASHDOTDOT = 4, ///< line style: dash / two dot pattern + + 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 +}; + +/** + Turn antialiased line drawings ON or OFF, if supported by platform. + Currently, only the Windows platform allows to change whether line drawings + are antialiased. Turning it OFF may accelerate heavy drawing operations. +*/ +inline void fl_antialias(int state) { + fl_graphics_driver->antialias(state); +} + +/** Return whether line drawings are currently antialiased. */ +inline int fl_antialias() { + return fl_graphics_driver->antialias(); +} + +// rectangles tweaked to exactly fill the pixel rectangle: + +/** + Draw a 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); +} + +/** + Draw a rounded border \e inside the given bounding box. + The radius code is optimized for speed and works best for values between + 5 and 15 units. + */ +inline void fl_rounded_rect(int x, int y, int w, int h, int r) { + fl_graphics_driver->rounded_rect(x, y, w, h, r); +} + +/** + Draw a border \e inside the given bounding box. + This is the same as fl_rect(int x, int y, int w, int h) but with + Fl_Rect \p r as input argument. +*/ +inline void fl_rect(Fl_Rect r) { + fl_rect(r.x(), r.y(), r.w(), r.h()); +} + +/** Draw a dotted rectangle, used to indicate keyboard focus on a widget. + + This method draws the rectangle in the current color and independent of + the Fl::visible_focus() option. You may need to set the current color + with fl_color() before you call this. +*/ +inline void fl_focus_rect(int x, int y, int w, int h) { + fl_graphics_driver->focus_rect(x, y, w, h); +} + +/** Draw with passed color a border \e inside the given bounding box. + \warning The current color is changed to \p c upon return. +*/ +inline void fl_rect(int x, int y, int w, int h, Fl_Color c) { + fl_color(c); + fl_rect(x, y, w, h); +} + +/** Color 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); +} + +/** Color with current color a rounded rectangle that exactly fills the given bounding box. + The radius code is optimized for speed and works best for values between + 5 and 15 units. +*/ +inline void fl_rounded_rectf(int x, int y, int w, int h, int r) { + fl_graphics_driver->rounded_rectf(x, y, w, h, r); +} + +/** Color with passed color a rectangle that exactly fills the given bounding box. + \warning The current color is changed to \p c upon return. +*/ +inline void fl_rectf(int x, int y, int w, int h, Fl_Color c) { + fl_color(c); + fl_rectf(x, y, w, h); +} + +/** Color with current color a rectangle that exactly fills the given bounding box. */ +inline void fl_rectf(Fl_Rect r) { + fl_graphics_driver->rectf(r.x(), r.y(), r.w(), r.h()); +} + +/** Color with passed color a rectangle that exactly fills the given bounding box. + \warning The current color is changed to \p c upon return. +*/ +inline void fl_rectf(Fl_Rect r, Fl_Color c) { + fl_color(c); + fl_rectf(r); +} + +/** + Color a rectangle with "exactly" the passed r,g,b 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. On other screens, the current color is changed + to \p fl_color(r,g,b) upon return. +*/ +inline void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) { + fl_graphics_driver->colored_rectf(x, y, w, h, r, g, b); +} + +/** + Color a rectangle with "exactly" the passed r,g,b color. + This is the same as fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) + but with Fl_Rect \p bb (bounding box) as argument instead of (x, y, w, h). + \see fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) +*/ +inline void fl_rectf(Fl_Rect bb, uchar r, uchar g, uchar b) { + fl_graphics_driver->colored_rectf(bb.x(), bb.y(), bb.w(), bb.h(), r, g, b); +} + +// line segments: +/** + Draw 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); +} +/** + Draw 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: +/** + Outline 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); +} +/** + Outline 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 +/** + Fill a 3-sided polygon. +*/ +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); +} +/** + Fill 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: +/** + Draw 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); +} +/** + Draw 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); +} +/** + Draw 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: +/** + Draw 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); +} +/** + Draw 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); +} +/** + Draw 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 Windows. 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. + + \image html fl_pie_arc_diagram.png "fl_pie() and fl_arc()" + \image latex fl_pie_arc_diagram.png "fl_pie() and fl_arc()" width=4cm +*/ +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. + + \image html fl_pie_arc_diagram.png "fl_pie() and fl_arc()" + \image latex fl_pie_arc_diagram.png "fl_pie() and fl_arc()" width=4cm +*/ +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.cxx and fl_arc.cxx): +/** + Save 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(); +} +/** + Restore the current transformation matrix from the stack. +*/ +inline void fl_pop_matrix() { + fl_graphics_driver->pop_matrix(); +} +/** + Concatenate 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->mult_matrix(x, 0, 0, y, 0, 0); +} +/** + Concatenate 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->mult_matrix(x, 0, 0, x, 0, 0); +} +/** + Concatenate 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); +} +/** + Concatenate 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); +} +/** + Set the transformation matrix to identity. + */ +inline void fl_load_identity() { + fl_graphics_driver->load_identity(); +} +/** + Set the current transformation matrix. + \param[in] a,b,c,d,x,y transformation matrix elements + */ +inline void fl_load_matrix(double a, double b, double c, double d, double x, double y) { + fl_graphics_driver->load_matrix(a, b, c, d, x, y); +} +/** + Concatenate another transformation onto the current one. + + \param[in] a,b,c,d,x,y transformation matrix elements such that + X' = aX + cY + x and Y' = bX +dY + y +*/ +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); +} +/** + Start drawing a list of points. Points are added to the list with fl_vertex(). +*/ +inline void fl_begin_points() { + fl_graphics_driver->begin_points(); +} +/** + Start drawing a list of lines. +*/ +inline void fl_begin_line() { + fl_graphics_driver->begin_line(); +} +/** + Start drawing a closed sequence of lines. +*/ +inline void fl_begin_loop() { + fl_graphics_driver->begin_loop(); +} +/** + Start drawing a convex filled polygon. +*/ +inline void fl_begin_polygon() { + fl_graphics_driver->begin_polygon(); +} +/** + Add 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); +} +/** + Add a series of points on a Bézier 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); +} +/** + Add a series of points to the current path on the arc of a circle. + + The arc is drawn counter-clockwise from 3 o'clock. If \p end is less than + \p start then it draws the arc in a clockwise direction. To draw an arc across + the 3 o'clock line, \p start and \p end can be greater than 360 or less than 0. + For example, to draw a counter-clockwise arc from 6 to 12 o'clock, \p start + would be -90 deg, and \p end would be at +90 deg. + + 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 + + \image html fl_arc_xyr_diagram.png "fl_arc(x,y,r,a1,a2)" + \image latex fl_arc_xyr_diagram.png "fl_arc(x,y,r,a1,a2)" width=6cm + + Examples: + \code + // Draw an arc of points + fl_begin_points(); + fl_arc(100.0, 100.0, 50.0, 0.0, 180.0); + fl_end_points(); + + // Draw arc with a line + fl_begin_line(); + fl_arc(200.0, 100.0, 50.0, 0.0, 180.0); + fl_end_line(); + + // Draw filled arc + fl_begin_polygon(); + fl_arc(300.0, 100.0, 50.0, 0.0, 180.0); + fl_end_polygon(); + \endcode +*/ +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(x,y,r) is equivalent to fl_arc(x,y,r,0,360), but may be faster. + \param[in] x,y,r center and radius of circle + + \note fl_circle() is best used as part of the \ref drawing_complex API, that is, + flanked by fl_begin_XXX() and fl_end_XXX() calls where XXX can be 'loop' or 'polygon' + to draw, respectively a circle or a disk. Transformation functions (e.g., fl_scale(double, double)) + can be also used for fl_circle() to draw empty of filled ellipses. + 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(). +
    Nevertheless, fl_circle() can also be used by itself to draw circles. +*/ +inline void fl_circle(double x, double y, double r) { + fl_graphics_driver->circle(x, y, r); +} +/** + End list of points, and draw. +*/ +inline void fl_end_points() { + fl_graphics_driver->end_points(); +} +/** + End list of lines, and draw. +*/ +inline void fl_end_line() { + fl_graphics_driver->end_line(); +} +/** + End closed sequence of lines, and draw. +*/ +inline void fl_end_loop() { + fl_graphics_driver->end_loop(); +} +/** + End convex filled polygon, and draw. +*/ +inline void fl_end_polygon() { + fl_graphics_driver->end_polygon(); +} +/** + Start 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(); +} +/** + 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(); +} +/** + End complex filled polygon, and draw. +*/ +inline void fl_end_complex_polygon() { + fl_graphics_driver->end_complex_polygon(); +} +// get and use transformed positions: +/** + Transform 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); +} +/** + Transform 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); +} +/** + Transform 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); +} +/** + Transform 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); +} +/** + Add 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); +} + +/** Copy a rectangular area of the given offscreen buffer into the current drawing destination. + \param x,y position where to draw the copied rectangle + \param w,h size of the copied rectangle + \param pixmap offscreen buffer containing the rectangle to copy + \param srcx,srcy origin in offscreen buffer of rectangle to copy +*/ +inline void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { + fl_graphics_driver->copy_offscreen(x, y, w, h, pixmap, srcx, srcy); +} + +FL_EXPORT Fl_Offscreen fl_create_offscreen(int w, int h); +FL_EXPORT void fl_begin_offscreen(Fl_Offscreen b); +FL_EXPORT void fl_end_offscreen(void); +FL_EXPORT void fl_delete_offscreen(Fl_Offscreen bitmap); +FL_EXPORT void fl_rescale_offscreen(Fl_Offscreen &ctx); + +/** @} */ + +/** \addtogroup fl_attributes + @{ */ +/* NOTE: doxygen comments here to avoid triplication in os-specific sources */ + +// Fonts: +/* + Set the current font, which is then used in various drawing routines. + Implemented and documented in src/fl_draw.cxx +*/ +FL_EXPORT void fl_font(Fl_Font face, Fl_Fontsize fsize); + +/** + Return 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(); +} +/** + Return 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: +/** + Return 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); +/** + Return 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(); +} +/** Return the typographical width of a nul-terminated string + using the current font face and size. +*/ +FL_EXPORT double fl_width(const char *txt); + +/** Return the typographical width of a sequence of \p n characters + using the current font face and size. +*/ +inline double fl_width(const char *txt, int n) { + return fl_graphics_driver->width(txt, n); +} +/** Return the typographical width of a single character + using the current font face and size. + + \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); +} +/** Determine the minimum pixel dimensions of a nul-terminated string + using the current fl_font(). + + 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. + + Note the desired font and font size must be set with fl_font() before calling + this function. + + This differs slightly from fl_measure() in that the dx/dy values are also + returned. + + No FLTK symbol expansion will be performed. + + Example use: + \code + int dx,dy,W,H; + fl_font(FL_HELVETICA, 12); // set font face+size first + fl_text_extents("Some text", dx, dy, W, H); // get width and height of string + printf("text's width=%d, height=%d\n", W, H); + \endcode +*/ +FL_EXPORT void fl_text_extents(const char *, int &dx, int &dy, int &w, int &h); + +/** Determine the minimum pixel dimensions of a sequence of \p n characters + (bytes) using the current fl_font(). + + \note The string length is measured in bytes, not (UTF-8) 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-specific cases +/** + Convert text from Windows/X11 latin1 character set to local encoding. + \param[in] t character string (latin1 encoding) + \param[in] n optional number of characters (bytes) 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); +/** + Convert text from local encoding to Windows/X11 latin1 character set. + \param[in] t character string (local encoding) + \param[in] n optional number of characters (bytes) 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); +/** + Convert 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); +/** + Convert 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 + @{ */ + +FL_EXPORT float fl_override_scale(); + +FL_EXPORT void fl_restore_scale(float s); + +/** + Draw a nul-terminated UTF-8 string starting at the given \p x, \p y 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); +/** + Draw a nul-terminated UTF-8 string starting at the given \p x, \p y + 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 all fltk platforms except + X11 without Xft. +*/ +FL_EXPORT void fl_draw(int angle, const char *str, int x, int y); +/** + Draws starting at the given \p x, \p y location a UTF-8 string of length \p n bytes. +*/ +inline void fl_draw(const char *str, int n, int x, int y) { + fl_graphics_driver->draw(str, n, x, y); +} +/** + Draw at the given \p x, \p y location a UTF-8 string of length \p n bytes + rotating \p angle degrees counter-clockwise. + + \note When using X11 (Unix, Linux, Cygwin et al.) this needs Xft to work. + Under plain X11 (w/o Xft) rotated text is not supported by FLTK. + A warning will be issued to stderr at runtime (only once) if you + use this method with an angle other than 0. +*/ +inline void fl_draw(int angle, const char *str, int n, int x, int y) { + fl_graphics_driver->draw(angle, str, n, x, y); +} +/** + Draw a UTF-8 string of length \p n bytes right to left starting at the given \p x, \p y 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); +/** + Fancy string drawing function which is used to draw all the labels. + + The string is formatted and aligned inside the passed box. + Handles '\\t' and '\\n', expands all other control characters to '^X', + and aligns inside or against the edges of the box. + See Fl_Widget::align() for values of \p align. The value FL_ALIGN_INSIDE + is ignored, as this function always prints inside the box. + If \p img is provided and is not \p NULL, the image is drawn above or + below the text as specified by the \p align value. + The \p draw_symbols argument specifies whether or not to look for symbol + names starting with the '\@' character' + + \param[in] str UTF-8 string, can start and end with an '\@sym' symbol, + can contain '\\n' + \param[in] x,y,w,h bounding box + \param[in] align label and image alignment in bounding box + \param[in] img pointer to image + \param[in] draw_symbols if true, interprete leading and trailing '\@sym' + as graphical symbols + \param[in] spacing spacing between text and image + */ +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, int spacing = 0); +/** + The same as fl_draw(const char*,int,int,int,int,Fl_Align,Fl_Image*,int) with + the addition of the \p callthis parameter, which is a pointer to a text drawing + function such as fl_draw(const char*, int, int, int) to do the real work. + + \param[in] str UTF-8 string, can start and end with an '\@sym' symbol, + can contain '\\n' + \param[in] x,y,w,h bounding box + \param[in] align label and image alignment in bounding box + \param[in] callthis pointer to text drawing function + \param[in] img pointer to image + \param[in] draw_symbols if true, interprete leading and trailing '\@sym' + as graphical symbols + \param[in] spacing spacing between text and image + */ +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, int spacing = 0); + +// 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); +FL_EXPORT void fl_draw_box_focus(Fl_Boxtype, int x, int y, int w, int h, Fl_Color, Fl_Color); + +// basic GUI objects (check marks, arrows, more to come ...): + +// Draw a check mark in the given color inside the bounding box bb. +void fl_draw_check(Fl_Rect bb, Fl_Color col); + +// Draw one or more "arrows" (triangles) +FL_EXPORT void fl_draw_arrow(Fl_Rect bb, Fl_Arrow_Type t, Fl_Orientation o, Fl_Color color); + +// Draw a potentially small, filled circle +FL_EXPORT void fl_draw_circle(int x, int y, int d, Fl_Color color); + +// Draw the full "radio button" of a radio menu entry or radio button +// This requires scheme specific handling (particularly gtk+ scheme) +FL_EXPORT void fl_draw_radio(int x, int y, int d, Fl_Color color); + +// images: + +/** + Draw 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 r,g,b order. + Luminance data is only one gray 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 show() 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 + abs(D) 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); +} + +/** + Draw 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); +} + +/** + Draw 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. + + \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 per pixel 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 void* \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); +} + +/** + Draw 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) +*/ +inline void fl_draw_image_mono(Fl_Draw_Image_Cb cb, void *data, int X, int Y, int W, int H, int D = 1) { + fl_graphics_driver->draw_image_mono(cb, data, X, Y, W, H, D); +} + +/** + Check 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 +*/ +inline char fl_can_do_alpha_blending() { + return Fl_Graphics_Driver::default_driver().can_do_alpha_blending(); +} + +FL_EXPORT uchar *fl_read_image(uchar *p, int X, int Y, int W, int H, int alpha = 0); +FL_EXPORT Fl_RGB_Image *fl_capture_window(Fl_Window *win, int x, int y, int w, int h); + +// pixmaps: +/** + Draw XPM image data, with the top-left corner at the given position. + The image is dithered on 8-bit displays so you won't lose color + space for programs displaying both images and pixmaps. + + \param[in] data pointer to XPM image data + \param[in] x,y position of top-left corner + \param[in] bg background color + + \returns 0 if there was any error decoding the XPM data. +*/ +FL_EXPORT int fl_draw_pixmap(const char *const *data, int x, int y, Fl_Color bg = FL_GRAY); +/** + Draw XPM image data, with the top-left corner at the given position. + \see fl_draw_pixmap(const char* const* data, int x, int y, Fl_Color bg) +*/ +inline int fl_draw_pixmap(/*const*/ char *const *data, int x, int y, Fl_Color bg = FL_GRAY) { + return fl_draw_pixmap((const char *const *)data, x, y, bg); +} +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_EXPORT void fl_cursor(Fl_Cursor, Fl_Color fg, 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: +FL_EXPORT void fl_set_status(int X, int Y, int W, int H); +/** Inform text input methods about the current text insertion cursor. + \param font Font currently in use in text input. + \param size Size of the current font. + \param X,Y Position of the bottom of the current text insertion cursor. + \param W,H Width and height of the current text insertion cursor. + \param win Points to the Fl_Window object containing the current text widget, or NULL. + */ +FL_EXPORT void fl_set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win = 0); +/** Resets marked text. + + In many languages, typing a character can involve multiple keystrokes. For + example, the Ä can be composed of two dots (¨) on top of the + character, followed by the letter A (on a Mac with U.S. keyboard, you'd + type Alt-U, Shift-A. To inform the user that the dots may be followed by + another character, the ¨ is underlined). + + Call this function if character composition needs to be aborted for some + reason. One such example would be the text input widget losing focus. + */ +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 diff --git a/include/linux/amd64/FL/fl_message.H b/include/linux/amd64/FL/fl_message.H new file mode 100644 index 0000000..50f2ef9 --- /dev/null +++ b/include/linux/amd64/FL/fl_message.H @@ -0,0 +1,22 @@ +// +// Standard message header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef _FL_fl_message_H_ +#define _FL_fl_message_H_ + +#include "fl_ask.H" + +#endif diff --git a/include/linux/amd64/FL/fl_show_colormap.H b/include/linux/amd64/FL/fl_show_colormap.H new file mode 100644 index 0000000..97c93dc --- /dev/null +++ b/include/linux/amd64/FL/fl_show_colormap.H @@ -0,0 +1,43 @@ +// +// Colormap picker header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 diff --git a/include/linux/amd64/FL/fl_show_input.H b/include/linux/amd64/FL/fl_show_input.H new file mode 100644 index 0000000..217556f --- /dev/null +++ b/include/linux/amd64/FL/fl_show_input.H @@ -0,0 +1,17 @@ +// +// 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#include "fl_ask.H" diff --git a/include/linux/amd64/FL/fl_string_functions.h b/include/linux/amd64/FL/fl_string_functions.h new file mode 100644 index 0000000..b88dc49 --- /dev/null +++ b/include/linux/amd64/FL/fl_string_functions.h @@ -0,0 +1,49 @@ +/* + * Platform agnostic string portability functions for the Fast Light Tool Kit (FLTK). + * + * Copyright 2020-2022 by Bill Spitzak and others. + * + * This library is free software. Distribution and use rights are outlined in + * the file "COPYING" which should have been included with this file. If this + * file is missing or damaged, see the license at: + * + * https://www.fltk.org/COPYING.php + * + * Please see the following page on how to report bugs and issues: + * + * https://www.fltk.org/bugs.php + */ + +/** + \file fl_string_functions.h + Public header for FLTK's platform-agnostic string handling. +*/ + +#ifndef _FL_fl_string_functions_h_ +#define _FL_fl_string_functions_h_ + +#include "Fl_Export.H" + +#ifdef __cplusplus +extern "C" { +#endif + +#include // size_t + +/** \defgroup fl_string String handling functions + String handling functions declared in + @{ +*/ + +FL_EXPORT char* fl_strdup(const char *s); + +FL_EXPORT size_t fl_strlcpy(char *, const char *, size_t); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _FL_fl_string_functions_h_ */ diff --git a/include/linux/amd64/FL/fl_types.h b/include/linux/amd64/FL/fl_types.h new file mode 100644 index 0000000..94cd70b --- /dev/null +++ b/include/linux/amd64/FL/fl_types.h @@ -0,0 +1,59 @@ +/* + * Simple "C"-style types for the Fast Light Tool Kit (FLTK). + * + * Copyright 1998-2020 by Bill Spitzak and others. + * + * This library is free software. Distribution and use rights are outlined in + * the file "COPYING" which should have been included with this file. If this + * file is missing or damaged, see the license at: + * + * https://www.fltk.org/COPYING.php + * + * Please see the following page on how to report bugs and issues: + * + * https://www.fltk.org/bugs.php + */ + +/** \file + * This file contains simple "C"-style type definitions. + */ + +#ifndef FL_TYPES_H +#define FL_TYPES_H + +#include "fl_attr.h" + +/** \name Miscellaneous */ +/**@{*/ /* group: Miscellaneous */ + +/** unsigned char */ +typedef unsigned char uchar; +/** unsigned long */ +typedef unsigned long ulong; + +/** 16-bit Unicode character + 8-bit indicator for keyboard flags. + + \note This \b should be 24-bit Unicode character + 8-bit indicator for + keyboard flags. The upper 8 bits are currently unused but reserved. + + Due to compatibility issues this type and all FLTK \b shortcuts can only + be used with 16-bit Unicode characters (U+0000 .. U+FFFF) and + not with the full range of unicode characters (U+0000 .. U+10FFFF). + + This is caused by the bit flags \c FL_SHIFT, \c FL_CTRL, \c FL_ALT, and + \c FL_META being all in the range 0x010000 .. 0x400000. + + \todo Discuss and decide whether we can "shift" these special keyboard + flags to the upper byte to enable full 21-bit Unicode characters + (U+0000 .. U+10FFFF) plus the keyboard indicator bits as this + was originally intended. This would be possible if we could rely on \b all + programs being coded with symbolic names and not hard coded bit values. + + \internal Can we do the move for 1.4 or, if not, for any later version + that is allowed to break the ABI? +*/ +typedef unsigned int Fl_Shortcut; + +/**@}*/ /* group: Miscellaneous */ + +#endif diff --git a/include/linux/amd64/FL/fl_utf8.h b/include/linux/amd64/FL/fl_utf8.h new file mode 100644 index 0000000..bd61ab8 --- /dev/null +++ b/include/linux/amd64/FL/fl_utf8.h @@ -0,0 +1,223 @@ +/* + * Author: Jean-Marc Lienher ( http://oksid.ch ) + * Copyright 2000-2010 by O'ksi'D. + * Copyright 2016-2021 by Bill Spitzak and others. + * + * This library is free software. Distribution and use rights are outlined in + * the file "COPYING" which should have been included with this file. If this + * file is missing or damaged, see the license at: + * + * https://www.fltk.org/COPYING.php + * + * Please see the following page on how to report bugs and issues: + * + * https://www.fltk.org/bugs.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 UTF-8 character handling +*/ + +#ifndef _HAVE_FL_UTF8_HDR_ +#define _HAVE_FL_UTF8_HDR_ + +#include "Fl_Export.H" +#include "fl_types.h" +#include // FILE *fl_fopen() +#include // struct stat + +#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 UTF-8. + \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 byte length of a UTF-8 text */ +FL_EXPORT int fl_utf8strlen(const char *text, int len); + +/* 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 UTF-8 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 UTF-8 sequence, return the number of bytes used */ +FL_EXPORT int fl_utf8encode(unsigned ucs, char* buf); + +/* F2: Move forward to the next valid UTF-8 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 UTF-8 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 UTF-8 string into UTF16 */ +FL_EXPORT unsigned fl_utf8toUtf16(const char* src, unsigned srclen, unsigned short* dst, unsigned dstlen); + +/* F2: Convert a UTF-8 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 UTF-8 - 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 UTF-8 string into ASCII, eliding untranslatable glyphs */ +FL_EXPORT unsigned fl_utf8toa (const char *src, unsigned srclen, char *dst, unsigned dstlen); + +/* F2: Convert 8859-1 string to UTF-8 */ +FL_EXPORT unsigned fl_utf8froma (char *dst, unsigned dstlen, const char *src, unsigned srclen); + +/* F2: Returns true if the current O/S locale is UTF-8 */ +FL_EXPORT int fl_utf8locale(void); + +/* F2: Examine the first len characters of src, to determine if the input text is UTF-8 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 UTF-8 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 UTF-8 to a local multi-byte encoding */ +FL_EXPORT char* fl_utf2mbcs(const char *src); + +/* F2: Convert a local multi-byte encoding to UTF-8 - mainly for win32? */ +FL_EXPORT unsigned fl_utf8from_mb(char *dst, unsigned dstlen, const char *src, unsigned srclen); + +/*****************************************************************************/ +#ifdef _WIN32 +/* these two Windows-only functions are kept for API compatibility */ +/* OD: Attempt to convert the UTF-8 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 UTF-8 */ +FL_EXPORT char *fl_locale_to_utf8(const char *s, int len, unsigned int codepage); +#endif /* _WIN32 */ + +/***************************************************************************** + * The following functions are intended to provide portable, UTF-8 aware + * versions of standard functions + */ + +/* OD: UTF-8 aware strncasecmp - converts to lower case Unicode and tests */ +FL_EXPORT int fl_utf_strncasecmp(const char *s1, const char *s2, int n); + +/* OD: UTF-8 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 UTF-8 string to the lower case equivalent */ +FL_EXPORT int fl_utf_tolower(const unsigned char *str, int len, char *buf); + +/* OD: converts the UTF-8 string to the upper case equivalent */ +FL_EXPORT int fl_utf_toupper(const unsigned char *str, int len, char *buf); + +/* OD: Portable UTF-8 aware chmod wrapper */ +FL_EXPORT int fl_chmod(const char* f, int mode); + +/* OD: Portable UTF-8 aware access wrapper */ +FL_EXPORT int fl_access(const char* f, int mode); + +/* OD: Portable UTF-8 aware stat wrapper */ +FL_EXPORT int fl_stat(const char *path, struct stat *buffer); + +/* OD: Portable UTF-8 aware getcwd wrapper */ +FL_EXPORT char *fl_getcwd(char *buf, int len); + +/* Portable UTF-8 aware chdir wrapper */ +FL_EXPORT int fl_chdir(const char *path); + +/* OD: Portable UTF-8 aware fopen wrapper */ +FL_EXPORT FILE *fl_fopen(const char *f, const char *mode); + +/* OD: Portable UTF-8 aware system wrapper */ +FL_EXPORT int fl_system(const char* f); + +/* OD: Portable UTF-8 aware execvp wrapper */ +FL_EXPORT int fl_execvp(const char *file, char *const *argv); + +/* OD: Portable UTF-8 aware open wrapper */ +FL_EXPORT int fl_open(const char *fname, int oflags, ...); + +FL_EXPORT int fl_open_ext(const char *fname, int binary, int oflags, ...); + +/* Portable wrapper around unix-style close() function */ +FL_EXPORT int fl_close_fd(int fd); + +/* OD: Portable UTF-8 aware unlink wrapper */ +FL_EXPORT int fl_unlink(const char *fname); + +/* OD: Portable UTF-8 aware rmdir wrapper */ +FL_EXPORT int fl_rmdir(const char *f); + +/* OD: Portable UTF-8 aware getenv wrapper */ +FL_EXPORT char* fl_getenv(const char *name); + +/* Portable UTF-8 aware putenv wrapper */ +FL_EXPORT int fl_putenv(const char *var); + +/* OD: Portable UTF-8 aware mkdir wrapper */ +FL_EXPORT int fl_mkdir(const char* f, int mode); + +/* OD: Portable UTF-8 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_ */ diff --git a/include/linux/amd64/FL/forms.H b/include/linux/amd64/FL/forms.H new file mode 100644 index 0000000..9523b4d --- /dev/null +++ b/include/linux/amd64/FL/forms.H @@ -0,0 +1,831 @@ +// +// Forms emulation header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 + // because 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) (FL_SOCKET, 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)->insert_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)->insert_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,(int)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() FL_OVERRIDE; +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_EXPORT 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__ */ diff --git a/include/linux/amd64/FL/gl.h b/include/linux/amd64/FL/gl.h new file mode 100644 index 0000000..7b5e9c4 --- /dev/null +++ b/include/linux/amd64/FL/gl.h @@ -0,0 +1,99 @@ +// +// OpenGL header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2018 by Bill Spitzak and others. +// +// You must include this instead of GL/gl.h to get the Microsoft +// APIENTRY stuff included (from ) 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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 you try to use a visual not returned by glxChooseVisual. + + Historically, this did not always work well with Fl_Double_Window's! + It can try to draw into the front buffer. + Depending on the system this might 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 +# endif +# ifndef APIENTRY +# if defined(__CYGWIN__) +# define APIENTRY __attribute__ ((__stdcall__)) +# else +# define APIENTRY +# endif +# endif + +# ifdef __APPLE__ // PORTME: OpenGL path abstraction +# ifndef GL_SILENCE_DEPRECATION +# define GL_SILENCE_DEPRECATION 1 +# endif +# if !defined(__gl3_h_) // make sure OpenGL/gl3.h was not included before +# include +# endif +# else +# include +# endif // __APPLE__ // PORTME: OpenGL Path abstraction + +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); +FL_EXPORT void gl_rectf(int x,int y,int w,int 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); +FL_EXPORT void gl_texture_pile_height(int max); +FL_EXPORT int gl_texture_pile_height(); +FL_EXPORT void gl_texture_reset(); + +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 diff --git a/include/linux/amd64/FL/gl2opengl.h b/include/linux/amd64/FL/gl2opengl.h new file mode 100644 index 0000000..a22fd3d --- /dev/null +++ b/include/linux/amd64/FL/gl2opengl.h @@ -0,0 +1,40 @@ +/* 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. + +*/ + +#ifndef _FL_gl2opengl_h_ +#define _FL_gl2opengl_h_ + +#include +#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);} + +#endif /* _FL_gl2opengl_h_ */ diff --git a/include/linux/amd64/FL/gl_draw.H b/include/linux/amd64/FL/gl_draw.H new file mode 100644 index 0000000..dbd17fd --- /dev/null +++ b/include/linux/amd64/FL/gl_draw.H @@ -0,0 +1,19 @@ +// +// OpenGL header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2010 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#include "gl.h" + +extern FL_EXPORT void gl_remove_displaylist_fonts(); diff --git a/include/linux/amd64/FL/glu.h b/include/linux/amd64/FL/glu.h new file mode 100644 index 0000000..de92387 --- /dev/null +++ b/include/linux/amd64/FL/glu.h @@ -0,0 +1,45 @@ +// +// 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 ) 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. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_glu_H +# define FL_glu_H + +# include "Enumerations.H" // for color names +# ifdef _WIN32 +# include +# endif +# ifndef APIENTRY +# if defined(__CYGWIN__) +# define APIENTRY __attribute__ ((__stdcall__)) +# else +# define APIENTRY +# endif +# endif + +# ifdef __APPLE__ // PORTME: OpenGL Path abstraction +# include +# else +# include +# endif + +#endif // !FL_glu_H diff --git a/include/linux/amd64/FL/glut.H b/include/linux/amd64/FL/glut.H new file mode 100644 index 0000000..6ddf270 --- /dev/null +++ b/include/linux/amd64/FL/glut.H @@ -0,0 +1,550 @@ +// +// GLUT emulation header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.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. + +// Notes: as pointed out in STR #3458 the current GLUT window, +// i.e. the global static variable 'glut_window' can be NULL ... +// (a) if not (yet) initialized +// (b) if the current GLUT window is deleted at any time. +// The FLTK implementation silently ignores function calls if the current +// window is NULL to avoid dereferencing a NULL pointer. This is obviously +// compatible with GLUT version 3.7 according to comment #5 on STR #3458. +// According to the same comment FreeGLUT 3.0 would issue an error message +// and quit. +// Albrecht-S, Oct 2023 + +#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_compatibility.cxx): +*/ +class FL_EXPORT Fl_Glut_Window : public Fl_Gl_Window { + void _init(); + int mouse_down; +protected: + void draw() FL_OVERRIDE; + void draw_overlay() FL_OVERRIDE; + int handle(int) FL_OVERRIDE; +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 *t=0); + Fl_Glut_Window(int x, int y, int w, int h, const char *t=0); + ~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() { + if (glut_window) glut_window->redraw(); +} + +FL_EXPORT void glutPostWindowRedisplay(int win); + +FL_EXPORT void glutSwapBuffers(); + +inline int glutGetWindow() { + return glut_window ? glut_window->number : 0; +} + +FL_EXPORT void glutSetWindow(int win); + +inline void glutSetWindowTitle(char *t) { + if (glut_window) glut_window->label(t); +} + +inline void glutSetIconTitle(char *t) { + if (glut_window) glut_window->iconlabel(t); +} + +inline void glutPositionWindow(int x, int y) { + if (glut_window) glut_window->position(x,y); +} + +inline void glutReshapeWindow(int w, int h) { + if (glut_window) glut_window->size(w,h); +} + +inline void glutPopWindow() { + if (glut_window) glut_window->show(); +} + +inline void glutPushWindow() { /* do nothing */ } + +inline void glutIconifyWindow() { + if (glut_window) glut_window->iconize(); +} + +inline void glutShowWindow() { + if (glut_window) glut_window->show(); +} + +inline void glutHideWindow() { + if (glut_window) glut_window->hide(); +} + +inline void glutFullScreen() { + if (glut_window) glut_window->fullscreen(); +} + +inline void glutSetCursor(Fl_Cursor cursor) { + if (glut_window) 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() { + if (glut_window) glut_window->make_overlay_current(); +} + +inline void glutRemoveOverlay() { + if (glut_window) glut_window->hide_overlay(); +} + +inline void glutUseLayer(GLenum layer) { + if (!glut_window) + return; + layer ? glut_window->make_overlay_current() : glut_window->make_current(); +} + +enum {GLUT_NORMAL, GLUT_OVERLAY}; + +inline void glutPostOverlayRedisplay() { + if (glut_window) glut_window->redraw_overlay(); +} + +inline void glutShowOverlay() { + if (glut_window) glut_window->redraw_overlay(); +} + +inline void glutHideOverlay() { + if (glut_window) 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(const 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) { + if (glut_window) glut_window->menu[b] = glut_menu; +} + +inline void glutDetachMenu(int b) { + if (glut_window) glut_window->menu[b] = 0; +} + +inline void glutDisplayFunc(void (*f)()) { + if (glut_window) glut_window->display = f; +} + +inline void glutReshapeFunc(void (*f)(int w, int h)) { + if (glut_window) glut_window->reshape = f; +} + +inline void glutKeyboardFunc(void (*f)(uchar key, int x, int y)) { + if (glut_window) glut_window->keyboard = f; +} + +inline void glutMouseFunc(void (*f)(int b, int state, int x, int y)) { + if (glut_window) 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)) { + if (glut_window) glut_window->motion = f; +} + +inline void glutPassiveMotionFunc(void (*f)(int x, int y)) { + if (glut_window) glut_window->passivemotion = f; +} + +inline void glutEntryFunc(void (*f)(int s)) { + if (glut_window) glut_window->entry = f; +} + +enum {GLUT_LEFT, GLUT_ENTERED}; + +inline void glutVisibilityFunc(void (*f)(int s)) { + if (glut_window) glut_window->visibility = f; +} +enum {GLUT_NOT_VISIBLE, GLUT_VISIBLE}; + +FL_EXPORT void glutIdleFunc(void (*f)()); + +inline void glutTimerFunc(unsigned int msec, void (*f)(int), int value) { + Fl::add_timeout(msec*.001, (void (*)(void *))f, (void *)(fl_intptr_t)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)) { + if (glut_window) 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)()) { + if (glut_window) 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_ diff --git a/include/linux/amd64/FL/mac.H b/include/linux/amd64/FL/mac.H new file mode 100644 index 0000000..b0a2b84 --- /dev/null +++ b/include/linux/amd64/FL/mac.H @@ -0,0 +1,208 @@ +// +// Mac header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2018 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// Do not directly include this file, instead use . 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_PLATFORM_H) +# error "Never use directly; include instead." +#endif // !FL_PLATFORM_H + +#ifdef __OBJC__ + @class NSOpenGLContext; +# ifndef GL_SILENCE_DEPRECATION +# define GL_SILENCE_DEPRECATION 1 +# endif +#elif defined(__cplusplus) + class NSOpenGLContext; +#endif /* __OBJC__ */ +extern NSOpenGLContext *fl_mac_glcontext(GLContext rc); + +#ifdef __OBJC__ +@class FLWindow; // a subclass of the NSWindow Cocoa class +typedef FLWindow *Window; +#else +typedef class FLWindow *Window; // pointer to the FLWindow objective-c class +#endif // __OBJC__ + +#include // for Fl_Callback + +#if (defined(FL_LIBRARY) || defined(FL_INTERNALS)) // this part must be compiled when building the FLTK libraries + +// Standard MacOS C/C++ includes... +#include +#undef check // because of Fl::check() + +#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 +#ifndef MAC_OS_X_VERSION_10_7 +#define MAC_OS_X_VERSION_10_7 1070 +#endif +#ifndef MAC_OS_X_VERSION_10_8 +#define MAC_OS_X_VERSION_10_8 1080 +#endif +#ifndef MAC_OS_X_VERSION_10_9 +#define MAC_OS_X_VERSION_10_9 1090 +#endif +#ifndef MAC_OS_X_VERSION_10_10 +#define MAC_OS_X_VERSION_10_10 101000 +#endif +#ifndef MAC_OS_X_VERSION_10_11 +#define MAC_OS_X_VERSION_10_11 101100 +#endif +#ifndef MAC_OS_X_VERSION_10_12 +#define MAC_OS_X_VERSION_10_12 101200 +#endif +#ifndef MAC_OS_X_VERSION_10_13 +#define MAC_OS_X_VERSION_10_13 101300 +#endif +#ifndef MAC_OS_X_VERSION_10_14 +#define MAC_OS_X_VERSION_10_14 101400 +#endif +#ifndef MAC_OS_X_VERSION_10_15 +#define MAC_OS_X_VERSION_10_15 101500 +#endif +#ifndef MAC_OS_X_VERSION_10_16 +#define MAC_OS_X_VERSION_10_16 101600 +#endif +#ifndef MAC_OS_VERSION_11_0 +#define MAC_OS_VERSION_11_0 110000 +#endif +#ifndef MAC_OS_VERSION_12_0 +#define MAC_OS_VERSION_12_0 120000 +#endif +#ifndef MAC_OS_VERSION_13_0 +#define MAC_OS_VERSION_13_0 130000 +#endif +#ifndef MAC_OS_VERSION_14_0 +#define MAC_OS_VERSION_14_0 140000 +#endif +#ifndef MAC_OS_VERSION_15_0 +#define MAC_OS_VERSION_15_0 150000 +#endif + + +#ifndef NSINTEGER_DEFINED // appears with 10.5 in NSObjCRuntime.h +#if defined(__LP64__) && __LP64__ +typedef long NSInteger; +typedef unsigned long NSUInteger; +#else +typedef int NSInteger; +typedef unsigned int NSUInteger; +#endif +#endif + +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4 +typedef CGImageAlphaInfo CGBitmapInfo; +#endif + +struct flCocoaRegion { + int count; + CGRect *rects; +}; // a region is the union of a series of rectangles + +#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 + +#else + +typedef struct CGContext* CGContextRef; + +#endif // FL_LIBRARY || FL_INTERNALS + +extern CGContextRef fl_gc; + +#endif // FL_DOXYGEN +/** \file + Mac OS X-specific symbols. + */ + +/** \defgroup group_macosx Mac OS X-specific symbols + Mac OS X-specific symbols declared in + \sa \ref osissues_macos + \{ */ + +/** + Attaches a callback to the "About myprog" item of the system application menu. + For back-compatibility. + Equivalent to Fl_Sys_Menu_Bar::about(Fl_Callback *cb, void *user_data). + */ +void fl_mac_set_about(Fl_Callback *cb, void *user_data, int shortcut = 0); + +/** Returns the macOS-specific graphics context for the current window */ +extern CGContextRef fl_mac_gc(); +/** Returns the macOS-specific window reference corresponding to the given Fl_Window object */ +extern FLWindow *fl_mac_xid(const Fl_Window *win); +/** Returns the Fl_Window corresponding to the given macOS-specific window reference */ +extern Fl_Window *fl_mac_find(FLWindow *); +class Fl_Gl_Window; + +/** The version number of the running Mac OS X (e.g., 100604 for 10.6.4, 101300 for 10.13, 140102 for 14.1.2). + FLTK initializes this global variable before main() begins running. If + the value is needed in a static initializer, a previous call to Fl::system_driver() + makes sure \ref fl_mac_os_version has been initialized. + */ +extern int fl_mac_os_version; + +struct Fl_Menu_Item; + +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 and next one won't be displayed if Fl_Mac_App_Menu::print + is set to an empty string. + */ + static const char *print; + /** Localizable text for the "Print Front Window" application menu item. */ + static const char *print_no_titlebar; + /** Localizable text for the "Toggle print titlebar" application menu item. */ + static const char *toggle_print_titlebar; + /** 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; + /** Adds custom menu item(s) to the application menu of the system menu bar. + They are positioned after the "Print Front Window / Toggle printing of titlebar" items, or at their place + if they were removed with Fl_Mac_App_Menu::print = "". + \param m zero-ending array of Fl_Menu_Item 's. + */ + static void custom_application_menu_items(const Fl_Menu_Item *m); +}; + +/** @} */ + diff --git a/include/linux/amd64/FL/math.h b/include/linux/amd64/FL/math.h new file mode 100644 index 0000000..b78357e --- /dev/null +++ b/include/linux/amd64/FL/math.h @@ -0,0 +1,50 @@ +// +// Math header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2020 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// Xcode on macOS 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 +# undef fl_math_h_cyclic_include + +# 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__) + +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__ + +#endif // !fl_math_h diff --git a/include/linux/amd64/FL/names.h b/include/linux/amd64/FL/names.h new file mode 100644 index 0000000..984afbf --- /dev/null +++ b/include/linux/amd64/FL/names.h @@ -0,0 +1,146 @@ +// +// Event and other names header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2024 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// Thanks to Greg Ercolano for this addition. + +/** + \file names.h + This file defines arrays of human readable names for FLTK symbolic constants. +*/ + +#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 ' appears. + + \b Example: + \code + #include // 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", + "FL_SCREEN_CONFIGURATION_CHANGED", + "FL_FULLSCREEN", + "FL_ZOOM_GESTURE", + "FL_ZOOM_EVENT", + "FL_EVENT_28", // not yet defined, just in case it /will/ be defined ... + "FL_EVENT_29", // not yet defined, just in case it /will/ be defined ... + "FL_EVENT_30" // not yet defined, just in case it /will/ be defined ... +}; + +/** + This is an array of font names you can use to convert font numbers into names. + + The array gets defined inline wherever your '\#include ' appears. + + \b Example: + \code + #include // 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", +}; + +/** + This is an array of callback reason names you can use to convert callback reasons into names. + + The array gets defined inline wherever your '\#include ' appears. + */ +const char * const fl_callback_reason_names[] = +{ + "FL_REASON_UNKNOWN", + "FL_REASON_SELECTED", + "FL_REASON_DESELECTED", + "FL_REASON_RESELECTED", + "FL_REASON_OPENED", + "FL_REASON_CLOSED", + "FL_REASON_DRAGGED", + "FL_REASON_CANCELLED", + "FL_REASON_CHANGED", + "FL_REASON_GOT_FOCUS", + "FL_REASON_LOST_FOCUS", + "FL_REASON_RELEASED", + "FL_REASON_ENTER_KEY", + NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + "FL_REASON_USER", "FL_REASON_USER+1", "FL_REASON_USER+2", "FL_REASON_USER+3", +}; + +/** @} */ + +#endif /* FL_NAMES_H */ diff --git a/include/linux/amd64/FL/platform.H b/include/linux/amd64/FL/platform.H new file mode 100644 index 0000000..715a10c --- /dev/null +++ b/include/linux/amd64/FL/platform.H @@ -0,0 +1,81 @@ +// +// Platform header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2023 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// These are FLTK symbols that are necessary or useful for calling +// platform specific functions. This file #include's certain platform +// specific system header files that are necessary to declare platform +// specific FLTK functions, for instance "Windows.h" under Windows. + +// You should include this file if (and ONLY if) you need to call +// platform specific functions directly. + +// See FLTK documentation: chapter "Operating System Issues" on when +// you need to #include + +#if !defined(FL_PLATFORM_H) && !defined(FL_DOXYGEN) +# define FL_PLATFORM_H + +# include +# include // will bring in FL/fl_config.h +# include // for uchar +class Fl_Window; + +# ifdef _WIN32 +# include "win32.H" +# elif defined(FLTK_USE_WAYLAND) +# include "wayland.H" +# elif defined(FLTK_USE_X11) +# include "x11.H" +# elif defined(__APPLE__) +# include "mac.H" +# endif // _WIN32 + +// +// cross-platform declarations +// +#if defined(FL_LIBRARY) || defined(FL_INTERNALS) +# include + +class FL_EXPORT Fl_X { +public: + fl_uintptr_t xid; + Fl_Window* w; + Fl_Region region; + Fl_X *next; + // static variables, static functions and member functions + static Fl_X* first; + static Fl_X* flx(const Fl_Window* w) {return w ? (Fl_X*)w->flx_ : 0;} +# if defined(FLTK_USE_X11) && FLTK_USE_X11 // for backward compatibility + static void make_xid(Fl_Window*, XVisualInfo* =fl_visual, Colormap=fl_colormap); + static Fl_X* set_xid(Fl_Window*, Window); + static inline Fl_X* i(const Fl_Window* w) {return flx(w);} +# endif +}; + +inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::flx(w); return xTemp ? (Window)xTemp->xid : 0; } +#else +extern FL_EXPORT Window fl_xid_(const Fl_Window* w); +# define fl_xid(w) fl_xid_(w) +#endif // FL_LIBRARY || FL_INTERNALS + +extern FL_EXPORT Fl_Window* fl_find(Window xid); +extern FL_EXPORT void fl_open_display(); +extern FL_EXPORT void fl_close_display(); +extern FL_EXPORT Window fl_window; +extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); +extern FL_EXPORT void fl_open_callback(void (*)(const char *)); + +#endif // !FL_PLATFORM_H diff --git a/include/linux/amd64/FL/platform_types.h b/include/linux/amd64/FL/platform_types.h new file mode 100644 index 0000000..67656b7 --- /dev/null +++ b/include/linux/amd64/FL/platform_types.h @@ -0,0 +1,152 @@ +/* + * Copyright 2016-2023 by Bill Spitzak and others. + * + * This library is free software. Distribution and use rights are outlined in + * the file "COPYING" which should have been included with this file. If this + * file is missing or damaged, see the license at: + * + * https://www.fltk.org/COPYING.php + * + * Please see the following page on how to report bugs and issues: + * + * https://www.fltk.org/bugs.php + */ + +#ifndef Fl_Platform_Types_H +#define Fl_Platform_Types_H + +/** \file + Definitions of platform-dependent types. + The exact nature of these types varies with the platform. + Therefore, portable FLTK applications should not assume these types + have a specific size, or that they are pointers. + */ + +#ifdef FL_DOXYGEN + +/** An integral type large enough to store a pointer or a long value. + A pointer value can be safely cast to fl_intptr_t, and later cast back + to its initial pointer type without change to the pointer value. + A variable of type fl_intptr_t can also store a long int value. */ +typedef opaque fl_intptr_t; +/** An unsigned integral type large enough to store a pointer or an unsigned long value. + A pointer value can be safely cast to fl_uintptr_t, and later cast back + to its initial pointer type without change to the pointer value. + A variable of type fl_uintptr_t can also store an unsigned long int value. */ +typedef opaque fl_uintptr_t; + +/** + Platform-specific value representing an offscreen drawing buffer. + \note This value can be safely cast to these types on each platform: + \li X11: Pixmap + \li Wayland: cairo_t * + \li Windows: HBITMAP + \li macOS: CGContextRef + */ +typedef opaque Fl_Offscreen; + +/** + Pointer to a platform-specific structure representing a collection of rectangles. + \note This pointer can be safely cast to these types on each platform: + \li X11: Region as defined by X11 + \li Wayland: cairo_region_t * + \li Windows: HRGN + \li macOS: struct flCocoaRegion * + */ +typedef struct opaque *Fl_Region; +typedef opaque FL_SOCKET; /**< socket or file descriptor */ +/** + Pointer to a platform-specific structure representing the window's OpenGL rendering context. + \note This pointer can be safely cast to these types on each platform: + \li X11: GLXContext + \li Wayland: EGLContext + \li Windows: HGLRC + \li macOS: NSOpenGLContext * + */ +typedef struct opaque *GLContext; + +/** + Platform-specific point in time, used for delta time calculation. + \note This type may be a struct. sizeof(Fl_Timestamp) may be different on + different platforms. Fl_Timestamp may change with future ABI changes. + */ +typedef opaque Fl_Timestamp; + +# define FL_COMMAND opaque /**< An alias for FL_CTRL on Windows and X11, or FL_META on MacOS X */ +# define FL_CONTROL opaque /**< An alias for FL_META on Windows and X11, or FL_CTRL on MacOS X */ + +#else /* FL_DOXYGEN */ + +#ifndef FL_PLATFORM_TYPES_H +#define FL_PLATFORM_TYPES_H + +#include +#include // for time_t + +/* Platform-dependent types are defined here. + These types must be defined by any platform: + FL_SOCKET, struct dirent, fl_intptr_t, fl_uintptr_t + + NOTE: *FIXME* AlbrechtS 13 Apr 2016 (concerning FL_SOCKET) + ---------------------------------------------------------- + The Fl::add_fd() API is partially inconsistent because some of the methods + explicitly use 'int', but the callback typedefs use FL_SOCKET. With the + definition of FL_SOCKET below we can have different data sizes and + different signedness of socket numbers on *some* platforms. + */ + +#ifdef _WIN64 + +#if defined(_MSC_VER) && (_MSC_VER < 1600) +# include /* stdint.h not available before VS 2010 (1600) */ +#else +# include +#endif + +typedef intptr_t fl_intptr_t; +typedef uintptr_t fl_uintptr_t; + +#else /* ! _WIN64 */ + +typedef long fl_intptr_t; +typedef unsigned long fl_uintptr_t; + +#endif /* _WIN64 */ + +typedef void *GLContext; +typedef void *Fl_Region; +typedef fl_uintptr_t Fl_Offscreen; + +/* Allows all hybrid combinations except WIN32 + X11 with MSVC */ +#if defined(_WIN32) && !defined(__MINGW32__) + struct dirent {char d_name[1];}; +#else +# include +#endif + +# if defined(_WIN64) && defined(_MSC_VER) +typedef unsigned __int64 FL_SOCKET; /* *FIXME* - FL_SOCKET (see above) */ +# else +typedef int FL_SOCKET; +# endif + +#include +extern FL_EXPORT int fl_command_modifier(); +extern FL_EXPORT int fl_control_modifier(); +# define FL_COMMAND fl_command_modifier() +# define FL_CONTROL fl_control_modifier() + +#endif /* FL_PLATFORM_TYPES_H */ + +/* This is currently the same for all platforms but may change in the future */ +struct Fl_Timestamp_t { + time_t sec; + int usec; +}; + +typedef struct Fl_Timestamp_t Fl_Timestamp; + +#endif /* FL_DOXYGEN */ + +#endif /* Fl_Platform_Types_H */ + diff --git a/include/linux/amd64/FL/wayland.H b/include/linux/amd64/FL/wayland.H new file mode 100644 index 0000000..71981d9 --- /dev/null +++ b/include/linux/amd64/FL/wayland.H @@ -0,0 +1,61 @@ +// +// Wayland/X11 hybrid platform header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#if !defined(FL_PLATFORM_H) +# error "Never use directly; include instead." +#endif // !FL_PLATFORM_H + +/** \file + \anchor wayland_H Definitions of functions specific to the Wayland platform. +*/ + +// *********** for Wayland component *********** + +typedef struct _cairo cairo_t; + +/** Returns the Wayland display in use */ +extern FL_EXPORT struct wl_display *fl_wl_display(); +/** Returns the wl_surface associated to a shown window */ +extern FL_EXPORT struct wl_surface *fl_wl_surface(struct wld_window *xid); +/** Returns a platform-specific reference associated to a shown window */ +extern FL_EXPORT struct wld_window *fl_wl_xid(const Fl_Window *win); +/** Returns the Fl_Window corresponding to a given the platform-specific window reference */ +extern FL_EXPORT Fl_Window *fl_wl_find(struct wld_window *); +/** Returns the cairo context associated to the current window or Fl_Image_Surface */ +extern FL_EXPORT cairo_t *fl_wl_gc(); +/** Returns the wl_compositor of the current Wayland session. + This allows, for example, to create a wl_surface with + \code + struct wl_surface *my_wl_surface = wl_compositor_create_surface(fl_wl_compositor()); + \endcode + */ +extern FL_EXPORT struct wl_compositor *fl_wl_compositor(); +/** Returns the current buffer scaling factor for \p window. */ +extern FL_EXPORT int fl_wl_buffer_scale(Fl_Window *window); +typedef void *EGLContext; +/** Returns the EGLContext corresponding to the given GLContext */ +extern FL_EXPORT EGLContext fl_wl_glcontext(GLContext rc); + +#ifndef FL_DOXYGEN + +# ifdef FLTK_USE_X11 +// *********** for X11 component *********** +# include "x11.H" +# else + typedef struct wld_window *Window; +# endif + +#endif // FL_DOXYGEN diff --git a/include/linux/amd64/FL/win32.H b/include/linux/amd64/FL/win32.H new file mode 100644 index 0000000..d7bfd5c --- /dev/null +++ b/include/linux/amd64/FL/win32.H @@ -0,0 +1,93 @@ +// +// Windows platform header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// Do not directly include this file, instead use . It will +// include this file if _WIN32 is defined. This is to encourage +// portability of even the system-specific code... + +#ifdef FL_DOXYGEN + +/** \file + Definitions of functions specific to the Windows platform. +*/ + +/** Returns the Windows-specific window reference corresponding to the given Fl_Window object */ +extern HWND fl_win32_xid(const Fl_Window *win); +/** Returns the Fl_Window corresponding to the given Windows-specific window reference */ +extern Fl_Window *fl_win32_find(HWND); +/** Returns the Windows-specific GL rendering context corresponding to the given GLContext */ +extern HGLRC fl_win32_glcontext(GLContext rc); +/** Returns the Windows-specific graphics context for the current window */ +extern HDC fl_win32_gc(); +/** Returns the Windows-specific display in use */ +extern HINSTANCE fl_win32_display(); + +#else + +#ifndef FL_PLATFORM_H +# error "Never use directly; include instead." +#endif // !FL_PLATFORM_H + +#include +typedef HWND Window; + +typedef struct HGLRC__ *HGLRC; +extern FL_EXPORT HGLRC fl_win32_glcontext(GLContext rc); +extern FL_EXPORT HWND fl_win32_xid(const Fl_Window *win); +extern FL_EXPORT Fl_Window *fl_win32_find(HWND); + +// 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 + +extern FL_EXPORT UINT fl_wake_msg; +extern FL_EXPORT char fl_override_redirect; // hack into Fl_Window::make_xid() +extern FL_EXPORT HPALETTE fl_palette; // non-zero only on 8-bit displays! +extern void fl_release_dc(HWND w, HDC dc); +extern FL_EXPORT void fl_save_dc( HWND w, HDC dc); + +#endif // FL_LIBRARY || FL_INTERNALS + +// 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 + int pwidth; // the width of the pen, if present +} *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 HINSTANCE fl_win32_display(); +extern FL_EXPORT HDC fl_gc; +extern FL_EXPORT HDC fl_win32_gc(); +extern FL_EXPORT MSG fl_msg; +extern FL_EXPORT HDC fl_GetDC(Window); +extern FL_EXPORT HDC fl_makeDC(HBITMAP); + +#endif // FL_DOXYGEN diff --git a/include/linux/amd64/FL/x.H b/include/linux/amd64/FL/x.H new file mode 100644 index 0000000..92bc2c8 --- /dev/null +++ b/include/linux/amd64/FL/x.H @@ -0,0 +1,26 @@ +// +// *Deprecated* platform header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2018 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// IMPORTANT: This file is deprecated since FLTK 1.4.0. DO NOT include it. +// FL/x.H will be removed in a future FLTK release. + +// Please #include instead if you really need it. See +// documentation in FL/platform.H to decide whether you need that file. + +#if !defined(Fl_X_H) && !defined(FL_DOXYGEN) +# define Fl_X_H +# include +#endif // !Fl_X_H diff --git a/include/linux/amd64/FL/x11.H b/include/linux/amd64/FL/x11.H new file mode 100644 index 0000000..c347302 --- /dev/null +++ b/include/linux/amd64/FL/x11.H @@ -0,0 +1,125 @@ +// +// X11 platform header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2022 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +// Do not directly include this file, instead use . It will +// include this file if FLTK_USE_X11 is defined. This is to encourage +// portability of even the system-specific code... + +#ifdef FL_DOXYGEN + +/** \file + Definitions of functions specific to the X11 platform. +*/ + +/** Returns the X11 Display in use */ +extern Display *fl_x11_display(); +/** Have FLTK use a pre-established X11 connection. + This function must be called before FLTK attempts to open its own X11 connection, + that is, as long as fl_x11_display() returns NULL. + \param d the X11 Display* value representing a valid, pre-established X11 connection + */ +extern void fl_x11_use_display(Display *d); +/** Returns the Window reference for the given Fl_Window, or zero if not \c shown(). */ +extern Window fl_x11_xid(const Fl_Window *win); +/** Returns the Fl_Window corresponding to the given Window reference. */ +extern Fl_Window *fl_x11_find(Window xid); +/** Returns the X11-specific currently active graphics context. */ +extern GC fl_x11_gc(); +/** Returns the Cairo-specific currently active graphics context (FLTK_GRAPHICS_CAIRO=On) */ +extern cairo_t* fl_cairo_gc(); +#else // ! FL_DOXYGEN + +#ifndef FL_PLATFORM_H +# error "Never use directly; include instead." +#endif // !FL_PLATFORM_H + +#include + +#if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files +# pragma set woff 3322 +#endif +#include +#include +#if defined(_ABIN32) || defined(_ABI64) +# pragma reset woff 3322 +#endif +#include + +typedef struct __GLXcontextRec *GLXContext; +extern GLXContext fl_x11_glcontext(GLContext rc); + +// constant info about the X server connection: +extern FL_EXPORT Display *fl_display; +extern FL_EXPORT Display *fl_x11_display(); +extern FL_EXPORT void fl_x11_use_display(Display *); +extern FL_EXPORT Window fl_x11_xid(const Fl_Window *win); +extern FL_EXPORT Fl_Window *fl_x11_find(Window); +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; +#if FLTK_USE_CAIRO + typedef struct _cairo cairo_t; + extern FL_EXPORT cairo_t* fl_cairo_gc(); +#endif +extern FL_EXPORT GC fl_x11_gc(); +FL_EXPORT ulong fl_xpixel(Fl_Color i); +FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b); + +// 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; + +#if defined(FL_LIBRARY) || defined(FL_INTERNALS) +extern FL_EXPORT Window fl_message_window; +extern FL_EXPORT void *fl_xftfont; + +// 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_EXPORT 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; + +extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid() + +#endif // FL_LIBRARY || FL_INTERNALS + +#endif // FL_DOXYGEN diff --git a/lib/linux/amd64/libfltk.a b/lib/linux/amd64/libfltk.a index b867326..cde573d 100644 Binary files a/lib/linux/amd64/libfltk.a and b/lib/linux/amd64/libfltk.a differ diff --git a/lib/linux/amd64/libfltk_forms.a b/lib/linux/amd64/libfltk_forms.a index b00f9d1..2afa541 100644 Binary files a/lib/linux/amd64/libfltk_forms.a and b/lib/linux/amd64/libfltk_forms.a differ diff --git a/lib/linux/amd64/libfltk_gl.a b/lib/linux/amd64/libfltk_gl.a index 8044daa..dfd5c41 100644 Binary files a/lib/linux/amd64/libfltk_gl.a and b/lib/linux/amd64/libfltk_gl.a differ diff --git a/lib/linux/amd64/libfltk_images.a b/lib/linux/amd64/libfltk_images.a index 0735f3f..a136976 100644 Binary files a/lib/linux/amd64/libfltk_images.a and b/lib/linux/amd64/libfltk_images.a differ