#include <config.h>
-#include <utility>
-#include <iomanip>
-#include <X11/Xlib.h>
-
-#include FORMS_H_LOCATION
-
#ifdef __GNUG_
#pragma implementation
#endif
-#include "Color.h"
-#include "LColor.h"
-#include "Lsstream.h"
#include "FormPreferences.h"
#include "form_preferences.h"
#include "ButtonController.tmpl"
-#include "input_validators.h"
+#include "Dialogs.h"
+
+#include "buffer.h"
+#include "converter.h"
+#include "debug.h"
#include "LyXView.h"
#include "language.h"
#include "lyxfunc.h"
-#include "Dialogs.h"
+#include "lyxlex.h"
#include "lyxrc.h"
+#include "LColor.h"
+#include "Lsstream.h"
+
#include "combox.h"
-#include "debug.h"
-#include "lyxlex.h"
+#include "Color.h"
#include "input_validators.h"
#include "xforms_helpers.h"
#include "helper_funcs.h"
-#include "converter.h"
#include "support/lyxfunctional.h"
#include "support/lyxmanip.h"
#include "graphics/GraphicsCache.h"
+#include <utility>
+#include <iomanip>
+#include <X11/Xlib.h>
+
using std::endl;
using std::pair;
using std::make_pair;
FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
: FormBaseBI(lv, d, _("Preferences"), false),
colors_(*this), converters_(*this), inputs_misc_(*this),
- formats_(*this), interface_(*this), language_(*this),
+ formats_(*this), interface_(*this), language_(*this),
lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
printer_(*this), screen_fonts_(*this), spelloptions_(*this)
{
AddName(user_lyxdir, "preferences.xform");
colors_.modifiedXformsPrefs = !XformsColor::write(filename);
}
-
+
lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
}
// Allow the base class to control messages
setMessageWidget(dialog_->text_warning);
-
+
// build the tab folders
converters_tab_.reset(build_inner_tab());
look_n_feel_tab_.reset(build_inner_tab());
bool FormPreferences::input(FL_OBJECT * ob, long)
{
lyx::Assert(ob);
-
+
// whatever checks you need to ensure the user hasn't entered
// some totally ridiculous value somewhere. Change activate to suit.
// comments before each test describe what is _valid_
void FormPreferences::update()
{
if (!dialog_.get()) return;
-
+
// read lyxrc entries
colors_.update();
formats_.update(); // Must be before converters_.update()
if (modifiedXformsPrefs) {
for (vector<XformsColor>::const_iterator cit =
- xformsColorDB.begin();
+ xformsColorDB.begin();
cit != xformsColorDB.end(); ++cit) {
fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
if (cit->colorID == GUI_COLOR_CURSOR) {
fl_mapcolor(GUI_COLOR_CURSOR,
cit->r, cit->g, cit->b);
- fl_set_cursor_color(FL_DEFAULT_CURSOR,
- GUI_COLOR_CURSOR, FL_WHITE);
- fl_set_cursor_color(XC_question_arrow,
- GUI_COLOR_CURSOR, FL_WHITE);
+ setCursorColor(GUI_COLOR_CURSOR);
}
}
Dialogs::redrawGUI();
// Create a valid X11 name of the form "#rrggbb"
string const hexname = X11hexname(cit->color());
-
+
if (lcolor.getX11Name(lc) != hexname) {
lyxerr[Debug::GUI]
<< "FormPreferences::Colors::apply: "
fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
fl_set_slider_step(dialog_->slider_value, 0.01);
fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
-
+
fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
fl_set_slider_step(dialog_->slider_red, 1.0);
fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
-
+
fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
fl_set_slider_step(dialog_->slider_green, 1.0);
fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
-
+
fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
fl_set_slider_step(dialog_->slider_blue, 1.0);
fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
{
if (ob == dialog_->browser_lyx_objs) {
InputBrowserLyX();
-
+
} else if (ob == dialog_->dial_hue ||
ob == dialog_->slider_saturation ||
ob == dialog_->slider_value) {
// Display either RGB or HSV but not both!
SwitchColorSpace();
-
+
// Deactivate the modify button to begin with...
setEnabled(dialog_->button_modify, false);
-
+
fl_unfreeze_form(dialog_->form);
}
int const h = int(hue);
int const s = int(100.0 * sat);
int const v = int(100.0 * val);
-
+
string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
tostr(v);
fl_set_object_label(dialog_->text_color_values, label.c_str());
RGBColor col = HSVColor(hue, sat, val);
-
+
fl_freeze_form(dialog_->form);
fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
fl_unfreeze_form(dialog_->form);
if (selLyX < 1) return;
-
+
fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
bool modify = false;
-
+
// Is the choice an Xforms color...
if (selLyX - 1 < xformsColorDB.size()) {
vector<XformsColor>::size_type const i = selLyX - 1;
string const label = tostr(red) + string(", ") + tostr(green) +
string(", ") + tostr(blue);
fl_set_object_label(dialog_->text_color_values, label.c_str());
-
+
fl_freeze_form(dialog_->form);
RGBColor col = RGBColor(red, green, blue);
fl_unfreeze_form(dialog_->form);
if (selLyX < 1) return;
-
+
bool modify = false;
-
+
// Is the choice an Xforms color...
if (selLyX - 1 < xformsColorDB.size()) {
vector<XformsColor>::size_type const i = selLyX - 1;
}
fl_freeze_form(dialog_->form);
- setEnabled(dialog_->button_modify, false);
+ setEnabled(dialog_->button_modify, false);
fl_unfreeze_form(dialog_->form);
}
HSVColor hsv = HSVColor(col);
hsv.h = max(hsv.h, 0.0);
-
+
fl_set_dial_value(dialog_->dial_hue, hsv.h);
fl_set_slider_value(dialog_->slider_saturation, hsv.s);
fl_set_slider_value(dialog_->slider_value, hsv.v);
string const label = tostr(h) + string(", ") + tostr(s) +
string(", ") + tostr(v);
fl_set_object_label(dialog_->text_color_values, label.c_str());
-
+
} else {
fl_show_object(dialog_->slider_red);
fl_show_object(dialog_->slider_blue);
string(", ") + tostr(b);
fl_set_object_label(dialog_->text_color_values, label.c_str());
}
-
+
fl_unfreeze_form(dialog_->form);
}
}
-bool FormPreferences::Converters::Browser()
+bool FormPreferences::Converters::Browser()
{
int const i = fl_get_browser(dialog_->browser_all);
if (i <= 0) return false;
setEnabled(dialog_->button_add, false);
setEnabled(dialog_->button_delete, true);
-
+
fl_unfreeze_form(dialog_->form);
return false;
}
string const from = GetFrom();
string const to = GetTo();
int const sel = local_converters.getNumber(from, to);
-
+
fl_freeze_form(dialog_->form);
if (sel < 0) {
fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
- fl_set_button_shortcut(dialog_->button_add,
+ fl_set_button_shortcut(dialog_->button_add,
scex(_("Add|#A")), 1);
fl_deselect_browser(dialog_->browser_all);
} else {
fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
fl_set_button_shortcut(dialog_->button_add,
- scex(_("Modify|#M")), 1);
-
+ scex(_("Modify|#M")), 1);
+
int top = max(sel-5, 0);
fl_set_browser_topline(dialog_->browser_all, top);
fl_select_browser_line(dialog_->browser_all, sel+1);
}
-bool FormPreferences::Formats::Browser()
+bool FormPreferences::Formats::Browser()
{
int const i = fl_get_browser(dialog_->browser_all);
if (i <= 0) return false;
setEnabled(dialog_->button_add, false);
setEnabled(dialog_->button_delete, true);
-
+
fl_unfreeze_form(dialog_->form);
return false;
}
if (sel < 0) {
fl_set_object_label(dialog_->button_add,
- idex(_("Add|#A")));
+ idex(_("Add|#A")));
fl_set_button_shortcut(dialog_->button_add,
- scex(_("Add|#A")), 1);
+ scex(_("Add|#A")), 1);
fl_deselect_browser(dialog_->browser_all);
setEnabled(dialog_->button_delete, false);
} else {
fl_set_object_label(dialog_->button_add,
- idex(_("Modify|#M")));
+ idex(_("Modify|#M")));
fl_set_button_shortcut(dialog_->button_add,
- scex(_("Modify|#M")), 1);
+ scex(_("Modify|#M")), 1);
int const top = max(sel-5, 0);
fl_set_browser_topline(dialog_->browser_all, top);
parent_.browse(dialog_->input_bind_file,
N_("Bind file"), "*.bind", dir1, dir2);
-
+
} else if (ob == dialog_->button_ui_file_browse) {
string dir = AddName(system_lyxdir, "ui");
string name = N_("Sys UI|#S#s");
parent_.browse(dialog_->input_ui_file,
N_("UI file"), "*.ui", dir1, dir2);
}
-
+
return true;
}
lyxrc.primary_kbmap = name_1;
lyxrc.secondary_kbmap = name_2;
}
-
+
button = fl_get_button(dialog_->check_rtl_support);
lyxrc.rtl_support = static_cast<bool>(button);
combo_default_lang->setcallback(ComboCB, &parent_);
for (Languages::const_iterator cit = languages.begin();
- cit != languages.end(); ++cit) {
+ cit != languages.end(); ++cit) {
combo_default_lang->addto(cit->second.lang());
}
// to use its address in a block-if statement.
// No it's not! Leads to crash.
// setPrehandler(
- // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
+ // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
// C_FormPreferencesFeedbackCB);
setPrehandler(dialog_->input_kbmap1);
fl_set_input(dialog_->input_kbmap1, "");
fl_set_input(dialog_->input_kbmap2, "");
}
-
+
fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
fl_set_button(dialog_->check_mark_foreign,
lyxrc.mark_foreign_language);
void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
{
- FormPreferences * pre = static_cast<FormPreferences*>(v);
- // This is safe, as nothing is done to the pointer, other than
- // to use its address in a block-if statement.
- pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
+ FormPreferences * pre = static_cast<FormPreferences*>(v);
+ // This is safe, as nothing is done to the pointer, other than
+ // to use its address in a block-if statement.
+ pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
}
void FormPreferences::LnFmisc::update()
{
fl_set_button(dialog_->check_banner, lyxrc.show_banner);
- fl_set_button(dialog_->check_auto_region_delete,
+ fl_set_button(dialog_->check_auto_region_delete,
lyxrc.auto_region_delete);
fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
fl_set_input(dialog_->input_checktex,
lyxrc.chktex_command.c_str());
fl_set_input(dialog_->input_paperoption,
- lyxrc.view_dvi_paper_option.c_str());
+ lyxrc.view_dvi_paper_option.c_str());
fl_set_button(dialog_->check_autoreset_classopt,
- lyxrc.auto_reset_options);
+ lyxrc.auto_reset_options);
}
button = fl_get_button(dialog_->check_last_files);
str = fl_get_input(dialog_->input_lastfiles);
if (!button) str.erase();
-
+
lyxrc.check_lastfiles = button;
lyxrc.lastfiles = str;
lyxrc.num_lastfiles = static_cast<unsigned int>
bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
{
bool activate = true;
-
+
// !ob if function is called from Paths::update() to de/activate
// objects,
// otherwise the function is called by an xforms CB via input().
parent_.browse(dialog_->input_serverpipe,
N_("LyX Server pipes"), string());
}
-
+
return activate;
}
if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
fl_set_button(dialog_->check_last_files,
- lyxrc.check_lastfiles);
+ lyxrc.check_lastfiles);
fl_set_input(dialog_->input_lastfiles, str.c_str());
fl_set_counter_value(dialog_->counter_lastfiles,
lyxrc.num_lastfiles);
changed = true;
lyxrc.dpi = ivalue;
}
-
+
double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
changed = true;
setPrehandler(dialog_->input_huger);
}
-
+
string const
FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
{
str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
else if (ob == dialog_->counter_zoom)
str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
- else if (ob == dialog_->counter_dpi)
+ else if (ob == dialog_->counter_dpi)
str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
else if (ob == dialog_->input_tiny
|| ob == dialog_->input_script
activate = false;
str = N_("Fonts must be positive!");
- // Fontsizes -- tiny < script < footnote etc.
} else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
+ // Fontsizes -- tiny < script < footnote etc.
strToDbl(fl_get_input(dialog_->input_script)) ||
strToDbl(fl_get_input(dialog_->input_script)) >
strToDbl(fl_get_input(dialog_->input_footnote)) ||
if (!activate)
parent_.postWarning(str);
-
+
return activate;
}
string choice = fl_get_choice_text(dialog_->choice_spell_command);
choice = strip(frontStrip(choice));
-
+
lyxrc.isp_command = choice;
#if 0
choice = fl_get_input(dialog_->input_escape_chars);
if (button && choice.empty()) button = 0;
if (!button) choice.erase();
-
+
lyxrc.isp_use_esc_chars = static_cast<bool>(button);
lyxrc.isp_esc_chars = choice;
dialog_.reset(parent_.build_spelloptions());
fl_addto_choice(dialog_->choice_spell_command,
-#if 0
- _(" none | ispell | aspell "));
-#else
_(" ispell | aspell "));
-#endif
fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
parent_.browse(dialog_->input_personal_dict,
N_("Personal dictionary"), "*.ispell");
}
-
+
return true; // All input is valid!
}
choice = 2;
#endif
fl_set_choice(dialog_->choice_spell_command, choice);
-
+
string str;
if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
fl_set_button(dialog_->check_alt_lang,
lyxrc.isp_use_alt_lang);
fl_set_input(dialog_->input_alt_lang, str.c_str());
-
+
str.erase();
if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
void FormPreferences::browse(FL_OBJECT * inpt,
string const & title,
- string const & pattern,
+ string const & pattern,
pair<string,string> const & dir1,
pair<string,string> const & dir2)
{