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