]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreferences.h
Swap two printer related help messages.
[lyx.git] / src / frontends / xforms / FormPreferences.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1995 Matthias Ettrich
8  *          Copyright 1995-2000 The LyX Team.
9  *
10  *          This file copyright 1999-2000
11  *          Allan Rae
12  *======================================================*/
13 /* FormPreferences.h
14  * FormPreferences Interface Class
15  */
16
17 #ifndef FORMPREFERENCES_H
18 #define FORMPREFERENCES_H
19
20 #ifdef __GNUG_
21 #pragma interface
22 #endif
23
24 #include <utility> // pair
25 #include "FormBase.h"
26 #include "Color.h" // NamedColor
27 #include "xform_helpers.h" // XformColor
28
29 class Combox;
30 class Dialogs;
31 class LyXView;
32 class RGBColor;
33 struct FD_form_colors;
34 struct FD_form_converters;
35 struct FD_form_formats;
36 struct FD_form_inputs_misc;
37 struct FD_form_interface;
38 struct FD_form_language;
39 struct FD_form_lnf_misc;
40 struct FD_form_outer_tab;
41 struct FD_form_outputs_misc;
42 struct FD_form_paths;
43 struct FD_form_preferences;
44 struct FD_form_printer;
45 struct FD_form_screen_fonts;
46 struct FD_form_spellchecker;
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 FormBaseBI {
53 public:
54         /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
55         FormPreferences(LyXView *, Dialogs *);
56         ///
57         ~FormPreferences();
58         ///
59         static int FeedbackCB(FL_OBJECT *, int,
60                               FL_Coord, FL_Coord, int, void *);
61
62 private:
63         /// Connect signals etc. Set form's max size.
64         virtual void connect();
65         /// Disconnect signals. Also perform any necessary housekeeping.
66         virtual void disconnect();
67         /** Redraw the form (on receipt of a Signal indicating, for example,
68             that the xform colours have been re-mapped). */
69         virtual void redraw();
70         /// Update the dialog.
71         virtual void update();
72         /// Hide the dialog.
73         virtual void hide();
74         /// OK (Save) from dialog
75         virtual void ok();
76         /// Apply from dialog
77         virtual void apply();
78         /// Filter the inputs -- return true if entries are valid
79         virtual bool input(FL_OBJECT *, long);
80         /// Build the dialog
81         virtual void build();
82         /// Pointer to the actual instantiation of xform's form.
83         virtual FL_FORM * form() const;
84         /// control which feedback message is output
85         void feedback(FL_OBJECT *);
86
87         /// Set the preemptive handler for each FL_OBJECT.
88         static void setPreHandler(FL_OBJECT *);
89         /// The preemptive handler for feedback messages.
90         void Feedback(FL_OBJECT *, int);
91         /// Print a warning message and set warning flag.
92         void printWarning( string const & );
93         /** Launch a file dialog and modify input if it returns a new file.
94             For an explanation of the various parameters, see xform_helpers.h.
95          */
96         void browse( FL_OBJECT * input,
97                      string const & title, string const & pattern, 
98                      std::pair<string,string> const & dir1,
99                      std::pair<string,string> const & dir2 );
100         
101         /// Type definitions from the fdesign produced header file.
102         FD_form_preferences * build_preferences();
103         ///
104         FD_form_outer_tab * build_outer_tab();
105         ///
106         FD_form_colors * build_colors();
107         ///
108         FD_form_converters * build_converters();
109         ///
110         FD_form_formats * build_formats();
111         ///
112         FD_form_inputs_misc * build_inputs_misc();
113         ///
114         FD_form_interface * build_interface();
115         ///
116         FD_form_language * build_language();
117         ///
118         FD_form_lnf_misc * build_lnf_misc();
119         ///
120         FD_form_outputs_misc * build_outputs_misc();
121         ///
122         FD_form_paths * build_paths();
123         ///
124         FD_form_printer * build_printer();
125         ///
126         FD_form_screen_fonts * build_screen_fonts();
127         ///
128         FD_form_spellchecker * build_spellchecker();
129
130         /// Real GUI implementation.
131         FD_form_preferences * dialog_;
132         /// Converters tabfolder
133         FD_form_outer_tab * converters_tab_;
134         /// reLyX and other import/input stuff
135         FD_form_outer_tab * inputs_tab_;
136         /// HCI configuration
137         FD_form_outer_tab * look_n_feel_tab_;
138         /// Outputs tabfolder
139         FD_form_outer_tab * outputs_tab_;
140         /// Spellchecker, language stuff, etc
141         FD_form_outer_tab * lang_opts_tab_;
142
143         /** Flag whether a warning has been posted to the text window.
144             If so, don't redraw the window when the mouse leaves an object. */
145         bool warningPosted;
146         
147         /** Each tab folder is encapsulated in its own class.
148          */
149
150         class Colors {
151         public:
152                 ///
153                 enum GuiColors {
154                         GUI_COLOR_CHOICE = FL_FREE_COL1,
155                         GUI_COLOR_HUE_DIAL = FL_FREE_COL2,
156                         GUI_COLOR_CURSOR = FL_FREE_COL3
157                 };
158                 ///
159                 Colors( FormPreferences & p ) : parent_(p), dialog_(0) {}
160                 ///
161                 ~Colors();
162                 ///
163                 FD_form_colors const * dialog() { return dialog_; }
164                 ///
165                 void apply(); // not const as modifies modifiedXformPrefs.
166                 ///
167                 void build();
168                 ///
169                 string const feedback(FL_OBJECT const * const) const;
170                 ///
171                 void input(FL_OBJECT const * const);
172                 ///
173                 void update() { LoadBrowserLyX(); }
174                 
175                 /// Flag whether Xforms colors have changed since last file save
176                 bool modifiedXformPrefs;
177
178         private:
179                 ///
180                 void AdjustVal( int, int, double ) const;
181                 ///
182                 void InputBrowserLyX() const;
183                 ///
184                 void InputHSV();
185                 ///
186                 void InputRGB();
187                 ///
188                 void LoadBrowserLyX();
189                 ///
190                 void Modify();
191                 ///
192                 void SwitchColorSpace() const;
193                 ///
194                 string const X11hexname(RGBColor const &) const;
195
196                 ///
197                 FormPreferences & parent_;
198                 ///
199                 FD_form_colors * dialog_;
200
201                 /// A vector of LyX LColor GUI name and associated RGB color.
202                 std::vector<NamedColor> lyxColorDB;
203                 /// A vector of xform color ID, RGB colors and associated name.
204                 std::vector<XformColor> xformColorDB;
205         };
206         ///
207         friend class Colors;
208
209         ///
210         class Converters {
211         public:
212                 ///
213                 Converters( FormPreferences & p ) : parent_(p), dialog_(0) {}
214                 ///
215                 ~Converters();
216                 ///
217                 FD_form_converters const * dialog() { return dialog_; }
218                 ///
219                 void apply() const;
220                 ///
221                 void build();
222                 ///
223                 string const feedback(FL_OBJECT const * const) const;
224                 ///
225                 bool input( FL_OBJECT const * const );
226                 ///
227                 void update();
228                 ///
229                 void UpdateBrowser();
230                 ///
231                 void UpdateChoices() const;
232
233         private:
234                 ///
235                 bool Add();
236                 ///
237                 bool Browser();
238                 ///
239                 bool Delete();
240                 ///
241                 bool Input();
242                 ///
243                 string const GetFrom() const;
244                 ///
245                 string const GetTo() const;
246
247                 ///
248                 FormPreferences & parent_;
249                 ///
250                 FD_form_converters * dialog_;
251         };
252         ///
253         friend class Converters;
254
255         ///
256         class Formats {
257         public:
258                 ///
259                 Formats( FormPreferences &  p ) : parent_(p), dialog_(0) {}
260                 ///
261                 ~Formats();
262                 ///
263                 FD_form_formats const * dialog() { return dialog_; }
264                 ///
265                 void apply() const;
266                 ///
267                 void build();
268                 ///
269                 string const feedback(FL_OBJECT const * const) const;
270                 ///
271                 bool input( FL_OBJECT const * const );
272                 ///
273                 void update();
274
275         private:
276                 ///
277                 bool Add();
278                 ///
279                 bool Browser();
280                 ///
281                 void UpdateBrowser();
282                 ///
283                 bool Delete();
284                 ///
285                 bool Input();
286
287                 ///
288                 FormPreferences & parent_;
289                 ///
290                 FD_form_formats * dialog_;
291         };
292         ///
293         friend class Formats;
294
295         ///
296         class InputsMisc {
297         public:
298                 ///
299                 InputsMisc( FormPreferences &  p ) : parent_(p), dialog_(0) {}
300                 ///
301                 ~InputsMisc();
302                 ///
303                 FD_form_inputs_misc const * dialog() { return dialog_; }
304                 ///
305                 void apply() const;
306                 ///
307                 void build();
308                 ///
309                 string const feedback(FL_OBJECT const * const) const;
310                 ///
311                 void update();
312
313         private:
314                 ///
315                 FormPreferences & parent_;
316                 ///
317                 FD_form_inputs_misc * dialog_;
318         };
319         ///
320         friend class InputsMisc;
321         
322         ///
323         class Interface {
324         public:
325                 ///
326                 Interface( FormPreferences &  p ) : parent_(p), dialog_(0) {}
327                 ///
328                 ~Interface();
329                 ///
330                 FD_form_interface const * dialog() { return dialog_; }
331                 ///
332                 void apply() const;
333                 ///
334                 void build();
335                 ///
336                 string const feedback(FL_OBJECT const * const) const;
337                 ///
338                 bool input( FL_OBJECT const * const );
339                 ///
340                 void update();
341
342         private:
343                 ///
344                 FormPreferences & parent_;
345                 ///
346                 FD_form_interface * dialog_;
347         };
348         ///
349         friend class Interface;
350
351         ///
352         class Language {
353         public:
354                 ///
355                 Language( FormPreferences &  p )
356                         : parent_(p), dialog_(0), combo_default_lang(0) {}
357                 ///
358                 ~Language();
359                 ///
360                 FD_form_language const * dialog() { return dialog_; }
361                 ///
362                 void apply(); // not const because calls update()
363                 ///
364                 void build();
365                 ///
366                 string const feedback(FL_OBJECT const * const) const;
367                 ///
368                 bool input( FL_OBJECT const * const );
369                 ///
370                 void update();
371                 ///
372                 static void ComboCB(int, void *, Combox *);
373
374         private:
375                 ///
376                 FormPreferences & parent_;
377                 ///
378                 FD_form_language * dialog_;
379                 ///
380                 Combox * combo_default_lang;
381         };
382         ///
383         friend class Language;
384         
385         ///
386         class LnFmisc {
387         public:
388                 ///
389                 LnFmisc( FormPreferences &  p ) : parent_(p), dialog_(0) {}
390                 ///
391                 ~LnFmisc();
392                 ///
393                 FD_form_lnf_misc const * dialog() { return dialog_; }
394                 ///
395                 void apply() const;
396                 ///
397                 void build();
398                 ///
399                 string const feedback(FL_OBJECT const * const) const;
400                 ///
401                 void update();
402
403         private:
404                 ///
405                 FormPreferences & parent_;
406                 ///
407                 FD_form_lnf_misc * dialog_;
408         };
409         ///
410         friend class LnFmisc;
411
412         ///
413         class OutputsMisc {
414         public:
415                 ///
416                 OutputsMisc( FormPreferences &  p ) : parent_(p), dialog_(0) {}
417                 ///
418                 ~OutputsMisc();
419                 ///
420                 FD_form_outputs_misc const * dialog() { return dialog_; }
421                 ///
422                 void apply() const;
423                 ///
424                 void build();
425                 ///
426                 string const feedback(FL_OBJECT const * const) const;
427                 ///
428                 void update();
429
430         private:
431                 ///
432                 FormPreferences & parent_;
433                 ///
434                 FD_form_outputs_misc * dialog_;
435         };
436         ///
437         friend class OutputsMisc;
438
439         ///
440         class Paths {
441         public:
442                 ///
443                 Paths( FormPreferences &  p ) : parent_(p), dialog_(0) {}
444                 ///
445                 ~Paths();
446                 ///
447                 FD_form_paths const * dialog() { return dialog_; }
448                 ///
449                 void apply();
450                 ///
451                 void build();
452                 ///
453                 string const feedback(FL_OBJECT const * const) const;
454                 ///
455                 bool input(FL_OBJECT const * const);
456                 ///
457                 void update();
458
459         private:
460                 ///
461                 FormPreferences & parent_;
462                 ///
463                 FD_form_paths * dialog_;
464         };
465         ///
466         friend class Paths;
467
468         ///
469         class Printer {
470         public:
471                 ///
472                 Printer( FormPreferences &  p ) : parent_(p), dialog_(0) {}
473                 ///
474                 ~Printer();
475                 ///
476                 FD_form_printer const * dialog() { return dialog_; }
477                 ///
478                 void apply() const;
479                 ///
480                 void build();
481                 ///
482                 string const feedback(FL_OBJECT const * const) const;
483                 ///
484                 void update();
485
486         private:
487                 ///
488                 FormPreferences & parent_;
489                 ///
490                 FD_form_printer * dialog_;
491         };
492         ///
493         friend class Printer;
494
495         ///
496         class ScreenFonts {
497         public:
498                 ///
499                 ScreenFonts( FormPreferences &  p ) : parent_(p), dialog_(0) {}
500                 ///
501                 ~ScreenFonts();
502                 ///
503                 FD_form_screen_fonts const * dialog() { return dialog_; }
504                 ///
505                 void apply() const;
506                 ///
507                 void build();
508                 ///
509                 string const feedback(FL_OBJECT const * const) const;
510                 ///
511                 bool input();
512                 ///
513                 void update();
514
515         private:
516                 ///
517                 FormPreferences & parent_;
518                 ///
519                 FD_form_screen_fonts * dialog_;
520         };
521         ///
522         friend class ScreenFonts;
523
524         ///
525         class SpellChecker {
526         public:
527                 ///
528                 SpellChecker( FormPreferences &  p ) : parent_(p), dialog_(0) {}
529                 ///
530                 ~SpellChecker();
531                 ///
532                 FD_form_spellchecker const * dialog() { return dialog_; }
533                 ///
534                 void apply(); // not const because calls update()!
535                 ///
536                 void build();
537                 ///
538                 string const feedback(FL_OBJECT const * const) const;
539                 ///
540                 bool input(FL_OBJECT const * const);
541                 ///
542                 void update();
543
544         private:
545                 ///
546                 FormPreferences & parent_;
547                 ///
548                 FD_form_spellchecker * dialog_;
549         };
550         ///
551         friend class SpellChecker;
552
553         /** The tab folders.
554          */
555         
556         ///
557         Colors colors_;
558         ///
559         Converters converters_;
560         ///
561         InputsMisc inputs_misc_;
562         ///
563         Formats formats_;
564         ///
565         Interface interface_;
566         ///
567         Language language_;
568         ///
569         LnFmisc lnf_misc_;
570         ///
571         OutputsMisc outputs_misc_;
572         ///
573         Paths paths_;
574         ///
575         Printer printer_;
576         ///
577         ScreenFonts screen_fonts_;
578         ///
579         SpellChecker spellchecker_;
580
581         /** A couple of helper structs to enable colors to be sorted by name
582             and by color */
583         ///
584         struct SortColorsByName {
585                 ///
586                 int operator()(NamedColor const & a, NamedColor const & b) const
587                         { return (a.getname() < b.getname()); }
588         };
589         ///
590         struct SortColorsByColor {
591                 ///
592                 SortColorsByColor(RGBColor c) : col(c) {}
593                 ///
594                 int operator()(RGBColor const &, RGBColor const &) const;
595                 ///
596                 RGBColor col;
597         };
598
599 };
600
601 #endif