*
* \author Angus Leeming
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-
-#include "ControlPrefs.h"
#include "FormPreferences.h"
+#include "ControlPrefs.h"
#include "forms/form_preferences.h"
-#include "xformsBC.h"
-#include "ButtonController.h"
-#include "Color.h"
-#include "input_validators.h"
+#include "FormColorpicker.h"
#include "forms_gettext.h"
-#include "xforms_helpers.h"
-#include "helper_funcs.h" // getSecond
+#include "input_validators.h"
+#include "xformsBC.h"
+
+#include "controllers/helper_funcs.h" // getSecond
+#include "controllers/frnt_lang.h"
#include "buffer.h"
#include "converter.h"
#include "format.h"
-#include "debug.h"
-#include "language.h"
-#include "frnt_lang.h"
-#include "lyxlex.h"
-#include "lyxrc.h"
#include "LColor.h"
-#include "Lsstream.h"
-#include "funcrequest.h"
-#include "author.h"
+#include "lyxfont.h"
-#include "support/lyxfunctional.h"
-#include "support/lyxmanip.h"
+#include "support/lstrings.h"
+#include "support/tostr.h"
+#include "support/path_defines.h"
#include "support/filetools.h"
-#include "support/LAssert.h"
-#include "graphics/GraphicsCache.h"
-#include "graphics/GraphicsTypes.h"
-
-#include <boost/bind.hpp>
-
-#include FORMS_H_LOCATION
+#include "lyx_forms.h"
#include "combox.h"
-#include <utility>
#include <iomanip>
-#include <X11/Xlib.h>
+
+using lyx::support::AddName;
+using lyx::support::ChangeExtension;
+using lyx::support::rtrim;
+using lyx::support::strToDbl;
+using lyx::support::trim;
+using lyx::support::user_lyxdir;
using std::endl;
-using std::pair;
using std::make_pair;
using std::max;
using std::min;
+
+using std::pair;
using std::vector;
-using std::setw;
-using std::setfill;
+using std::string;
-extern string system_lyxdir;
-extern string user_lyxdir;
namespace {
}
-string const X11hexname(RGBColor const & col)
-{
- ostringstream ostr;
-
- ostr << '#' << std::setbase(16) << setfill('0')
- << setw(2) << col.r
- << setw(2) << col.g
- << setw(2) << col.b;
-
- return STRCONV(ostr.str());
-}
#if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
bool const scalableTabfolders = false;
// Stack tabs
// Now add them to the tabfolder
fl_addto_tabfolder(dialog_->tabfolder_prefs,
- _("Look & Feel"),
+ _("Look & Feel").c_str(),
look_n_feel_tab_->form);
fl_addto_tabfolder(dialog_->tabfolder_prefs,
- _("Lang Opts"),
+ _("Lang Opts").c_str(),
lang_opts_tab_->form);
fl_addto_tabfolder(dialog_->tabfolder_prefs,
- _("Conversion"),
+ _("Conversion").c_str(),
converters_tab_->form);
fl_addto_tabfolder(dialog_->tabfolder_prefs,
- _("Inputs"),
+ _("Inputs").c_str(),
inputs_tab_->form);
fl_addto_tabfolder(dialog_->tabfolder_prefs,
- _("Outputs"),
+ _("Outputs").c_str(),
outputs_tab_->form);
// now build the nested tabfolders
// Starting with look and feel
fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
- _("Screen Fonts"),
+ _("Screen Fonts").c_str(),
screen_fonts_.dialog()->form);
fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
- _("Interface"),
+ _("Interface").c_str(),
interface_.dialog()->form);
fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
- _("Colors"),
+ _("Colors").c_str(),
colors_.dialog()->form);
fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
- _("Misc"),
+ _("Misc").c_str(),
lnf_misc_.dialog()->form);
fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
- _("Identity"),
+ _("Identity").c_str(),
identity_.dialog()->form);
// then build converters
fl_addto_tabfolder(converters_tab_->tabfolder_inner,
- _("Formats"),
+ _("Formats").c_str(),
formats_.dialog()->form);
fl_addto_tabfolder(converters_tab_->tabfolder_inner,
- _("Converters"),
+ _("Converters").c_str(),
converters_.dialog()->form);
// then build inputs
// Paths should probably go in a few inner_tab called Files
fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
- _("Paths"),
+ _("Paths").c_str(),
paths_.dialog()->form);
fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
- _("Misc"),
+ _("Misc").c_str(),
inputs_misc_.dialog()->form);
// then building outputs
fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
- _("Printer"),
+ _("Printer").c_str(),
printer_.dialog()->form);
fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
- _("Misc"),
+ _("Misc").c_str(),
outputs_misc_.dialog()->form);
// then building usage
fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
- _("Spell checker"),
+ _("Spell checker").c_str(),
spelloptions_.dialog()->form);
fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
- _("Language"),
+ _("Language").c_str(),
language_.dialog()->form);
}
// The "Save" button has been pressed.
if (controller().isClosing() && colors_.modifiedXformsPrefs) {
string const filename =
- AddName(user_lyxdir, "preferences.xform");
+ AddName(user_lyxdir(), "preferences.xform");
colors_.modifiedXformsPrefs = !XformsColor::write(filename);
}
}
string const FormPreferences::getFeedback(FL_OBJECT * ob)
{
- lyx::Assert(ob);
+ BOOST_ASSERT(ob);
if (ob->form->fdui == colors_.dialog())
return colors_.feedback(ob);
ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
{
- lyx::Assert(ob);
+ BOOST_ASSERT(ob);
bool valid = true;
void FormPreferences::Colors::build()
{
+ picker_.reset(new FormColorpicker);
dialog_.reset(build_preferences_colors(&parent_));
fl_set_object_color(dialog_->button_color,
GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
- fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
- fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
- fl_set_dial_step(dialog_->dial_hue, 1.0);
- fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
-
- fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
- fl_set_slider_step(dialog_->slider_saturation, 0.01);
- fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
-
- 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);
-
// set up the feedback mechanism
setPrehandler(dialog_->browser_lyx_objs);
setPrehandler(dialog_->button_color);
setPrehandler(dialog_->button_modify);
- setPrehandler(dialog_->dial_hue);
- setPrehandler(dialog_->slider_saturation);
- setPrehandler(dialog_->slider_value);
- setPrehandler(dialog_->slider_red);
- setPrehandler(dialog_->slider_green);
- setPrehandler(dialog_->slider_blue);
- setPrehandler(dialog_->radio_rgb);
- setPrehandler(dialog_->radio_hsv);
}
if (ob == dialog_->button_modify)
return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
- if (ob == dialog_->dial_hue ||
- ob == dialog_->slider_saturation ||
- ob == dialog_->slider_value ||
- ob == dialog_->slider_red ||
- ob == dialog_->slider_green ||
- ob == dialog_->slider_blue)
- return _("Find a new color.");
-
- if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
- return _("Toggle between RGB and HSV color spaces.");
-
return string();
}
if (ob == dialog_->browser_lyx_objs) {
InputBrowserLyX();
- } else if (ob == dialog_->dial_hue ||
- ob == dialog_->slider_saturation ||
- ob == dialog_->slider_value) {
- InputHSV();
-
- } else if (ob == dialog_->slider_red ||
- ob == dialog_->slider_green ||
- ob == dialog_->slider_blue) {
- InputRGB();
-
- } else if (ob == dialog_->radio_rgb ||
- ob == dialog_->radio_hsv) {
- SwitchColorSpace();
-
} else if (ob == dialog_->button_modify) {
Modify();
}
fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
fl_redraw_object(dialog_->button_color);
- // 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);
}
-void FormPreferences::Colors::InputHSV()
-{
- double const hue = fl_get_dial_value(dialog_->dial_hue);
- double const sat = fl_get_slider_value(dialog_->slider_saturation);
- double const val = fl_get_slider_value(dialog_->slider_value);
-
- 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_redraw_object(dialog_->button_color);
-
- col = HSVColor(hue, 1.0, 1.0);
- col.r = max(col.r, 0u);
- fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
- fl_redraw_object(dialog_->dial_hue);
-
- // Ascertain whether to activate the Modify button.
- vector<NamedColor>::size_type const selLyX =
- fl_get_browser(dialog_->browser_lyx_objs);
-
- 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;
- modify = (xformsColorDB[i].color() != col);
- }
- // or a LyX Logical color?
- else {
- vector<NamedColor>::size_type const i = selLyX - 1 -
- xformsColorDB.size();
- modify = (lyxColorDB[i].color() != col);
- }
-
- setEnabled(dialog_->button_modify, modify);
-}
-
-
-void FormPreferences::Colors::InputRGB()
-{
- int const red = int(fl_get_slider_value(dialog_->slider_red));
- int const green = int(fl_get_slider_value(dialog_->slider_green));
- int const blue = int(fl_get_slider_value(dialog_->slider_blue));
-
- 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_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
- fl_redraw_object(dialog_->button_color);
-
- // Ascertain whether to activate the Modify button.
- vector<NamedColor>::size_type const selLyX =
- fl_get_browser(dialog_->browser_lyx_objs);
-
- 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;
- modify = (xformsColorDB[i].color() != col);
- }
- // or a LyX Logical color?
- else {
- vector<NamedColor>::size_type const i = selLyX - 1 -
- xformsColorDB.size();
- modify = (lyxColorDB[i].color() != col);
- }
-
- setEnabled(dialog_->button_modify, modify);
-}
-
-
void FormPreferences::Colors::LoadBrowserLyX()
{
if (!dialog_->browser_lyx_objs->visible)
if (selLyX < 1)
return;
- RGBColor col;
- fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
+ RGBColor before;
+ fl_getmcolor(GUI_COLOR_CHOICE, &before.r, &before.g, &before.b);
+
+ RGBColor col = picker_->requestColor(before);
+ if (before == col)
+ return;
+
+ fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
+ fl_redraw_object(dialog_->button_color);
// Is the choice an Xforms color...
if (selLyX - 1 < xformsColorDB.size()) {
lyxColorDB[i].g = col.g;
lyxColorDB[i].b = col.b;
}
-
- fl_freeze_form(dialog_->form);
- setEnabled(dialog_->button_modify, false);
- fl_unfreeze_form(dialog_->form);
-}
-
-
-void FormPreferences::Colors::SwitchColorSpace() const
-{
- bool const hsv = fl_get_button(dialog_->radio_hsv);
-
- RGBColor col;
- fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
-
- fl_freeze_form(dialog_->form);
-
- if (hsv) {
- fl_hide_object(dialog_->slider_red);
- fl_hide_object(dialog_->slider_blue);
- fl_hide_object(dialog_->slider_green);
- fl_show_object(dialog_->dial_hue);
- fl_show_object(dialog_->slider_saturation);
- fl_show_object(dialog_->slider_value);
-
- 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);
-
- col = HSVColor(hsv.h, 1.0, 1.0);
- col.r = max(col.r, 0u);
- fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
- fl_redraw_object(dialog_->dial_hue);
-
- // Adjust the label a bit, but not the actual values.
- // Means that toggling from one space to the other has no
- // effect on the final color.
- int const h = int(hsv.h);
- int const s = int(100 * hsv.s);
- int const v = int(100 * hsv.v);
- string const label = tostr(h) + ", " + tostr(s) +
- ", " + 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);
- fl_show_object(dialog_->slider_green);
- fl_hide_object(dialog_->dial_hue);
- fl_hide_object(dialog_->slider_saturation);
- fl_hide_object(dialog_->slider_value);
-
- fl_set_slider_value(dialog_->slider_red, col.r);
- fl_set_slider_value(dialog_->slider_green, col.g);
- fl_set_slider_value(dialog_->slider_blue, col.b);
-
- // Adjust the label a bit. Same reasoning as above.
- int const r = int(col.r);
- int const g = int(col.g);
- int const b = int(col.b);
- string const label = tostr(r) + ", " + tostr(g) +
- ", " + tostr(b);
- fl_set_object_label(dialog_->text_color_values, label.c_str());
- }
-
- fl_unfreeze_form(dialog_->form);
}
FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
{
if (ob == dialog_->browser_all)
- return _("All the currently defined converters known to LyX.");
+ return _("All explicitly defined converters for LyX");
if (ob == dialog_->choice_from)
return _("Convert \"from\" this format");
(fl_get_counter_value(dialog_->counter_wm_jump));
// See FIXME below
- // grfx::DisplayType old_value = rc.display_graphics;
+ // lyx::graphics::DisplayType old_value = rc.display_graphics;
switch (fl_get_choice(dialog_->choice_display)) {
case 4:
- rc.display_graphics = grfx::NoDisplay;
+ rc.display_graphics = lyx::graphics::NoDisplay;
break;
case 3:
- rc.display_graphics = grfx::ColorDisplay;
+ rc.display_graphics = lyx::graphics::ColorDisplay;
break;
case 2:
- rc.display_graphics = grfx::GrayscaleDisplay;
+ rc.display_graphics = lyx::graphics::GrayscaleDisplay;
break;
case 1:
- rc.display_graphics = grfx::MonochromeDisplay;
+ rc.display_graphics = lyx::graphics::MonochromeDisplay;
break;
default:
- rc.display_graphics = grfx::ColorDisplay;
+ rc.display_graphics = lyx::graphics::ColorDisplay;
break;
}
#endif
#if 0
if (old_value != rc.display_graphics) {
- grfx::GCache & gc = grfx::GCache::get();
+ lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
gc.changeDisplay();
}
#endif
setPrehandler(dialog_->check_preview_latex);
setPrehandler(dialog_->counter_wm_jump);
- fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
+ fl_addto_choice(dialog_->choice_display,
+ _("Monochrome|Grayscale|Color|Do not display").c_str());
}
fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
switch (rc.display_graphics) {
- case grfx::NoDisplay:
+ case lyx::graphics::NoDisplay:
fl_set_choice(dialog_->choice_display, 4);
break;
- case grfx::ColorDisplay:
+ case lyx::graphics::ColorDisplay:
fl_set_choice(dialog_->choice_display, 3);
break;
- case grfx::GrayscaleDisplay:
+ case lyx::graphics::GrayscaleDisplay:
fl_set_choice(dialog_->choice_display, 2);
break;
- case grfx::MonochromeDisplay:
+ case lyx::graphics::MonochromeDisplay:
fl_set_choice(dialog_->choice_display, 1);
break;
default:
int const choice =
fl_get_choice(dialog_->choice_default_papersize) - 1;
- rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
+ rc.default_papersize = static_cast<PAPER_SIZE>(choice);
rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
rc.chktex_command = fl_get_input(dialog_->input_checktex);
fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
fl_addto_choice(dialog_->choice_default_papersize,
- _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
+ _(" default | US letter | US legal "
+ "| US executive | A3 | A4 | A5 | B5 ").c_str());
// set up the feedback mechanism
setPrehandler(dialog_->counter_line_len);
dialog_.reset(build_preferences_spelloptions(&parent_));
fl_addto_choice(dialog_->choice_spell_command,
- _(" ispell | aspell "));
+ _(" ispell | aspell ").c_str());
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);