2 // "$Id: Fl_Help_View.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $"
4 // Help Viewer widget definitions.
6 // Copyright 1997-2002 by Easy Software Products.
7 // Image support donated by Matthias Melcher, Copyright 2000.
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Library General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Library General Public License for more details.
19 // You should have received a copy of the GNU Library General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 // Please report all bugs and problems to "fltk-bugs@fltk.org".
27 #ifndef Fl_Help_View_H
28 # define Fl_Help_View_H
31 // Include necessary header files...
36 # include "Fl_Group.H"
37 # include "Fl_Scrollbar.H"
39 # include "Fl_Shared_Image.H"
43 // Fl_Help_Func type - link callback function for files...
47 typedef const char *(Fl_Help_Func)(Fl_Widget *, const char *);
51 // Fl_Help_Block structure...
56 const char *start, // Start of text
58 uchar border; // Draw border?
59 Fl_Color bgcolor; // Background color
60 int x, // Indentation/starting X coordinate
61 y, // Starting Y coordinate
64 int line[32]; // Left starting position for each line
68 // Fl_Help_Link structure...
73 char filename[192], // Reference filename
74 name[32]; // Link target (blank if none)
75 int x, // X offset of link text
76 y, // Y offset of link text
77 w, // Width of link text
78 h; // Height of link text
82 // Fl_Help_Target structure...
87 char name[32]; // Target name
88 int y; // Y offset of target
92 // Fl_Help_View class...
95 class FL_EXPORT Fl_Help_View : public Fl_Group //// Help viewer widget
97 enum { RIGHT = -1, CENTER, LEFT }; // Alignments
99 char title_[1024]; // Title string
100 Fl_Color defcolor_, // Default text color
101 bgcolor_, // Background color
102 textcolor_, // Text color
103 linkcolor_; // Link color
104 uchar textfont_, // Default font for text
105 textsize_; // Default font size
106 const char *value_; // HTML text value
108 int nblocks_, // Number of blocks/paragraphs
109 ablocks_; // Allocated blocks
110 Fl_Help_Block *blocks_; // Blocks
112 int nfonts_; // Number of fonts in stack
113 uchar fonts_[100][2]; // Font stack
115 Fl_Help_Func *link_; // Link transform function
117 int nlinks_, // Number of links
118 alinks_; // Allocated links
119 Fl_Help_Link *links_; // Links
121 int ntargets_, // Number of targets
122 atargets_; // Allocated targets
123 Fl_Help_Target *targets_; // Targets
125 char directory_[1024]; // Directory for current file
126 char filename_[1024]; // Current filename
127 int topline_, // Top line in document
128 leftline_, // Lefthand position
129 size_, // Total document length
130 hsize_; // Maximum document width
131 Fl_Scrollbar scrollbar_, // Vertical scrollbar for document
132 hscrollbar_; // Horizontal scrollbar
134 Fl_Help_Block *add_block(const char *s, int xx, int yy, int ww, int hh, uchar border = 0);
135 void add_link(const char *n, int xx, int yy, int ww, int hh);
136 void add_target(const char *n, int yy);
137 static int compare_targets(const Fl_Help_Target *t0, const Fl_Help_Target *t1);
138 int do_align(Fl_Help_Block *block, int line, int xx, int a, int &l);
141 void format_table(int *table_width, int *columns, const char *table);
142 int get_align(const char *p, int a);
143 const char *get_attr(const char *p, const char *n, char *buf, int bufsize);
144 Fl_Color get_color(const char *n, Fl_Color c);
145 Fl_Shared_Image *get_image(const char *name, int W, int H);
146 int get_length(const char *l);
149 void initfont(uchar &f, uchar &s) { nfonts_ = 0;
150 fl_font(f = fonts_[0][0] = textfont_,
151 s = fonts_[0][1] = textsize_); }
152 void pushfont(uchar f, uchar s) { if (nfonts_ < 99) nfonts_ ++;
153 fl_font(fonts_[nfonts_][0] = f,
154 fonts_[nfonts_][1] = s); }
155 void popfont(uchar &f, uchar &s) { if (nfonts_ > 0) nfonts_ --;
156 fl_font(f = fonts_[nfonts_][0],
157 s = fonts_[nfonts_][1]); }
161 Fl_Help_View(int xx, int yy, int ww, int hh, const char *l = 0);
163 const char *directory() const { if (directory_[0]) return (directory_);
164 else return ((const char *)0); }
165 const char *filename() const { if (filename_[0]) return (filename_);
166 else return ((const char *)0); }
167 void link(Fl_Help_Func *fn) { link_ = fn; }
168 int load(const char *f);
169 void resize(int,int,int,int);
170 int size() const { return (size_); }
171 void textcolor(Fl_Color c) { if (textcolor_ == defcolor_) textcolor_ = c; defcolor_ = c; }
172 Fl_Color textcolor() const { return (defcolor_); }
173 void textfont(uchar f) { textfont_ = f; format(); }
174 uchar textfont() const { return (textfont_); }
175 void textsize(uchar s) { textsize_ = s; format(); }
176 uchar textsize() const { return (textsize_); }
177 const char *title() { return (title_); }
178 void topline(const char *n);
180 int topline() const { return (topline_); }
182 int leftline() const { return (leftline_); }
183 void value(const char *v);
184 const char *value() const { return (value_); }
187 #endif // !Fl_Help_View_H
190 // End of "$Id: Fl_Help_View.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $".