From 4f89cf2b1dec00eb703eb44dbd08827d95cd4a10 Mon Sep 17 00:00:00 2001 From: John Spray Date: Tue, 26 Oct 2004 09:10:17 +0000 Subject: [PATCH] gtk graphics dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9129 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 7 + src/frontends/gtk/Dialogs.C | 5 +- src/frontends/gtk/GGraphics.C | 567 ++++++++ src/frontends/gtk/GGraphics.h | 106 ++ src/frontends/gtk/Makefile.am | 3 +- src/frontends/gtk/ghelpers.C | 10 + src/frontends/gtk/ghelpers.h | 2 + src/frontends/gtk/glade/graphics.glade | 1687 ++++++++++++++++++++++++ 8 files changed, 2384 insertions(+), 3 deletions(-) create mode 100644 src/frontends/gtk/GGraphics.C create mode 100644 src/frontends/gtk/GGraphics.h create mode 100644 src/frontends/gtk/glade/graphics.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 5a2b2acce4..a42c8f0cb3 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,10 @@ +2004-10-23 John Spray + + * ghelpers.[Ch]: Add buildLengthUnitList() to get vector of + available length unit strings + * The Graphics dialog: + Dialogs.C, Makefile.am, GGraphics.C, GGraphics.h + 2004-10-11 John Spray * GWorkArea.C: allow user to scroll only one half workarea height diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 442795385a..86b99ca182 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -64,7 +64,7 @@ #include "FormERT.h" #include "FormExternal.h" #include "FormFloat.h" -#include "FormGraphics.h" +#include "GGraphics.h" #include "FormInclude.h" #include "GLog.h" #include "GMathPanel.h" @@ -239,8 +239,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new FormFloat(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "graphics") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlGraphics(*dialog)); - dialog->setView(new FormGraphics(*dialog)); + dialog->setView(new GGraphics(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "include") { dialog->setController(new ControlInclude(*dialog)); diff --git a/src/frontends/gtk/GGraphics.C b/src/frontends/gtk/GGraphics.C new file mode 100644 index 0000000000..60bcf411a8 --- /dev/null +++ b/src/frontends/gtk/GGraphics.C @@ -0,0 +1,567 @@ +/** + * \file GGraphics.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 + +#include "GGraphics.h" +#include "ControlGraphics.h" + +#include "ghelpers.h" + +#include "controllers/helper_funcs.h" + +#include "insets/insetgraphicsParams.h" +#include "paper.h" +#include "lyxrc.h" // for lyxrc.default_papersize + +#include "support/lyxlib.h" // for float_equal +#include "support/lstrings.h" + +#include "debug.h" + +using std::vector; +using std::string; + +namespace lyx { + +using support::float_equal; +using support::token; + +namespace frontend { + +namespace { +string defaultUnit("cm"); +} // namespace anon + +GGraphics::GGraphics(Dialog & parent) + : GViewCB(parent, _("Graphics"), false) +{} + + +void GGraphics::doBuild() +{ + string const gladeName = findGladeFile("graphics"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * button; + xml_->get_widget("Close", button); + setCancel(button); + xml_->get_widget("Ok", button); + setOK(button); + xml_->get_widget("Apply", button); + setApply(button); + xml_->get_widget("Restore", button); + setRestore(button); + + xml_->get_widget("Notebook", notebook_); + + // File Page + xml_->get_widget("File", fileentry_); + xml_->get_widget("DisplayScale", displayscalespin_); + xml_->get_widget("OutputScale", outputscalespin_); + xml_->get_widget("Browse", browsebutton_); + xml_->get_widget("Edit", editbutton_); + xml_->get_widget("Display", displaycombo_); + xml_->get_widget("Width", widthspin_); + xml_->get_widget("Height", heightspin_); + xml_->get_widget("MaintainAspectRatio", aspectcheck_); + xml_->get_widget("WidthUnits", widthunitscombo_); + xml_->get_widget("HeightUnits", heightunitscombo_); + xml_->get_widget("SetScaling", setscalingradio_); + xml_->get_widget("SetSize", setsizeradio_); + + // Bounding Box Page + xml_->get_widget("ClipToBoundingBox", clipcheck_); + xml_->get_widget("RightTopX", righttopxspin_); + xml_->get_widget("RightTopY", righttopyspin_); + xml_->get_widget("LeftBottomX", leftbottomxspin_); + xml_->get_widget("LeftBottomY", leftbottomyspin_); + xml_->get_widget("BoundingUnits", bbunitscombo_); + xml_->get_widget("GetFromFile", bbfromfilebutton_); + + // Extra Page + xml_->get_widget("Angle", anglespin_); + xml_->get_widget("Origin", origincombo_); + xml_->get_widget("UseSubfigure", subfigcheck_); + xml_->get_widget("SubfigureCaption", subfigentry_); + xml_->get_widget("LatexOptions", latexoptsentry_); + xml_->get_widget("DraftMode", draftcheck_); + xml_->get_widget("UnzipOnExport", unzipcheck_); + + // Setup the columnrecord we use for combos + cols_.add(stringcol_); + + // The file page + + // Disable for read-only documents. + bcview().addReadOnly(browsebutton_); + bcview().addReadOnly(aspectcheck_); + + fileentry_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + displayscalespin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + displaycombo_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + outputscalespin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + heightspin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + heightunitscombo_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + widthspin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + widthunitscombo_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + aspectcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + + setscalingradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GGraphics::onSizingModeChange)); + setsizeradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GGraphics::onSizingModeChange)); + + browsebutton_->signal_clicked().connect( + sigc::mem_fun(*this, &GGraphics::onBrowseClicked)); + + editbutton_->signal_clicked().connect( + sigc::mem_fun(*this, &GGraphics::onEditClicked)); + + vector const unit_list = buildLengthUnitList(); + PopulateComboBox(heightunitscombo_, unit_list); + PopulateComboBox(widthunitscombo_, unit_list); + + // the bounding box page + leftbottomxspin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onBBChange)); + leftbottomyspin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onBBChange)); + righttopxspin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onBBChange)); + righttopyspin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onBBChange)); + bbunitscombo_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onBBChange)); + clipcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GGraphics::onBBChange)); + + bbfromfilebutton_->signal_clicked().connect( + sigc::mem_fun(*this, &GGraphics::onBBFromFileClicked)); + + // disable for read-only documents + bcview().addReadOnly(bbfromfilebutton_); + bcview().addReadOnly(clipcheck_); + PopulateComboBox(bbunitscombo_, getBBUnits()); + + + // the extra section + + // disable for read-only documents + bcview().addReadOnly(anglespin_); + bcview().addReadOnly(origincombo_); + bcview().addReadOnly(subfigcheck_); + bcview().addReadOnly(latexoptsentry_); + bcview().addReadOnly(draftcheck_); + bcview().addReadOnly(unzipcheck_); + + anglespin_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + origincombo_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + subfigentry_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + latexoptsentry_->signal_changed().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + draftcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + unzipcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GGraphics::onInput)); + + subfigcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GGraphics::onSubFigCheckToggled)); + + vector origindata = getRotationOriginData(); + + // Store the identifiers for later + origins_ = getSecond(origindata); + PopulateComboBox(origincombo_, getFirst(origindata)); + + // set the right default unit + switch (lyxrc.default_papersize) { + case PAPER_DEFAULT: break; + case PAPER_USLETTER: + case PAPER_LEGALPAPER: + case PAPER_EXECUTIVEPAPER: defaultUnit = "in"; break; + case PAPER_A3PAPER: + case PAPER_A4PAPER: + case PAPER_A5PAPER: + case PAPER_B5PAPER: defaultUnit = "cm"; break; + } +} + + +void GGraphics::onSizingModeChange() +{ + bool const scalingmode = setscalingradio_->get_active(); + + outputscalespin_->set_sensitive(scalingmode); + widthspin_->set_sensitive(!scalingmode); + heightspin_->set_sensitive(!scalingmode); + widthunitscombo_->set_sensitive(!scalingmode); + heightunitscombo_->set_sensitive(!scalingmode); + aspectcheck_->set_sensitive(!scalingmode); + bc().input(ButtonPolicy::SMI_VALID); +} + + +void GGraphics::PopulateComboBox(Gtk::ComboBox * combo, + vector const & strings) +{ + Glib::RefPtr model = Gtk::ListStore::create(cols_); + vector::const_iterator it = strings.begin(); + vector::const_iterator end = strings.end(); + for (int rowindex = 0; it != end; ++it, ++rowindex) { + Gtk::TreeModel::iterator row = model->append(); + (*row)[stringcol_] = *it; + } + + combo->set_model(model); + Gtk::CellRendererText * cell = Gtk::manage(new Gtk::CellRendererText); + combo->pack_start(*cell, true); + combo->add_attribute(*cell, "text", 0); +} + + +void GGraphics::updateComboFromLength(Gtk::ComboBox * combo, + LyXLength const & len) +{ + string unit = stringFromUnit(len.unit()); + if (unit.empty()) + unit = defaultUnit; + + Gtk::TreeModel::iterator it = combo->get_model()->children().begin(); + Gtk::TreeModel::iterator end = combo->get_model()->children().end(); + for (; it != end ; ++it) { + if ((*it)[stringcol_] == unit) { + combo->set_active(it); + return; + } + } + // Fallen through, we didn't find the target length! + combo->set_active(0); + lyxerr << "GGraphics::updateComboFromLength: couldn't find " + "target unit '" << unit << "'\n"; +} + + +void GGraphics::apply() +{ + // Create the parameters structure and fill the data from the dialog. + InsetGraphicsParams & igp = controller().params(); + + // the file section + igp.filename.set(fileentry_->get_text(), + kernel().bufferFilepath()); + + igp.lyxscale = + static_cast(displayscalespin_->get_adjustment()->get_value()); + if (igp.lyxscale == 0) { + igp.lyxscale = 100; + } + + switch (displaycombo_->get_active_row_number()) { + case 4: + igp.display = graphics::NoDisplay; + break; + case 3: + igp.display = graphics::ColorDisplay; + break; + case 2: + igp.display = graphics::GrayscaleDisplay; + break; + case 1: + igp.display = graphics::MonochromeDisplay; + break; + case 0: + igp.display = graphics::DefaultDisplay; + } + + if (setscalingradio_->get_active()) { + igp.scale = outputscalespin_->get_adjustment()->get_value(); + if (float_equal(igp.scale, 0.0, 0.05)) + igp.scale = 100.0; + igp.width = LyXLength(); + } else { + igp.scale = 0.0; + Glib::ustring const widthunit = + (*widthunitscombo_->get_active())[stringcol_]; + igp.width = LyXLength(widthspin_->get_text() + widthunit); + } + + + Glib::ustring const heightunit = + (*heightunitscombo_->get_active())[stringcol_]; + igp.height = LyXLength(heightspin_->get_text() + heightunit); + + igp.keepAspectRatio = aspectcheck_->get_active(); + igp.draft = draftcheck_->get_active(); + igp.noUnzip = !unzipcheck_->get_active(); + + // the bb section + + if (!controller().bbChanged) { + // don't write anything + igp.bb.erase(); + } else { + Glib::ustring const bbunit = (*bbunitscombo_->get_active())[stringcol_]; + string bb; + + if (leftbottomxspin_->get_text().empty()) + bb = "0"; + else + bb = leftbottomxspin_->get_text() + bbunit; + + bb += ' '; + + if (leftbottomyspin_->get_text().empty()) + bb += "0"; + else + bb += leftbottomyspin_->get_text() + bbunit; + + bb += ' '; + + if (righttopxspin_->get_text().empty()) + bb += "0"; + else + bb += righttopxspin_->get_text() + bbunit; + + bb += ' '; + + if (righttopyspin_->get_text().empty()) + bb += "0"; + else + bb += righttopyspin_->get_text() + bbunit; + + /// The bounding box with "xLB yLB yRT yRT ", divided by a space! + igp.bb = bb; + } + igp.clip = clipcheck_->get_active(); + + // the extra section + igp.rotateAngle = anglespin_->get_adjustment()->get_value(); + + int const origin_pos = origincombo_->get_active_row_number(); + igp.rotateOrigin = origins_[origin_pos]; + + igp.subcaption = subfigcheck_->get_active(); + igp.subcaptionText = subfigentry_->get_text(); + + igp.special = latexoptsentry_->get_text(); +} + + +void GGraphics::update() { + // Update dialog with details from inset + InsetGraphicsParams & igp = controller().params(); + + // the file section + string const name = + igp.filename.outputFilename(kernel().bufferFilepath()); + fileentry_->set_text(name); + displayscalespin_->get_adjustment()->set_value(igp.lyxscale); + + + switch (igp.display) { + case graphics::NoDisplay: + displaycombo_->set_active(4); + break; + case graphics::ColorDisplay: + displaycombo_->set_active(3); + break; + case graphics::GrayscaleDisplay: + displaycombo_->set_active(2); + break; + case graphics::MonochromeDisplay: + displaycombo_->set_active(1); + break; + case graphics::DefaultDisplay: + displaycombo_->set_active(0); + } + + outputscalespin_->get_adjustment()->set_value(igp.scale); + widthspin_->get_adjustment()->set_value(igp.width.value()); + updateComboFromLength(widthunitscombo_, igp.width); + heightspin_->get_adjustment()->set_value(igp.height.value()); + updateComboFromLength(heightunitscombo_, igp.height); + + if (!float_equal(igp.scale, 0.0, 0.05)) { + //scaling sizing mode + setscalingradio_->set_active(true); + } else { + setsizeradio_->set_active(true); + } + + aspectcheck_->set_active(igp.keepAspectRatio); + draftcheck_->set_active(igp.draft); + unzipcheck_->set_active(!igp.noUnzip); + + // the bb section + // set the bounding box values, if exists. First we need the whole + // path, because the controller knows nothing about the doc-dir + updateBB(igp.filename.absFilename(), igp.bb); + clipcheck_->set_active(igp.clip); + + // the extra section + anglespin_->get_adjustment()->set_value(igp.rotateAngle); + + int origin_pos; + if (igp.rotateOrigin.empty()) { + origin_pos = 0; + } else { + origin_pos = findPos(origins_, igp.rotateOrigin); + } + origincombo_->set_active(origin_pos); + + + subfigcheck_->set_active(igp.subcaption); + subfigentry_->set_text(igp.subcaptionText); + subfigentry_->set_sensitive(subfigcheck_->get_active()); + latexoptsentry_->set_text(igp.special); + + // open dialog in the file-tab, whenever filename is empty + if (igp.filename.empty()) { + notebook_->set_current_page(0); + } + + bc().input(ButtonPolicy::SMI_INVALID); +} + + +void GGraphics::updateBB(string const & filename, string const & bb_inset) +{ + // Update dialog with details from inset + // set the bounding box values, if exists. First we need the whole + // path, because the controller knows nothing about the doc-dir + + if (bb_inset.empty()) { + lyxerr[Debug::GRAPHICS] + << "GGraphics::updateBB() [no BoundingBox]\n"; + string const bb = controller().readBB(filename); + if (!bb.empty()) { + // get the values from the file + // in this case we always have the point-unit + leftbottomxspin_->set_text(token(bb, ' ', 0)); + leftbottomyspin_->set_text(token(bb, ' ', 1)); + righttopxspin_->set_text(token(bb, ' ', 2)); + righttopyspin_->set_text(token(bb, ' ', 3)); + } else { + // no bb from file + leftbottomxspin_->set_text(""); + leftbottomyspin_->set_text(""); + righttopxspin_->set_text(""); + righttopyspin_->set_text(""); + } + updateComboFromLength(bbunitscombo_,LyXLength("bp")); + } else { + // get the values from the inset + lyxerr[Debug::GRAPHICS] + << "FormGraphics::updateBB(): igp has BoundingBox" + << " ["<< bb_inset << "]\n"; + + LyXLength anyLength; + anyLength = LyXLength(token(bb_inset, ' ', 0)); + + updateComboFromLength(bbunitscombo_, anyLength); + + leftbottomxspin_->get_adjustment()->set_value(anyLength.value()); + + anyLength = LyXLength(token(bb_inset, ' ', 1)); + leftbottomyspin_->get_adjustment()->set_value(anyLength.value()); + + anyLength = LyXLength(token(bb_inset, ' ', 2)); + righttopxspin_->get_adjustment()->set_value(anyLength.value()); + + anyLength = LyXLength(token(bb_inset, ' ', 3)); + righttopyspin_->get_adjustment()->set_value(anyLength.value()); + } + controller().bbChanged = false; +} + + +void GGraphics::onBrowseClicked() +{ + // Get the filename from the dialog + string const in_name = fileentry_->get_text(); + string const out_name = controller().browse(in_name); + lyxerr[Debug::GRAPHICS] + << "[FormGraphics]out_name: " << out_name << "\n"; + if (out_name != in_name && !out_name.empty()) { + fileentry_->set_text(out_name); + } + if (controller().isFilenameValid(out_name) && + !controller().bbChanged) { + updateBB(out_name, string()); + } + + bc().input(ButtonPolicy::SMI_VALID); +} + + +void GGraphics::onBBChange() +{ + controller().bbChanged = true; + bc().input(ButtonPolicy::SMI_VALID); +} + + +void GGraphics::onBBFromFileClicked() +{ + string const filename = fileentry_->get_text(); + if (!filename.empty()) { + string bb = controller().readBB(filename); + if (!bb.empty()) { + leftbottomxspin_->set_text(token(bb, ' ', 0)); + leftbottomyspin_->set_text(token(bb, ' ', 1)); + righttopxspin_->set_text(token(bb, ' ', 2)); + righttopyspin_->set_text(token(bb, ' ', 3)); + updateComboFromLength(bbunitscombo_,LyXLength("bp")); + } + controller().bbChanged = false; + } else { + leftbottomxspin_->set_text(""); + leftbottomyspin_->set_text(""); + righttopxspin_->set_text(""); + righttopyspin_->set_text(""); + updateComboFromLength(bbunitscombo_,LyXLength("bp")); + } + bc().input(ButtonPolicy::SMI_VALID); +} + + +void GGraphics::onSubFigCheckToggled() +{ + subfigentry_->set_sensitive(subfigcheck_->get_active()); + bc().input(ButtonPolicy::SMI_VALID); +} + + +void GGraphics::onEditClicked() +{ + controller().editGraphics(); +} + + +void GGraphics::onInput() +{ + bc().input(ButtonPolicy::SMI_VALID); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GGraphics.h b/src/frontends/gtk/GGraphics.h new file mode 100644 index 0000000000..3eb3af1e9f --- /dev/null +++ b/src/frontends/gtk/GGraphics.h @@ -0,0 +1,106 @@ +// -*- C++ -*- +/** + * \file GGraphics.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 GGRAPHICS_H +#define GGRAPHICS_H + +#include "GViewBase.h" + +#include "lyxlength.h" + +#include +#include + +namespace lyx { +namespace frontend { + +class ControlGraphics; + +/** This class provides a GTK+ implementation of the Graphics Dialog. + */ +class GGraphics + : public GViewCB { +public: + /// + GGraphics(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(); + /// Update the BoundingBox info. + void updateBB(std::string const & filename, std::string const & bb_inset); + + void PopulateComboBox(Gtk::ComboBox * combo, + std::vector const & strings); + + void updateComboFromLength(Gtk::ComboBox * combo, + LyXLength const & len); + + bool updating_; + + /// Store the LaTeX names for the rotation origins. + std::vector origins_; + + Gtk::TreeModelColumn stringcol_; + Gtk::TreeModel::ColumnRecord cols_; + + Gtk::Notebook * notebook_; + + // File Page + Gtk::Entry * fileentry_; + Gtk::SpinButton * displayscalespin_; + Gtk::SpinButton * outputscalespin_; + Gtk::Button * browsebutton_; + Gtk::Button * editbutton_; + Gtk::ComboBox * displaycombo_; + Gtk::SpinButton * widthspin_; + Gtk::SpinButton * heightspin_; + Gtk::CheckButton * aspectcheck_; + Gtk::ComboBox * widthunitscombo_; + Gtk::ComboBox * heightunitscombo_; + Gtk::RadioButton * setscalingradio_; + Gtk::RadioButton * setsizeradio_; + + // Bounding Box Page + Gtk::CheckButton * clipcheck_; + Gtk::SpinButton * righttopxspin_; + Gtk::SpinButton * righttopyspin_; + Gtk::SpinButton * leftbottomxspin_; + Gtk::SpinButton * leftbottomyspin_; + Gtk::ComboBox * bbunitscombo_; + Gtk::Button * bbfromfilebutton_; + + // Extra Page + Gtk::SpinButton * anglespin_; + Gtk::ComboBox * origincombo_; + Gtk::CheckButton * subfigcheck_; + Gtk::Entry * subfigentry_; + Gtk::Entry * latexoptsentry_; + Gtk::CheckButton * draftcheck_; + Gtk::CheckButton * unzipcheck_; + + void onSizingModeChange(); + void onBrowseClicked(); + void onBBChange(); + void onBBFromFileClicked(); + void onSubFigCheckToggled(); + void onEditClicked(); + void onInput(); +}; + +} // namespace frontend +} // namespace lyx + +#endif // GGRAPHICS_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 3b0d85a9c8..1e193ac341 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -30,6 +30,8 @@ libgtk_la_SOURCES = \ GCharacter.h \ GErrorList.C \ GErrorList.h \ + GGraphics.C \ + GGraphics.h \ GLog.C \ GLog.h \ GLyXKeySym.C \ @@ -116,7 +118,6 @@ xforms_objects = \ ../xforms/FormERT.lo \ ../xforms/FormExternal.lo \ ../xforms/FormFloat.lo \ - ../xforms/FormGraphics.lo \ ../xforms/FormInclude.lo \ ../xforms/FormMathsBitmap.lo \ ../xforms/FormMathsDelim.lo \ diff --git a/src/frontends/gtk/ghelpers.C b/src/frontends/gtk/ghelpers.C index 1d19e18055..87d37574f8 100644 --- a/src/frontends/gtk/ghelpers.C +++ b/src/frontends/gtk/ghelpers.C @@ -13,15 +13,25 @@ #include "ghelpers.h" #include "debug.h" +#include "lengthcommon.h" #include "support/filetools.h" #include "support/path_defines.h" using std::string; +using std::vector; namespace lyx { namespace frontend { +vector const buildLengthUnitList() +{ + vector data(unit_name_gui, unit_name_gui + num_units); + + return data; +} + + string const findGladeFile(string const & name) { // First, search in the installation directories. diff --git a/src/frontends/gtk/ghelpers.h b/src/frontends/gtk/ghelpers.h index 738ca8a126..b0bce13b8b 100644 --- a/src/frontends/gtk/ghelpers.h +++ b/src/frontends/gtk/ghelpers.h @@ -18,6 +18,8 @@ namespace lyx { namespace frontend { +std::vector const buildLengthUnitList(); + /** name is the name of the glade file, without path or extension. * Eg, "aboutlyx", "tableCreate". */ diff --git a/src/frontends/gtk/glade/graphics.glade b/src/frontends/gtk/glade/graphics.glade new file mode 100644 index 0000000000..aa0d9c5363 --- /dev/null +++ b/src/frontends/gtk/glade/graphics.glade @@ -0,0 +1,1687 @@ + + + + + + + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + GTK_RELIEF_NORMAL + True + 0 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-undo + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Restore + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + gtk-apply + True + GTK_RELIEF_NORMAL + True + -10 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 6 + True + False + 0 + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + 6 + True + 2 + 3 + False + 6 + 6 + + + + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Browse... + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-execute + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Run _Editor + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 2 + 3 + 1 + 2 + fill + + + + + + + True + File: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + File + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + + + + + True + <b>Source File</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 5 + 6 + 12 + 0 + + + + True + False + 0 + + + + True + _Scale: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + DisplayScale + + + 0 + False + False + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 1000 1 10 10 + + + 6 + False + True + + + + + + True + % + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + True + Default +Monochrome +Grayscale +Color +Do not display + + + 6 + False + True + GTK_PACK_END + + + + + + True + Display Mode: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + GTK_PACK_END + + + + + + + + + + True + <b>LyX Display</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + True + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 6 + 6 + 12 + 0 + + + + True + 5 + 4 + False + 6 + 6 + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 0.1 1e+06 1 10 10 + + + 2 + 3 + 2 + 3 + + + + + + + True + True + _Maintain aspect ratio + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 2 + 3 + 4 + 5 + fill + + + + + + + True + True + Set Scaling + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Sca_le: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + OutputScale + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 10000 1 10 10 + + + 2 + 3 + 0 + 1 + + + + + + + True + _Width: + True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + Width + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + _Height: + True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + Height + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + % + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 3 + 4 + 0 + 1 + fill + + + + + + + True + + + 3 + 4 + 2 + 3 + fill + fill + + + + + + True + + + 3 + 4 + 3 + 4 + fill + fill + + + + + + True + + + 1 + 4 + 1 + 2 + fill + + + + + + True + True + Set Size + True + GTK_RELIEF_NORMAL + True + False + False + True + SetScaling + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 0.1 1e+06 1 10 10 + + + 2 + 3 + 3 + 4 + + + + + + + + + + + True + <b>Output Size</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + True + + + + + False + True + + + + + + True + Image + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 6 + True + False + 0 + + + + True + False + 0 + + + + True + 3 + 3 + False + 6 + 6 + + + + True + Right top: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Left bottom: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + X + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + Y + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 1e+06 1 10 10 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 0 1e+06 1 10 10 + + + 1 + 2 + 2 + 3 + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 0 1e+06 1 10 10 + + + 2 + 3 + 1 + 2 + + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 0 1e+06 1 10 10 + + + 2 + 3 + 2 + 3 + + + + + + 0 + True + True + + + + + + True + False + 0 + + + + + + + + True + False + 0 + + + + + + + + True + + + 0 + False + True + GTK_PACK_END + + + + + + True + Units: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + GTK_PACK_END + + + + + + + + + 0 + False + True + + + + + + + + + 0 + True + True + + + + + 0 + False + True + + + + + + + + + + True + False + 0 + + + + True + True + Clip to bounding box + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-refresh + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Get from file + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + GTK_PACK_END + + + + + 0 + False + True + + + + + + + + + False + True + + + + + + True + Bounding Box + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 6 + True + False + 0 + + + + True + False + 0 + + + + True + Rotation Angle: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 360 -360 360 1 10 10 + + + 5 + False + True + + + + + + True + deg. + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + True + + + 5 + False + True + GTK_PACK_END + + + + + + True + Rotation Origin: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + GTK_PACK_END + + + + + 0 + False + True + + + + + + True + True + Use Subfigure + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 5 + False + False + + + + + + True + False + 0 + + + + True + Subfigure Caption: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 12 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + + + 6 + True + True + + + + + 0 + False + False + + + + + + True + False + 0 + + + + True + LaTeX options: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + + + 6 + True + True + + + + + 6 + False + True + + + + + + True + True + Draft M_ode + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Unzip on export + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + False + True + + + + + + True + Extra + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + + -- 2.39.2