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