/**
* \file FormCharacter.C
- * Copyright 2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author Edwin Leuven, leuven@fee.uva.nl
- * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Edwin Leuven
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS.
*/
-#include <vector>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include <config.h>
-#include "xformsBC.h"
-#include "ControlCharacter.h"
#include "FormCharacter.h"
#include "forms/form_character.h"
-#include "gettext.h"
-#include "combox.h"
-#include "helper_funcs.h"
+
#include "xforms_helpers.h"
-#include FORMS_H_LOCATION
+#include "xformsBC.h"
-#include "frnt_lang.h"
+#include "controllers/frnt_lang.h"
+#include "controllers/helper_funcs.h"
+
+#include "LColor.h"
#include "support/lstrings.h"
+#include "lyx_forms.h"
+#include "combox.h"
+
+using frnt::BarPair;
+using frnt::ColorPair;
+using frnt::FamilyPair;
+using frnt::getBarData;
+using frnt::getColorData;
+using frnt::getFamilyData;
+using frnt::getLanguageData;
+using frnt::getSeriesData;
+using frnt::getShapeData;
+using frnt::getSizeData;
+using frnt::LanguagePair;
+using frnt::SeriesPair;
+using frnt::ShapePair;
+using frnt::SizePair;
+
+using lyx::support::getStringFromVector;
+
using std::vector;
-using std::find;
+using std::string;
-using namespace frnt;
-typedef FormCB<ControlCharacter, FormDB<FD_character> > base_class;
+typedef FormController<ControlCharacter, FormView<FD_character> > base_class;
-FormCharacter::FormCharacter(ControlCharacter & c, Dialogs & d)
- : base_class(c, d, _("Character Layout"), false)
+FormCharacter::FormCharacter(Dialog & parent)
+ : base_class(parent, _("Text Style"), false)
{}
-void FormCharacter::ComboInputCB(int, void * v, Combox *)
-{
- FormCharacter * pre = static_cast<FormCharacter*>(v);
- // must use input() directly, to avoid treating the Combox
- // as an FL_OBJECT, leading to a crash (bug 406)
- pre->bc().input(pre->input(0, 0));
-}
-
void FormCharacter::build()
{
dialog_.reset(build_character(this));
// create a string of entries " entry1 | entry2 | entry3 | entry4 "
// with which to initialise the xforms choice object.
- string choice = " " + getStringFromVector(getFirst(family), " | ") +" ";
+ string choice = ' ' + getStringFromVector(getFirst(family), " | ") + ' ';
fl_addto_choice(dialog_->choice_family, choice.c_str());
- choice = " " + getStringFromVector(getFirst(series), " | ") + " ";
+ choice = ' ' + getStringFromVector(getFirst(series), " | ") + ' ';
fl_addto_choice(dialog_->choice_series, choice.c_str());
- choice = " " + getStringFromVector(getFirst(shape), " | ") + " ";
+ choice = ' ' + getStringFromVector(getFirst(shape), " | ") + ' ';
fl_addto_choice(dialog_->choice_shape, choice.c_str());
- choice = " " + getStringFromVector(getFirst(size), " | ") + " ";
+ choice = ' ' + getStringFromVector(getFirst(size), " | ") + ' ';
fl_addto_choice(dialog_->choice_size, choice.c_str());
- choice = " " + getStringFromVector(getFirst(bar), " | ") + " ";
+ choice = ' ' + getStringFromVector(getFirst(bar), " | ") + ' ';
fl_addto_choice(dialog_->choice_bar, choice.c_str());
- choice = " " + getStringFromVector(getFirst(color), " | ") + " ";
+ choice = ' ' + getStringFromVector(getFirst(color), " | ") + ' ';
fl_addto_choice(dialog_->choice_color, choice.c_str());
- // xforms appears to need this to prevent a crash...
- fl_addto_choice(dialog_->choice_language, "prevent crash");
-
- // insert default language box manually
- fl_addto_form(dialog_->form);
- FL_OBJECT * ob = dialog_->choice_language;
- fl_hide_object(dialog_->choice_language);
-
- combo_language2_.reset(new Combox(FL_COMBOX_DROPLIST));
- combo_language2_->add(ob->x, ob->y, ob->w, ob->h, 250);
- combo_language2_->shortcut("#L", 1);
- combo_language2_->setcallback(ComboInputCB, this);
- fl_end_form();
-
- // build up the combox entries
- vector<LanguagePair>::const_iterator it = langs.begin();
- vector<LanguagePair>::const_iterator end = langs.end();
- for (; it != end; ++it) {
- combo_language2_->addto(it->first);
- }
- combo_language2_->select(1);
+ choice = ' ' + getStringFromVector(getFirst(langs), " | ") + ' ';
+ fl_addto_combox(dialog_->combox_language, choice.c_str());
+ fl_set_combox_browser_height(dialog_->combox_language, 250);
// Manage the ok, apply and cancel/close buttons
- bc().setApply(dialog_->button_apply);
- bc().setCancel(dialog_->button_close);
- bc().addReadOnly(dialog_->check_toggle_all);
+ bcview().setApply(dialog_->button_apply);
+ bcview().setCancel(dialog_->button_close);
+ bcview().addReadOnly(dialog_->check_toggle_all);
}
if (!form()) return;
int pos = fl_get_choice(dialog_->choice_family);
- controller().setFamily(family_[pos-1]);
+ controller().setFamily(family_[pos - 1]);
pos = fl_get_choice(dialog_->choice_series);
- controller().setSeries(series_[pos-1]);
+ controller().setSeries(series_[pos - 1]);
pos = fl_get_choice(dialog_->choice_shape);
- controller().setShape(shape_[pos-1]);
+ controller().setShape(shape_[pos - 1]);
pos = fl_get_choice(dialog_->choice_size);
- controller().setSize(size_[pos-1]);
+ controller().setSize(size_[pos - 1]);
pos = fl_get_choice(dialog_->choice_bar);
- controller().setBar(bar_[pos-1]);
+ controller().setBar(bar_[pos - 1]);
pos = fl_get_choice(dialog_->choice_color);
- controller().setColor(color_[pos-1]);
+ controller().setColor(color_[pos - 1]);
- pos = combo_language2_->get();
- controller().setLanguage(lang_[pos-1]);
+ pos = fl_get_combox(dialog_->combox_language);
+ controller().setLanguage(lang_[pos - 1]);
bool const toggleall = fl_get_button(dialog_->check_toggle_all);
controller().setToggleAll(toggleall);
fl_set_choice(dialog_->choice_color, pos+1);
pos = int(findPos(lang_, controller().getLanguage()));
- combo_language2_->select(pos+1);
+ fl_set_combox(dialog_->combox_language, pos+1);
fl_set_button(dialog_->check_toggle_all, controller().getToggleAll());
}
ButtonPolicy::SMInput activate = ButtonPolicy::SMI_NOOP;
int pos = fl_get_choice(dialog_->choice_family);
- if (family_[pos-1] != LyXFont::IGNORE_FAMILY)
+ if (family_[pos - 1] != LyXFont::IGNORE_FAMILY)
activate = ButtonPolicy::SMI_VALID;
pos = fl_get_choice(dialog_->choice_series);
- if (series_[pos-1] != LyXFont::IGNORE_SERIES)
+ if (series_[pos - 1] != LyXFont::IGNORE_SERIES)
activate = ButtonPolicy::SMI_VALID;
pos = fl_get_choice(dialog_->choice_shape);
- if (shape_[pos-1] != LyXFont::IGNORE_SHAPE)
+ if (shape_[pos - 1] != LyXFont::IGNORE_SHAPE)
activate = ButtonPolicy::SMI_VALID;
pos = fl_get_choice(dialog_->choice_size);
- if (size_[pos-1] != LyXFont::IGNORE_SIZE)
+ if (size_[pos - 1] != LyXFont::IGNORE_SIZE)
activate = ButtonPolicy::SMI_VALID;
pos = fl_get_choice(dialog_->choice_bar);
- if (bar_[pos-1] != frnt::IGNORE)
+ if (bar_[pos - 1] != frnt::IGNORE)
activate = ButtonPolicy::SMI_VALID;
pos = fl_get_choice(dialog_->choice_color);
- if (color_[pos-1] != LColor::ignore)
+ if (color_[pos - 1] != LColor::ignore)
activate = ButtonPolicy::SMI_VALID;
- pos = combo_language2_->get();
- if (lang_[pos-1] != "No change")
+ pos = fl_get_combox(dialog_->combox_language);
+ if (lang_[pos - 1] != "No change")
activate = ButtonPolicy::SMI_VALID;
return activate;