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