2 * FormPreferences Interface Class Implementation
6 #include "lyx_gui_misc.h"
8 #include FORMS_H_LOCATION
10 #include "FormPreferences.h"
11 #include "form_preferences.h"
12 #include "xform_macros.h"
13 #include "input_validators.h"
21 #ifdef SIGC_CXX_NAMESPACES
25 C_RETURNCB(FormPreferences, WMHideCB)
26 C_GENERICCB(FormPreferences, OKCB)
27 C_GENERICCB(FormPreferences, ApplyCB)
28 C_GENERICCB(FormPreferences, CancelCB)
29 C_GENERICCB(FormPreferences, InputCB)
32 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
33 : dialog_(0), bind_(0), misc_(0), screen_fonts_(0),
34 interface_fonts_(0), printer_(0), paths_(0),
35 lv_(lv), d_(d), u_(0), h_(0)
37 // let the dialog be shown
38 // This is a permanent connection so we won't bother
39 // storing a copy because we won't be disconnecting.
40 d->showPreferences.connect(slot(this,&FormPreferences::show));
44 FormPreferences::~FormPreferences()
50 void FormPreferences::build()
52 dialog_ = build_preferences();
54 screen_fonts_ = build_screen_fonts();
55 interface_fonts_ = build_interface_fonts();
57 printer_ = build_printer();
58 paths_ = build_paths();
60 fl_addto_tabfolder(dialog_->tabfolder_prefs,
63 fl_addto_tabfolder(dialog_->tabfolder_prefs,
65 screen_fonts_->form_screen_fonts);
66 fl_addto_tabfolder(dialog_->tabfolder_prefs,
68 interface_fonts_->form_interface_fonts);
69 fl_addto_tabfolder(dialog_->tabfolder_prefs,
72 fl_addto_tabfolder(dialog_->tabfolder_prefs,
74 printer_->form_printer);
75 fl_addto_tabfolder(dialog_->tabfolder_prefs,
79 fl_set_form_atclose(dialog_->form_preferences,
80 C_FormPreferencesWMHideCB, 0);
84 void FormPreferences::show()
89 update(); // make sure its up-to-date
91 if (dialog_->form_preferences->visible) {
92 fl_raise_form(dialog_->form_preferences);
94 fl_show_form(dialog_->form_preferences,
95 FL_PLACE_MOUSE | FL_FREE_SIZE,
102 void FormPreferences::hide()
105 && dialog_->form_preferences
106 && dialog_->form_preferences->visible) {
107 fl_hide_form(dialog_->form_preferences);
112 void FormPreferences::apply()
114 // set the new lyxrc entries
115 // many of these need to trigger other functions when the assignment
116 // is made. For example, screen zoom and font types. These could be
117 // handled either by signals/slots in lyxrc or just directly call the
118 // associated functions here.
121 lyxrc.bind_file = fl_get_input(bind_->input_bind);
123 lyxrc.show_banner = fl_get_button(misc_->check_banner);
124 lyxrc.auto_region_delete = fl_get_button(misc_->
125 check_auto_region_delete);
126 lyxrc.exit_confirmation = fl_get_button(misc_->check_exit_confirm);
127 lyxrc.display_shortcuts = fl_get_button(misc_->check_display_shortcuts);
128 lyxrc.autosave = static_cast<unsigned int>
129 (fl_get_counter_value(misc_->counter_autosave));
130 lyxrc.ascii_linelen = static_cast<unsigned int>
131 (fl_get_counter_value(misc_->counter_line_len));
133 lyxrc.roman_font_name = fl_get_input(screen_fonts_->input_roman);
134 lyxrc.sans_font_name = fl_get_input(screen_fonts_->input_sans);
135 lyxrc.typewriter_font_name = fl_get_input(screen_fonts_->
137 lyxrc.font_norm = fl_get_input(screen_fonts_->input_encoding);
138 lyxrc.use_scalable_fonts = fl_get_button(screen_fonts_->check_scalable);
139 lyxrc.zoom = static_cast<unsigned int>
140 (fl_get_counter_value(screen_fonts_->counter_zoom));
141 lyxrc.font_sizes[LyXFont::SIZE_TINY] =
142 strToDbl(fl_get_input(screen_fonts_->input_tiny));
143 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] =
144 strToDbl(fl_get_input(screen_fonts_->input_script));
145 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] =
146 strToDbl(fl_get_input(screen_fonts_->input_footnote));
147 lyxrc.font_sizes[LyXFont::SIZE_SMALL] =
148 strToDbl(fl_get_input(screen_fonts_->input_small));
149 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] =
150 strToDbl(fl_get_input(screen_fonts_->input_normal));
151 lyxrc.font_sizes[LyXFont::SIZE_LARGE] =
152 strToDbl(fl_get_input(screen_fonts_->input_large));
153 lyxrc.font_sizes[LyXFont::SIZE_LARGER] =
154 strToDbl(fl_get_input(screen_fonts_->input_larger));
155 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] =
156 strToDbl(fl_get_input(screen_fonts_->input_largest));
157 lyxrc.font_sizes[LyXFont::SIZE_HUGE] =
158 strToDbl(fl_get_input(screen_fonts_->input_huge));
159 lyxrc.font_sizes[LyXFont::SIZE_HUGER] =
160 strToDbl(fl_get_input(screen_fonts_->input_huger));
162 lyxrc.popup_font_name =
163 fl_get_input(interface_fonts_->input_popup_font);
164 lyxrc.menu_font_name = fl_get_input(interface_fonts_->input_menu_font);
165 lyxrc.font_norm_menu = fl_get_input(interface_fonts_->input_encoding);
167 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
168 lyxrc.print_command = fl_get_input(printer_->input_command);
169 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
170 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
171 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
172 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
173 lyxrc.print_file_extension =
174 fl_get_input(printer_->input_file_extension);
175 lyxrc.print_spool_command =
176 fl_get_input(printer_->input_spool_command);
177 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
178 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
179 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
180 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
181 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
182 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
183 lyxrc.print_extra_options =
184 fl_get_input(printer_->input_extra_options);
185 lyxrc.print_spool_printerprefix =
186 fl_get_input(printer_->input_spool_prefix);
187 lyxrc.print_paper_dimension_flag =
188 fl_get_input(printer_->input_paper_size);
189 lyxrc.printer = fl_get_input(printer_->input_name);
191 lyxrc.document_path = fl_get_input(paths_->input_default_path);
192 lyxrc.template_path = fl_get_input(paths_->input_template_path);
193 lyxrc.tempdir_path = fl_get_input(paths_->input_temp_dir);
194 lyxrc.lastfiles = fl_get_input(paths_->input_lastfiles);
195 lyxrc.backupdir_path = fl_get_input(paths_->input_backup_path);
196 lyxrc.use_tempdir = fl_get_button(paths_->check_use_temp_dir);
197 lyxrc.check_lastfiles = fl_get_button(paths_->check_last_files);
198 lyxrc.make_backup = fl_get_button(paths_->check_make_backups);
199 lyxrc.num_lastfiles = static_cast<unsigned int>
200 (fl_get_counter_value(paths_->counter_lastfiles));
204 void FormPreferences::update()
207 // read lyxrc entries
209 fl_set_input(bind_->input_bind, lyxrc.bind_file.c_str());
211 fl_set_button(misc_->check_banner,
213 fl_set_button(misc_->check_auto_region_delete,
214 lyxrc.auto_region_delete);
215 fl_set_button(misc_->check_exit_confirm,
216 lyxrc.exit_confirmation);
217 fl_set_button(misc_->check_display_shortcuts,
218 lyxrc.display_shortcuts);
219 fl_set_counter_value(misc_->counter_autosave,
221 fl_set_counter_value(misc_->counter_line_len,
222 lyxrc.ascii_linelen);
224 fl_set_input(screen_fonts_->input_roman,
225 lyxrc.roman_font_name.c_str());
226 fl_set_input(screen_fonts_->input_sans,
227 lyxrc.sans_font_name.c_str());
228 fl_set_input(screen_fonts_->input_typewriter,
229 lyxrc.typewriter_font_name.c_str());
230 fl_set_input(screen_fonts_->input_encoding,
231 lyxrc.font_norm.c_str());
232 fl_set_button(screen_fonts_->check_scalable,
233 lyxrc.use_scalable_fonts);
234 fl_set_counter_value(screen_fonts_->counter_zoom,
236 fl_set_input(screen_fonts_->input_tiny,
237 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
238 fl_set_input(screen_fonts_->input_script,
239 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
240 fl_set_input(screen_fonts_->input_footnote,
241 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
242 fl_set_input(screen_fonts_->input_small,
243 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
244 fl_set_input(screen_fonts_->input_normal,
245 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
246 fl_set_input(screen_fonts_->input_large,
247 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
248 fl_set_input(screen_fonts_->input_larger,
249 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
250 fl_set_input(screen_fonts_->input_largest,
251 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
252 fl_set_input(screen_fonts_->input_huge,
253 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
254 fl_set_input(screen_fonts_->input_huger,
255 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
257 fl_set_input(interface_fonts_->input_popup_font,
258 lyxrc.popup_font_name.c_str());
259 fl_set_input(interface_fonts_->input_menu_font,
260 lyxrc.menu_font_name.c_str());
261 fl_set_input(interface_fonts_->input_encoding,
262 lyxrc.font_norm_menu.c_str());
264 fl_set_button(printer_->check_adapt_output,
265 lyxrc.print_adapt_output);
266 fl_set_input(printer_->input_command,
267 lyxrc.print_command.c_str());
268 fl_set_input(printer_->input_page_range,
269 lyxrc.print_pagerange_flag.c_str());
270 fl_set_input(printer_->input_copies,
271 lyxrc.print_copies_flag.c_str());
272 fl_set_input(printer_->input_reverse,
273 lyxrc.print_reverse_flag.c_str());
274 fl_set_input(printer_->input_to_printer,
275 lyxrc.print_to_printer.c_str());
276 fl_set_input(printer_->input_file_extension,
277 lyxrc.print_file_extension.c_str());
278 fl_set_input(printer_->input_spool_command,
279 lyxrc.print_spool_command.c_str());
280 fl_set_input(printer_->input_paper_type,
281 lyxrc.print_paper_flag.c_str());
282 fl_set_input(printer_->input_even_pages,
283 lyxrc.print_evenpage_flag.c_str());
284 fl_set_input(printer_->input_odd_pages,
285 lyxrc.print_oddpage_flag.c_str());
286 fl_set_input(printer_->input_collated,
287 lyxrc.print_collcopies_flag.c_str());
288 fl_set_input(printer_->input_landscape,
289 lyxrc.print_landscape_flag.c_str());
290 fl_set_input(printer_->input_to_file,
291 lyxrc.print_to_file.c_str());
292 fl_set_input(printer_->input_extra_options,
293 lyxrc.print_extra_options.c_str());
294 fl_set_input(printer_->input_spool_prefix,
295 lyxrc.print_spool_printerprefix.c_str());
296 fl_set_input(printer_->input_paper_size,
297 lyxrc.print_paper_dimension_flag.c_str());
298 fl_set_input(printer_->input_name,
299 lyxrc.printer.c_str());
301 fl_set_input(paths_->input_default_path,
302 lyxrc.document_path.c_str());
303 fl_set_input(paths_->input_template_path,
304 lyxrc.template_path.c_str());
305 fl_set_input(paths_->input_temp_dir,
306 lyxrc.tempdir_path.c_str());
307 fl_set_input(paths_->input_lastfiles,
308 lyxrc.lastfiles.c_str());
309 fl_set_input(paths_->input_backup_path,
310 lyxrc.backupdir_path.c_str());
311 fl_set_button(paths_->check_use_temp_dir,
313 fl_set_button(paths_->check_last_files,
314 lyxrc.check_lastfiles);
315 fl_set_button(paths_->check_make_backups,
317 fl_set_counter_value(paths_->counter_lastfiles,
318 lyxrc.num_lastfiles);
323 void FormPreferences::input()
325 bool activate = true;
327 // whatever checks you need
330 fl_activate_object(dialog_->button_ok);
331 fl_activate_object(dialog_->button_apply);
332 fl_set_object_lcol(dialog_->button_ok, FL_BLACK);
333 fl_set_object_lcol(dialog_->button_apply, FL_BLACK);
335 fl_deactivate_object(dialog_->button_ok);
336 fl_deactivate_object(dialog_->button_apply);
337 fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE);
338 fl_set_object_lcol(dialog_->button_apply, FL_INACTIVE);
343 void FormPreferences::free()
345 // we don't need to delete u and h here because
346 // hide() does that after disconnecting.
348 if (dialog_->form_preferences
349 && dialog_->form_preferences->visible) {
352 fl_free_form(dialog_->form_preferences);
359 int FormPreferences::WMHideCB(FL_FORM * form, void *)
361 // Ensure that the signals (u and h) are disconnected even if the
362 // window manager is used to close the dialog.
363 FormPreferences * pre = static_cast<FormPreferences*>(form->u_vdata);
369 void FormPreferences::OKCB(FL_OBJECT * ob, long)
371 FormPreferences * pre = static_cast<FormPreferences*>(ob->form->u_vdata);
375 pre->lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
379 void FormPreferences::ApplyCB(FL_OBJECT * ob, long)
381 FormPreferences * pre = static_cast<FormPreferences*>(ob->form->u_vdata);
386 void FormPreferences::CancelCB(FL_OBJECT * ob, long)
388 FormPreferences * pre = static_cast<FormPreferences*>(ob->form->u_vdata);
393 void FormPreferences::InputCB(FL_OBJECT * ob, long)
395 FormPreferences * pre = static_cast<FormPreferences*>(ob->form->u_vdata);