source: NonGTP/FLTK/include/fltk/Style.h @ 773

Revision 773, 7.6 KB checked in by gumbau, 19 years ago (diff)

FLTK imported to SVN repository to be linked agains the GeoTool? application

Line 
1//
2// "$Id: Style.h 4303 2005-05-01 03:33:52Z spitzak $"
3//
4// Style structure used by Widgets
5//
6// Copyright 1998-2003 by Bill Spitzak and others.
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Library General Public
10// License as published by the Free Software Foundation; either
11// version 2 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16// Library General Public License for more details.
17//
18// You should have received a copy of the GNU Library General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21// USA.
22//
23// Please report all bugs and problems to "fltk-bugs@fltk.org".
24//
25
26#ifndef fltk_Style_h
27#define fltk_Style_h
28
29#include "Color.h"
30
31namespace fltk {
32
33class FL_API Widget;
34class FL_API Rectangle;
35class FL_API Symbol;
36typedef Symbol Box;
37
38extern FL_API Box* const UP_BOX;
39extern FL_API Box* const DOWN_BOX;
40extern FL_API Box* const THIN_UP_BOX;
41extern FL_API Box* const THIN_DOWN_BOX;
42extern FL_API Box* const ENGRAVED_BOX;
43extern FL_API Box* const EMBOSSED_BOX;
44extern FL_API Box* const BORDER_BOX;
45extern FL_API Box* const FLAT_BOX;
46extern FL_API Box* const HIGHLIGHT_UP_BOX;
47extern FL_API Box* const HIGHLIGHT_DOWN_BOX;
48extern FL_API Box* const ROUND_UP_BOX;
49extern FL_API Box* const ROUND_DOWN_BOX;
50extern FL_API Box* const DIAMOND_UP_BOX;
51extern FL_API Box* const DIAMOND_DOWN_BOX;
52extern FL_API Box* const NO_BOX;
53extern FL_API Box* const SHADOW_BOX;
54extern FL_API Box* const ROUNDED_BOX;
55extern FL_API Box* const RSHADOW_BOX;
56extern FL_API Box* const RFLAT_BOX;
57extern FL_API Box* const OVAL_BOX;
58extern FL_API Box* const OSHADOW_BOX;
59extern FL_API Box* const OFLAT_BOX;
60extern FL_API Box* const BORDER_FRAME;
61extern FL_API Box* const DOTTED_FRAME;
62extern FL_API Box* const PLASTIC_UP_BOX;
63extern FL_API Box* const PLASTIC_DOWN_BOX;
64
65struct Font;
66FL_API Font* font(const char* name, int attrib = 0);
67enum {  // values for attributes:
68  BOLD = 1,
69  ITALIC = 2,
70  BOLD_ITALIC = 3
71};
72extern FL_API Font* const HELVETICA;
73extern FL_API Font* const HELVETICA_BOLD;
74extern FL_API Font* const HELVETICA_ITALIC;
75extern FL_API Font* const HELVETICA_BOLD_ITALIC;
76extern FL_API Font* const COURIER;
77extern FL_API Font* const COURIER_BOLD;
78extern FL_API Font* const COURIER_ITALIC;
79extern FL_API Font* const COURIER_BOLD_ITALIC;
80extern FL_API Font* const TIMES;
81extern FL_API Font* const TIMES_BOLD;
82extern FL_API Font* const TIMES_ITALIC;
83extern FL_API Font* const TIMES_BOLD_ITALIC;
84extern FL_API Font* const SYMBOL_FONT;
85extern FL_API Font* const SCREEN_FONT;
86extern FL_API Font* const SCREEN_BOLD_FONT;
87extern FL_API Font* const ZAPF_DINGBATS;
88FL_API Font* font(int);
89
90class LabelType;
91extern FL_API LabelType* const NO_LABEL;
92extern FL_API LabelType* const NORMAL_LABEL;
93extern FL_API LabelType* const SYMBOL_LABEL; // same as NORMAL_LABEL
94extern FL_API LabelType* const SHADOW_LABEL;
95extern FL_API LabelType* const ENGRAVED_LABEL;
96extern FL_API LabelType* const EMBOSSED_LABEL;
97
98class Style;
99
100/*! \addtogroup glyphs
101  \{ */
102typedef void (*GlyphStyle)(int number, const Rectangle&);
103/*! Numbers understood by fltk::Widget::default_glyph(). All other numbers
104  draw the same as GLYPH_BOX. The numbers
105  0-99 are reserved for per-Widget glyphs, for instance for parts
106  of the fltk::Slider or for the checkmark drawn by fltk::CheckButton.
107*/
108enum GlyphNumber {
109  GLYPH_BOX = 100,      //!< Draw an empty buttonbox
110  GLYPH_UP,             //!< draw an up arrow
111  GLYPH_DOWN,           //!< draw a down arrow
112  GLYPH_LEFT,           //!< draw a left arrow
113  GLYPH_RIGHT,          //!< draw a right arrow
114  GLYPH_UP_BUTTON,      //!< draw an up arrow in a buttonbox
115  GLYPH_DOWN_BUTTON,    //!< draw a down arrow in a buttonbox
116  GLYPH_LEFT_BUTTON,    //!< draw a left arrow in a buttonbox
117  GLYPH_RIGHT_BUTTON    //!< draw a right arrow in a buttonbox
118};
119/*! \} */
120
121class FL_API Style {
122 public:
123  // Everything is public for various back-compatability hacks:
124  const Style* parent_;
125  Box*          box_;
126  Box*          buttonbox_;
127  Box*          focusbox_;
128  GlyphStyle    glyph_;
129  Font*         labelfont_;
130  Font*         textfont_;
131  LabelType*    labeltype_;
132  Color         color_;
133  Color         textcolor_;
134  Color         selection_color_;
135  Color         selection_textcolor_;
136  Color         buttoncolor_;
137  Color         labelcolor_;
138  Color         highlight_color_;
139  Color         highlight_textcolor_;
140  float         labelsize_;
141  float         textsize_;
142  float         leading_;
143  unsigned char scrollbar_align_;
144  unsigned char scrollbar_width_;
145  bool          dynamic_;
146  // global settings:
147  static bool   hide_underscore_;
148  static bool   draw_boxes_inactive_;
149  static int    wheel_scroll_lines_;
150
151  // Get functions, which search parents if value is zero:
152  Box*          box()           const;
153  Box*          buttonbox()     const;
154  Box*          focusbox()      const;
155  GlyphStyle    glyph()         const;
156  Font*         labelfont()     const;
157  Font*         textfont()      const;
158  LabelType*    labeltype()     const;
159  Color         color()         const;
160  Color         textcolor()     const;
161  Color         selection_color() const;
162  Color         selection_textcolor() const;
163  Color         buttoncolor()   const;
164  Color         labelcolor()    const;
165  Color         highlight_color() const;
166  Color         highlight_textcolor() const;
167  float         labelsize()     const;
168  float         textsize()      const;
169  float         leading()       const;
170  unsigned char scrollbar_align() const;
171  unsigned char scrollbar_width() const;
172
173  bool          hide_underscore() const {return hide_underscore_;}
174  bool          draw_boxes_inactive() const {return draw_boxes_inactive_;}
175  int           wheel_scroll_lines() const {return wheel_scroll_lines_;}
176
177  // Set functions:
178  void box              (Box* v)        {box_ = v;              }
179  void buttonbox        (Box* v)        {buttonbox_ = v;        }
180  void focusbox         (Box* v)        {focusbox_ = v;         }
181  void glyph            (GlyphStyle v)  {glyph_ = v;            }
182  void labelfont        (Font* v)       {labelfont_ = v;        }
183  void textfont         (Font* v)       {textfont_ = v;         }
184  void labeltype        (LabelType* v)  {labeltype_ = v;        }
185  void color            (Color v)       {color_ = v;            }
186  void textcolor        (Color v)       {textcolor_ = v;        }
187  void selection_color  (Color v)       {selection_color_ = v;  }
188  void selection_textcolor(Color v)     {selection_textcolor_ = v;}
189  void buttoncolor      (Color v)       {buttoncolor_ = v;      }
190  void labelcolor       (Color v)       {labelcolor_ = v;       }
191  void highlight_color  (Color v)       {highlight_color_ = v;  }
192  void highlight_textcolor(Color v)     {highlight_textcolor_ = v;}
193  void labelsize        (float v)       {labelsize_ = v;        }
194  void textsize         (float v)       {textsize_ = v;         }
195  void leading          (float v)       {leading_ = v;          }
196  void scrollbar_align  (unsigned char v) {scrollbar_align_ = v;}       
197  void scrollbar_width  (unsigned char v) {scrollbar_width_ = v;}       
198
199  void hide_underscore  (bool v)        {hide_underscore_ = v;  }
200  void draw_boxes_inactive(bool v)      {draw_boxes_inactive_ = v;}
201  void wheel_scroll_lines(int v)        {wheel_scroll_lines_ = v;}
202
203  Style();
204  bool dynamic() const {return dynamic_;}
205
206  static Style* find(const char* name);
207};
208
209struct FL_API NamedStyle : public Style {
210  const char* name;
211  void  (*revertfunc)(Style*);
212  NamedStyle** back_pointer; // used by StyleSet
213  static NamedStyle* first;
214  NamedStyle* next;
215  NamedStyle(const char* name, void (*revert)(Style*), NamedStyle** backptr);
216};
217
218/*! \addtogroup themes
219  \{ */
220extern "C" {typedef bool (*Theme)();}
221extern FL_API Theme theme_;
222inline Theme theme() {return theme_;}
223inline void theme(Theme f) {theme_ = f;}
224FL_API void load_theme();
225FL_API void reload_theme();
226FL_API bool reset_theme();
227/*! \} */ // Doxygen bug(?) requires this
228
229}
230
231/*! \addtogroup themes
232  \{ */
233extern "C" FL_API bool fltk_theme();
234/*! \} */
235
236
237#endif
238
239//
240// End of "$Id: Style.h 4303 2005-05-01 03:33:52Z spitzak $".
241//
Note: See TracBrowser for help on using the repository browser.