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