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