diff --git a/documentation/src/fluid.dox b/documentation/src/fluid.dox index adaf448dd..e716c15d6 100644 --- a/documentation/src/fluid.dox +++ b/documentation/src/fluid.dox @@ -19,7 +19,6 @@ Subchapters: \li \ref fluid_i18n \li \ref fluid_limitations - \section fluid_what_is_fluid What is FLUID? The Fast Light User Interface Designer, or FLUID, is a @@ -69,7 +68,6 @@ Widgets may either call a named callback function that you write in another source file, or you can supply a small piece of C++ source and FLUID will write a private callback function into the .cxx file. - \section fluid_fluid_under_unix Running FLUID Under UNIX To run FLUID under UNIX, type: @@ -109,14 +107,12 @@ background with '&' then you will be able to abort FLUID by typing CTRL-C on the terminal. It will exit immediately, losing any changes. - \section fluid_fluid_under_windows Running FLUID Under Microsoft Windows To run FLUID under WIN32, double-click on the \e FLUID.exe file. You can also run FLUID from the Command Prompt window. FLUID always runs in the background under WIN32. - \section fluid_compiling_fl_files Compiling .fl files FLUID can also be called as a command-line @@ -150,7 +146,6 @@ files to be compiled: fluid -c $< \endcode - \section fluid_tutorial A Short Tutorial FLUID is an amazingly powerful little program. However, this @@ -188,7 +183,6 @@ You can safely skip this section as long as you realize the CubeView is a sublass of Fl_Gl_Window and will respond to calls from CubeViewUI, generated by FLUID. - \par The CubeView Class Definition Here is the CubeView class definition, as given by its header file @@ -251,7 +245,6 @@ class CubeView : public Fl_Gl_Window { }; \endcode - \par The CubeView Class Implementation Here is the CubeView implementation. It is very similar to the @@ -381,7 +374,6 @@ void CubeView::draw() { We will completely construct a window to display and control the CubeView defined in the previous section using FLUID. - \par Defining the CubeViewUI Class Once you have started FLUID, the first step in defining a class is to @@ -394,7 +386,6 @@ browser window. \image html fluid1.gif "Figure 9-3: FLUID file for CubeView" \image latex fluid1.eps "FLUID file for CubeView" width=10cm - \par Adding the Class Constructor Click on the CubeViewUI class in the FLUID window and add a new method @@ -426,7 +417,6 @@ When you are finished you should have something like this: We will talk about the \p show() method that is highlighted shortly. - \par Adding the CubeView Widget What we have is nice, but does little to show our cube. We have already @@ -452,7 +442,6 @@ now available to CubeViewUI. \image html fluid3-cxx.gif "Figure 9-5: CubeView methods" \image latex fluid3-cxx.eps "CubeView methods" width=10cm - \par Defining the Callbacks Each of the widgets we defined before adding CubeView can have @@ -475,7 +464,6 @@ There is no reason no wait until after you have added CubeView to enter these callbacks. FLUID assumes you are smart enough not to refer to members or functions that don't exist. - \par Adding a Class Method You can add class methods within FLUID that have nothing to do with the @@ -494,7 +482,6 @@ type of \p void. Once the new method has been added, highlight its name and select New->Code->Code. Enter the method's code in the code window. - \subsection fluid_addconst Adding Constructor Initialization Code If you need to add code to initialize class, for example setting @@ -502,21 +489,20 @@ initial values of the horizontal and vertical angles in the CubeView, you can simply highlight the Constructor and select New->Code->Code. Add any required code. - \subsection fluid_gencode Generating the Code Now that we have completely defined the CubeViewUI, we have to generate the code. There is one last trick to ensure this all works. Open the preferences dialog from Edit->Preferences. -At the bottom of the preferences dialog box is the key: "Include -Header from Code". Select that option and set your desired file +At the bottom of the preferences dialog box is the key: +"Include Header from Code". +Select that option and set your desired file extensions and you are in business. You can include the CubeViewUI.h (or whatever extension you prefer) as you would any other C++ class. - \section fluid_references FLUID Reference The following sections describe each of the windows in FLUID. @@ -569,10 +555,12 @@ window. The menu items are: \par File/Open... (Ctrl+o) +\par Discards the current editing session and reads in a different .fl file. You are asked for confirmation if you have changed the current file. +\par FLUID can also read .fd files produced by the Forms and XForms "fdesign" programs. It is best to File/Merge them instead of opening them. FLUID does not @@ -586,6 +574,7 @@ read! \par File/Insert... (Ctrl+i) +\par Inserts the contents of another .fl file, without changing the name of the current .fl file. All the functions (even if they have the same names as the current ones) @@ -594,28 +583,34 @@ where you want. \par File/Save (Ctrl+s) +\par Writes the current data to the .fl file. If the file is unnamed then FLUID will ask for a filename. \par File/Save As... (Ctrl+Shift+S) +\par Asks for a new filename and saves the file. \par File/Write Code (Ctrl+Shift+C) +\par "Compiles" the data into a .cxx and .h file. These are exactly the same as the files you get when you run FLUID with the \c -c switch. +\par The output file names are the same as the .fl file, with the leading directory and trailing ".fl" stripped, and ".h" or ".cxx" appended. \par File/Write Strings (Ctrl+Shift+W) +\par Writes a message file for all of the text labels defined in the current file. +\par The output file name is the same as the .fl file, with the leading directory and trailing ".fl" stripped, and ".txt", ".po", or ".msg" appended depending on the @@ -623,46 +618,57 @@ stripped, and ".txt", ".po", or ".msg" appended depending on the \par File/Quit (Ctrl+q) +\par Exits FLUID. You are asked for confirmation if you have changed the current file. \par Edit/Undo (Ctrl+z) +\par This isn't implemented yet. You should do save often so you can recover from any mistakes you make. \par Edit/Cut (Ctrl+x) +\par Deletes the selected widgets and all of their children. These are saved to a "clipboard" file and can be pasted back into any FLUID window. \par Edit/Copy (Ctrl+c) +\par Copies the selected widgets and all of their children to the "clipboard" file. \par Edit/Paste (Ctrl+c) +\par Pastes the widgets from the clipboard file. +\par If the widget is a window, it is added to whatever function is selected, or contained in the current selection. +\par If the widget is a normal widget, it is added to whatever window or group is selected. If none is, it is added to the window or group that is the parent of the current selection. +\par To avoid confusion, it is best to select exactly one widget before doing a paste. +\par Cut/paste is the only way to change the parent of a widget. \par Edit/Select All (Ctrl+a) +\par Selects all widgets in the same group as the current selection. +\par If they are all selected already then this selects all widgets in that group's parent. Repeatedly typing Ctrl+a will select larger and larger groups of widgets until everything is @@ -670,12 +676,14 @@ selected. \par Edit/Open... (F1 or double click) +\par Displays the current widget in the attributes panel. If the widget is a window and it is not visible then the window is shown instead. \par Edit/Sort +\par Sorts the selected widgets into left to right, top to bottom order. You need to do this to make navigation keys in FLTK work correctly. You may then fine-tune the sorting with @@ -684,6 +692,7 @@ the positions of windows or functions. \par Edit/Earlier (F2) +\par Moves all of the selected widgets one earlier in order among the children of their parent (if possible). This will affect navigation order, and if the widgets overlap it will affect how @@ -693,21 +702,25 @@ windows within functions. \par Edit/Later (F3) +\par Moves all of the selected widgets one later in order among the children of their parent (if possible). \par Edit/Group (F7) +\par Creates a new Fl_Group and make all the currently selected widgets children of it. \par Edit/Ungroup (F8) +\par Deletes the parent group if all the children of a group are selected. \par Edit/Overlays on/off (Ctrl+Shift+O) +\par Toggles the display of the red overlays off, without changing the selection. This makes it easier to see box borders and how the layout looks. The overlays will be forced back on if you @@ -715,12 +728,14 @@ change the selection. \par Edit/Project Settings... (Ctrl+p) +\par Displays the project settings panel. The output filenames control the extensions or names of the files the are generated by FLUID. If you check the "Include .h from .cxx" button the code file will include the header file automatically. +\par The \ref fluid_i18n "internationalization" options are described later in this chapter. @@ -729,22 +744,26 @@ later in this chapter. \par Edit/GUI Settings... (Shift+Ctrl+p) +\par Displays the GUI settings panel. This panel is used to control the user interface settings. \par New/Code/Function +\par Creates a new C function. You will be asked for a name for the function. This name should be a legal C++ function template, without the return type. You can pass arguments which can be referred to by code you type into the individual widgets. +\par If the function contains any unnamed windows, it will be declared as returning a Fl_Window pointer. The unnamed window will be returned from it (more than one unnamed window is useless). If the function contains only named windows, it will be declared as returning nothing (\c void ). +\par It is possible to make the .cxx output be a self-contained program that can be compiled and executed. This is done by deleting the function name so @@ -753,22 +772,26 @@ is done by deleting the function name so \p Fl::run(). This can also be used to test resize behavior or other parts of the user interface. +\par You can change the function name by double-clicking on the function. \par New/Window +\par Creates a new Fl_Window widget. The window is added to the currently selected function, or to the function containing the currently selected item. The window will appear, sized to 100x100. You can resize it to whatever size you require. +\par The widget panel will also appear and is described later in this chapter. \par New/... +\par All other items on the New menu are subclasses of Fl_Widget. Creating them will add them to the currently selected group or window, or the group or window @@ -776,28 +799,34 @@ containing the currently selected widget. The initial dimensions and position are chosen by copying the current widget, if possible. +\par When you create the widget you will get the widget's control panel, which is described later in this chapter. \par Layout/Align/... +\par Align all selected widgets to the first widget in the selection. \par Layout/Space Evenly/... +\par Space all selected widgets evenly inside the selected space. Widgets will be sorted from first to last. \par Layout/Make Same Size/... +\par Make all slected widgets the same size as the first selected widget. \par Layout/Center in Group/... +\par Center all selected widgets relative to their parent widget \par Layout/Grid... (Ctrl+g) +\par Displays the grid settings panel. This panel controls the grid that all widgets snap to when you move and @@ -806,23 +835,28 @@ be dragged from its original position to actually change. \par Shell/Execute Command... (Alt+x) +\par Displays the shell command panel. The shell command is commonly used to run a 'make' script to compile the FLTK output. \par Shell/Execute Again (Alt+g) +\par Run the shell command again. \par Help/About FLUID +\par Pops up a panel showing the version of FLUID. \par Help/On FLUID +\par Shows this chapter of the manual. \par Help/Manual +\par Shows the contents page of the manual \subsection fluid_widget_panel The Widget Panel @@ -862,37 +896,44 @@ undone, however. \par Label (text field) +\par String to print next to or inside the button. You can put newlines into the string to make multiple lines. The easiest way is by typing Ctrl+j. -Symbols +\par +\ref common_labels "Symbols" can be added to the label using the at sign ("@"). \par Label (pull down menu) +\par How to draw the label. Normal, shadowed, engraved, and embossed change the appearance of the text. \par Image +\par The active image for the widget. Click on the \b Browse... button to pick an image file using the file chooser. \par Inactive +\par The inactive image for the widget. Click on the \b Browse... button to pick an image file using the file chooser. \par Alignment (buttons) +\par Where to draw the label. The arrows put it on that side of the widget, you can combine the to put it in the corner. The "box" button puts the label inside the widget, rather than outside. +\par The \b clip button clips the label to the widget box, the \b wrap button wraps any text in the label, and the text image button puts the text over the image instead of under @@ -900,29 +941,35 @@ the image. \par Position (text fields) +\par The position fields show the current position and size of the widget box. Enter new values to move and/or resize a widget. \par Values (text fields) +\par The values and limits of the current widget. Depending on the type of widget, some or all of these fields may be inactive. \par Shortcut +\par The shortcut key to activate the widget. Click on the shortcut button and press any key sequence to set the shortcut. \par Attributes (buttons) +\par The \b Visible button controls whether the widget is visible (on) or hidden (off) initially. Don't change this for windows or for the immediate children of a Tabs group. +\par The \b Active button controls whether the widget is activated (on) or deactivated (off) initially. Most widgets appear greyed out when deactivated. +\par The \b Resizable button controls whether the window is resizeable. In addition all the size changes of a window or group will go "into" the resizable child. If you have @@ -933,6 +980,7 @@ using hierarchies of groups. Unfortunately the only way to test it is to compile the program. Resizing the FLUID window is \e not the same as what will happen in the user program. +\par The \b Hotspot button causes the parent window to be positioned with that widget centered on the mouse. This position is determined when the FLUID function is called, @@ -941,12 +989,14 @@ you want the window to hide and then reappear at a new position, you should have your program set the hotspot itself just before \p show(). +\par The \b Border button turns the window manager border on or off. On most window managers you will have to close the window and reopen it to see the effect. \par X Class (text field) +\par The string typed into here is passed to the X window manager as the class. This can change the icon or window decorations. On most (all?) window managers you will have to close the window @@ -959,6 +1009,7 @@ and reopen it to see the effect. \par Label Font (pulldown menu) +\par Font to draw the label in. Ignored by symbols, bitmaps, and pixmaps. Your program can change the actual font used by these "slots" in case you want some font other than the 16 @@ -966,25 +1017,30 @@ provided. \par Label Size (pulldown menu) +\par Pixel size (height) for the font to draw the label in. Ignored by symbols, bitmaps, and pixmaps. To see the result without dismissing the panel, type the new number and then Tab. \par Label Color (button) +\par Color to draw the label. Ignored by pixmaps (bitmaps, however, do use this color as the foreground color). \par Box (pulldown menu) +\par The boxtype to draw as a background for the widget. +\par Many widgets will work, and draw faster, with a "frame" instead of a "box". A frame does not draw the colored interior, leaving whatever was already there visible. Be careful, as FLUID may draw this ok but the real program may leave unwanted stuff inside the widget. +\par If a window is filled with child widgets, you can speed up redrawing by changing the window's box type to "NO_BOX". FLUID will display a checkerboard for any @@ -994,15 +1050,18 @@ random garbage will be displayed. \par Down Box (pulldown menu) +\par The boxtype to draw when a button is pressed or for some parts of other widgets like scrollbars and valuators. \par Color (button) +\par The color to draw the box with. \par Select Color (button) +\par Some widgets will use this color for certain parts. FLUID does not always show the result of this: this is the color buttons draw in when pushed down, and the color of input fields @@ -1010,6 +1069,7 @@ when they have the focus. \par Text Font, Size, and Color +\par Some widgets display text, such as input fields, pull-down menus, and browsers. @@ -1020,34 +1080,40 @@ menus, and browsers. \par Class +\par This is how you use your own subclasses of Fl_Widget. Whatever identifier you type in here will be the class that is instantiated. +\par In addition, no \p \#include header file is put in the .h file. You must provide a \p \#include line as the first line of the "Extra Code" which declares your subclass. +\par The class must be similar to the class you are spoofing. It does not have to be a subclass. It is sometimes useful to change this to another FLTK class. Currently the only way to get a double-buffered window is to change this field for the window to "Fl_Double_Window" and to add -\code \#include \endcode +\code #include \endcode to the extra code. \par Type (upper-right pulldown menu) +\par Some classes have subtypes that modify their appearance or behavior. You pick the subtype off of this menu. \par Name (text field) +\par Name of a variable to declare, and to store a pointer to this widget into. This variable will be of type "*". If the name is blank then no variable is created. +\par You can name several widgets with "name[0]", "name[1]", "name[2]", etc. This will cause FLUID to declare an array of pointers. The array is big enough that the highest number found can be stored. All widgets @@ -1055,6 +1121,7 @@ that in the array must be the same type. \par Public (button) +\par Controls whether the widget is publicly accessible. When embedding widgets in a C++ class, this controls whether the widget is \p public or \p private in the class. @@ -1063,15 +1130,18 @@ Otherwise is controls whether the widget is declared \par Extra Code (text fields) +\par These four fields let you type in literal lines of code to dump into the .h or .cxx files. +\par If the text starts with a \# or the word \p extern then FLUID thinks this is an "include" line, and it is written to the .h file. If the same include line occurs several times then only one copy is written. +\par All other lines are "code" lines. The current widget is pointed to by the local variable \p o. The window being constructed is pointed to by the local variable @@ -1079,6 +1149,7 @@ window being constructed is pointed to by the local variable function here, and any named widgets that are before this one. +\par FLUID will check for matching parenthesis, braces, and quotes, but does not do much other error checking. Be careful here, as it may be hard to figure out what widget is producing @@ -1088,13 +1159,16 @@ code. \par Callback (text field) +\par This can either be the name of a function, or a small snippet -of code. If you enter anything but letters, numbers, and the +of code. If you enter anything other than letters, numbers, and the underscore then FLUID treats it as code. -A name names a function in your own code. It must be +\par +A name refers to a function in your own code. It must be declared as void name(*,void*). +\par A code snippet is inserted into a static function in the .cxx output file. The function prototype is void name(class *o, void *v) @@ -1104,16 +1178,19 @@ and quotes, but does not do much other error checking. Be careful here, as it may be hard to figure out what widget is producing an error in the compiler. +\par If the callback is blank then no callback is set. \par User Data (text field) +\par This is a value for the \p user_data() of the widget. If blank the default value of zero is used. This can be any piece of C code that can be cast to a \p void pointer. \par Type (text field) +\par The \p void* in the callback function prototypes is replaced with this. You may want to use \p long for old XForms code. Be warned that anything other than \p void* @@ -1122,16 +1199,19 @@ pointer types are ok, and \p long is usually ok, too. \par When (pulldown menu) +\par When to do the callback. This can be \b Never, \b Changed, \b Release, or \b Enter Key. The value of Enter Key is only useful for text input fields. +\par There are other rare but useful values for the \p when() field that are not in the menu. You should use the extra code fields to put these values in. \par No Change (button) +\par The No Change button means the callback is done on the matching event even if the data is not changed. @@ -1208,56 +1288,67 @@ recommend you either put the images in the same directory as the \par Notes for All Image Types +\par FLUID runs using the default visual of your X server. This may be 8 bits, which will give you dithered images. You may get better results in your actual program by adding the code "Fl::visual(FL_RGB)" to your code right before the first window is displayed. +\par All widgets with the same image on them share the same code and source X pixmap. Thus once you have put an image on a widget, it is nearly free to put the same image on many other widgets. +\par If you edit an image at the same time you are using it in FLUID, the only way to convince FLUID to read the image file again is to remove the image from all widgets that are using it or re-load the .fl file. +\par Don't rely on how FLTK crops images that are outside the widget, as this may change in future versions! The cropping of inside labels will probably be unchanged. +\par To more accurately place images, make a new "box" widget and put the image in that as the label. \par XBM (X Bitmap) Files +\par FLUID reads X bitmap files which use C source code to define a bitmap. Sometimes they are stored with the ".h" or ".bm" extension rather than the standard ".xbm" extension. +\par FLUID writes code to construct an Fl_Bitmap image and use it to label the widget. The '1' bits in the bitmap are drawn using the label color of the widget. You can change this color in the FLUID widget attributes panel. The '0' bits are transparent. +\par The program "bitmap" on the X distribution does an adequate job of editing bitmaps. \par XPM (X Pixmap) Files +\par FLUID reads X pixmap files as used by the \p libxpm library. These files use C source code to define a pixmap. The filenames usually have the ".xpm" extension. +\par FLUID writes code to construct an Fl_Pixmap image and use it to label the widget. The label color of the widget is ignored, even for 2-color images that could be a bitmap. XPM files can mark a single color as being transparent, and FLTK uses this information to generate a transparency mask for the image. +\par We have not found any good editors for small iconic pictures. For pixmaps we have used XPaint @@ -1265,6 +1356,7 @@ and the KDE icon editor. \par BMP Files +\par FLUID reads Windows BMP image files which are often used in WIN32 applications for icons. FLUID converts BMP files into (modified) XPM format and uses a Fl_BMP_Image image to label the @@ -1274,6 +1366,7 @@ the code may be much bigger than the .bmp file. \par GIF Files +\par FLUID reads GIF image files which are often used in HTML documents to make icons. FLUID converts GIF files into (modified) XPM format and uses a Fl_GIF_Image image to label the @@ -1284,6 +1377,7 @@ the first image of an animated GIF file is used. \par JPEG Files +\par If FLTK is compiled with JPEG support, FLUID can read JPEG image files which are often used for digital photos. FLUID uses a Fl_JPEG_Image image to label the widget, and writes @@ -1291,6 +1385,7 @@ uncompressed RGB or grayscale data to the source file. \par PNG (Portable Network Graphics) Files +\par If FLTK is compiled with PNG support, FLUID can read PNG image files which are often used in HTML documents. FLUID uses a Fl_PNG_Image image to label the widget, and writes uncompressed @@ -1298,7 +1393,6 @@ RGB or grayscale data to the source file. PNG images can provide a full alpha channel for partial transparency, and FLTK supports this as best as possible on each platform. - \section fluid_i18n Internationalization with FLUID FLUID supports internationalization (I18N for short) of label @@ -1329,7 +1423,7 @@ need to call \p setlocale() and \p textdomain() or message file. To use GNU gettext for I18N, open the preferences window and -choose "GNU gettext" from the "Use" chooser. Two new input +choose "GNU gettext" from the \b Use: chooser. Two new input fields will then appear to control the include file and function/macro name to use when retrieving the localized label strings. @@ -1337,12 +1431,12 @@ strings. \image html fluid-gettext.gif "Figure 9-11: Internationalization using GNU gettext" \image latex fluid-gettext.eps "Internationalization using GNU gettext" width=10cm -The \p \#include +The \b \#include field controls the header file to include for I18N; by default this is \b , the standard I18N file for GNU gettext. -The "Function" field controls the function (or macro) that +The \b Function: field controls the function (or macro) that will retrieve the localized message; by default the \p gettext function will be called. @@ -1354,7 +1448,7 @@ each .fl file; you still need to call \p setlocale() to select the appropriate language. To use POSIX catgets for I18N, open the preferences window -and choose "POSIX catgets" from the "Use" chooser. Three new +and choose "POSIX catgets" from the \b Use: chooser. Three new input fields will then appear to control the include file, catalog file, and set number for retrieving the localized label strings. @@ -1362,18 +1456,18 @@ strings. \image html fluid-catgets.gif "Figure 9-12: Internationalization using POSIX catgets" \image latex fluid-catgets.eps "Internationalization using POSIX catgets" width=10cm -The \p \#include +The \b \#include field controls the header file to include for I18N; by default this is \b , the standard I18N file for POSIX catgets. -The "File" field controls the name of the catalog file +The \b File: field controls the name of the catalog file variable to use when retrieving localized messages; by default the file field is empty which forces a local (static) catalog file to be used for all of the windows defined in your .fl file. -The "Set" field controls the set number in the catalog file. +The \b Set: field controls the set number in the catalog file. The default set is 1 and rarely needs to be changed.