diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index d34204ecb2..e940600e1c 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,4 +1,10 @@ +2006-01-24 John Spray + * GTabular.[Ch], glade/tabular.glade: Add tabular dialog (incomplete) + * LyXGtkLengthEntry.[Ch]: Add length entry widget + * Dialogs.C, Makefile.am, lyx_gui.C: Remove xforms references + 2006-01-23 John Spray + * LyXGdkImage.[Ch]: replace xforms Image class * Makefile.am: build LyXGdkImage * GPainter.C: use new Gdk Image class diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 20c31d7fbd..92683dee69 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -1,5 +1,5 @@ /** - * \file xforms/Dialogs.C +// * \file xforms/Dialogs.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * @@ -21,8 +21,6 @@ #include "Dialogs.h" #include "Dialog.h" -#include "Tooltips.h" - #include "ControlAboutlyx.h" #include "ControlBibtex.h" #include "ControlBox.h" @@ -61,34 +59,34 @@ #include "GText.h" #include "GMathDelim.h" #include "GBibItem.h" -#include "FormBibtex.h" +//#include "FormBibtex.h" #include "GBox.h" -#include "FormBranch.h" +//#include "FormBranch.h" #include "GChanges.h" #include "GCharacter.h" #include "GCitation.h" #include "GDocument.h" #include "GErrorList.h" #include "GERT.h" -#include "FormExternal.h" +//#include "FormExternal.h" #include "GFloat.h" #include "GGraphics.h" #include "GInclude.h" #include "GLog.h" #include "GMathPanel.h" -#include "FormMathsBitmap.h" +//#include "FormMathsBitmap.h" #include "GMathsMatrix.h" -#include "FormMathsSpace.h" -#include "FormMathsStyle.h" +//#include "FormMathsSpace.h" +//#include "FormMathsStyle.h" #include "GNote.h" #include "GParagraph.h" -#include "FormPreamble.h" -#include "FormPreferences.h" +//#include "FormPreamble.h" +//#include "FormPreferences.h" #include "GPrint.h" #include "GRef.h" #include "GSearch.h" #include "GSendto.h" -#include "FormTabular.h" +#include "GTabular.h" #include "GTexinfo.h" #include "GShowFile.h" #include "GSpellchecker.h" @@ -96,14 +94,14 @@ #include "GToc.h" #include "GUrl.h" #include "GVSpace.h" -#include "FormWrap.h" +//#include "FormWrap.h" #ifdef HAVE_LIBAIKSAURUS #include "ControlThesaurus.h" #include "GThesaurus.h" #endif -#include "xformsBC.h" +//#include "xformsBC.h" #include "ButtonController.h" #include "arrows.xbm" @@ -130,12 +128,12 @@ using namespace lyx::frontend; namespace { -FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title, - char const * const * data, int size) -{ - char const * const * const end = data + size; - return new FormMathsBitmap(parent, title, std::vector(data, end)); -} +//FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title, +// char const * const * data, int size) +//{ +// char const * const * const end = data + size; +// return new FormMathsBitmap(parent, title, std::vector(data, end)); +//} char const * const dialognames[] = { @@ -194,9 +192,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GBibItem(*dialog)); dialog->bc().bp(new OkCancelReadOnlyPolicy); } else if (name == "bibtex") { - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlBibtex(*dialog)); - dialog->setView(new FormBibtex(*dialog)); +// dialog->setView(new FormBibtex(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "box") { dialog->bc().view(new GBC(dialog->bc())); @@ -234,9 +232,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GERT(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "external") { - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlExternal(*dialog)); - dialog->setView(new FormExternal(*dialog)); +// dialog->setView(new FormExternal(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "file") { dialog->bc().view(new GBC(dialog->bc())); @@ -288,176 +286,176 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathaccents") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("Maths Decorations & Accents"), - latex_deco, nr_latex_deco); - bitmap->addBitmap( - BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true)); - bitmap->addBitmap( - BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("Maths Decorations & Accents"), +// latex_deco, nr_latex_deco); +// bitmap->addBitmap( +// BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true)); +// bitmap->addBitmap( +// BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "matharrows") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow); - bitmap->addBitmap( - BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true)); - bitmap->addBitmap( - BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false)); - bitmap->addBitmap( - BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow); +// bitmap->addBitmap( +// BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true)); +// bitmap->addBitmap( +// BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false)); +// bitmap->addBitmap( +// BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathoperators") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("Binary Ops"), - latex_bop, nr_latex_bop); - bitmap->addBitmap( - BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("Binary Ops"), +// latex_bop, nr_latex_bop); +// bitmap->addBitmap( +// BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathrelations") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("Binary Relations"), - latex_brel, nr_latex_brel); - bitmap->addBitmap( - BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("Binary Relations"), +// latex_brel, nr_latex_brel); +// bitmap->addBitmap( +// BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathgreek") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("Greek"), - latex_greek, nr_latex_greek); - bitmap->addBitmap( - BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true)); - bitmap->addBitmap( - BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("Greek"), +// latex_greek, nr_latex_greek); +// bitmap->addBitmap( +// BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true)); +// bitmap->addBitmap( +// BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathmisc") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("Misc"), - latex_misc, nr_latex_misc); - bitmap->addBitmap( - BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true)); - bitmap->addBitmap( - BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true)); - bitmap->addBitmap( - BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false)); - bitmap->addBitmap( - BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("Misc"), +// latex_misc, nr_latex_misc); +// bitmap->addBitmap( +// BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true)); +// bitmap->addBitmap( +// BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true)); +// bitmap->addBitmap( +// BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false)); +// bitmap->addBitmap( +// BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathdots") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("Dots"), - latex_dots, nr_latex_dots); - bitmap->addBitmap( - BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("Dots"), +// latex_dots, nr_latex_dots); +// bitmap->addBitmap( +// BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathbigoperators") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("Big Operators"), - latex_varsz, nr_latex_varsz); - bitmap->addBitmap( - BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("Big Operators"), +// latex_varsz, nr_latex_varsz); +// bitmap->addBitmap( +// BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathamsmisc") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("AMS Misc"), - latex_ams_misc, nr_latex_ams_misc); - bitmap->addBitmap( - BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true)); - bitmap->addBitmap( - BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("AMS Misc"), +// latex_ams_misc, nr_latex_ams_misc); +// bitmap->addBitmap( +// BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true)); +// bitmap->addBitmap( +// BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathamsarrows") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("AMS Arrows"), - latex_ams_arrows, nr_latex_ams_arrows); - bitmap->addBitmap( - BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true)); - bitmap->addBitmap( - BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("AMS Arrows"), +// latex_ams_arrows, nr_latex_ams_arrows); +// bitmap->addBitmap( +// BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true)); +// bitmap->addBitmap( +// BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathamsrelations") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("AMS Relations"), - latex_ams_rel, nr_latex_ams_rel); - bitmap->addBitmap( - BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("AMS Relations"), +// latex_ams_rel, nr_latex_ams_rel); +// bitmap->addBitmap( +// BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathamsnegatedrelations") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("AMS Negated Rel"), - latex_ams_nrel, nr_latex_ams_nrel); - bitmap->addBitmap( - BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("AMS Negated Rel"), +// latex_ams_nrel, nr_latex_ams_nrel); +// bitmap->addBitmap( +// BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathamsoperators") { - FormMathsBitmap * bitmap = - createFormBitmap(*dialog, _("AMS Operators"), - latex_ams_ops, nr_latex_ams_ops); - bitmap->addBitmap( - BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true)); +// FormMathsBitmap * bitmap = +// createFormBitmap(*dialog, _("AMS Operators"), +// latex_ams_ops, nr_latex_ams_ops); +// bitmap->addBitmap( +// BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true)); - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(bitmap); +// dialog->setView(bitmap); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathdelimiter") { @@ -471,14 +469,14 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GMathsMatrix(*dialog)); dialog->bc().bp(new OkCancelReadOnlyPolicy); } else if (name == "mathspace") { - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(new FormMathsSpace(*dialog)); +// dialog->setView(new FormMathsSpace(*dialog)); dialog->bc().bp(new IgnorantPolicy); } else if (name == "mathstyle") { - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlMath(*dialog)); - dialog->setView(new FormMathsStyle(*dialog)); +// dialog->setView(new FormMathsStyle(*dialog)); dialog->bc().bp(new IgnorantPolicy); } else if (name == "note") { dialog->bc().view(new GBC(dialog->bc())); @@ -486,9 +484,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GNote(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "branch") { - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlBranch(*dialog)); - dialog->setView(new FormBranch(*dialog)); +// dialog->setView(new FormBranch(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "paragraph") { dialog->bc().view(new GBC(dialog->bc())); @@ -496,14 +494,14 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GParagraph(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "preamble") { - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlPreamble(*dialog)); - dialog->setView(new FormPreamble(*dialog)); +// dialog->setView(new FormPreamble(*dialog)); dialog->bc().bp(new OkApplyCancelPolicy); } else if (name == "prefs") { - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlPrefs(*dialog)); - dialog->setView(new FormPreferences(*dialog)); +// dialog->setView(new FormPreferences(*dialog)); dialog->bc().bp(new PreferencesPolicy); } else if (name == "print") { dialog->bc().view(new GBC(dialog->bc())); @@ -526,9 +524,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GSpellchecker(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "tabular") { - dialog->bc().view(new xformsBC(dialog->bc())); + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlTabular(*dialog)); - dialog->setView(new FormTabular(*dialog)); + dialog->setView(new GTabular(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "tabularcreate") { dialog->bc().view(new GBC(dialog->bc())); @@ -563,9 +561,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GVSpace(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "wrap") { - dialog->bc().view(new xformsBC(dialog->bc())); +// dialog->bc().view(new xformsBC(dialog->bc())); dialog->setController(new ControlWrap(*dialog)); - dialog->setView(new FormWrap(*dialog)); +// dialog->setView(new FormWrap(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } @@ -575,12 +573,14 @@ Dialogs::DialogPtr Dialogs::build(string const & name) void Dialogs::toggleTooltips() { - Tooltips::toggleEnabled(); + // Turning off tooltips is not necessary and will + // not be implemented by me - jcs +// Tooltips::toggleEnabled(); } /// Are the tooltips on or off? bool Dialogs::tooltipsEnabled() { - return Tooltips::enabled(); +// return Tooltips::enabled(); } diff --git a/src/frontends/gtk/GTabular.C b/src/frontends/gtk/GTabular.C new file mode 100644 index 0000000000..3cc5d16c51 --- /dev/null +++ b/src/frontends/gtk/GTabular.C @@ -0,0 +1,200 @@ +/** + * \file GTabular.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#include + +// Too hard to make concept checks work with this file +#ifdef _GLIBCXX_CONCEPT_CHECKS +#undef _GLIBCXX_CONCEPT_CHECKS +#endif +#ifdef _GLIBCPP_CONCEPT_CHECKS +#undef _GLIBCPP_CONCEPT_CHECKS +#endif + +#include "GTabular.h" +#include "ControlTabular.h" + +#include "ghelpers.h" + +#include "controllers/helper_funcs.h" + +#include "debug.h" + +using std::string; +using std::vector; + +/* +class GtkLengthEntry : public Gtk::HBox { +public: + GtkLengthEntry::GtkLengthEntry(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + +protected: + Gtk::SpinButton spin_; + Gtk::ComboBoxText combo_; + +}; + +GtkLengthEntry::GtkLengthEntry( + BaseObjectType* cobject, + const Glib::RefPtr& refGlade) +: Gtk::HBox(cobject), spin_(0.1, 2) +{ + pack_start (spin_, true, true, 0); + pack_start (combo_, true, true, 0); + spin_.set_range(0.0, 99999.0f); + set_spacing(6); + show_all(); +}*/ + + + +namespace lyx { + +namespace frontend { + +namespace { +string defaultUnit("cm"); +} // namespace anon + +GTabular::GTabular(Dialog & parent) + : GViewCB(parent, _("Table Settings"), false) +{} + + +void GTabular::doBuild() +{ + string const gladeName = findGladeFile("tabular"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * button; + xml_->get_widget("Close", button); + setCancel(button); + + + // **** Current cell coords **** + xml_->get_widget("CurrentRow", cellrowspin_); + xml_->get_widget("CurrentColumn", cellcolspin_); + + // **** Table tab **** + xml_->get_widget("HorizontalAlignment", horzaligncombo_); + xml_->get_widget("VerticalAlignment", vertaligncombo_); + xml_->get_widget("SpecifyWidth", specifywidthcheck_); + xml_->get_widget_derived ("Width", widthlength_); + xml_->get_widget("LaTeXArgument", latexargsentry_); + xml_->get_widget("RotateTable", rotatetablecheck_); + + // **** This Cell tab **** + xml_->get_widget("UpperBorder", upperbordercheck_); + xml_->get_widget("LowerBorder", lowerbordercheck_); + xml_->get_widget("LeftBorder", leftbordercheck_); + xml_->get_widget("RightBorder", rightbordercheck_); + xml_->get_widget("RotateCell", rotatecellcheck_); + xml_->get_widget("MultiColumn", multicolcheck_); + xml_->get_widget("NoBorders", button); + button->signal_clicked().connect( + sigc::bind(sigc::mem_fun(*this, >abular::allBorders), false)); + xml_->get_widget("AllBorders", button); + button->signal_clicked().connect( + sigc::bind(sigc::mem_fun(*this, >abular::allBorders), true)); + + // **** Longtable tab **** + + // Disable for read-only documents. +// bcview().addReadOnly(browsebutton_); + +} + + +void GTabular::apply() +{ + +} + + +void GTabular::update() +{ + LyXTabular const & tabular = controller().tabular(); + LyXTabular::idx_type const cell = controller().getActiveCell(); + bool multicol = tabular.isMultiColumn(cell); + + cellcolspin_->get_adjustment()->set_value(tabular.column_of_cell (cell)+1); + cellrowspin_->get_adjustment()->set_value(tabular.row_of_cell (cell)); + + // **** Table tab **** + int align = tabular.getAlignment(cell); + if (align == LYX_ALIGN_RIGHT) + horzaligncombo_->set_active(2); + else if (align == LYX_ALIGN_CENTER) + horzaligncombo_->set_active(1); + else + horzaligncombo_->set_active(0); + + align = tabular.getVAlignment(cell); + if (align == LyXTabular::LYX_VALIGN_BOTTOM) + vertaligncombo_->set_active(2); + else if (align == LyXTabular::LYX_VALIGN_MIDDLE) + vertaligncombo_->set_active(1); + else + vertaligncombo_->set_active(0); + + + LyXLength pwidth; + string special; + + if (multicol) { + special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI); + pwidth = tabular.getMColumnPWidth(cell); + } else { + special = tabular.getAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN); + pwidth = tabular.getColumnPWidth(cell); + } + + latexargsentry_->set_text(special); + specifywidthcheck_->set_active(!pwidth.zero()); + widthlength_->set_length(pwidth); + rotatetablecheck_->set_active(tabular.getRotateTabular()); + + //TODO: insert 'Block' entry into halign as neccessary + + + // **** This Cell tab **** + multicolcheck_->set_active(multicol); + rotatecellcheck_->set_active(tabular.getRotateCell(cell)); +} + + +void GTabular::onInput() +{ + updateSensitivity(); +} + + +void GTabular::allBorders(bool borders) +{ + if (upperbordercheck_->is_sensitive()) + upperbordercheck_->set_active(borders); + if (lowerbordercheck_->is_sensitive()) + lowerbordercheck_->set_active(borders); + if (leftbordercheck_->is_sensitive()) + leftbordercheck_->set_active(borders); + if (rightbordercheck_->is_sensitive()) + rightbordercheck_->set_active(borders); +} + + +void GTabular::updateSensitivity() +{ + bool specifywidth = specifywidthcheck_->get_active(); + widthlength_->set_sensitive(specifywidth); + vertaligncombo_->set_sensitive(specifywidth); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GTabular.h b/src/frontends/gtk/GTabular.h new file mode 100644 index 0000000000..87ff169590 --- /dev/null +++ b/src/frontends/gtk/GTabular.h @@ -0,0 +1,77 @@ +// -*- C++ -*- +/** + * \file GTabular.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef GTABULAR_H +#define GTABULAR_H + +#include "GViewBase.h" + +#include "GtkLengthEntry.h" + +#include "lyxlength.h" + +#include +#include + +namespace lyx { +namespace frontend { + +class ControlTabular; + +/** This class provides a GTK+ implementation of the Tabular Dialog. + */ +class GTabular + : public GViewCB { +public: + /// + GTabular(Dialog &); +private: + + /// Set the Params variable for the Controller. + virtual void apply(); + /// Build the dialog. + virtual void doBuild(); + /// Update dialog before/whilst showing it. + virtual void update(); + void onInput(); + void allBorders(bool borders); + void updateSensitivity(); + + bool updating_; + + // **** Current cell coords **** + Gtk::SpinButton *cellrowspin_; + Gtk::SpinButton *cellcolspin_; + + // **** Table tab **** + Gtk::ComboBox *horzaligncombo_; + Gtk::ComboBox *vertaligncombo_; + Gtk::CheckButton *specifywidthcheck_; + GtkLengthEntry *widthlength_; + Gtk::Entry *latexargsentry_; + + Gtk::CheckButton *rotatetablecheck_; + + // **** This Cell tab **** + Gtk::CheckButton *upperbordercheck_; + Gtk::CheckButton *lowerbordercheck_; + Gtk::CheckButton *leftbordercheck_; + Gtk::CheckButton *rightbordercheck_; + Gtk::CheckButton *rotatecellcheck_; + Gtk::CheckButton *multicolcheck_; + + // **** Longtable tab **** +}; + +} // namespace frontend +} // namespace lyx + +#endif // GTABULAR_H diff --git a/src/frontends/gtk/GtkLengthEntry.C b/src/frontends/gtk/GtkLengthEntry.C new file mode 100644 index 0000000000..9317164723 --- /dev/null +++ b/src/frontends/gtk/GtkLengthEntry.C @@ -0,0 +1,81 @@ + +/** + * \file GtkLengthEntry.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#include + +// Too hard to make concept checks work with this file +#ifdef _GLIBCXX_CONCEPT_CHECKS +#undef _GLIBCXX_CONCEPT_CHECKS +#endif +#ifdef _GLIBCPP_CONCEPT_CHECKS +#undef _GLIBCPP_CONCEPT_CHECKS +#endif + +#include "GtkLengthEntry.h" + + +namespace lyx { +namespace frontend { + + +GtkLengthEntry::GtkLengthEntry( + BaseObjectType* cobject, + const Glib::RefPtr& refGlade) +: Gtk::HBox(cobject), spin_(0.1, 2) +{ + + spin_.set_range(0.0, 99999.0f); + populateUnitCombo (combo_, true); + relative_ = true; + + set_spacing(6); + pack_start (spin_, true, true, 0); + pack_start (combo_, true, true, 0); + show_all(); +} + + +void GtkLengthEntry::set_length(LyXLength const & length) +{ + setWidgetsFromLength (*spin_.get_adjustment(), combo_, length); +} + + +void GtkLengthEntry::set_length(std::string const & length) +{ + setWidgetsFromLength (*spin_.get_adjustment(), combo_, LyXLength(length)); +} + + +LyXLength const GtkLengthEntry::get_length() +{ + return LyXLength(getLengthFromWidgets(*spin_.get_adjustment(), combo_)); +} + + +std::string const GtkLengthEntry::get_length_string() +{ + return getLengthFromWidgets(*spin_.get_adjustment(), combo_); +} + + +void GtkLengthEntry::set_relative(bool rel) +{ + combo_.clear(); + if (rel != relative_) { + populateUnitCombo (combo_, rel); + relative_ = rel; + } +} + + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GtkLengthEntry.h b/src/frontends/gtk/GtkLengthEntry.h new file mode 100644 index 0000000000..e684085de1 --- /dev/null +++ b/src/frontends/gtk/GtkLengthEntry.h @@ -0,0 +1,51 @@ + +// -*- C++ -*- +/** + * \file GtkLengthEntry.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author John Spray + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef GLENGTHENTRY_H +#define GLENGTHENTRY_H + + +#include "ghelpers.h" +#include "lengthcommon.h" + +#include +#include + + +class FuncRequest; + +namespace lyx { +namespace frontend { + +class GtkLengthEntry : public Gtk::HBox { +public: + GtkLengthEntry::GtkLengthEntry(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + + void set_length(LyXLength const & length); + void set_length(std::string const & length); + LyXLength const get_length(); + std::string const get_length_string(); + void set_relative(bool rel); + + Gtk::SpinButton *get_spin(); + Gtk::ComboBoxText *get_combo(); + +protected: + Gtk::SpinButton spin_; + Gtk::ComboBoxText combo_; + bool relative_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // NOT GTKLENGTHENTRY_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 8658901b3e..162fad8cc6 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -14,11 +14,9 @@ AM_CPPFLAGS += \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/frontends \ -I$(top_srcdir)/src/frontends/controllers \ - -I../xforms \ - -I$(top_srcdir)/src/frontends/xforms \ $(BOOST_INCLUDES) @GTK_FRONTEND_CFLAGS@ -libgtk_la_LIBADD = $(xforms_objects) ../xforms/forms/*.lo @GTK_FRONTEND_LIBS@ @XFORMS_LIBS@ +libgtk_la_LIBADD = @GTK_FRONTEND_LIBS@ # Alphabetical order please. It makes it easier to figure out what's missing. libgtk_la_SOURCES = \ @@ -89,6 +87,8 @@ libgtk_la_SOURCES = \ GSpellchecker.h \ GTableCreate.C \ GTableCreate.h \ + GTabular.C \ + GTabular.h \ GTexinfo.C \ GTexinfo.h \ GText.C \ @@ -113,6 +113,10 @@ libgtk_la_SOURCES = \ GWorkArea.h \ GXpmBtnTbl.C \ GXpmBtnTbl.h \ + LyXGdkImage.C \ + LyXGdkImage.h \ + GtkLengthEntry.C \ + GtkLengthEntry.h \ GtkmmX.h \ IdSc.C \ IdSc.h \ @@ -131,35 +135,3 @@ libgtk_la_SOURCES = \ xftFontLoader.h \ xftFontMetrics.C - -xforms_objects = \ - ../xforms/bmtable.lo \ - ../xforms/checkedwidgets.lo \ - ../xforms/ColorHandler.lo \ - ../xforms/Color.lo \ - ../xforms/combox.lo \ - ../xforms/fdesign_base.lo \ - ../xforms/FormBibtex.lo \ - ../xforms/FormBranch.lo \ - ../xforms/FormBrowser.lo \ - ../xforms/FormColorpicker.lo \ - ../xforms/FormDialogView.lo \ - ../xforms/FormExternal.lo \ - ../xforms/FormMathsBitmap.lo \ - ../xforms/FormMathsDelim.lo \ - ../xforms/FormMathsSpace.lo \ - ../xforms/FormMathsStyle.lo \ - ../xforms/FormPreamble.lo \ - ../xforms/FormPreferences.lo \ - ../xforms/forms_gettext.lo \ - ../xforms/FormTabular.lo \ - ../xforms/FormText.lo \ - ../xforms/FormWrap.lo \ - ../xforms/freebrowser.lo \ - ../xforms/input_validators.lo \ - ../xforms/RadioButtonGroup.lo \ - ../xforms/Tooltips.lo \ - ../xforms/xformsBC.lo \ - ../xforms/xforms_helpers.lo \ - ../xforms/xformsImage.lo \ - ../xforms/xforms_resize.lo diff --git a/src/frontends/gtk/glade/Makefile.am b/src/frontends/gtk/glade/Makefile.am index 7ed621a292..69264c70bd 100644 --- a/src/frontends/gtk/glade/Makefile.am +++ b/src/frontends/gtk/glade/Makefile.am @@ -28,6 +28,7 @@ dist_glade_DATA = \ sendto.glade \ showfile.glade \ spellcheck.glade \ + tabular.glade \ tableCreate.glade \ texinfo.glade \ text.glade \ diff --git a/src/frontends/gtk/glade/tabular.glade b/src/frontends/gtk/glade/tabular.glade new file mode 100644 index 0000000000..f47f82be1c --- /dev/null +++ b/src/frontends/gtk/glade/tabular.glade @@ -0,0 +1,1483 @@ + + + + + + + True + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + False + 12 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 12 + True + False + 0 + + + + True + <b>Column</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 12 + 12 + 0 + + + + True + 5 + 2 + False + 3 + 6 + + + + True + _Horizontal alignment: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _Vertical alignment: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + _Width: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + Left +Center +Right + False + True + + + 1 + 2 + 0 + 1 + fill + + + + + + True + Top +Middle +Bottom + False + True + + + 1 + 2 + 1 + 2 + fill + fill + + + + + + True + False + 0 + + + + True + False + 0 + + + + + + + + + + + 0 + True + True + + + + + 1 + 2 + 4 + 5 + fill + fill + + + + + + True + LaTe_X argument: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + LaTeXArgument + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + + + + + + + True + True + _Specify width + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 2 + 3 + 4 + fill + + + + + + + + 0 + True + True + + + + + + True + <b>Whole Table</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 12 + 12 + 0 + + + + True + False + 6 + + + + True + True + _Rotate through 90° + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + + 0 + True + True + + + + + False + True + + + + + + True + Table + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 12 + True + False + 6 + + + + True + True + _Upper border + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Lower border + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + L_eft border + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Right border + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + 0 + + + + True + True + _All Borders + True + GTK_RELIEF_NORMAL + True + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + False + 0 + + + + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-clear + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _No Borders + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + + + + 0 + False + True + + + + + + True + True + _Rotate through 90° + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Multi-column + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + False + False + + + + + + True + This Cell + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 12 + True + False + 6 + + + + True + True + _Make this table a long table + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Page break on selected row + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + <b>Special Rows</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 0 + 12 + 0 + + + + True + 5 + 8 + False + 6 + 12 + + + + True + Header: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + First header: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Footer: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + Last footer: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + Upper border + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 5 + 6 + 0 + 1 + fill + + + + + + + True + Lower border + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 7 + 8 + 0 + 1 + fill + + + + + + + True + True + On + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + True + On + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + True + On + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + True + On + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + Double + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 5 + 6 + 1 + 2 + fill + + + + + + + True + True + Double + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 5 + 6 + 2 + 3 + fill + + + + + + + True + True + Double + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 5 + 6 + 3 + 4 + fill + + + + + + + True + True + Double + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 5 + 6 + 4 + 5 + fill + + + + + + + True + True + Double + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 7 + 8 + 4 + 5 + fill + + + + + + + True + True + Double + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 7 + 8 + 3 + 4 + fill + + + + + + + True + True + Double + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 7 + 8 + 2 + 3 + fill + + + + + + + True + True + Double + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 7 + 8 + 1 + 2 + fill + + + + + + + True + True + Empty + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 3 + 4 + 2 + 3 + fill + + + + + + + True + True + Empty + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 3 + 4 + 4 + 5 + fill + + + + + + + True + + + 6 + 7 + 0 + 5 + fill + + + + + + True + + + 4 + 5 + 0 + 5 + fill + + + + + + True + + + 2 + 3 + 0 + 5 + fill + + + + + + + 0 + True + True + + + + + False + True + + + + + + True + Long Table + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + 0 + True + True + + + + + + True + False + 6 + + + + True + Current Cell: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 999999 1 10 10 + + + 0 + False + False + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 99999 1 10 10 + + + 0 + False + False + + + + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + diff --git a/src/frontends/gtk/lyx_gui.C b/src/frontends/gtk/lyx_gui.C index 6b45f4e981..9f37537d35 100644 --- a/src/frontends/gtk/lyx_gui.C +++ b/src/frontends/gtk/lyx_gui.C @@ -48,10 +48,6 @@ #include "xftFontLoader.h" #include "GWorkArea.h" -//just for xforms -#include "lyx_forms.h" -#include "xforms_helpers.h" - #include "support/lyxlib.h" #include "support/os.h" #include "support/filetools.h" @@ -79,7 +75,6 @@ using lyx::support::package; using lyx::frontend::colorCache; using lyx::frontend::GView; -using lyx::frontend::XformsColor; extern BufferList bufferlist; @@ -99,60 +94,14 @@ bool finished = false; /// estimate DPI from X server int getDPI() { + //TODO use GDK instead Screen * scr = ScreenOfDisplay(getDisplay(), getScreen()); return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) + (WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2); } - -/// set default GUI configuration -void setDefaults() -{ - FL_IOPT cntl; - cntl.buttonFontSize = FL_NORMAL_SIZE; - cntl.browserFontSize = FL_NORMAL_SIZE; - cntl.labelFontSize = FL_NORMAL_SIZE; - cntl.choiceFontSize = FL_NORMAL_SIZE; - cntl.inputFontSize = FL_NORMAL_SIZE; - cntl.menuFontSize = FL_NORMAL_SIZE; - cntl.borderWidth = -1; - cntl.vclass = FL_DefaultVisual; - fl_set_defaults(FL_PDVisual - | FL_PDButtonFontSize - | FL_PDBrowserFontSize - | FL_PDLabelFontSize - | FL_PDChoiceFontSize - | FL_PDInputFontSize - | FL_PDMenuFontSize - | FL_PDBorderWidth, &cntl); -} - - extern "C" { - -int LyX_XErrHandler(Display * display, XErrorEvent * xeev) { - // We don't abort on BadWindow - if (xeev->error_code == BadWindow) { - lyxerr << "BadWindow received !" << std::endl; - lyxerr << "If you're using xforms 1.0 or greater, " - << " please report this to lyx-devel@lists.lyx.org" - << std::endl; - return 0; - } - - // emergency cleanup - LyX::cref().emergencyCleanup(); - - // Get the reason for the crash. - char etxt[513]; - XGetErrorText(display, xeev->error_code, etxt, 512); - lyxerr << etxt << " id: " << xeev->resourceid << std::endl; - // By doing an abort we get a nice backtrace. (hopefully) - lyx::support::abort(); - return 0; -} - } /// read in geometry specification @@ -161,47 +110,10 @@ char geometry[40]; } // namespace anon -void parse_init_xforms(int & argc, char * argv[]) -{ - setDefaults(); - - FL_CMD_OPT cmdopt[] = { - {"-geometry", "*.geometry", XrmoptionSepArg, "690x510"} - }; - - FL_resource res[] = { - {"geometry", "geometryClass", FL_STRING, geometry, "", 40} - }; - - const int num_res = sizeof(res)/sizeof(FL_resource); - fl_initialize(&argc, argv, "LyX", cmdopt, num_res); - - // It appears that, in xforms >=0.89.5, fl_initialize() - // calls setlocale() and ruins our LC_NUMERIC setting. - - fl_get_app_resources(res, num_res); - - Display * display = fl_get_display(); - - if (!display) { - lyxerr << "LyX: unable to access X display, exiting" - << std::endl; - ::exit(1); - } - - fcntl(ConnectionNumber(display), F_SETFD, FD_CLOEXEC); - - XSetErrorHandler(LyX_XErrHandler); - -} - - void lyx_gui::parse_init(int & argc, char * argv[]) { new Gtk::Main(argc, argv); - parse_init_xforms(argc, argv); - using namespace lyx::graphics; Image::newImage = boost::bind(&LyXGdkImage::newImage); Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats); @@ -213,130 +125,13 @@ void lyx_gui::parse_init(int & argc, char * argv[]) } -void parse_lyxrc_xforms() -{ - XformsColor::read(lyx::support::AddName(package().user_support(), - "preferences.xform")); - - if (lyxrc.popup_font_encoding.empty()) - lyxrc.popup_font_encoding = lyxrc.font_norm; - // Set the font name for popups and menus - string boldfontname = lyxrc.popup_bold_font - + "-*-*-*-?-*-*-*-*-" - + lyxrc.popup_font_encoding; - // "?" means "scale that font" - string fontname = lyxrc.popup_normal_font - + "-*-*-*-?-*-*-*-*-" - + lyxrc.popup_font_encoding; - - int bold = fl_set_font_name(FL_BOLD_STYLE, boldfontname.c_str()); - int normal = fl_set_font_name(FL_NORMAL_STYLE, fontname.c_str()); - if (bold < 0) - lyxerr << "Could not set menu font to " - << boldfontname << std::endl; - - if (normal < 0) - lyxerr << "Could not set popup font to " - << fontname << std::endl; - - if (bold < 0 && normal < 0) { - lyxerr << "Using 'helvetica' font for menus" << std::endl; - boldfontname = "-*-helvetica-bold-r-*-*-*-?-*-*-*-*-iso8859-1"; - fontname = "-*-helvetica-medium-r-*-*-*-?-*-*-*-*-iso8859-1"; - bold = fl_set_font_name(FL_BOLD_STYLE, boldfontname.c_str()); - normal = fl_set_font_name(FL_NORMAL_STYLE, fontname.c_str()); - - if (bold < 0 && normal < 0) { - lyxerr << "Could not find helvetica font. Using 'fixed'." - << std::endl; - fl_set_font_name(FL_NORMAL_STYLE, "fixed"); - normal = bold = 0; - } - } - if (bold < 0) - fl_set_font_name(FL_BOLD_STYLE, fontname.c_str()); - else if (normal < 0) - fl_set_font_name(FL_NORMAL_STYLE, boldfontname.c_str()); - - fl_setpup_fontstyle(FL_NORMAL_STYLE); - fl_setpup_fontsize(FL_NORMAL_SIZE); - fl_setpup_color(FL_MCOL, FL_BLACK); - fl_set_goodies_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE); - fl_set_tooltip_font(FL_NORMAL_STYLE, FL_NORMAL_SIZE); -} - - void lyx_gui::parse_lyxrc() { - parse_lyxrc_xforms(); -} - - -void start_xforms() -{ - // initial geometry - int xpos = -1; - int ypos = -1; - unsigned int width = 690; - unsigned int height = 510; - - int const geometryBitmask = - XParseGeometry(geometry, - &xpos, &ypos, &width, &height); - - // if width is not set by geometry, check it against monitor width - if (!(geometryBitmask & WidthValue)) { - Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); - if (WidthOfScreen(scr) - 8 < int(width)) - width = WidthOfScreen(scr) - 8; - } - - // if height is not set by geometry, check it against monitor height - if (!(geometryBitmask & HeightValue)) { - Screen * scr = ScreenOfDisplay(fl_get_display(), fl_screen); - if (HeightOfScreen(scr) - 24 < int(height)) - height = HeightOfScreen(scr) - 24; - } - - Screen * s = ScreenOfDisplay(fl_get_display(), fl_screen); - - // recalculate xpos if it's not set - if (xpos == -1) - xpos = (WidthOfScreen(s) - width) / 2; - - // recalculate ypos if it's not set - if (ypos == -1) - ypos = (HeightOfScreen(s) - height) / 2; - - lyxerr[Debug::GUI] << "Creating view: " << width << 'x' << height - << '+' << xpos << '+' << ypos << std::endl; - -// XFormsView view(width, height); -// view.show(xpos, ypos, "LyX"); -// view.init(); -} - - -static void events_xforms() -{ - if (fl_check_forms() == FL_EVENT) { - XEvent ev; - fl_XNextEvent(&ev); - lyxerr[Debug::GUI] - << "Received unhandled X11 event" << std::endl - << "Type: " << ev.xany.type - << " Target: 0x" << std::hex << ev.xany.window - << std::dec << std::endl; - } } void lyx_gui::start(string const & batch, std::vector const & files) { - start_xforms(); - // just for debug - //XSynchronize(getDisplay(), true); - boost::shared_ptr view_ptr(new GView); LyX::ref().addLyXView(view_ptr); @@ -362,7 +157,6 @@ void lyx_gui::start(string const & batch, std::vector const & files) while (!finished) { while (Gtk::Main::events_pending()) Gtk::Main::iteration(false); - events_xforms(); } // FIXME: breaks emergencyCleanup @@ -381,7 +175,7 @@ FuncStatus lyx_gui::getStatus(FuncRequest const & ev) { FuncStatus flag; switch (ev.action) { - // Add this back if the gtk doc prefs dialog includes preamble - jcs + // TODO: Add this back if the gtk doc prefs dialog includes preamble - jcs /*case LFUN_DIALOG_SHOW: if (ev.argument == "preamble") flag.unknown(true);