* GGraphics, GVSpace, GBox: update to use new ghelpers functions

* ghelpers: add getLengthFromWidgets, setWidgetsFromLength,
  comboBoxTextSet, populateUnitCombo.  Remove buildLengthNoRelUnitList.
* GDocument.[Ch], Makefile.am, Dialogs.C: start work on document
  dialog.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9709 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Spray 2005-03-11 00:25:56 +00:00
parent 2db5077754
commit fc71ca3447
16 changed files with 2772 additions and 207 deletions

View File

@ -1,3 +1,11 @@
2005-03-10 John Spray <spray_john@users.sf.net>
* GGraphics, GVSpace, GBox: update to use new ghelpers functions
* ghelpers: add getLengthFromWidgets, setWidgetsFromLength,
comboBoxTextSet, populateUnitCombo. Remove buildLengthNoRelUnitList.
* GDocument.[Ch], Makefile.am, Dialogs.C: start work on document
dialog.
2005-03-04 John Spray <spray_john@users.sf.net>
* GToolbar.C: remember existing selection when update()ing

View File

@ -67,7 +67,7 @@
#include "GChanges.h"
#include "GCharacter.h"
#include "FormCitation.h"
#include "FormDocument.h"
#include "GDocument.h"
#include "GErrorList.h"
#include "GERT.h"
#include "FormExternal.h"
@ -217,9 +217,10 @@ Dialogs::DialogPtr Dialogs::build(string const & name)
dialog->setView(new FormCitation(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "document") {
dialog->bc().view(new GBC(dialog->bc()));
dialog->setController(new ControlDocument(*dialog));
dialog->setView(new FormDocument(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
dialog->setView(new GDocument(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "errorlist") {
dialog->bc().view(new GBC(dialog->bc()));
dialog->setController(new ControlErrorList(*dialog));

View File

@ -115,7 +115,7 @@ void GBox::doBuild()
//widthunitscombo_ is populated in setSpecial
box_gui_tokens_special_length(ids_spec_, gui_names_spec_);
vector<string> heightunits = buildLengthUnitList();
vector<string> heightunits = buildLengthUnitList(true);
// Append special entries, skipping the first item "None"
heightunits.insert(heightunits.end(),
++gui_names_spec_.begin(), gui_names_spec_.end());
@ -220,7 +220,7 @@ void GBox::setSpecial(bool ibox)
unsigned int const initselection = widthunitscombo_->get_active_row_number();
widthunitsstore_->clear();
vector<string> normalunits = buildLengthUnitList();
vector<string> normalunits = buildLengthUnitList(true);
if (ibox) {
vector<string>::const_iterator it = normalunits.begin();
vector<string>::const_iterator end = normalunits.end();

View File

@ -0,0 +1,289 @@
/**
* \file GDocument.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 <config.h>
// 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 "GDocument.h"
#include "ghelpers.h"
#include "ControlDocument.h"
#include "controllers/helper_funcs.h"
#include "support/lstrings.h"
#include "lyxtextclasslist.h"
#include "bufferparams.h"
#include "tex-strings.h"
using std::string;
namespace lyx {
using support::bformat;
namespace frontend {
GDocument::GDocument(Dialog & parent)
: GViewCB<ControlDocument, GViewGladeB>(parent, _("Document Settings"), false)
{}
void GDocument::doBuild()
{
string const gladeName = findGladeFile("document");
xml_ = Gnome::Glade::Xml::create(gladeName);
// Manage the action area buttons
Gtk::Button * button;
xml_->get_widget("Cancel", button);
setCancel(button);
xml_->get_widget("OK", button);
setOK(button);
xml_->get_widget("Apply", button);
setApply(button);
xml_->get_widget("Revert", button);
setRestore(button);
xml_->get_widget("UseClassDefaults", button);
button->signal_clicked().connect(
sigc::mem_fun(*this, &GDocument::resetToDefaults));
xml_->get_widget("SaveAsDocumentDefaults", button);
button->signal_clicked().connect(
sigc::mem_fun(*this, &GDocument::saveAsDefaults));
// *** Start "Document" Page ***
Gtk::Box * box = NULL;
xml_->get_widget("DocumentClass", box);
// Prevent combo making dialog super-wide due to long class names
classcombo_.set_size_request(1, -1);
box->pack_start(classcombo_, true, true, 0);
box->show_all();
// Populate Document Class combo
for (LyXTextClassList::const_iterator cit = textclasslist.begin();
cit != textclasslist.end(); ++cit) {
if (cit->isTeXClassAvailable()) {
classcombo_.append_text(cit->description());
} else {
string item =
bformat(_("Unavailable: %1$s"), cit->description());
classcombo_.append_text(item);
}
}
xml_->get_widget("ExtraOptions", extraoptionsentry_);
xml_->get_widget("PostscriptDriver", box);
box->pack_start(psdrivercombo_, true, true, 0);
box->show_all();
// Populate Postscript driver combo
for (int i = 0; tex_graphics[i][0]; ++i) {
psdrivercombo_.append_text(tex_graphics[i]);
}
xml_->get_widget("Font", box);
box->pack_start(fontcombo_, true, true, 0);
box->show_all();
// Populate font combo
for (int i = 0; tex_fonts[i][0]; ++i) {
fontcombo_.append_text(tex_fonts[i]);
}
xml_->get_widget("FontSize", box);
box->pack_start(fontsizecombo_, true, true, 0);
box->show_all();
fontsizecombo_.append_text(_("Default"));
fontsizecombo_.append_text(_("10"));
fontsizecombo_.append_text(_("11"));
fontsizecombo_.append_text(_("12"));
// These are the corresponding strings to be passed to the backend
fontsizemap_[0] = "default";
fontsizemap_[1] = "10";
fontsizemap_[2] = "11";
fontsizemap_[3] = "12";
Gtk::SpinButton * spin;
xml_->get_widget("LineSpacing", spin);
linespacingadj_ = spin->get_adjustment();
xml_->get_widget("Indentation", indentradio_);
xml_->get_widget("VerticalSpace", vspaceradio_);
vspaceradio_->signal_toggled().connect(
sigc::mem_fun(*this, &GDocument::updateParagraphSeparationSensitivity));
xml_->get_widget("VerticalSpaceSize", box);
box->pack_start(vspacesizecombo_, true, true, 0);
box->show_all();
// The order of these items is magic
vspacesizecombo_.append_text(_("Small Skip"));
vspacesizecombo_.append_text(_("Medium Skip"));
vspacesizecombo_.append_text(_("Big Skip"));
vspacesizecombo_.append_text(_("Custom"));
vspacesizemap_[0] = VSpace::SMALLSKIP;
vspacesizemap_[1] = VSpace::MEDSKIP;
vspacesizemap_[2] = VSpace::BIGSKIP;
vspacesizemap_[3] = VSpace::LENGTH;
vspacesizecombo_.signal_changed().connect(
sigc::mem_fun(*this,
&GDocument::updateParagraphSeparationSensitivity));
xml_->get_widget("VerticalSpaceLength", vspacelengthspin_);
vspacelengthadj_ = vspacelengthspin_->get_adjustment();
xml_->get_widget("VerticalSpaceUnit", box);
box->pack_start(vspaceunitcombo_, true, true, 0);
box->show_all();
populateUnitCombo(vspaceunitcombo_, false);
updateParagraphSeparationSensitivity();
// *** End "Document" Page ***
}
void GDocument::update()
{
BufferParams & params = controller().params();
// *** Start "Document" Page ***
// Document Class
classcombo_.set_active(params.textclass);
// Extra Options
extraoptionsentry_->set_text(params.options);
// Postscript driver
comboBoxTextSet(psdrivercombo_, params.graphicsDriver);
// Font & Size
comboBoxTextSet(fontcombo_, params.fonts);
for (int i = 0; i <= 3; ++i) {
if (fontsizemap_[i] == params.fontsize)
fontsizecombo_.set_active(i);
}
// Line Spacing
linespacingadj_->set_value(params.spacing().getValue());
// Paragraph Separation
if (params.paragraph_separation == BufferParams::PARSEP_INDENT) {
indentradio_->set_active(true);
} else {
vspaceradio_->set_active(true);
}
// Paragraph Separation Vertical Space Size
VSpace::vspace_kind const skipkind = params.getDefSkip().kind();
for (int i = 0; i <= 3; ++i) {
if (vspacesizemap_[i] == skipkind)
vspacesizecombo_.set_active(i);
}
LyXLength vspacelen = params.getDefSkip().length().len();
setWidgetsFromLength(*vspacelengthadj_, vspaceunitcombo_, vspacelen);
// *** End "Document" Page ***
// Be a cheesy bastard, for the moment
bc().valid();
}
void GDocument::apply()
{
BufferParams & params = controller().params();
// *** Start "Document" Page ***
// Document Class
params.textclass = classcombo_.get_active_row_number();
// Extra Options
params.options = extraoptionsentry_->get_text();
// Postscript Driver
params.graphicsDriver = psdrivercombo_.get_active_text();
// Font & Size
params.fonts = fontcombo_.get_active_text();
params.fontsize =
fontsizemap_[fontsizecombo_.get_active_row_number()];
// Line Spacing
params.spacing().set(Spacing::Other, linespacingadj_->get_value());
// Paragraph Separation
if (indentradio_->get_active()) {
params.paragraph_separation = BufferParams::PARSEP_INDENT;
} else {
params.paragraph_separation = BufferParams::PARSEP_SKIP;
}
// Paragraph Separation Vertical Space Size
VSpace::vspace_kind const selection =
vspacesizemap_[vspacesizecombo_.get_active_row_number()];
params.setDefSkip(VSpace(selection));
if (selection == VSpace::LENGTH) {
string const length =
getLengthFromWidgets(*vspacelengthadj_,
vspaceunitcombo_);
params.setDefSkip(VSpace(LyXGlueLength(length)));
}
// *** End "Document" Page ***
}
void GDocument::saveAsDefaults()
{
apply();
controller().saveAsDefault();
}
void GDocument::resetToDefaults()
{
BufferParams & params = controller().params();
params.textclass = classcombo_.get_active_row_number();
params.useClassDefaults();
update();
}
void GDocument::updateParagraphSeparationSensitivity()
{
bool const vspacesensitive = vspaceradio_->get_active();
vspacesizecombo_.set_sensitive(vspacesensitive);
bool const lengthsensitive = vspacesensitive &&
(vspacesizecombo_.get_active_row_number() == 3);
vspacelengthspin_->set_sensitive(lengthsensitive);
vspaceunitcombo_.set_sensitive(lengthsensitive);
}
} // namespace frontend
} // namespace lyx

View File

@ -0,0 +1,67 @@
// -*- C++ -*-
/**
* \file GDocument.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \auther John Spray
*
* Full author contact details are available in file CREDITS.
*/
#ifndef GDOCUMENT_H
#define GDOCUMENT_H
#include "GViewBase.h"
#include "vspace.h"
#include <gtkmm.h>
#include <map>
namespace lyx {
namespace frontend {
class ControlDocument;
/** This class provides a gtk implementation of the document dialog.
*/
class GDocument
: public GViewCB<ControlDocument, GViewGladeB> {
public:
GDocument(Dialog &);
private:
/// Build the dialog
virtual void doBuild();
/// Apply from dialog
virtual void apply();
/// Update the dialog
virtual void update();
void saveAsDefaults();
void resetToDefaults();
// *** Start "Document" Page ***
Gtk::ComboBoxText classcombo_;
Gtk::Entry * extraoptionsentry_;
Gtk::ComboBoxText psdrivercombo_;
Gtk::ComboBoxText fontcombo_;
Gtk::ComboBoxText fontsizecombo_;
Gtk::Adjustment * linespacingadj_;
Gtk::RadioButton * indentradio_;
Gtk::RadioButton * vspaceradio_;
Gtk::ComboBoxText vspacesizecombo_;
std::map<int, std::string> fontsizemap_;
std::map<int, VSpace::vspace_kind> vspacesizemap_;
Gtk::ComboBoxText vspaceunitcombo_;
Gtk::SpinButton * vspacelengthspin_;
Gtk::Adjustment * vspacelengthadj_;
void updateParagraphSeparationSensitivity();
// *** End "Document" Page ***
};
} // namespace frontend
} // namespace lyx
#endif

View File

@ -81,8 +81,15 @@ void GGraphics::doBuild()
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_);
Gtk::VBox * box;
xml_->get_widget("WidthUnits", box);
box->pack_start(widthunitscombo_, true, true, 0);
box->show_all();
xml_->get_widget("HeightUnits", box);
box->pack_start(heightunitscombo_, true, true, 0);
box->show_all();
xml_->get_widget("SetScaling", setscalingradio_);
xml_->get_widget("SetSize", setsizeradio_);
@ -123,11 +130,11 @@ void GGraphics::doBuild()
sigc::mem_fun(*this, &GGraphics::onInput));
heightspin_->signal_changed().connect(
sigc::mem_fun(*this, &GGraphics::onInput));
heightunitscombo_->signal_changed().connect(
heightunitscombo_.signal_changed().connect(
sigc::mem_fun(*this, &GGraphics::onInput));
widthspin_->signal_changed().connect(
sigc::mem_fun(*this, &GGraphics::onInput));
widthunitscombo_->signal_changed().connect(
widthunitscombo_.signal_changed().connect(
sigc::mem_fun(*this, &GGraphics::onInput));
aspectcheck_->signal_toggled().connect(
sigc::mem_fun(*this, &GGraphics::onInput));
@ -143,9 +150,8 @@ void GGraphics::doBuild()
editbutton_->signal_clicked().connect(
sigc::mem_fun(*this, &GGraphics::onEditClicked));
vector<string> const unit_list = buildLengthUnitList();
PopulateComboBox(heightunitscombo_, unit_list);
PopulateComboBox(widthunitscombo_, unit_list);
populateUnitCombo(widthunitscombo_, true);
populateUnitCombo(heightunitscombo_, true);
// the bounding box page
leftbottomxspin_->signal_changed().connect(
@ -211,8 +217,8 @@ void GGraphics::onSizingModeChange()
outputscalespin_->set_sensitive(scalingmode);
widthspin_->set_sensitive(!scalingmode);
heightspin_->set_sensitive(!scalingmode);
widthunitscombo_->set_sensitive(!scalingmode);
heightunitscombo_->set_sensitive(!scalingmode);
widthunitscombo_.set_sensitive(!scalingmode);
heightunitscombo_.set_sensitive(!scalingmode);
aspectcheck_->set_sensitive(!scalingmode);
bc().input(ButtonPolicy::SMI_VALID);
}
@ -276,15 +282,10 @@ void GGraphics::apply()
igp.width = LyXLength();
} else {
igp.scale = string();
Glib::ustring const widthunit =
(*widthunitscombo_->get_active())[stringcol_];
igp.width = LyXLength(widthspin_->get_text() + widthunit);
igp.width = LyXLength(getLengthFromWidgets(*widthspin_->get_adjustment(), widthunitscombo_));
}
Glib::ustring const heightunit =
(*heightunitscombo_->get_active())[stringcol_];
igp.height = LyXLength(heightspin_->get_text() + heightunit);
igp.height = LyXLength(getLengthFromWidgets(*heightspin_->get_adjustment(), heightunitscombo_));
igp.keepAspectRatio = aspectcheck_->get_active();
igp.draft = draftcheck_->get_active();
@ -375,12 +376,9 @@ void GGraphics::update() {
}
outputscalespin_->get_adjustment()->set_value(convert<double>(igp.scale));
widthspin_->get_adjustment()->set_value(igp.width.value());
unitsComboFromLength(widthunitscombo_, stringcol_,
igp.width, defaultUnit);
heightspin_->get_adjustment()->set_value(igp.height.value());
unitsComboFromLength(heightunitscombo_, stringcol_,
igp.height, defaultUnit);
setWidgetsFromLength(*widthspin_->get_adjustment(), widthunitscombo_, igp.width);
setWidgetsFromLength(*heightspin_->get_adjustment(), heightunitscombo_, igp.height);
if (!igp.scale.empty()
&& !float_equal(convert<double>(igp.scale), 0.0, 0.05)) {

View File

@ -65,8 +65,8 @@ private:
Gtk::SpinButton * widthspin_;
Gtk::SpinButton * heightspin_;
Gtk::CheckButton * aspectcheck_;
Gtk::ComboBox * widthunitscombo_;
Gtk::ComboBox * heightunitscombo_;
Gtk::ComboBoxText widthunitscombo_;
Gtk::ComboBoxText heightunitscombo_;
Gtk::RadioButton * setscalingradio_;
Gtk::RadioButton * setsizeradio_;

View File

@ -30,10 +30,6 @@ using std::vector;
namespace lyx {
namespace frontend {
namespace {
string defaultUnit("cm");
} // namespace anon
GVSpace::GVSpace(Dialog & parent)
: GViewCB<ControlVSpace, GViewGladeB>(parent, _("VSpace Settings"), false)
{}
@ -47,46 +43,27 @@ void GVSpace::doBuild()
Gtk::Button * button;
xml_->get_widget("Cancel", button);
setCancel(button);
xml_->get_widget("Insert", button);
xml_->get_widget("OK", button);
setOK(button);
xml_->get_widget("Spacing", spacingcombo_);
xml_->get_widget("Value", valuespin_);
xml_->get_widget("ValueUnits", valueunitscombo_);
Gtk::VBox * box;
xml_->get_widget("ValueUnits", box);
box->pack_start(valueunitscombo_, true, true, 0);
box->show_all();
xml_->get_widget("Protect", protectcheck_);
cols_.add(stringcol_);
PopulateComboBox(valueunitscombo_, buildLengthNoRelUnitList());
populateUnitCombo(valueunitscombo_, false);
spacingcombo_->signal_changed().connect(
sigc::mem_fun(*this, &GVSpace::onSpacingComboChanged));
}
void GVSpace::PopulateComboBox(Gtk::ComboBox * combo,
vector<string> const & strings)
{
Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(cols_);
vector<string>::const_iterator it = strings.begin();
vector<string>::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 GVSpace::update()
{
// set the right default unit
defaultUnit = getDefaultUnit();
VSpace const space = controller().params();
int pos = 0;
@ -117,14 +94,10 @@ void GVSpace::update()
bool const custom_vspace = space.kind() == VSpace::LENGTH;
if (custom_vspace) {
LyXLength length(space.length().asString());
valuespin_->get_adjustment()->set_value(length.value());
unitsComboFromLength(valueunitscombo_, stringcol_,
length, defaultUnit);
setWidgetsFromLength(*valuespin_->get_adjustment(), valueunitscombo_, space.length().len());
} else {
valuespin_->get_adjustment()->set_value(0.0f);
unitsComboFromLength(valueunitscombo_, stringcol_,
LyXLength(defaultUnit), defaultUnit);
setWidgetsFromLength(*valuespin_->get_adjustment(), valueunitscombo_, LyXLength());
}
}
@ -149,9 +122,7 @@ void GVSpace::apply()
space = VSpace(VSpace::VFILL);
break;
case 5:
Glib::ustring const valueunit =
(*valueunitscombo_->get_active())[stringcol_];
space = VSpace(LyXGlueLength(valuespin_->get_text() + valueunit));
space = VSpace(LyXGlueLength(getLengthFromWidgets(*valuespin_->get_adjustment(), valueunitscombo_)));
break;
}
@ -164,7 +135,7 @@ void GVSpace::apply()
void GVSpace::onSpacingComboChanged()
{
bool const custom = spacingcombo_->get_active_row_number() == 5;
valueunitscombo_->set_sensitive(custom);
valueunitscombo_.set_sensitive(custom);
valuespin_->set_sensitive(custom);
}

View File

@ -29,17 +29,11 @@ private:
virtual void doBuild();
virtual void update();
void PopulateComboBox(Gtk::ComboBox * combo,
std::vector<std::string> const & strings);
void onSpacingComboChanged();
Gtk::TreeModelColumn<Glib::ustring> stringcol_;
Gtk::TreeModel::ColumnRecord cols_;
Gtk::ComboBox * spacingcombo_;
Gtk::SpinButton * valuespin_;
Gtk::ComboBox * valueunitscombo_;
Gtk::ComboBoxText valueunitscombo_;
Gtk::CheckButton * protectcheck_;
};

View File

@ -33,6 +33,8 @@ libgtk_la_SOURCES = \
GChanges.h \
GCharacter.C \
GCharacter.h \
GDocument.C \
GDocument.h \
GErrorList.C \
GErrorList.h \
GERT.C \
@ -130,7 +132,6 @@ xforms_objects = \
../xforms/FormCitation.lo \
../xforms/FormColorpicker.lo \
../xforms/FormDialogView.lo \
../xforms/FormDocument.lo \
../xforms/FormExternal.lo \
../xforms/FormMathsBitmap.lo \
../xforms/FormMathsDelim.lo \

View File

@ -28,20 +28,64 @@
#include "support/filetools.h"
#include "support/package.h"
#include <sstream>
using std::string;
using std::vector;
namespace lyx {
namespace frontend {
string const getLengthFromWidgets(Gtk::Adjustment const & adj, Gtk::ComboBoxText const & combo)
{
std::ostringstream os;
os << adj.get_value();
os << combo.get_active_text();
return os.str();
}
void setWidgetsFromLength(Gtk::Adjustment & adj, Gtk::ComboBoxText & combo, LyXLength const & length)
{
adj.set_value(length.value());
string unit = stringFromUnit(length.unit());
if (unit.empty())
unit = getDefaultUnit();
comboBoxTextSet(combo,unit);
}
void populateUnitCombo(Gtk::ComboBoxText & combo, bool const userelative)
{
vector<string> units = buildLengthUnitList(userelative);
vector<string>::const_iterator it = units.begin();
vector<string>::const_iterator end = units.end();
for(; it != end; ++it)
combo.append_text(*it);
}
int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target)
{
int const children = combo.get_model()->children().size();
for (int i = 0; i < children; i++) {
combo.set_active(i);
if (combo.get_active_text() == target)
return 0;
}
return -1;
}
Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func)
{
switch (func.action) {
case LFUN_MENUWRITE: return Gtk::Stock::SAVE;
case LFUN_MENUNEW: return Gtk::Stock::NEW;
case LFUN_WRITEAS: return Gtk::Stock::SAVE_AS;
case LFUN_CENTER: return Gtk::Stock::JUSTIFY_CENTER;
case LFUN_TOCVIEW: return Gtk::Stock::INDEX;
case LFUN_CLOSEBUFFER: return Gtk::Stock::CLOSE;
@ -93,7 +137,7 @@ string const getDefaultUnit()
void unitsComboFromLength(Gtk::ComboBox * combo,
Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
LyXLength const & len,
std::string defunit)
std::string const & defunit)
{
string unit = stringFromUnit(len.unit());
if (unit.empty())
@ -115,23 +159,19 @@ void unitsComboFromLength(Gtk::ComboBox * combo,
}
vector<string> const buildLengthUnitList()
{
vector<string> data(unit_name_gui, unit_name_gui + num_units);
return data;
}
vector<string> const buildLengthNoRelUnitList()
vector<string> const buildLengthUnitList(bool const userelative)
{
//vector<string> data(unit_name_gui, unit_name_gui + num_units);
vector<string> data;
for (int i = 0; i < num_units; ++i) {
string str(unit_name_gui[i]);
if (str.find("%") == string::npos)
data.push_back(unit_name_gui[i]);
if (userelative) {
data = vector<string>(unit_name_gui, unit_name_gui + num_units);
} else {
for (int i = 0; i < num_units; ++i) {
string str(unit_name_gui[i]);
if (str.find("%") == string::npos)
data.push_back(unit_name_gui[i]);
}
}
return data;
}

View File

@ -24,20 +24,32 @@ class FuncRequest;
namespace lyx {
namespace frontend {
std::string const getLengthFromWidgets(
Gtk::Adjustment const & adj,
Gtk::ComboBoxText const & combo);
void setWidgetsFromLength(
Gtk::Adjustment & adj,
Gtk::ComboBoxText & combo,
LyXLength const & length);
int comboBoxTextSet(Gtk::ComboBoxText & combo, Glib::ustring target);
void populateUnitCombo(Gtk::ComboBoxText & combo, bool userelative);
// Get a GTK stockID from a lyx function id.
// Return Gtk::Stock::MISSING_IMAGE if no suitable stock found
Gtk::BuiltinStockID getGTKStockIcon(FuncRequest const & func);
std::string const getDefaultUnit();
void unitsComboFromLength(Gtk::ComboBox * combo,
Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
LyXLength const & len,
std::string defunit);
void unitsComboFromLength(
Gtk::ComboBox * combo,
Gtk::TreeModelColumn<Glib::ustring> const & stringcol,
LyXLength const & len,
std::string const & defunit);
std::vector<std::string> const buildLengthUnitList();
std::vector<std::string> const buildLengthNoRelUnitList();
std::vector<std::string> const buildLengthUnitList(bool userelative);
/** name is the name of the glade file, without path or extension.
* Eg, "aboutlyx", "tableCreate".

View File

@ -8,6 +8,7 @@ dist_glade_DATA = \
box.glade \
changes.glade \
character.glade \
document.glade
errors.glade \
ERT.glade \
float.glade \

File diff suppressed because it is too large Load Diff

View File

@ -112,6 +112,19 @@
</widget>
</child>
<child>
<widget class="GtkButton" id="Close">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="Ok">
<property name="visible">True</property>
@ -124,19 +137,6 @@
<property name="response_id">-5</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="Close">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
@ -773,36 +773,6 @@ Do not display</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="WidthUnits">
<property name="visible">True</property>
<property name="sensitive">False</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="HeightUnits">
<property name="visible">True</property>
<property name="sensitive">False</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
@ -884,6 +854,46 @@ Do not display</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="WidthUnits">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="HeightUnits">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -43,73 +43,15 @@
</child>
<child>
<widget class="GtkButton" id="Insert">
<widget class="GtkButton" id="OK">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-ok</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">_Insert</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
@ -224,8 +166,14 @@ Custom</property>
</child>
<child>
<widget class="GtkComboBox" id="ValueUnits">
<widget class="GtkVBox" id="ValueUnits">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">4</property>