fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Help_View.H
Go to the documentation of this file.
1 //
2 // "$Id$"
3 //
4 // Help Viewer widget definitions.
5 //
6 // Copyright 1997-2010 by Easy Software Products.
7 // Image support by Matthias Melcher, Copyright 2000-2009.
8 //
9 // This library is free software. Distribution and use rights are outlined in
10 // the file "COPYING" which should have been included with this file. If this
11 // file is missing or damaged, see the license at:
12 //
13 // http://www.fltk.org/COPYING.php
14 //
15 // Please report all bugs and problems on the following page:
16 //
17 // http://www.fltk.org/str.php
18 //
19 
20 /* \file
21  Fl_Help_View widget . */
22 
23 #ifndef Fl_Help_View_H
24 # define Fl_Help_View_H
25 
26 //
27 // Include necessary header files...
28 //
29 
30 # include <stdio.h>
31 # include "Fl.H"
32 # include "Fl_Group.H"
33 # include "Fl_Scrollbar.H"
34 # include "fl_draw.H"
35 # include "Fl_Shared_Image.H"
36 # include "filename.H"
37 
38 
39 //
40 // Fl_Help_Func type - link callback function for files...
41 //
42 
43 
44 typedef const char *(Fl_Help_Func)(Fl_Widget *, const char *);
45 
46 
47 //
48 // Fl_Help_Block structure...
49 //
50 
51 struct Fl_Help_Block {
52  const char *start, // Start of text
53  *end; // End of text
54  uchar border; // Draw border?
55  Fl_Color bgcolor; // Background color
56  int x, // Indentation/starting X coordinate
57  y, // Starting Y coordinate
58  w, // Width
59  h; // Height
60  int line[32]; // Left starting position for each line
61 };
62 
63 //
64 // Fl_Help_Link structure...
65 //
67 struct Fl_Help_Link {
68  char filename[192],
69  name[32];
70  int x,
71  y,
72  w,
73  h;
74 };
75 
76 /*
77  * Fl_Help_View font stack opaque implementation
78  */
79 
85  void get(Fl_Font &afont, Fl_Fontsize &asize, Fl_Color &acolor) {afont=f; asize=s; acolor=c;}
86  void set(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor) {f=afont; s=asize; c=acolor;}
87  Fl_Help_Font_Style(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor) {set(afont, asize, acolor);}
88  Fl_Help_Font_Style(){} // For in table use
89 };
90 
92 const size_t MAX_FL_HELP_FS_ELTS = 100;
93 
97  nfonts_ = 0;
98  }
99 
101  nfonts_ = 0;
102  elts_[nfonts_].set(f, s, c);
103  fl_font(f, s);
104  fl_color(c);
105  }
107  void top(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { elts_[nfonts_].get(f, s, c); }
110  if (nfonts_ < MAX_FL_HELP_FS_ELTS-1) nfonts_ ++;
111  elts_[nfonts_].set(f, s, c);
112  fl_font(f, s); fl_color(c);
113  }
115  void pop(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) {
116  if (nfonts_ > 0) nfonts_ --;
117  top(f, s, c);
118  fl_font(f, s); fl_color(c);
119  }
121  size_t count() const {return nfonts_;} // Gets the current number of fonts in the stack
122 
123 protected:
124  size_t nfonts_;
125  Fl_Help_Font_Style elts_[100];
126 };
127 
131  char name[32];
132  int y;
133 };
134 
200 class FL_EXPORT Fl_Help_View : public Fl_Group { // Help viewer widget
201 
202  enum { RIGHT = -1, CENTER, LEFT };
203 
204  char title_[1024];
205  Fl_Color defcolor_,
206  bgcolor_,
207  textcolor_,
208  linkcolor_;
211  const char *value_;
213  int nblocks_,
214  ablocks_;
216 
218 
219  int nlinks_,
220  alinks_;
222 
223  int ntargets_,
224  atargets_;
226 
227  char directory_[FL_PATH_MAX];
228  char filename_[FL_PATH_MAX];
229  int topline_,
230  leftline_,
231  size_,
232  hsize_,
233  scrollbar_size_;
235  hscrollbar_;
236 
237  static int selection_first;
238  static int selection_last;
243  static int selected;
244  static int draw_mode;
245  static int mouse_x;
246  static int mouse_y;
247  static int current_pos;
251 
252 
253  void initfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { f = textfont_; s = textsize_; c = textcolor_; fstack_.init(f, s, c); }
254  void pushfont(Fl_Font f, Fl_Fontsize s) {fstack_.push(f, s, textcolor_);}
255  void pushfont(Fl_Font f, Fl_Fontsize s, Fl_Color c) {fstack_.push(f, s, c);}
256  void popfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) {fstack_.pop(f, s, c);}
257 
258  Fl_Help_Block *add_block(const char *s, int xx, int yy, int ww, int hh, uchar border = 0);
259  void add_link(const char *n, int xx, int yy, int ww, int hh);
260  void add_target(const char *n, int yy);
261  static int compare_targets(const Fl_Help_Target *t0, const Fl_Help_Target *t1);
262  int do_align(Fl_Help_Block *block, int line, int xx, int a, int &l);
263 #if FLTK_ABI_VERSION >= 10303
264 protected:
265 #endif
266  void draw();
267 #if FLTK_ABI_VERSION >= 10303
268 private:
269 #endif
270  void format();
271  void format_table(int *table_width, int *columns, const char *table);
272  void free_data();
273  int get_align(const char *p, int a);
274  const char *get_attr(const char *p, const char *n, char *buf, int bufsize);
275  Fl_Color get_color(const char *n, Fl_Color c);
276  Fl_Shared_Image *get_image(const char *name, int W, int H);
277  int get_length(const char *l);
278 #if FLTK_ABI_VERSION >= 10303
279 public:
280 #endif
281  int handle(int);
282 #if FLTK_ABI_VERSION >= 10303
283 private:
284 #endif
285 
286  void hv_draw(const char *t, int x, int y, int entity_extra_length = 0);
287  char begin_selection();
288  char extend_selection();
289  void end_selection(int c=0);
290  void clear_global_selection();
291  Fl_Help_Link *find_link(int, int);
292  void follow_link(Fl_Help_Link*);
293 
294 public:
295 
296  Fl_Help_View(int xx, int yy, int ww, int hh, const char *l = 0);
297  ~Fl_Help_View();
299  const char *directory() const { if (directory_[0]) return (directory_);
300  else return ((const char *)0); }
302  const char *filename() const { if (filename_[0]) return (filename_);
303  else return ((const char *)0); }
304  int find(const char *s, int p = 0);
327  void link(Fl_Help_Func *fn) { link_ = fn; }
328  int load(const char *f);
329  void resize(int,int,int,int);
331  int size() const { return (size_); }
332  void size(int W, int H) { Fl_Widget::size(W, H); }
334  void textcolor(Fl_Color c) { if (textcolor_ == defcolor_) textcolor_ = c; defcolor_ = c; }
336  Fl_Color textcolor() const { return (defcolor_); }
338  void textfont(Fl_Font f) { textfont_ = f; format(); }
340  Fl_Font textfont() const { return (textfont_); }
342  void textsize(Fl_Fontsize s) { textsize_ = s; format(); }
344  Fl_Fontsize textsize() const { return (textsize_); }
346  const char *title() { return (title_); }
347  void topline(const char *n);
348  void topline(int);
350  int topline() const { return (topline_); }
351  void leftline(int);
353  int leftline() const { return (leftline_); }
354  void value(const char *val);
356  const char *value() const { return (value_); }
357  void clear_selection();
358  void select_all();
368  int scrollbar_size() const {
369  return(scrollbar_size_);
370  }
390  void scrollbar_size(int newSize) {
391  scrollbar_size_ = newSize;
392  }
393 };
394 
395 #endif // !Fl_Help_View_H
396 
397 //
398 // End of "$Id$".
399 //
Fl_Help_View::initfont
void initfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c)
Definition: Fl_Help_View.H:253
fl_font
void fl_font(Fl_Font face, Fl_Fontsize fsize)
Definition: fl_draw.H:509
Fl_Help_Font_Style
Definition: Fl_Help_View.H:81
Fl_Help_View::directory
const char * directory() const
Definition: Fl_Help_View.H:299
Fl.H
Fl_Help_View::selected
static int selected
Definition: Fl_Help_View.H:243
buf
static char * buf
Definition: fl_encoding_mac_roman.cxx:76
Fl_Help_Font_Style::s
Fl_Fontsize s
Font Size.
Definition: Fl_Help_View.H:83
Fl_Scrollbar
Definition: Fl_Scrollbar.H:43
Fl_Help_View::link_
Fl_Help_Func * link_
Link transform function.
Definition: Fl_Help_View.H:217
Fl_Help_Func
const typedef char *() Fl_Help_Func(Fl_Widget *, const char *)
Fl_Group::find
int find(const Fl_Widget *) const
Definition: Fl_Group.cxx:52
Fl_Color
unsigned int Fl_Color
Definition: Enumerations.H:934
Fl_Help_Block::w
int w
Definition: Fl_Help_View.H:56
Fl_Help_Font_Style::f
Fl_Font f
Font.
Definition: Fl_Help_View.H:82
Fl_Help_View::hv_selection_color
static Fl_Color hv_selection_color
Definition: Fl_Help_View.H:249
Fl_Help_View::textcolor_
Fl_Color textcolor_
Text color.
Definition: Fl_Help_View.H:205
Fl_Help_View::textsize
Fl_Fontsize textsize() const
Definition: Fl_Help_View.H:344
Fl_Help_View::scrollbar_size
void scrollbar_size(int newSize)
Definition: Fl_Help_View.H:390
fl_color
void fl_color(Fl_Color c)
Definition: fl_draw.H:52
Fl_Help_Font_Stack::init
void init(Fl_Font f, Fl_Fontsize s, Fl_Color c)
Definition: Fl_Help_View.H:100
Fl_Help_View::current_view
static Fl_Help_View * current_view
Definition: Fl_Help_View.H:248
Fl_Help_View::current_pos
static int current_pos
Definition: Fl_Help_View.H:247
filename.H
Fl_Group::draw
void draw()
Definition: Fl_Group.cxx:738
Fl_Scrollbar.H
H
static int H
Definition: Fl_Tooltip.cxx:76
Fl_Help_Font_Stack::count
size_t count() const
Definition: Fl_Help_View.H:121
Fl_Help_View::pushfont
void pushfont(Fl_Font f, Fl_Fontsize s, Fl_Color c)
Definition: Fl_Help_View.H:255
Fl_Help_Block::border
uchar border
Definition: Fl_Help_View.H:54
FL_EXPORT
#define FL_EXPORT
Definition: Fl_Export.H:35
Fl_Help_Block::y
int y
Definition: Fl_Help_View.H:56
LEFT
Definition: Fl_Tabs.cxx:331
Fl_Help_Block::start
const char * start
Definition: Fl_Help_View.H:52
Fl_Help_Block::bgcolor
Fl_Color bgcolor
Definition: Fl_Help_View.H:55
Fl_Help_Target
Definition: Fl_Help_View.H:130
Fl_Help_Font_Style::Fl_Help_Font_Style
Fl_Help_Font_Style()
Definition: Fl_Help_View.H:88
Fl_Help_View::textcolor
void textcolor(Fl_Color c)
Definition: Fl_Help_View.H:334
Fl_Help_Block::end
const char * end
Definition: Fl_Help_View.H:52
Fl_Help_View::nlinks_
int nlinks_
Number of links.
Definition: Fl_Help_View.H:219
Fl_Help_View::textcolor
Fl_Color textcolor() const
Definition: Fl_Help_View.H:336
p
static menustate * p
Definition: Fl_Menu.cxx:606
Fl_Help_View::filename
const char * filename() const
Definition: Fl_Help_View.H:302
FL_PATH_MAX
#define FL_PATH_MAX
Definition: filename.H:38
Fl_Help_View::selection_push_first
static int selection_push_first
Definition: Fl_Help_View.H:239
Fl_Help_Font_Stack::Fl_Help_Font_Stack
Fl_Help_Font_Stack()
Definition: Fl_Help_View.H:96
fl_draw.H
utility header to pull drawing functions together
Fl_Help_Target::name
char name[32]
Target name.
Definition: Fl_Help_View.H:131
Fl_Help_Font_Stack::push
void push(Fl_Font f, Fl_Fontsize s, Fl_Color c)
Definition: Fl_Help_View.H:109
Fl_Help_View::mouse_x
static int mouse_x
Definition: Fl_Help_View.H:245
Fl_Help_Block::h
int h
Definition: Fl_Help_View.H:56
Fl_Help_View::size
int size() const
Definition: Fl_Help_View.H:331
Fl_Help_View::hv_selection_text_color
static Fl_Color hv_selection_text_color
Definition: Fl_Help_View.H:250
Fl_Help_View::selection_push_last
static int selection_push_last
Definition: Fl_Help_View.H:240
Fl_Fontsize
int Fl_Fontsize
Definition: Enumerations.H:906
Fl_Help_View::scrollbar_size
int scrollbar_size() const
Definition: Fl_Help_View.H:368
table
static symbol table[]
Definition: factory.cxx:1109
Fl_Help_Font_Style::c
Fl_Color c
Font Color.
Definition: Fl_Help_View.H:84
Fl_Help_Font_Stack::nfonts_
size_t nfonts_
current number of fonts in stack
Definition: Fl_Help_View.H:124
Fl_Help_View::topline
int topline() const
Definition: Fl_Help_View.H:350
Fl_Help_View::link
void link(Fl_Help_Func *fn)
Definition: Fl_Help_View.H:327
Fl_Widget
Definition: Fl_Widget.H:101
Fl_Group
Definition: Fl_Group.H:41
Fl_Help_Font_Style::Fl_Help_Font_Style
Fl_Help_Font_Style(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor)
Definition: Fl_Help_View.H:87
Fl_Group::resize
void resize(int, int, int, int)
Definition: Fl_Group.cxx:634
Fl_Shared_Image.H
Fl_Help_View::targets_
Fl_Help_Target * targets_
Targets.
Definition: Fl_Help_View.H:225
Fl_Help_Target::y
int y
Y offset of target.
Definition: Fl_Help_View.H:132
Fl_Help_View::title
const char * title()
Definition: Fl_Help_View.H:346
Fl_Help_View::blocks_
Fl_Help_Block * blocks_
Blocks.
Definition: Fl_Help_View.H:215
Fl_Help_View::selection_drag_first
static int selection_drag_first
Definition: Fl_Help_View.H:241
Fl_Help_View::fstack_
Fl_Help_Font_Stack fstack_
font stack management
Definition: Fl_Help_View.H:212
Fl_Group::handle
int handle(int)
Definition: Fl_Group.cxx:147
Fl_Widget::size
void size(int W, int H)
Definition: Fl_Widget.H:341
x
int x
Definition: test.c:73
Fl_Help_View::textsize
void textsize(Fl_Fontsize s)
Definition: Fl_Help_View.H:342
Fl_Help_View::textfont
void textfont(Fl_Font f)
Definition: Fl_Help_View.H:338
Fl_Font
int Fl_Font
Definition: Enumerations.H:877
Fl_Help_View::scrollbar_
Fl_Scrollbar scrollbar_
Vertical scrollbar for document.
Definition: Fl_Help_View.H:234
Fl_Help_Block::line
int line[32]
Definition: Fl_Help_View.H:60
Fl_Help_Block
Definition: Fl_Help_View.H:51
Fl_Group.H
Fl_Help_Font_Stack
Definition: Fl_Help_View.H:94
Fl_Help_View::textfont
Fl_Font textfont() const
Definition: Fl_Help_View.H:340
y
int y
Definition: test.c:74
set
int set
Definition: fl_boxtype.cxx:287
Fl_Help_View
Definition: Fl_Help_View.H:200
Fl_Help_View::size
void size(int W, int H)
Definition: Fl_Help_View.H:332
Fl_Help_View::ntargets_
int ntargets_
Number of targets.
Definition: Fl_Help_View.H:223
f
Fl_Box_Draw_F * f
Definition: fl_boxtype.cxx:285
Fl_Help_View::topline_
int topline_
Top line in document.
Definition: Fl_Help_View.H:229
Fl_Help_View::nblocks_
int nblocks_
Number of blocks/paragraphs.
Definition: Fl_Help_View.H:213
Fl_Help_Font_Stack::top
void top(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c)
Definition: Fl_Help_View.H:107
Fl_Help_View::selection_drag_last
static int selection_drag_last
Definition: Fl_Help_View.H:242
Fl_Help_Font_Stack::pop
void pop(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c)
Definition: Fl_Help_View.H:115
Fl_Help_View::value
const char * value() const
Definition: Fl_Help_View.H:356
Fl_Help_View::textfont_
Fl_Font textfont_
Default font for text.
Definition: Fl_Help_View.H:209
MAX_FL_HELP_FS_ELTS
const size_t MAX_FL_HELP_FS_ELTS
Definition: Fl_Help_View.H:92
Fl_Help_Font_Style::set
void set(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor)
Sets current font attributes.
Definition: Fl_Help_View.H:86
Fl_Help_View::value_
const char * value_
HTML text value.
Definition: Fl_Help_View.H:211
Fl_Help_View::draw_mode
static int draw_mode
Definition: Fl_Help_View.H:244
Fl_Help_View::pushfont
void pushfont(Fl_Font f, Fl_Fontsize s)
Definition: Fl_Help_View.H:254
Fl_Help_View::selection_last
static int selection_last
Definition: Fl_Help_View.H:238
uchar
unsigned char uchar
Definition: fl_types.h:30
Fl_Help_Block::x
int x
Definition: Fl_Help_View.H:56
Fl_Help_View::mouse_y
static int mouse_y
Definition: Fl_Help_View.H:246
name
static const char * name
Definition: Fl_arg.cxx:53
Fl_Help_View::selection_first
static int selection_first
Definition: Fl_Help_View.H:237
Fl_Help_View::textsize_
Fl_Fontsize textsize_
Default font size.
Definition: Fl_Help_View.H:210
Fl_Shared_Image
Definition: Fl_Shared_Image.H:50
Fl_Help_View::leftline
int leftline() const
Definition: Fl_Help_View.H:353
Fl_Help_Font_Style::get
void get(Fl_Font &afont, Fl_Fontsize &asize, Fl_Color &acolor)
Gets current font attributes.
Definition: Fl_Help_View.H:85
RIGHT
Definition: Fl_Tabs.cxx:331
Fl_Help_View::links_
Fl_Help_Link * links_
Links.
Definition: Fl_Help_View.H:221
Fl_Help_View::popfont
void popfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c)
Definition: Fl_Help_View.H:256