|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
00001 // 00002 // "$Id: Fl_Help_Dialog.cxx 7903 2010-11-28 21:06:39Z matt $" 00003 // 00004 // Fl_Help_Dialog dialog for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2010 by Bill Spitzak and others. 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Library General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00021 // USA. 00022 // 00023 // Please report all bugs and problems on the following page: 00024 // 00025 // http://www.fltk.org/str.php 00026 // 00027 00028 // generated by Fast Light User Interface Designer (fluid) version 1.0108 00029 00030 #include "../FL/Fl_Help_Dialog.H" 00031 #include "flstring.h" 00032 #include <FL/fl_ask.H> 00033 00034 void Fl_Help_Dialog::cb_back__i(Fl_Button*, void*) { 00035 if (index_ > 0) 00036 index_ --; 00037 00038 if (index_ == 0) 00039 back_->deactivate(); 00040 00041 forward_->activate(); 00042 00043 int l = line_[index_]; 00044 00045 if (strcmp(view_->filename(), file_[index_]) != 0) 00046 view_->load(file_[index_]); 00047 00048 view_->topline(l); 00049 } 00050 void Fl_Help_Dialog::cb_back_(Fl_Button* o, void* v) { 00051 ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_back__i(o,v); 00052 } 00053 00054 void Fl_Help_Dialog::cb_forward__i(Fl_Button*, void*) { 00055 if (index_ < max_) 00056 index_ ++; 00057 00058 if (index_ >= max_) 00059 forward_->deactivate(); 00060 00061 back_->activate(); 00062 00063 int l = view_->topline(); 00064 00065 if (strcmp(view_->filename(), file_[index_]) != 0) 00066 view_->load(file_[index_]); 00067 00068 view_->topline(l); 00069 } 00070 void Fl_Help_Dialog::cb_forward_(Fl_Button* o, void* v) { 00071 ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_forward__i(o,v); 00072 } 00073 00074 void Fl_Help_Dialog::cb_smaller__i(Fl_Button*, void*) { 00075 if (view_->textsize() > 8) 00076 view_->textsize(view_->textsize() - 2); 00077 00078 if (view_->textsize() <= 8) 00079 smaller_->deactivate(); 00080 larger_->activate(); 00081 } 00082 void Fl_Help_Dialog::cb_smaller_(Fl_Button* o, void* v) { 00083 ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_smaller__i(o,v); 00084 } 00085 00086 void Fl_Help_Dialog::cb_larger__i(Fl_Button*, void*) { 00087 if (view_->textsize() < 18) 00088 view_->textsize(view_->textsize() + 2); 00089 00090 if (view_->textsize() >= 18) 00091 larger_->deactivate(); 00092 smaller_->activate(); 00093 } 00094 void Fl_Help_Dialog::cb_larger_(Fl_Button* o, void* v) { 00095 ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_larger__i(o,v); 00096 } 00097 00098 void Fl_Help_Dialog::cb_find__i(Fl_Input*, void*) { 00099 find_pos_ = view_->find(find_->value(), find_pos_); 00100 } 00101 void Fl_Help_Dialog::cb_find_(Fl_Input* o, void* v) { 00102 ((Fl_Help_Dialog*)(o->parent()->parent()->parent()->user_data()))->cb_find__i(o,v); 00103 } 00104 00105 void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) { 00106 if (view_->filename()) 00107 { 00108 if (view_->changed()) 00109 { 00110 index_ ++; 00111 00112 if (index_ >= 100) 00113 { 00114 memmove(line_, line_ + 10, sizeof(line_[0]) * 90); 00115 memmove(file_, file_ + 10, sizeof(file_[0]) * 90); 00116 index_ -= 10; 00117 } 00118 00119 max_ = index_; 00120 00121 strlcpy(file_[index_], view_->filename(),sizeof(file_[0])); 00122 line_[index_] = view_->topline(); 00123 00124 if (index_ > 0) 00125 back_->activate(); 00126 else 00127 back_->deactivate(); 00128 00129 forward_->deactivate(); 00130 window_->label(view_->title()); 00131 } 00132 else // if ! view_->changed() 00133 { 00134 strlcpy(file_[index_], view_->filename(), sizeof(file_[0])); 00135 line_[index_] = view_->topline(); 00136 } 00137 } else { // if ! view_->filename() 00138 index_ = 0; // hitting an internal page will disable the back/fwd buffer 00139 file_[index_][0] = 0; // unnamed internal page 00140 line_[index_] = view_->topline(); 00141 back_->deactivate(); 00142 forward_->deactivate(); 00143 }; 00144 } 00145 void Fl_Help_Dialog::cb_view_(Fl_Help_View* o, void* v) { 00146 ((Fl_Help_Dialog*)(o->parent()->user_data()))->cb_view__i(o,v); 00147 } 00148 00149 Fl_Help_Dialog::Fl_Help_Dialog() { 00150 { window_ = new Fl_Double_Window(530, 385, "Help Dialog"); 00151 window_->user_data((void*)(this)); 00152 { Fl_Group* o = new Fl_Group(10, 10, 511, 25); 00153 { back_ = new Fl_Button(10, 10, 25, 25, "@<-"); 00154 back_->tooltip("Show the previous help page."); 00155 back_->shortcut(0xff51); 00156 back_->labelcolor((Fl_Color)2); 00157 back_->callback((Fl_Callback*)cb_back_); 00158 } // Fl_Button* back_ 00159 { forward_ = new Fl_Button(45, 10, 25, 25, "@->"); 00160 forward_->tooltip("Show the next help page."); 00161 forward_->shortcut(0xff53); 00162 forward_->labelcolor((Fl_Color)2); 00163 forward_->callback((Fl_Callback*)cb_forward_); 00164 } // Fl_Button* forward_ 00165 { smaller_ = new Fl_Button(80, 10, 25, 25, "F"); 00166 smaller_->tooltip("Make the help text smaller."); 00167 smaller_->labelfont(1); 00168 smaller_->labelsize(10); 00169 smaller_->callback((Fl_Callback*)cb_smaller_); 00170 } // Fl_Button* smaller_ 00171 { larger_ = new Fl_Button(115, 10, 25, 25, "F"); 00172 larger_->tooltip("Make the help text larger."); 00173 larger_->labelfont(1); 00174 larger_->labelsize(16); 00175 larger_->callback((Fl_Callback*)cb_larger_); 00176 } // Fl_Button* larger_ 00177 { Fl_Group* o = new Fl_Group(350, 10, 171, 25); 00178 o->box(FL_DOWN_BOX); 00179 o->color(FL_BACKGROUND2_COLOR); 00180 { find_ = new Fl_Input(375, 12, 143, 21, "@search"); 00181 find_->tooltip("find text in document"); 00182 find_->box(FL_FLAT_BOX); 00183 find_->labelsize(13); 00184 find_->textfont(4); 00185 find_->callback((Fl_Callback*)cb_find_); 00186 find_->when(FL_WHEN_ENTER_KEY_ALWAYS); 00187 } // Fl_Input* find_ 00188 o->end(); 00189 } // Fl_Group* o 00190 { Fl_Box* o = new Fl_Box(150, 10, 190, 25); 00191 Fl_Group::current()->resizable(o); 00192 } // Fl_Box* o 00193 o->end(); 00194 } // Fl_Group* o 00195 { view_ = new Fl_Help_View(10, 45, 510, 330); 00196 view_->box(FL_DOWN_BOX); 00197 view_->callback((Fl_Callback*)cb_view_); 00198 Fl_Group::current()->resizable(view_); 00199 } // Fl_Help_View* view_ 00200 window_->size_range(260, 150); 00201 window_->end(); 00202 } // Fl_Double_Window* window_ 00203 back_->deactivate(); 00204 forward_->deactivate(); 00205 00206 index_ = -1; 00207 max_ = 0; 00208 find_pos_ = 0; 00209 00210 fl_register_images(); 00211 } 00212 00213 Fl_Help_Dialog::~Fl_Help_Dialog() { 00214 delete window_; 00215 } 00216 00217 int Fl_Help_Dialog::h() { 00218 return (window_->h()); 00219 } 00220 00221 void Fl_Help_Dialog::hide() { 00222 window_->hide(); 00223 } 00224 00225 void Fl_Help_Dialog::load(const char *f) { 00226 view_->set_changed(); 00227 view_->load(f); 00228 window_->label(view_->title()); 00229 } 00230 00231 void Fl_Help_Dialog::position(int xx, int yy) { 00232 window_->position(xx, yy); 00233 } 00234 00235 void Fl_Help_Dialog::resize(int xx, int yy, int ww, int hh) { 00236 window_->resize(xx, yy, ww, hh); 00237 } 00238 00239 void Fl_Help_Dialog::show() { 00240 window_->show(); 00241 } 00242 00243 void Fl_Help_Dialog::show(int argc, char **argv) { 00244 window_->show(argc, argv); 00245 } 00246 00247 void Fl_Help_Dialog::textsize(Fl_Fontsize s) { 00248 view_->textsize(s); 00249 00250 if (s <= 8) 00251 smaller_->deactivate(); 00252 else 00253 smaller_->activate(); 00254 00255 if (s >= 18) 00256 larger_->deactivate(); 00257 else 00258 larger_->activate(); 00259 } 00260 00261 Fl_Fontsize Fl_Help_Dialog::textsize() { 00262 return (view_->textsize()); 00263 } 00264 00265 void Fl_Help_Dialog::topline(const char *n) { 00266 view_->topline(n); 00267 } 00268 00269 void Fl_Help_Dialog::topline(int n) { 00270 view_->topline(n); 00271 } 00272 00273 void Fl_Help_Dialog::value(const char *f) { 00274 view_->set_changed(); 00275 view_->value(f); 00276 window_->label(view_->title()); 00277 } 00278 00279 const char * Fl_Help_Dialog::value() const { 00280 return view_->value(); 00281 } 00282 00283 int Fl_Help_Dialog::visible() { 00284 return (window_->visible()); 00285 } 00286 00287 int Fl_Help_Dialog::w() { 00288 return (window_->w()); 00289 } 00290 00291 int Fl_Help_Dialog::x() { 00292 return (window_->x()); 00293 } 00294 00295 int Fl_Help_Dialog::y() { 00296 return (window_->y()); 00297 } 00298 00299 // 00300 // End of "$Id: Fl_Help_Dialog.cxx 7903 2010-11-28 21:06:39Z matt $". 00301 //