]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreferences.h
f855cf0d80802a3a16247414ee404a97f133bb0e
[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 "FormBase.h"
21
22 #ifdef __GNUG_
23 #pragma interface
24 #endif
25
26 class LyXView;
27 class Dialogs;
28 struct FD_form_colours;
29 struct FD_form_converters;
30 struct FD_form_formats;
31 struct FD_form_inputs_misc;
32 struct FD_form_interface;
33 struct FD_form_language;
34 struct FD_form_lnf_misc;
35 struct FD_form_outer_tab;
36 struct FD_form_outputs_misc;
37 struct FD_form_paths;
38 struct FD_form_preferences;
39 struct FD_form_printer;
40 struct FD_form_screen_fonts;
41 struct FD_form_spellchecker;
42 class Combox;
43 class Format;
44
45 /** This class provides an XForms implementation of the FormPreferences Dialog.
46     The preferences dialog allows users to set/save their preferences.
47  */
48 class FormPreferences : public FormBaseBI {
49 public:
50         /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
51         FormPreferences(LyXView *, Dialogs *);
52         ///
53         ~FormPreferences();
54         ///
55         static void ComboLanguageCB(int, void *, Combox *);
56         ///
57         static void FeedbackCB(FL_OBJECT *, long);
58         ///
59         void feedbackPost(FL_OBJECT *, int);
60
61 private:
62         /// helper struct for Colours
63         struct RGB {
64                 int r;
65                 int g;
66                 int b;
67                 RGB() : r(0), g(0), b(0) {}
68                 RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
69         };
70         ///
71         friend bool operator==(RGB const &, RGB const &);
72         ///
73         friend bool operator!=(RGB const &, RGB const &);
74         ///
75         typedef std::pair<string, RGB> X11Colour;
76
77         /// Update the dialog.
78         virtual void update();
79         ///
80         virtual void hide();
81         /// OK from dialog
82         virtual void ok();
83         /// Apply from dialog
84         virtual void apply();
85         /// Filter the inputs -- return true if entries are valid
86         virtual bool input(FL_OBJECT *, long);
87         /// Build the dialog
88         virtual void build();
89         /// control which feedback message is output
90         void feedback( FL_OBJECT * );
91         ///
92         virtual FL_FORM * form() const;
93
94         /** Folder specific apply functions.
95          */
96         
97         ///
98         void applyColours() const;
99         ///
100         void applyConverters() const;
101         ///
102         void applyFormats() const;
103         ///
104         void applyInputsMisc() const;
105         ///
106         void applyInterface() const;
107         ///
108         void applyLanguage(); // not const because calls updateLanguage!
109         ///
110         void applyLnFmisc() const;
111         ///
112         void applyOutputsMisc() const;
113         ///
114         void applyPaths(); // not const because calls updatePaths!
115         ///
116         void applyPrinter() const;
117         ///
118         void applyScreenFonts() const;
119         ///
120         void applySpellChecker(); // not const because calls updateSpellChecker!
121
122         /** Folder specific build functions.
123          */
124         
125         ///
126         void buildColours();
127         ///
128         void buildConverters();
129         ///
130         void buildFormats();
131         ///
132         void buildInputsMisc();
133         ///
134         void buildInterface();
135         ///
136         void buildLanguage();
137         ///
138         void buildLnFmisc();
139         ///
140         void buildOutputsMisc();
141         ///
142         void buildPaths();
143         ///
144         void buildPrinter();
145         ///
146         void buildScreenFonts();
147         ///
148         void buildSpellchecker();
149
150         /** Folder specific feedback functions.
151          */
152         
153         ///
154         string const feedbackColours(FL_OBJECT const * const) const;
155         ///
156         string const feedbackConverters(FL_OBJECT const * const) const;
157         ///
158         string const feedbackFormats( FL_OBJECT const * const ) const;
159         ///
160         string const feedbackInputsMisc(FL_OBJECT const * const) const;
161         ///
162         string const feedbackInterface(FL_OBJECT const * const) const;
163         ///
164         string const feedbackLanguage(FL_OBJECT const * const) const;
165         ///
166         string const feedbackLnFmisc(FL_OBJECT const * const) const;
167         ///
168         string const feedbackOutputsMisc(FL_OBJECT const * const) const;
169         ///
170         string const feedbackPaths(FL_OBJECT const * const) const;
171         ///
172         string const feedbackPrinter(FL_OBJECT const * const) const;
173         ///
174         string const feedbackScreenFonts(FL_OBJECT const * const) const;
175         ///
176         string const feedbackSpellChecker(FL_OBJECT const * const) const;
177
178         /** Folder specific input functions. Not all folders require one.
179          */
180         
181         ///
182         bool inputColours(FL_OBJECT const * const);
183         ///
184         bool inputFormats( FL_OBJECT const * const );
185         ///
186         bool inputLanguage(FL_OBJECT const * const);
187         ///
188         bool inputPaths(FL_OBJECT const * const);
189         ///
190         bool inputScreenFonts();
191         ///
192         bool inputSpellChecker(FL_OBJECT const * const);
193
194         /** Folder specific update functions.
195          */
196         
197         ///
198         void updateColours();
199         ///
200         void updateConverters();
201         ///
202         void updateFormats();
203         ///
204         void updateInputsMisc();
205         ///
206         void updateInterface();
207         ///
208         void updateLanguage();
209         ///
210         void updateLnFmisc();
211         ///
212         void updateOutputsMisc();
213         ///
214         void updatePaths();
215         ///
216         void updatePrinter();
217         ///
218         void updateScreenFonts();
219         ///
220         void updateSpellChecker();
221
222         /** Some helper functions for specific folders.
223          */
224         
225         ///
226         bool ColoursLoadBrowser( string const & );
227         ///
228         int  ColoursSearchEntry(RGB const & ) const;
229         ///
230         void ColoursUpdateBrowser( int );
231         ///
232         void ColoursUpdateRGB();
233         ///
234         bool FormatsInputAdd();
235         ///
236         bool FormatsInputBrowser();
237         ///
238         bool FormatsInputDelete();
239         ///
240         bool FormatsInputInput();
241
242         ///
243         bool WriteableDir( string const & ) const;
244         ///
245         bool ReadableDir( string const & ) const;
246         ///
247         bool WriteableFile( string const &, string const & = string() ) const;
248
249         /// The timer post handler.
250         void setPostHandler( FL_OBJECT * ) const;
251
252         /// Type definitions from the fdesign produced header file.
253         FD_form_preferences * build_preferences();
254         ///
255         FD_form_outer_tab * build_outer_tab();
256         ///
257         FD_form_colours * build_colours();
258         ///
259         FD_form_converters * build_converters();
260         ///
261         FD_form_formats * build_formats();
262         ///
263         FD_form_inputs_misc * build_inputs_misc();
264         ///
265         FD_form_interface * build_interface();
266         ///
267         FD_form_language * build_language();
268         ///
269         FD_form_lnf_misc * build_lnf_misc();
270         ///
271         FD_form_outputs_misc * build_outputs_misc();
272         ///
273         FD_form_paths * build_paths();
274         ///
275         FD_form_printer * build_printer();
276         ///
277         FD_form_screen_fonts * build_screen_fonts();
278         ///
279         FD_form_spellchecker * build_spellchecker();
280
281         /// Real GUI implementation.
282         FD_form_preferences * dialog_;
283         /// Converters tabfolder
284         FD_form_outer_tab * converters_tab_;
285         /// reLyX and other import/input stuff
286         FD_form_outer_tab * inputs_tab_;
287         /// HCI configuration
288         FD_form_outer_tab * look_n_feel_tab_;
289         /// Outputs tabfolder
290         FD_form_outer_tab * outputs_tab_;
291         /// Spellchecker, language stuff, etc
292         FD_form_outer_tab * usage_tab_;
293         ///
294         FD_form_colours * colours_;
295         ///
296         FD_form_converters * converters_;
297         ///
298         FD_form_formats * formats_;
299         ///
300         FD_form_inputs_misc * inputs_misc_;
301         ///
302         FD_form_interface * interface_;
303         ///
304         FD_form_language * language_;
305         ///
306         FD_form_lnf_misc * lnf_misc_;
307         ///
308         FD_form_outputs_misc * outputs_misc_;
309         ///
310         FD_form_paths * paths_;
311         ///
312         FD_form_printer * printer_;
313         ///
314         FD_form_screen_fonts * screen_fonts_;
315         ///
316         FD_form_spellchecker * spellchecker_;
317         ///
318         Combox * combo_default_lang;
319         ///
320         Combox * combo_kbmap_1;
321         ///
322         Combox * combo_kbmap_2;
323         /// 
324         FL_OBJECT * feedbackObj;
325
326         /// A vector of Formats, to be manipulated in the Format browser.
327         std::vector<Format> formats_vec;
328         /// A vector of RGB colours and associated name.
329         static std::vector<X11Colour> colourDB;
330         /** A collection of kmap files.
331             First entry is the file name, full path.
332             Second entry is the shorthand, as appears in the fl_choice.
333             Eg, system_lyxdir/kbd/american2.kmap, american2
334         */
335         static std::pair<std::vector<string>, std::vector<string> > dirlist;
336 };
337
338 inline
339 bool operator==(FormPreferences::RGB const & c1,
340                 FormPreferences::RGB const & c2)
341 {
342         return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
343 }
344
345
346 inline
347 bool operator!=(FormPreferences::RGB const & c1,
348                 FormPreferences::RGB const & c2)
349 {
350         return !(c1 == c2);
351 }
352
353 #endif