2 // "$Id: Fl_Help_Dialog.cxx 7903 2010-11-28 21:06:39Z matt $"
4 // Fl_Help_Dialog dialog for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
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
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"
32 #include <FL/fl_ask.H>
34 void Fl_Help_Dialog::cb_back__i(Fl_Button
*, void*) {
43 int l
= line_
[index_
];
45 if (strcmp(view_
->filename(), file_
[index_
]) != 0)
46 view_
->load(file_
[index_
]);
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*) {
59 forward_
->deactivate();
63 int l
= view_
->topline();
65 if (strcmp(view_
->filename(), file_
[index_
]) != 0)
66 view_
->load(file_
[index_
]);
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();
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();
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())
114 memmove(line_
, line_
+ 10, sizeof(line_
[0]) * 90);
115 memmove(file_
, file_
+ 10, sizeof(file_
[0]) * 90);
121 strlcpy(file_
[index_
], view_
->filename(),sizeof(file_
[0]));
122 line_
[index_
] = view_
->topline();
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();
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);
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);
185 find_
->callback((Fl_Callback
*)cb_find_
);
186 find_
->when(FL_WHEN_ENTER_KEY_ALWAYS
);
190 { Fl_Box
* o
= new Fl_Box(150, 10, 190, 25);
191 Fl_Group::current()->resizable(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);
202 } // Fl_Double_Window* window_
204 forward_
->deactivate();
210 fl_register_images();
213 Fl_Help_Dialog::~Fl_Help_Dialog() {
217 int Fl_Help_Dialog::h() {
218 return (window_
->h());
221 void Fl_Help_Dialog::hide() {
225 void Fl_Help_Dialog::load(const char *f
) {
226 view_
->set_changed();
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() {
243 void Fl_Help_Dialog::show(int argc
, char **argv
) {
244 window_
->show(argc
, argv
);
247 void Fl_Help_Dialog::textsize(Fl_Fontsize s
) {
251 smaller_
->deactivate();
253 smaller_
->activate();
256 larger_
->deactivate();
261 Fl_Fontsize
Fl_Help_Dialog::textsize() {
262 return (view_
->textsize());
265 void Fl_Help_Dialog::topline(const char *n
) {
269 void Fl_Help_Dialog::topline(int n
) {
273 void Fl_Help_Dialog::value(const char *f
) {
274 view_
->set_changed();
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 $".