00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef Fl_Help_View_H
00024 # define Fl_Help_View_H
00025
00026
00027
00028
00029
00030 # include <stdio.h>
00031 # include "Fl.H"
00032 # include "Fl_Group.H"
00033 # include "Fl_Scrollbar.H"
00034 # include "fl_draw.H"
00035 # include "Fl_Shared_Image.H"
00036 # include "filename.H"
00037
00038
00039
00040
00041
00042
00043
00044 typedef const char *(Fl_Help_Func)(Fl_Widget *, const char *);
00045
00046
00047
00048
00049
00050
00051 struct Fl_Help_Block {
00052 const char *start,
00053 *end;
00054 uchar border;
00055 Fl_Color bgcolor;
00056 int x,
00057 y,
00058 w,
00059 h;
00060 int line[32];
00061 };
00062
00063
00064
00065
00067 struct Fl_Help_Link {
00068 char filename[192],
00069 name[32];
00070 int x,
00071 y,
00072 w,
00073 h;
00074 };
00075
00076
00077
00078
00079
00081 struct FL_EXPORT Fl_Help_Font_Style {
00082 Fl_Font f;
00083 Fl_Fontsize s;
00084 Fl_Color c;
00085 void get(Fl_Font &afont, Fl_Fontsize &asize, Fl_Color &acolor) {afont=f; asize=s; acolor=c;}
00086 void set(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor) {f=afont; s=asize; c=acolor;}
00087 Fl_Help_Font_Style(Fl_Font afont, Fl_Fontsize asize, Fl_Color acolor) {set(afont, asize, acolor);}
00088 Fl_Help_Font_Style(){}
00089 };
00090
00092 const size_t MAX_FL_HELP_FS_ELTS = 100;
00093
00094 struct FL_EXPORT Fl_Help_Font_Stack {
00096 Fl_Help_Font_Stack() {
00097 nfonts_ = 0;
00098 }
00099
00100 void init(Fl_Font f, Fl_Fontsize s, Fl_Color c) {
00101 nfonts_ = 0;
00102 elts_[nfonts_].set(f, s, c);
00103 fl_font(f, s);
00104 fl_color(c);
00105 }
00107 void top(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { elts_[nfonts_].get(f, s, c); }
00109 void push(Fl_Font f, Fl_Fontsize s, Fl_Color c) {
00110 if (nfonts_ < MAX_FL_HELP_FS_ELTS-1) nfonts_ ++;
00111 elts_[nfonts_].set(f, s, c);
00112 fl_font(f, s); fl_color(c);
00113 }
00115 void pop(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) {
00116 if (nfonts_ > 0) nfonts_ --;
00117 top(f, s, c);
00118 fl_font(f, s); fl_color(c);
00119 }
00121 size_t count() const {return nfonts_;}
00122
00123 protected:
00124 size_t nfonts_;
00125 Fl_Help_Font_Style elts_[100];
00126 };
00127
00130 struct Fl_Help_Target {
00131 char name[32];
00132 int y;
00133 };
00134
00200 class FL_EXPORT Fl_Help_View : public Fl_Group {
00201
00202 enum { RIGHT = -1, CENTER, LEFT };
00203
00204 char title_[1024];
00205 Fl_Color defcolor_,
00206 bgcolor_,
00207 textcolor_,
00208 linkcolor_;
00209 Fl_Font textfont_;
00210 Fl_Fontsize textsize_;
00211 const char *value_;
00212 Fl_Help_Font_Stack fstack_;
00213 int nblocks_,
00214 ablocks_;
00215 Fl_Help_Block *blocks_;
00216
00217 Fl_Help_Func *link_;
00218
00219 int nlinks_,
00220 alinks_;
00221 Fl_Help_Link *links_;
00222
00223 int ntargets_,
00224 atargets_;
00225 Fl_Help_Target *targets_;
00226
00227 char directory_[FL_PATH_MAX];
00228 char filename_[FL_PATH_MAX];
00229 int topline_,
00230 leftline_,
00231 size_,
00232 hsize_,
00233 scrollbar_size_;
00234 Fl_Scrollbar scrollbar_,
00235 hscrollbar_;
00236
00237 static int selection_first;
00238 static int selection_last;
00239 static int selection_push_first;
00240 static int selection_push_last;
00241 static int selection_drag_first;
00242 static int selection_drag_last;
00243 static int selected;
00244 static int draw_mode;
00245 static int mouse_x;
00246 static int mouse_y;
00247 static int current_pos;
00248 static Fl_Help_View *current_view;
00249 static Fl_Color hv_selection_color;
00250 static Fl_Color hv_selection_text_color;
00251
00252
00253 void initfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) { f = textfont_; s = textsize_; c = textcolor_; fstack_.init(f, s, c); }
00254 void pushfont(Fl_Font f, Fl_Fontsize s) {fstack_.push(f, s, textcolor_);}
00255 void pushfont(Fl_Font f, Fl_Fontsize s, Fl_Color c) {fstack_.push(f, s, c);}
00256 void popfont(Fl_Font &f, Fl_Fontsize &s, Fl_Color &c) {fstack_.pop(f, s, c);}
00257
00258 Fl_Help_Block *add_block(const char *s, int xx, int yy, int ww, int hh, uchar border = 0);
00259 void add_link(const char *n, int xx, int yy, int ww, int hh);
00260 void add_target(const char *n, int yy);
00261 static int compare_targets(const Fl_Help_Target *t0, const Fl_Help_Target *t1);
00262 int do_align(Fl_Help_Block *block, int line, int xx, int a, int &l);
00263 #if FLTK_ABI_VERSION >= 10303
00264 protected:
00265 #endif
00266 void draw();
00267 #if FLTK_ABI_VERSION >= 10303
00268 private:
00269 #endif
00270 void format();
00271 void format_table(int *table_width, int *columns, const char *table);
00272 void free_data();
00273 int get_align(const char *p, int a);
00274 const char *get_attr(const char *p, const char *n, char *buf, int bufsize);
00275 Fl_Color get_color(const char *n, Fl_Color c);
00276 Fl_Shared_Image *get_image(const char *name, int W, int H);
00277 int get_length(const char *l);
00278 #if FLTK_ABI_VERSION >= 10303
00279 public:
00280 #endif
00281 int handle(int);
00282 #if FLTK_ABI_VERSION >= 10303
00283 private:
00284 #endif
00285
00286 void hv_draw(const char *t, int x, int y, int entity_extra_length = 0);
00287 char begin_selection();
00288 char extend_selection();
00289 void end_selection(int c=0);
00290 void clear_global_selection();
00291 Fl_Help_Link *find_link(int, int);
00292 void follow_link(Fl_Help_Link*);
00293
00294 public:
00295
00296 Fl_Help_View(int xx, int yy, int ww, int hh, const char *l = 0);
00297 ~Fl_Help_View();
00299 const char *directory() const { if (directory_[0]) return (directory_);
00300 else return ((const char *)0); }
00302 const char *filename() const { if (filename_[0]) return (filename_);
00303 else return ((const char *)0); }
00304 int find(const char *s, int p = 0);
00327 void link(Fl_Help_Func *fn) { link_ = fn; }
00328 int load(const char *f);
00329 void resize(int,int,int,int);
00331 int size() const { return (size_); }
00332 void size(int W, int H) { Fl_Widget::size(W, H); }
00334 void textcolor(Fl_Color c) { if (textcolor_ == defcolor_) textcolor_ = c; defcolor_ = c; }
00336 Fl_Color textcolor() const { return (defcolor_); }
00338 void textfont(Fl_Font f) { textfont_ = f; format(); }
00340 Fl_Font textfont() const { return (textfont_); }
00342 void textsize(Fl_Fontsize s) { textsize_ = s; format(); }
00344 Fl_Fontsize textsize() const { return (textsize_); }
00346 const char *title() { return (title_); }
00347 void topline(const char *n);
00348 void topline(int);
00350 int topline() const { return (topline_); }
00351 void leftline(int);
00353 int leftline() const { return (leftline_); }
00354 void value(const char *val);
00356 const char *value() const { return (value_); }
00357 void clear_selection();
00358 void select_all();
00368 int scrollbar_size() const {
00369 return(scrollbar_size_);
00370 }
00390 void scrollbar_size(int newSize) {
00391 scrollbar_size_ = newSize;
00392 }
00393 };
00394
00395 #endif // !Fl_Help_View_H
00396
00397
00398
00399