Back to index

texmacs  1.0.7.15
gui.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : gui.hpp
00004 * DESCRIPTION: Abstract interface to various GUIs.
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This module contains all system-wide routines of GUIs.
00008 * An abstract widget interface can be found in widget.hpp / message.hpp and
00009 * an abstract interface for drawing primitives in renderer.hpp.
00010 * The Widkit plug-in provides a default implementation for a widget library.
00011 * When using Widkit, you should provide a simple window implementation,
00012 * as specified in window.hpp.
00013 *******************************************************************************
00014 * This software falls under the GNU general public license version 3 or later.
00015 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00016 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00017 ******************************************************************************/
00018 
00019 #ifndef GUI_H
00020 #define GUI_H
00021 #include "tree.hpp"
00022 #include "bitmap_font.hpp"
00023 #include "timer.hpp"
00024 
00025 struct font;
00026 class widget;
00027 typedef unsigned int color;
00028 
00029 /******************************************************************************
00030 * Main routines
00031 ******************************************************************************/
00032 
00033 void gui_open (int& argc, char** argv);
00034   // start the gui
00035 void gui_interpose (void (*) (void));
00036   // specify an interpose routine for the main loop
00037 void gui_start_loop ();
00038   // start the main loop
00039 void gui_close ();
00040   // cleanly close the gui
00041 void gui_root_extents (SI& width, SI& height);
00042   // get the screen size
00043 void gui_maximal_extents (SI& width, SI& height);
00044   // get the maximal size of a window (can be larger than the screen size)
00045 void gui_refresh ();
00046   // update and redraw all windows (e.g. on change of output language)
00047 
00048 /******************************************************************************
00049 * Colors
00050 ******************************************************************************/
00051 
00052 extern color black, white, red, green, blue;
00053 extern color yellow, magenta, orange, brown, pink;
00054 extern color light_grey, grey, dark_grey;
00055 
00056 color  rgb_color (int r, int g, int b, int a= 255);
00057   // get a color by its RGB and alpha components
00058   // ranging from 0 to 255 included
00059 void   get_rgb_color (color col, int& r, int& g, int& b, int& a);
00060   // get the RGB components of a color
00061 color  named_color (string s, int a= 255);
00062   // get a color by its name
00063 string get_named_color (color c);
00064   // get a standard name for the color if it exists
00065 
00066 /******************************************************************************
00067 * Font support
00068 ******************************************************************************/
00069 
00070 void set_default_font (string name);
00071   // set the name of the default font
00072 font get_default_font (bool tt= false, bool mini= false, bool bold= false);
00073   // get the default font, depending on desired characteristics:
00074   // tt for a monospaced font, mini for a smaller font and bold for a bold font
00075 font get_default_styled_font (int style);
00076   // get the default font for a given style
00077   // (see widget.hpp for available styles)
00078   // NOTE: implemented in widget.cpp
00079 void load_system_font (string family, int size, int dpi,
00080                      font_metric& fnm, font_glyphs& fng);
00081   // load the metric and glyphs of a system font
00082   // you are not obliged to provide any system fonts
00083 
00084 /******************************************************************************
00085 * Clipboard support
00086 ******************************************************************************/
00087 
00088 bool set_selection (string cb, tree t, string s, string format);
00089   // Copy a selection 't' of a given 'format' to the clipboard 'cb',
00090   // where 's' contains the string serialization of t according to the format
00091   // Returns true on success
00092 bool get_selection (string cb, tree& t, string& s, string format);
00093   // Retrieve the selection 't' of a given 'format' from the clipboard 'cb',
00094   // where 's' is the string serialization of t according to the format
00095   // Returns true on success; sets t to (extern s) for external selections
00096 void clear_selection (string cb);
00097   // Clear the selection on clipboard 'cb'
00098 
00099 /******************************************************************************
00100 * Miscellaneous
00101 ******************************************************************************/
00102 
00103 #define INTERRUPT_EVENT   0
00104 #define INTERRUPTED_EVENT 1
00105 #define ANY_EVENT         2
00106 #define DRAG_EVENT        3
00107 #define MOTION_EVENT      4
00108 #define MENU_EVENT        5
00109 
00110 void beep ();
00111   // Issue a beep
00112 void needs_update ();
00113   // Inform the gui that the editor needs to update itself
00114   // before repainting can start
00115 bool check_event (int type);
00116   // Check whether an event of one of the above types has occurred;
00117   // we check for keyboard events while repainting windows
00118 void image_gc (string name= "*");
00119   // Garbage collect images of a given name (may use wildcards)
00120   // This routine only needs to be implemented if you use your own image cache
00121 void show_help_balloon (widget balloon, SI x, SI y);
00122   // Display a help balloon at position (x, y); the help balloon should
00123   // disappear as soon as the user presses a key or moves the mouse
00124 void show_wait_indicator (widget base, string message, string argument);
00125   // Display a wait indicator with a message and an optional argument
00126   // The indicator might for instance be displayed at the center of
00127   // the base widget which triggered the lengthy operation;
00128   // the indicator should be removed if the message is empty
00129 void external_event (string type, time_t t);
00130   // External events, such as pushing a button of a remote infrared commander
00131 
00132 #endif // defined GUI_H