]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreferences.h
Really dull and boring header shit
[lyx.git] / src / frontends / xforms / FormPreferences.h
1 // -*- C++ -*-
2 /**
3  * \file FormPreferences.h
4  * Copyright 1999-2001 Allan Rae
5  * Read the file COPYING
6  *
7  * \author Allan Rae
8  * \author Angus Leeming 
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #ifndef FORMPREFERENCES_H
14 #define FORMPREFERENCES_H
15
16 #ifdef __GNUG__
17 #pragma interface
18 #endif
19
20 #include "FormBaseDeprecated.h"
21 #include "Color.h" // NamedColor
22 #include "xforms_helpers.h" // XformColor
23
24 #include <boost/scoped_ptr.hpp>
25
26 #include FORMS_H_LOCATION
27 #include <utility> // pair
28
29 class Combox;
30 class Dialogs;
31 class LyXView;
32 class RGBColor;
33 struct FD_preferences;
34 struct FD_preferences_colors;
35 struct FD_preferences_converters;
36 struct FD_preferences_formats;
37 struct FD_preferences_inputs_misc;
38 struct FD_preferences_interface;
39 struct FD_preferences_language;
40 struct FD_preferences_lnf_misc;
41 struct FD_preferences_inner_tab;
42 struct FD_preferences_outputs_misc;
43 struct FD_preferences_paths;
44 struct FD_preferences_printer;
45 struct FD_preferences_screen_fonts;
46 struct FD_preferences_spelloptions;
47
48
49 /** This class provides an XForms implementation of the FormPreferences Dialog.
50     The preferences dialog allows users to set/save their preferences.
51  */
52 class FormPreferences : public FormBaseBI {
53 public:
54         ///
55         FormPreferences(LyXView &, Dialogs &);
56
57 private:
58         /// Pointer to the actual instantiation of the ButtonController.
59         virtual xformsBC & bc();
60         /** Redraw the form (on receipt of a Signal indicating, for example,
61             that the xforms colours have been re-mapped). */
62         virtual void redraw();
63         /// Update the dialog.
64         virtual void update();
65         /// Hide the dialog.
66         virtual void hide();
67         /// OK (Save) from dialog
68         virtual void ok();
69         /// Apply from dialog
70         virtual void apply();
71         /// Filter the inputs -- return true if entries are valid
72         virtual bool input(FL_OBJECT *, long);
73         /// Build the dialog
74         virtual void build();
75         /// Pointer to the actual instantiation of the xforms form.
76         virtual FL_FORM * form() const;
77         /// control which feedback message is output
78         string const getFeedback(FL_OBJECT *);
79         ///
80         void browse(FL_OBJECT * input,
81                     string const & title, string const & pattern,
82                     std::pair<string,string> const & dir1= std::make_pair(string(),string()),
83                     std::pair<string,string> const & dir2 = std::make_pair(string(),string()));
84
85         /// Real GUI implementation.
86         boost::scoped_ptr<FD_preferences> dialog_;
87         /// Converters tabfolder
88         boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
89         /// reLyX and other import/input stuff
90         boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
91         /// HCI configuration
92         boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
93         /// Outputs tabfolder
94         boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
95         /// Spellchecker, language stuff, etc
96         boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
97
98         /** Each tab folder is encapsulated in its own class.
99          */
100
101         class Colors {
102         public:
103                 ///
104                 enum GuiColors {
105                         GUI_COLOR_CHOICE   = FL_FREE_COL14,
106                         GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
107                         GUI_COLOR_CURSOR   = FL_FREE_COL16
108                 };
109                 ///
110                 Colors(FormPreferences & p);
111                 ///
112                 FD_preferences_colors const * dialog();
113                 ///
114                 void apply(); // not const as modifies modifiedXformsPrefs.
115                 ///
116                 void build();
117                 ///
118                 string const feedback(FL_OBJECT const * const) const;
119                 ///
120                 void input(FL_OBJECT const * const);
121                 ///
122                 void update() { LoadBrowserLyX(); }
123
124                 /// Flag whether Xforms colors have changed since last file save
125                 bool modifiedXformsPrefs;
126
127         private:
128                 ///
129                 void AdjustVal(int, int, double) const;
130                 ///
131                 void InputBrowserLyX() const;
132                 ///
133                 void InputHSV();
134                 ///
135                 void InputRGB();
136                 ///
137                 void LoadBrowserLyX();
138                 ///
139                 void Modify();
140                 ///
141                 void SwitchColorSpace() const;
142                 ///
143                 string const X11hexname(RGBColor const &) const;
144
145                 ///
146                 FormPreferences & parent_;
147                 ///
148                 boost::scoped_ptr<FD_preferences_colors> dialog_;
149
150                 /// A vector of LyX LColor GUI name and associated RGB color.
151                 std::vector<NamedColor> lyxColorDB;
152                 /// A vector of xforms color ID, RGB colors and associated name.
153                 std::vector<XformsColor> xformsColorDB;
154         };
155         ///
156         friend class Colors;
157
158         ///
159         class Converters {
160         public:
161                 ///
162                 Converters(FormPreferences & p);
163                 ///
164                 FD_preferences_converters const * dialog();
165                 ///
166                 void apply() const;
167                 ///
168                 void build();
169                 ///
170                 string const feedback(FL_OBJECT const * const) const;
171                 ///
172                 bool input(FL_OBJECT const * const);
173                 ///
174                 void update();
175                 ///
176                 void UpdateBrowser();
177                 ///
178                 void UpdateChoices() const;
179
180         private:
181                 ///
182                 bool Add();
183                 ///
184                 bool Browser();
185                 ///
186                 bool erase();
187                 ///
188                 bool Input();
189                 ///
190                 string const GetFrom() const;
191                 ///
192                 string const GetTo() const;
193
194                 ///
195                 FormPreferences & parent_;
196                 ///
197                 boost::scoped_ptr<FD_preferences_converters> dialog_;
198         };
199         ///
200         friend class Converters;
201
202         ///
203         class Formats {
204         public:
205                 ///
206                 Formats(FormPreferences &  p);
207                 ///
208                 FD_preferences_formats const * dialog();
209                 ///
210                 void apply() const;
211                 ///
212                 void build();
213                 ///
214                 string const feedback(FL_OBJECT const * const) const;
215                 ///
216                 bool input(FL_OBJECT const * const);
217                 ///
218                 void update();
219
220         private:
221                 ///
222                 bool Add();
223                 ///
224                 bool Browser();
225                 ///
226                 void UpdateBrowser();
227                 ///
228                 bool erase();
229                 ///
230                 bool Input();
231
232                 ///
233                 FormPreferences & parent_;
234                 ///
235                 boost::scoped_ptr<FD_preferences_formats> dialog_;
236         };
237         ///
238         friend class Formats;
239
240         ///
241         class InputsMisc {
242         public:
243                 ///
244                 InputsMisc(FormPreferences &  p);
245                 ///
246                 FD_preferences_inputs_misc const * dialog();
247                 ///
248                 void apply() const;
249                 ///
250                 void build();
251                 ///
252                 string const feedback(FL_OBJECT const * const) const;
253                 ///
254                 void update();
255
256         private:
257                 ///
258                 FormPreferences & parent_;
259                 ///
260                 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
261         };
262         ///
263         friend class InputsMisc;
264
265         ///
266         class Interface {
267         public:
268                 ///
269                 Interface(FormPreferences &  p);
270                 ///
271                 FD_preferences_interface const * dialog();
272                 ///
273                 void apply() const;
274                 ///
275                 void build();
276                 ///
277                 string const feedback(FL_OBJECT const * const) const;
278                 ///
279                 bool input(FL_OBJECT const * const);
280                 ///
281                 void update();
282
283         private:
284                 ///
285                 FormPreferences & parent_;
286                 ///
287                 boost::scoped_ptr<FD_preferences_interface> dialog_;
288         };
289         ///
290         friend class Interface;
291
292         ///
293         class Language {
294         public:
295                 ///
296                 Language(FormPreferences &  p);
297                 ///
298                 FD_preferences_language const * dialog();
299                 ///
300                 void apply(); // not const because calls update()
301                 ///
302                 void build();
303                 ///
304                 string const feedback(FL_OBJECT const * const) const;
305                 ///
306                 bool input(FL_OBJECT const * const);
307                 ///
308                 void update();
309                 ///
310                 static void ComboCB(int, void *, Combox *);
311
312         private:
313                 ///
314                 FormPreferences & parent_;
315                 ///
316                 boost::scoped_ptr<FD_preferences_language> dialog_;
317                 ///
318                 boost::scoped_ptr<Combox> combo_default_lang;
319                 ///
320                 std::vector<string> lang_;
321         };
322         ///
323         friend class Language;
324
325         ///
326         class LnFmisc {
327         public:
328                 ///
329                 LnFmisc(FormPreferences &  p);
330                 ///
331                 FD_preferences_lnf_misc const * dialog();
332                 ///
333                 void apply() const;
334                 ///
335                 void build();
336                 ///
337                 string const feedback(FL_OBJECT const * const) const;
338                 ///
339                 void update();
340
341         private:
342                 ///
343                 FormPreferences & parent_;
344                 ///
345                 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
346         };
347         ///
348         friend class LnFmisc;
349
350         ///
351         class OutputsMisc {
352         public:
353                 ///
354                 OutputsMisc(FormPreferences &  p);
355                 ///
356                 FD_preferences_outputs_misc const * dialog();
357                 ///
358                 void apply() const;
359                 ///
360                 void build();
361                 ///
362                 string const feedback(FL_OBJECT const * const) const;
363                 ///
364                 void update();
365
366         private:
367                 ///
368                 FormPreferences & parent_;
369                 ///
370                 boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
371         };
372         ///
373         friend class OutputsMisc;
374
375         ///
376         class Paths {
377         public:
378                 ///
379                 Paths(FormPreferences &  p);
380                 ///
381                 FD_preferences_paths const * dialog();
382                 ///
383                 void apply();
384                 ///
385                 void build();
386                 ///
387                 string const feedback(FL_OBJECT const * const) const;
388                 ///
389                 bool input(FL_OBJECT const * const);
390                 ///
391                 void update();
392
393         private:
394                 ///
395                 FormPreferences & parent_;
396                 ///
397                 boost::scoped_ptr<FD_preferences_paths> dialog_;
398         };
399         ///
400         friend class Paths;
401
402         ///
403         class Printer {
404         public:
405                 ///
406                 Printer(FormPreferences &  p);
407                 ///
408                 FD_preferences_printer const * dialog();
409                 ///
410                 void apply() const;
411                 ///
412                 void build();
413                 ///
414                 string const feedback(FL_OBJECT const * const) const;
415                 ///
416                 void update();
417
418         private:
419                 ///
420                 FormPreferences & parent_;
421                 ///
422                 boost::scoped_ptr<FD_preferences_printer> dialog_;
423         };
424         ///
425         friend class Printer;
426
427         ///
428         class ScreenFonts {
429         public:
430                 ///
431                 ScreenFonts(FormPreferences &  p);
432                 ///
433                 FD_preferences_screen_fonts const * dialog();
434                 ///
435                 void apply() const;
436                 ///
437                 void build();
438                 ///
439                 string const feedback(FL_OBJECT const * const) const;
440                 ///
441                 bool input();
442                 ///
443                 void update();
444
445         private:
446                 ///
447                 FormPreferences & parent_;
448                 ///
449                 boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
450         };
451         ///
452         friend class ScreenFonts;
453
454         ///
455         class SpellOptions {
456         public:
457                 ///
458                 SpellOptions(FormPreferences &  p);
459                 ///
460                 FD_preferences_spelloptions const * dialog();
461                 ///
462                 void apply(); // not const because calls update()!
463                 ///
464                 void build();
465                 ///
466                 string const feedback(FL_OBJECT const * const) const;
467                 ///
468                 bool input(FL_OBJECT const * const);
469                 ///
470                 void update();
471
472         private:
473                 ///
474                 FormPreferences & parent_;
475                 ///
476                 boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
477         };
478         ///
479         friend class SpellOptions;
480
481         /** The tab folders.
482          */
483
484         ///
485         Colors colors_;
486         ///
487         Converters converters_;
488         ///
489         InputsMisc inputs_misc_;
490         ///
491         Formats formats_;
492         ///
493         Interface interface_;
494         ///
495         Language language_;
496         ///
497         LnFmisc lnf_misc_;
498         ///
499         OutputsMisc outputs_misc_;
500         ///
501         Paths paths_;
502         ///
503         Printer printer_;
504         ///
505         ScreenFonts screen_fonts_;
506         ///
507         SpellOptions spelloptions_;
508
509         /** A couple of helper structs to enable colors to be sorted by name
510             and by color */
511         ///
512         struct SortColorsByName {
513                 ///
514                 int operator()(NamedColor const & a, NamedColor const & b) const
515                         { return (a.getname() < b.getname()); }
516         };
517         ///
518         struct SortColorsByColor {
519                 ///
520                 SortColorsByColor(RGBColor c) : col(c) {}
521                 ///
522                 int operator()(RGBColor const &, RGBColor const &) const;
523                 ///
524                 RGBColor col;
525         };
526         /// The ButtonController
527         ButtonController<PreferencesPolicy, xformsBC> bc_;
528 };
529
530
531 inline
532 xformsBC & FormPreferences::bc()
533 {
534         return bc_;
535 }
536
537 #endif