themes: Workaround for bug where a background color of RGB 0,0,0 in Black color schem...
[ntk.git] / src / Fl_Help_Dialog.cxx
blob5511e2679a4149bd385ffc9171630406d80dc31f
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.
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.
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.
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 // generated by Fast Light User Interface Designer (fluid) version 1.0108
30 #include "../FL/Fl_Help_Dialog.H"
31 #include "flstring.h"
32 #include <FL/fl_ask.H>
34 void Fl_Help_Dialog::cb_back__i(Fl_Button*, void*) {
35 if (index_ > 0)
36 index_ --;
38 if (index_ == 0)
39 back_->deactivate();
41 forward_->activate();
43 int l = line_[index_];
45 if (strcmp(view_->filename(), file_[index_]) != 0)
46 view_->load(file_[index_]);
48 view_->topline(l);
50 void Fl_Help_Dialog::cb_back_(Fl_Button* o, void* v) {
51 ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_back__i(o,v);
54 void Fl_Help_Dialog::cb_forward__i(Fl_Button*, void*) {
55 if (index_ < max_)
56 index_ ++;
58 if (index_ >= max_)
59 forward_->deactivate();
61 back_->activate();
63 int l = view_->topline();
65 if (strcmp(view_->filename(), file_[index_]) != 0)
66 view_->load(file_[index_]);
68 view_->topline(l);
70 void Fl_Help_Dialog::cb_forward_(Fl_Button* o, void* v) {
71 ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_forward__i(o,v);
74 void Fl_Help_Dialog::cb_smaller__i(Fl_Button*, void*) {
75 if (view_->textsize() > 8)
76 view_->textsize(view_->textsize() - 2);
78 if (view_->textsize() <= 8)
79 smaller_->deactivate();
80 larger_->activate();
82 void Fl_Help_Dialog::cb_smaller_(Fl_Button* o, void* v) {
83 ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_smaller__i(o,v);
86 void Fl_Help_Dialog::cb_larger__i(Fl_Button*, void*) {
87 if (view_->textsize() < 18)
88 view_->textsize(view_->textsize() + 2);
90 if (view_->textsize() >= 18)
91 larger_->deactivate();
92 smaller_->activate();
94 void Fl_Help_Dialog::cb_larger_(Fl_Button* o, void* v) {
95 ((Fl_Help_Dialog*)(o->parent()->parent()->user_data()))->cb_larger__i(o,v);
98 void Fl_Help_Dialog::cb_find__i(Fl_Input*, void*) {
99 find_pos_ = view_->find(find_->value(), find_pos_);
101 void Fl_Help_Dialog::cb_find_(Fl_Input* o, void* v) {
102 ((Fl_Help_Dialog*)(o->parent()->parent()->parent()->user_data()))->cb_find__i(o,v);
105 void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) {
106 if (view_->filename())
108 if (view_->changed())
110 index_ ++;
112 if (index_ >= 100)
114 memmove(line_, line_ + 10, sizeof(line_[0]) * 90);
115 memmove(file_, file_ + 10, sizeof(file_[0]) * 90);
116 index_ -= 10;
119 max_ = index_;
121 strlcpy(file_[index_], view_->filename(),sizeof(file_[0]));
122 line_[index_] = view_->topline();
124 if (index_ > 0)
125 back_->activate();
126 else
127 back_->deactivate();
129 forward_->deactivate();
130 window_->label(view_->title());
132 else // if ! view_->changed()
134 strlcpy(file_[index_], view_->filename(), sizeof(file_[0]));
135 line_[index_] = view_->topline();
137 } else { // if ! view_->filename()
138 index_ = 0; // hitting an internal page will disable the back/fwd buffer
139 file_[index_][0] = 0; // unnamed internal page
140 line_[index_] = view_->topline();
141 back_->deactivate();
142 forward_->deactivate();
145 void Fl_Help_Dialog::cb_view_(Fl_Help_View* o, void* v) {
146 ((Fl_Help_Dialog*)(o->parent()->user_data()))->cb_view__i(o,v);
149 Fl_Help_Dialog::Fl_Help_Dialog() {
150 { window_ = new Fl_Double_Window(530, 385, "Help Dialog");
151 window_->user_data((void*)(this));
152 { Fl_Group* o = new Fl_Group(10, 10, 511, 25);
153 { back_ = new Fl_Button(10, 10, 25, 25, "@<-");
154 back_->tooltip("Show the previous help page.");
155 back_->shortcut(0xff51);
156 back_->labelcolor((Fl_Color)2);
157 back_->callback((Fl_Callback*)cb_back_);
158 } // Fl_Button* back_
159 { forward_ = new Fl_Button(45, 10, 25, 25, "@->");
160 forward_->tooltip("Show the next help page.");
161 forward_->shortcut(0xff53);
162 forward_->labelcolor((Fl_Color)2);
163 forward_->callback((Fl_Callback*)cb_forward_);
164 } // Fl_Button* forward_
165 { smaller_ = new Fl_Button(80, 10, 25, 25, "F");
166 smaller_->tooltip("Make the help text smaller.");
167 smaller_->labelfont(1);
168 smaller_->labelsize(10);
169 smaller_->callback((Fl_Callback*)cb_smaller_);
170 } // Fl_Button* smaller_
171 { larger_ = new Fl_Button(115, 10, 25, 25, "F");
172 larger_->tooltip("Make the help text larger.");
173 larger_->labelfont(1);
174 larger_->labelsize(16);
175 larger_->callback((Fl_Callback*)cb_larger_);
176 } // Fl_Button* larger_
177 { Fl_Group* o = new Fl_Group(350, 10, 171, 25);
178 o->box(FL_DOWN_BOX);
179 o->color(FL_BACKGROUND2_COLOR);
180 { find_ = new Fl_Input(375, 12, 143, 21, "@search");
181 find_->tooltip("find text in document");
182 find_->box(FL_FLAT_BOX);
183 find_->labelsize(13);
184 find_->textfont(4);
185 find_->callback((Fl_Callback*)cb_find_);
186 find_->when(FL_WHEN_ENTER_KEY_ALWAYS);
187 } // Fl_Input* find_
188 o->end();
189 } // Fl_Group* o
190 { Fl_Box* o = new Fl_Box(150, 10, 190, 25);
191 Fl_Group::current()->resizable(o);
192 } // Fl_Box* o
193 o->end();
194 } // Fl_Group* o
195 { view_ = new Fl_Help_View(10, 45, 510, 330);
196 view_->box(FL_DOWN_BOX);
197 view_->callback((Fl_Callback*)cb_view_);
198 Fl_Group::current()->resizable(view_);
199 } // Fl_Help_View* view_
200 window_->size_range(260, 150);
201 window_->end();
202 } // Fl_Double_Window* window_
203 back_->deactivate();
204 forward_->deactivate();
206 index_ = -1;
207 max_ = 0;
208 find_pos_ = 0;
210 fl_register_images();
213 Fl_Help_Dialog::~Fl_Help_Dialog() {
214 delete window_;
217 int Fl_Help_Dialog::h() {
218 return (window_->h());
221 void Fl_Help_Dialog::hide() {
222 window_->hide();
225 void Fl_Help_Dialog::load(const char *f) {
226 view_->set_changed();
227 view_->load(f);
228 window_->label(view_->title());
231 void Fl_Help_Dialog::position(int xx, int yy) {
232 window_->position(xx, yy);
235 void Fl_Help_Dialog::resize(int xx, int yy, int ww, int hh) {
236 window_->resize(xx, yy, ww, hh);
239 void Fl_Help_Dialog::show() {
240 window_->show();
243 void Fl_Help_Dialog::show(int argc, char **argv) {
244 window_->show(argc, argv);
247 void Fl_Help_Dialog::textsize(Fl_Fontsize s) {
248 view_->textsize(s);
250 if (s <= 8)
251 smaller_->deactivate();
252 else
253 smaller_->activate();
255 if (s >= 18)
256 larger_->deactivate();
257 else
258 larger_->activate();
261 Fl_Fontsize Fl_Help_Dialog::textsize() {
262 return (view_->textsize());
265 void Fl_Help_Dialog::topline(const char *n) {
266 view_->topline(n);
269 void Fl_Help_Dialog::topline(int n) {
270 view_->topline(n);
273 void Fl_Help_Dialog::value(const char *f) {
274 view_->set_changed();
275 view_->value(f);
276 window_->label(view_->title());
279 const char * Fl_Help_Dialog::value() const {
280 return view_->value();
283 int Fl_Help_Dialog::visible() {
284 return (window_->visible());
287 int Fl_Help_Dialog::w() {
288 return (window_->w());
291 int Fl_Help_Dialog::x() {
292 return (window_->x());
295 int Fl_Help_Dialog::y() {
296 return (window_->y());
300 // End of "$Id: Fl_Help_Dialog.cxx 7903 2010-11-28 21:06:39Z matt $".