ubit
uconf.hpp
1 /************************************************************************
2  *
3  * uconf.hpp : configuration of the UAppli
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uconf_hpp_
18 #define _uconf_hpp_ 1
19 #include <ubit/udefs.hpp>
20 #include <ubit/ustr.hpp>
21 #include <ubit/ufont.hpp>
22 namespace ubit {
23 
24 
51 class UOption {
52 public:
53  const char *begname, *endname;
54  class UOptionArg* arg;
55 
56  static class UOptionArg* Arg(bool& val);
57  static class UOptionArg* Arg(int& val);
58  static class UOptionArg* Arg(float& val);
59  static class UOptionArg* Arg(UStr& val);
60  static class UOptionArg* Arg(char*& val);
61  static class UOptionArg* Arg(const char*& val);
62  static void parseOptions(int& argc, char** argv, UOption* options);
63 };
64 
65 /* ==================================================== ======== ======= */
68 class UConf {
69 public:
70  UConf();
71  virtual ~UConf();
72 
73  void useGL(bool = true);
80  void useFreeType(bool = true);
86  void setDepthBuffer(int size);
92  void setStencilBuffer(int size);
97  void setBpp(int bpp);
103  void setLocale(const UStr& s);
105 
106  void setScale(float v);
108 
109  void setVerbose(int v);
111 
112  void setDefaultBackground(const UBackground&);
114 
115  void setTransparentScrollbars(bool);
116 
117  virtual void printHelp();
119 
120  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121 
122  bool isUsingGL() const {return is_using_gl;}
123  bool isUsingFreeType() const {return is_using_freetype;}
124  bool isVerbose() const {return verbosity != 0;}
125  int getVerbosity() const {return verbosity;}
126 
127  const UStr& getLocale() const {return locale;}
129 
130  float getScale() const {return scale;}
132 
133  int getMouseSelectButton() const {return mouse_select_button;}
135 
136  int getMouseMenuButton() const {return mouse_menu_button;}
138 
139  int getMouseAltButton() const {return mouse_alt_button;}
144  // - - - misc options - - - - - - - - - - - - - - - - - - - - - - - - - - - -
145 
146  bool
147  xsync, usync,
149 
150  menu_grab,
152 
153  postpone_delete,
155 
156  soft_dbf,
158 
159  soft_wins, soft_menus,
161 
162  transp_scrollbars,
164 
165  tele_pointers,
167 
168  generic_textsel;
170 
171  int click_radius; // (pas unsigned, les dist ne le sont jamais)
173 
174  unsigned long multi_click_delay;
176 
177  unsigned long auto_repeat_delay;
179 
180  unsigned long open_tip_delay;
182 
183  unsigned long open_submenu_delay;
185 
186  // - - - option parsing - - - - - - - - - - - - - - - - - - - - - - - - - - -
187 
188  virtual void parseOptions(int& argc, char** argv, UOption* options);
197  virtual void readAttributes(const char* pathname);
222  UAttrList* getAttributes(const char* category);
224 
225  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
226 private:
227  friend class UDisp;
228  friend class UAppli;
229  friend class UAppliImpl;
230  friend class UUpdateContext;
231  friend class UEventFlow;
232  friend class UElem;
233  friend class UBox;
234  friend class UWin;
235  friend class UEdit;
236  friend class UIma;
237  friend class UPix;
238  friend class UGraph;
239  friend class UFont;
240  friend class UFontDesc;
241  friend class UHardFont;
242  friend class UFilebox;
243  friend class UGlcanvas;
244  friend class U3Dcanvas;
245  virtual void parseUbitOptions(int& argc, char** argv);
246 
247 protected:
248  bool freeze_options;
249  const char* const windowing_toolkit;
250  bool is_using_gl, is_using_freetype;
251  int bpp;
252  int depth_size, stencil_size;
253  int verbosity; // verbose mode.
254  float scale; // scaling factor for rendering the application [default = 1,0].
255  int filebox_width, filebox_height, filebox_line_count; // 400, 230, 10. !!!@@@ A VIRER !!!
256  const int& mouse_select_button;
257  const int& mouse_menu_button;
258  const int& mouse_alt_button;
259  UStr locale; // locale of the application [default = "" : the environment locale]
260  UStr display; // name of the X11 display [default = "": the local X server is used)
261  UFont* default_font; // the default font of the application [default = UFont::sans_serif].
262  UPix* unknow_image; // the image that appears instead of an unknown image (when applicable].
263  UFont* selection_font; // font of the text selection (can be null)
264  UColor* selection_color; // text color of the text selection (can be null)
265  UColor* selection_bgcolor; // background color of the text selection (can be null)
266  UBackground& default_background; // the default background of the application.
267 };
268 
269 }
270 #endif
specification and retreiving of non standard options on the command line.
Definition: uconf.hpp:51
[Instable/OpenGL] 3D canvas: makes it possible to display children in 3D space.
Definition: u3d.hpp:31
[Impl] Native Font.
Definition: uhardfont.hpp:35
Image.
Definition: uima.hpp:50
Box container.
Definition: ubox.hpp:64
unsigned long auto_repeat_delay
delay (in ms) before autoRepeat becomes active (see UElem::setAutoRepeat()).
Definition: uconf.hpp:177
unsigned long open_tip_delay
delay (in ms) before a UTip is opened.
Definition: uconf.hpp:180
unsigned long multi_click_delay
< UOn::mclick is not generated if the mouse if moved more than this distance.
Definition: uconf.hpp:174
Definition: uappliImpl.hpp:40
const UStr & getLocale() const
current locale.
Definition: uconf.hpp:127
class for drawing on widgets.
Definition: ugraph.hpp:44
Widget background.
Definition: ubackground.hpp:30
Display Context.
Definition: udisp.hpp:44
[impl] Internal representation for fonts.
Definition: ufontImpl.hpp:24
Text editing and caret controller.
Definition: uedit.hpp:30
Color attribute of an element or a widget.
Definition: ucolor.hpp:73
Attribute list.
Definition: uattr.hpp:167
The Application Context.
Definition: uappli.hpp:79
int getMouseAltButton() const
No of the alternate button [default = middle btn or Alt-btn on the Mac].
Definition: uconf.hpp:139
lightweight general purpose container.
Definition: uelem.hpp:44
int getMouseMenuButton() const
No of the button that opens contextual menus [default = right btn or Ctrl-btn on the Mac]...
Definition: uconf.hpp:136
Definition: uconf.cpp:471
float getScale() const
global scale of the application.
Definition: uconf.hpp:130
Event Flow.
Definition: ueventflow.hpp:34
Font of a UElem or UBox container.
Definition: ufont.hpp:30
configuration of the UAppli.
Definition: uconf.hpp:68
Definition: uupdatecontext.hpp:32
Definition: uhardfont.hpp:31
Definition: ufilebox.hpp:49
Base class for windows and menus.
Definition: uwin.hpp:47
Pixmap Image.
Definition: upix.hpp:31
unsigned long open_submenu_delay
delay (in ms) before a cascaded UMenu is opened.
Definition: uconf.hpp:183
bool usync
enables synchronous graphics rendering for X11 and Ubit [default: false].
Definition: uconf.hpp:147
Ubit String.
Definition: ustr.hpp:72
int getMouseSelectButton() const
No of the standard button [default = left btn].
Definition: uconf.hpp:133