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