You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

302 lines
7.7KB

  1. //
  2. // "$Id: Fl_Help_Dialog.cxx 7903 2010-11-28 21:06:39Z matt $"
  3. //
  4. // Fl_Help_Dialog dialog for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 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 on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. // generated by Fast Light User Interface Designer (fluid) version 1.0108
  28. #include "../FL/Fl_Help_Dialog.H"
  29. #include "flstring.h"
  30. #include <FL/fl_ask.H>
  31. void Fl_Help_Dialog::cb_back__i(Fl_Button*, void*) {
  32. if (index_ > 0)
  33. index_ --;
  34. if (index_ == 0)
  35. back_->deactivate();
  36. forward_->activate();
  37. int l = line_[index_];
  38. if (strcmp(view_->filename(), file_[index_]) != 0)
  39. view_->load(file_[index_]);
  40. view_->topline(l);
  41. }
  42. void Fl_Help_Dialog::cb_back_(Fl_Button* o, void* v) {
  43. ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_back__i(o,v);
  44. }
  45. void Fl_Help_Dialog::cb_forward__i(Fl_Button*, void*) {
  46. if (index_ < max_)
  47. index_ ++;
  48. if (index_ >= max_)
  49. forward_->deactivate();
  50. back_->activate();
  51. int l = view_->topline();
  52. if (strcmp(view_->filename(), file_[index_]) != 0)
  53. view_->load(file_[index_]);
  54. view_->topline(l);
  55. }
  56. void Fl_Help_Dialog::cb_forward_(Fl_Button* o, void* v) {
  57. ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_forward__i(o,v);
  58. }
  59. void Fl_Help_Dialog::cb_smaller__i(Fl_Button*, void*) {
  60. if (view_->textsize() > 8)
  61. view_->textsize(view_->textsize() - 2);
  62. if (view_->textsize() <= 8)
  63. smaller_->deactivate();
  64. larger_->activate();
  65. }
  66. void Fl_Help_Dialog::cb_smaller_(Fl_Button* o, void* v) {
  67. ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_smaller__i(o,v);
  68. }
  69. void Fl_Help_Dialog::cb_larger__i(Fl_Button*, void*) {
  70. if (view_->textsize() < 18)
  71. view_->textsize(view_->textsize() + 2);
  72. if (view_->textsize() >= 18)
  73. larger_->deactivate();
  74. smaller_->activate();
  75. }
  76. void Fl_Help_Dialog::cb_larger_(Fl_Button* o, void* v) {
  77. ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_larger__i(o,v);
  78. }
  79. void Fl_Help_Dialog::cb_find__i(Fl_Input*, void*) {
  80. find_pos_ = view_->find(find_->value(), find_pos_);
  81. }
  82. void Fl_Help_Dialog::cb_find_(Fl_Input* o, void* v) {
  83. ((Fl_Help_Dialog*)(o->parent()->parent()->parent()->user_data()))->cb_find__i(o,v);
  84. }
  85. void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) {
  86. if (view_->filename())
  87. {
  88. if (view_->changed())
  89. {
  90. index_ ++;
  91. if (index_ >= 100)
  92. {
  93. memmove(line_, line_ + 10, sizeof(line_[0]) * 90);
  94. memmove(file_, file_ + 10, sizeof(file_[0]) * 90);
  95. index_ -= 10;
  96. }
  97. max_ = index_;
  98. strlcpy(file_[index_], view_->filename(),sizeof(file_[0]));
  99. line_[index_] = view_->topline();
  100. if (index_ > 0)
  101. back_->activate();
  102. else
  103. back_->deactivate();
  104. forward_->deactivate();
  105. window_->label(view_->title());
  106. }
  107. else // if ! view_->changed()
  108. {
  109. strlcpy(file_[index_], view_->filename(), sizeof(file_[0]));
  110. line_[index_] = view_->topline();
  111. }
  112. } else { // if ! view_->filename()
  113. index_ = 0; // hitting an internal page will disable the back/fwd buffer
  114. file_[index_][0] = 0; // unnamed internal page
  115. line_[index_] = view_->topline();
  116. back_->deactivate();
  117. forward_->deactivate();
  118. };
  119. }
  120. void Fl_Help_Dialog::cb_view_(Fl_Help_View* o, void* v) {
  121. ((Fl_Help_Dialog*)(o->parent()->user_data()))->cb_view__i(o,v);
  122. }
  123. Fl_Help_Dialog::Fl_Help_Dialog() {
  124. { window_ = new Fl_Double_Window(530, 385, "Help Dialog");
  125. window_->user_data((void*)(this));
  126. { Fl_Group* o = new Fl_Group(10, 10, 511, 25);
  127. { back_ = new Fl_Button(10, 10, 25, 25, "@<-");
  128. back_->tooltip("Show the previous help page.");
  129. back_->shortcut(0xff51);
  130. back_->labelcolor((Fl_Color)2);
  131. back_->callback((Fl_Callback*)cb_back_);
  132. } // Fl_Button* back_
  133. { forward_ = new Fl_Button(45, 10, 25, 25, "@->");
  134. forward_->tooltip("Show the next help page.");
  135. forward_->shortcut(0xff53);
  136. forward_->labelcolor((Fl_Color)2);
  137. forward_->callback((Fl_Callback*)cb_forward_);
  138. } // Fl_Button* forward_
  139. { smaller_ = new Fl_Button(80, 10, 25, 25, "F");
  140. smaller_->tooltip("Make the help text smaller.");
  141. smaller_->labelfont(1);
  142. smaller_->labelsize(10);
  143. smaller_->callback((Fl_Callback*)cb_smaller_);
  144. } // Fl_Button* smaller_
  145. { larger_ = new Fl_Button(115, 10, 25, 25, "F");
  146. larger_->tooltip("Make the help text larger.");
  147. larger_->labelfont(1);
  148. larger_->labelsize(16);
  149. larger_->callback((Fl_Callback*)cb_larger_);
  150. } // Fl_Button* larger_
  151. { Fl_Group* o = new Fl_Group(350, 10, 171, 25);
  152. o->box(FL_DOWN_BOX);
  153. o->color(FL_BACKGROUND2_COLOR);
  154. { find_ = new Fl_Input(375, 12, 143, 21, "@search");
  155. find_->tooltip("find text in document");
  156. find_->box(FL_FLAT_BOX);
  157. find_->labelsize(13);
  158. find_->textfont(4);
  159. find_->callback((Fl_Callback*)cb_find_);
  160. find_->when(FL_WHEN_ENTER_KEY_ALWAYS);
  161. } // Fl_Input* find_
  162. o->end();
  163. } // Fl_Group* o
  164. { Fl_Box* o = new Fl_Box(150, 10, 190, 25);
  165. Fl_Group::current()->resizable(o);
  166. } // Fl_Box* o
  167. o->end();
  168. } // Fl_Group* o
  169. { view_ = new Fl_Help_View(10, 45, 510, 330);
  170. view_->box(FL_DOWN_BOX);
  171. view_->callback((Fl_Callback*)cb_view_);
  172. Fl_Group::current()->resizable(view_);
  173. } // Fl_Help_View* view_
  174. window_->size_range(260, 150);
  175. window_->end();
  176. } // Fl_Double_Window* window_
  177. back_->deactivate();
  178. forward_->deactivate();
  179. index_ = -1;
  180. max_ = 0;
  181. find_pos_ = 0;
  182. fl_register_images();
  183. }
  184. Fl_Help_Dialog::~Fl_Help_Dialog() {
  185. delete window_;
  186. }
  187. int Fl_Help_Dialog::h() {
  188. return (window_->h());
  189. }
  190. void Fl_Help_Dialog::hide() {
  191. window_->hide();
  192. }
  193. void Fl_Help_Dialog::load(const char *f) {
  194. view_->set_changed();
  195. view_->load(f);
  196. window_->label(view_->title());
  197. }
  198. void Fl_Help_Dialog::position(int xx, int yy) {
  199. window_->position(xx, yy);
  200. }
  201. void Fl_Help_Dialog::resize(int xx, int yy, int ww, int hh) {
  202. window_->resize(xx, yy, ww, hh);
  203. }
  204. void Fl_Help_Dialog::show() {
  205. window_->show();
  206. }
  207. void Fl_Help_Dialog::show(int argc, char **argv) {
  208. window_->show(argc, argv);
  209. }
  210. void Fl_Help_Dialog::textsize(Fl_Fontsize s) {
  211. view_->textsize(s);
  212. if (s <= 8)
  213. smaller_->deactivate();
  214. else
  215. smaller_->activate();
  216. if (s >= 18)
  217. larger_->deactivate();
  218. else
  219. larger_->activate();
  220. }
  221. Fl_Fontsize Fl_Help_Dialog::textsize() {
  222. return (view_->textsize());
  223. }
  224. void Fl_Help_Dialog::topline(const char *n) {
  225. view_->topline(n);
  226. }
  227. void Fl_Help_Dialog::topline(int n) {
  228. view_->topline(n);
  229. }
  230. void Fl_Help_Dialog::value(const char *f) {
  231. view_->set_changed();
  232. view_->value(f);
  233. window_->label(view_->title());
  234. }
  235. const char * Fl_Help_Dialog::value() const {
  236. return view_->value();
  237. }
  238. int Fl_Help_Dialog::visible() {
  239. return (window_->visible());
  240. }
  241. int Fl_Help_Dialog::w() {
  242. return (window_->w());
  243. }
  244. int Fl_Help_Dialog::x() {
  245. return (window_->x());
  246. }
  247. int Fl_Help_Dialog::y() {
  248. return (window_->y());
  249. }
  250. //
  251. // End of "$Id: Fl_Help_Dialog.cxx 7903 2010-11-28 21:06:39Z matt $".
  252. //