More expansion of gtk document dialog

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9726 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Spray 2005-03-21 09:57:51 +00:00
parent 542c82edbe
commit 293b9f37d7
4 changed files with 1634 additions and 710 deletions

View File

@ -1,3 +1,6 @@
2005-03-21 John Spray <spray_john@users.sf.net>
* GDocument.[Ch]: add "Page", "Margins", "Language" tabs.
2005-03-20 Alfredo Braunstein <abraunst@lyx.org> 2005-03-20 Alfredo Braunstein <abraunst@lyx.org>

View File

@ -23,23 +23,39 @@
#include "ControlDocument.h" #include "ControlDocument.h"
#include "controllers/helper_funcs.h" #include "controllers/helper_funcs.h"
#include "controllers/frnt_lang.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "lyxrc.h"
#include "lyxtextclasslist.h" #include "lyxtextclasslist.h"
#include "bufferparams.h" #include "bufferparams.h"
#include "tex-strings.h" #include "tex-strings.h"
#include "language.h"
using std::string; using std::string;
using std::vector;
namespace lyx { namespace lyx {
using support::bformat; using support::bformat;
using support::token;
namespace frontend { namespace frontend {
namespace {
char const * const encodings[] = { "Language Default", "LaTeX default",
"latin1", "latin2", "latin3", "latin4", "latin5", "latin9",
"koi8-r", "koi8-u", "cp866", "cp1251", "iso88595", "pt154", 0
};
}
GDocument::GDocument(Dialog & parent) GDocument::GDocument(Dialog & parent)
: GViewCB<ControlDocument, GViewGladeB>(parent, _("Document Settings"), false) : GViewCB<ControlDocument, GViewGladeB>(parent, _("Document Settings"), false),
lang_(getSecond(getLanguageData(false)))
{} {}
void GDocument::doBuild() void GDocument::doBuild()
@ -74,6 +90,9 @@ void GDocument::doBuild()
box->pack_start(classcombo_, true, true, 0); box->pack_start(classcombo_, true, true, 0);
box->show_all(); box->show_all();
classcombo_.signal_changed().connect(
sigc::mem_fun(*this, &GDocument::classChanged));
// Populate Document Class combo // Populate Document Class combo
for (LyXTextClassList::const_iterator cit = textclasslist.begin(); for (LyXTextClassList::const_iterator cit = textclasslist.begin();
cit != textclasslist.end(); ++cit) { cit != textclasslist.end(); ++cit) {
@ -109,15 +128,6 @@ void GDocument::doBuild()
xml_->get_widget("FontSize", box); xml_->get_widget("FontSize", box);
box->pack_start(fontsizecombo_, true, true, 0); box->pack_start(fontsizecombo_, true, true, 0);
box->show_all(); 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; Gtk::SpinButton * spin;
xml_->get_widget("LineSpacing", spin); xml_->get_widget("LineSpacing", spin);
@ -155,8 +165,118 @@ void GDocument::doBuild()
populateUnitCombo(vspaceunitcombo_, false); populateUnitCombo(vspaceunitcombo_, false);
updateParagraphSeparationSensitivity(); updateParagraphSeparationSensitivity();
// *** End "Document" Page *** // *** End "Document" Page ***
// *** Begin "Page" Page ***
xml_->get_widget("PageSize", box);
box->pack_start(pagesizecombo_, true, true, 0);
box->show_all();
pagesizecombo_.append_text(_("Default"));
pagesizecombo_.append_text(_("Custom"));
pagesizecombo_.append_text(_("US letter"));
pagesizecombo_.append_text(_("US legal"));
pagesizecombo_.append_text(_("US executive"));
pagesizecombo_.append_text(_("A3"));
pagesizecombo_.append_text(_("A4"));
pagesizecombo_.append_text(_("A5"));
pagesizecombo_.append_text(_("B3"));
pagesizecombo_.append_text(_("B4"));
pagesizecombo_.append_text(_("B5"));
pagesizecombo_.signal_changed().connect(
sigc::mem_fun(*this, &GDocument::pageSizeChanged));
xml_->get_widget("PageWidth", pagewidthspin_);
xml_->get_widget("PageHeight", pageheightspin_);
xml_->get_widget("PageWidthUnits", box);
box->pack_start(pagewidthunitscombo_, true, true, 0);
box->show_all();
populateUnitCombo(pagewidthunitscombo_, false);
xml_->get_widget("PageHeightUnits", box);
box->pack_start(pageheightunitscombo_, true, true, 0);
box->show_all();
populateUnitCombo(pageheightunitscombo_, false);
xml_->get_widget("Portrait", portraitradio_);
xml_->get_widget("Landscape", landscaperadio_);
xml_->get_widget("PageStyle", box);
box->pack_start(pagestylecombo_, true, true, 0);
box->show_all();
xml_->get_widget("DoubleSided", doublesidedtoggle_);
xml_->get_widget("TwoColumns", twocolumnstoggle_);
// *** End "Page" Page ***
// *** Begin "Margins" Page ***
xml_->get_widget("Margins", box);
box->pack_start(marginscombo_, true, true, 0);
box->show_all();
marginscombo_.signal_changed().connect(
sigc::mem_fun(*this, &GDocument::marginsChanged));
pagesizecombo_.signal_changed().connect(
sigc::mem_fun(*this, &GDocument::populateMargins));
xml_->get_widget("MarginTop", mtopspin_);
xml_->get_widget("MarginBottom", mbottomspin_);
xml_->get_widget("MarginInner", minnerspin_);
xml_->get_widget("MarginOuter", mouterspin_);
xml_->get_widget("MarginHeadSep", mheadsepspin_);
xml_->get_widget("MarginHeadHeight", mheadheightspin_);
xml_->get_widget("MarginFootSkip", mfootskipspin_);
xml_->get_widget("MarginTopUnits", box);
box->pack_start(mtopunitcombo_, true, true, 0);
populateUnitCombo(mtopunitcombo_, false);
xml_->get_widget("MarginBottomUnits", box);
box->pack_start(mbottomunitcombo_, true, true, 0);
populateUnitCombo(mbottomunitcombo_, false);
xml_->get_widget("MarginInnerUnits", box);
box->pack_start(minnerunitcombo_, true, true, 0);
populateUnitCombo(minnerunitcombo_, false);
xml_->get_widget("MarginOuterUnits", box);
box->pack_start(mouterunitcombo_, true, true, 0);
populateUnitCombo(mouterunitcombo_, false);
xml_->get_widget("MarginHeadSepUnits", box);
box->pack_start(mheadsepunitcombo_, true, true, 0);
populateUnitCombo(mheadsepunitcombo_, false);
xml_->get_widget("MarginHeadHeightUnits", box);
box->pack_start(mheadheightunitcombo_, true, true, 0);
populateUnitCombo(mheadheightunitcombo_, false);
xml_->get_widget("MarginFootSkipUnits", box);
box->pack_start(mfootskipunitcombo_, true, true, 0);
populateUnitCombo(mfootskipunitcombo_, false);
Gtk::Table * table;
xml_->get_widget("MarginsTable", table);
table->show_all();
// *** End "Margins" Page ***
// *** Start "Language" Page ***
xml_->get_widget("Language", box);
box->pack_start(languagecombo_, true, true, 0);
box->show_all();
vector<LanguagePair> const langs = getLanguageData(false);
vector<LanguagePair>::const_iterator lit = langs.begin();
vector<LanguagePair>::const_iterator lend = langs.end();
for (; lit != lend; ++lit) {
languagecombo_.append_text(lit->first);
}
xml_->get_widget("TextEncoding", box);
box->pack_start(encodingcombo_, true, true, 0);
box->show_all();
int i = 0;
while (encodings[i])
encodingcombo_.append_text(encodings[i++]);
xml_->get_widget("EnglishQuote", qenglishradio_);
xml_->get_widget("SwedishQuote", qswedishradio_);
xml_->get_widget("GermanQuote", qgermanradio_);
xml_->get_widget("PolishQuote", qpolishradio_);
xml_->get_widget("FrenchQuote", qfrenchradio_);
xml_->get_widget("DanishQuote", qdanishradio_);
// *** End "Language" Page ***
} }
@ -177,10 +297,7 @@ void GDocument::update()
// Font & Size // Font & Size
comboBoxTextSet(fontcombo_, params.fonts); comboBoxTextSet(fontcombo_, params.fonts);
for (int i = 0; i <= 3; ++i) { comboBoxTextSet(fontsizecombo_, params.fontsize);
if (fontsizemap_[i] == params.fontsize)
fontsizecombo_.set_active(i);
}
// Line Spacing // Line Spacing
linespacingadj_->set_value(params.spacing().getValue()); linespacingadj_->set_value(params.spacing().getValue());
@ -204,6 +321,113 @@ void GDocument::update()
// *** End "Document" Page *** // *** End "Document" Page ***
// *** Begin "Page" Page ***
int const psize = params.papersize2;
pagesizecombo_.set_active(psize);
setWidgetsFromLength(
*(pagewidthspin_->get_adjustment()),
pagewidthunitscombo_, LyXLength(params.paperwidth));
setWidgetsFromLength(
*(pageheightspin_->get_adjustment()),
pageheightunitscombo_, LyXLength(params.paperheight));
if (params.orientation == ORIENTATION_PORTRAIT)
portraitradio_->set_active();
else
landscaperadio_->set_active();
if (params.columns == 2)
twocolumnstoggle_->set_active(true);
else
twocolumnstoggle_->set_active(false);
doublesidedtoggle_->set_active(params.sides == LyXTextClass::TwoSides);
comboBoxTextSet(pagestylecombo_, params.pagestyle);
// *** End "Page" Page ***
// *** Begin "Margins" Page ***
int item = params.paperpackage;
if (params.use_geometry) {
item = 1;
} else if (item > 0) {
item = item + 1;
}
marginscombo_.set_active(item);
setWidgetsFromLength(
*(mtopspin_->get_adjustment()),
mtopunitcombo_,
LyXLength(params.topmargin));
setWidgetsFromLength(
*(mbottomspin_->get_adjustment()),
mbottomunitcombo_,
LyXLength(params.bottommargin));
setWidgetsFromLength(
*(minnerspin_->get_adjustment()),
minnerunitcombo_,
LyXLength(params.leftmargin));
setWidgetsFromLength(
*(mouterspin_->get_adjustment()),
mouterunitcombo_,
LyXLength(params.rightmargin));
setWidgetsFromLength(
*(mheadsepspin_->get_adjustment()),
mheadsepunitcombo_,
LyXLength(params.headsep));
setWidgetsFromLength(
*(mheadheightspin_->get_adjustment()),
mheadheightunitcombo_,
LyXLength(params.headheight));
setWidgetsFromLength(
*(mfootskipspin_->get_adjustment()),
mfootskipunitcombo_,
LyXLength(params.footskip));
// *** End "Margins" Page ***
// *** Start "Language" Page ***
int const langpos = findPos(lang_,
params.language->lang());
languagecombo_.set_active(langpos);
// Default to "auto"
encodingcombo_.set_active(0);
if (params.inputenc == "default") {
encodingcombo_.set_active(1);
} else {
int i = 0;
while (encodings[i]) {
if (encodings[i] == params.inputenc)
encodingcombo_.set_active(i);
++i;
}
}
switch (params.quotes_language) {
case InsetQuotes::EnglishQ:
qenglishradio_->set_active();
break;
case InsetQuotes::SwedishQ:
qswedishradio_->set_active();
break;
case InsetQuotes::GermanQ:
qgermanradio_->set_active();
break;
case InsetQuotes::PolishQ:
qpolishradio_->set_active();
break;
case InsetQuotes::FrenchQ:
qfrenchradio_->set_active();
break;
case InsetQuotes::DanishQ:
qdanishradio_->set_active();
break;
}
// *** End "Language" Page ***
// Be a cheesy bastard, for the moment // Be a cheesy bastard, for the moment
bc().valid(); bc().valid();
} }
@ -226,8 +450,7 @@ void GDocument::apply()
// Font & Size // Font & Size
params.fonts = fontcombo_.get_active_text(); params.fonts = fontcombo_.get_active_text();
params.fontsize = params.fontsize = fontsizecombo_.get_active_text();
fontsizemap_[fontsizecombo_.get_active_row_number()];
// Line Spacing // Line Spacing
params.spacing().set(Spacing::Other, linespacingadj_->get_value()); params.spacing().set(Spacing::Other, linespacingadj_->get_value());
@ -252,6 +475,98 @@ void GDocument::apply()
} }
// *** End "Document" Page *** // *** End "Document" Page ***
// *** Begin "Page" Page ***
params.papersize2 = VMARGIN_PAPER_TYPE(
pagesizecombo_.get_active_row_number());
params.paperwidth = getLengthFromWidgets(
*(pagewidthspin_->get_adjustment()), pagewidthunitscombo_);
params.paperheight = getLengthFromWidgets(
*(pageheightspin_->get_adjustment()), pageheightunitscombo_);
if (portraitradio_->get_active())
params.orientation = ORIENTATION_PORTRAIT;
else
params.orientation = ORIENTATION_LANDSCAPE;
if (twocolumnstoggle_->get_active())
params.columns = 2;
else
params.columns = 1;
if (doublesidedtoggle_->get_active())
params.sides = LyXTextClass::TwoSides;
else
params.sides = LyXTextClass::OneSide;
params.pagestyle = pagestylecombo_.get_active_text();
// *** End "Page" Page ***
// *** Begin "Margins" Page ***
int psize = pagesizecombo_.get_active_row_number();
bool geom_papersize = (psize == 1 || psize == 5 || psize == 8 || psize == 9);
params.use_geometry =
(marginscombo_.get_active_row_number() == 1 || geom_papersize);
int margin = marginscombo_.get_active_row_number();
if (margin > 0) {
margin = margin - 1;
}
params.paperpackage = PAPER_PACKAGES(margin);
params.setPaperStuff();
params.topmargin = getLengthFromWidgets(
*(mtopspin_->get_adjustment()),
mtopunitcombo_);
params.bottommargin = getLengthFromWidgets(
*(mbottomspin_->get_adjustment()),
mbottomunitcombo_);
params.leftmargin = getLengthFromWidgets(
*(minnerspin_->get_adjustment()),
minnerunitcombo_);
params.rightmargin = getLengthFromWidgets(
*(mouterspin_->get_adjustment()),
mouterunitcombo_);
params.headsep = getLengthFromWidgets(
*(mheadsepspin_->get_adjustment()),
mheadsepunitcombo_);
params.headheight = getLengthFromWidgets(
*(mheadheightspin_->get_adjustment()),
mheadheightunitcombo_);
params.footskip = getLengthFromWidgets(
*(mfootskipspin_->get_adjustment()),
mfootskipunitcombo_);
// *** End "Margins" Page ***
// *** Start "Language" Page ***
int const encodingsel = encodingcombo_.get_active_row_number();
if (encodingsel == 0)
params.inputenc = "auto";
else if (encodingsel == 1)
params.inputenc = "default";
else
params.inputenc = encodings[encodingsel];
int const langsel = languagecombo_.get_active_row_number();
params.language = languages.getLanguage(lang_[langsel]);
if (qenglishradio_->get_active())
params.quotes_language = InsetQuotes::EnglishQ;
else if (qswedishradio_->get_active())
params.quotes_language = InsetQuotes::SwedishQ;
else if (qgermanradio_->get_active())
params.quotes_language = InsetQuotes::GermanQ;
else if (qpolishradio_->get_active())
params.quotes_language = InsetQuotes::PolishQ;
else if (qfrenchradio_->get_active())
params.quotes_language = InsetQuotes::FrenchQ;
else if (qdanishradio_->get_active())
params.quotes_language = InsetQuotes::DanishQ;
// *** End "Language" Page ***
} }
@ -285,5 +600,105 @@ void GDocument::updateParagraphSeparationSensitivity()
} }
void GDocument::classChanged()
{
ControlDocument & ctrl = controller();
BufferParams & params = ctrl.params();
lyx::textclass_type const tc = classcombo_.get_active_row_number();
if (ctrl.loadTextclass(tc)) {
params.textclass = tc;
if (lyxrc.auto_reset_options) {
params.useClassDefaults();
update();
} else {
fontsizecombo_.clear();
fontsizecombo_.append_text("default");
string const fontsizeitems = ctrl.textClass().opt_fontsize();
for (int n = 0; !token(fontsizeitems, '|', n).empty(); ++n)
fontsizecombo_.append_text(token(fontsizeitems, '|', n));
comboBoxTextSet(fontsizecombo_, params.fontsize);
pagestylecombo_.clear();
pagestylecombo_.append_text("default");
string const pagestyleitems = ctrl.textClass().opt_pagestyle();
std::cerr << "pagestyleitems=" << pagestyleitems << "\n";
for (int n=0; !token(pagestyleitems,'|',n).empty(); ++n)
pagestylecombo_.append_text(token(pagestyleitems,'|',n));
comboBoxTextSet(pagestylecombo_, params.pagestyle);
std::cerr << "params.pagestyle=" << params.pagestyle << "\n";
}
} else {
classcombo_.set_active(params.textclass);
}
}
void GDocument::pageSizeChanged()
{
bool const customsize = pagesizecombo_.get_active_row_number() == 1;
pagewidthspin_->set_sensitive(customsize);
pageheightspin_->set_sensitive(customsize);
pagewidthunitscombo_.set_sensitive(customsize);
pageheightunitscombo_.set_sensitive(customsize);
if (customsize)
portraitradio_->set_active();
}
void GDocument::populateMargins()
{
int olditem = marginscombo_.get_active_row_number();
marginscombo_.clear();
// Magic order
marginscombo_.append_text(_("Default"));
marginscombo_.append_text(_("Custom"));
int papersize = pagesizecombo_.get_active_row_number();
if (papersize < 0)
papersize = 0;
bool const a4size = (papersize == 6 || papersize == 0
&& lyxrc.default_papersize == PAPER_A4PAPER);
if (a4size && portraitradio_->get_active()) {
marginscombo_.append_text(_("Small margins"));
marginscombo_.append_text(_("Very small margins"));
marginscombo_.append_text(_("Very wide margins"));
} else if (olditem > 1) {
olditem = 0;
}
marginscombo_.set_active(olditem);
}
void GDocument::marginsChanged()
{
bool const custom =
marginscombo_.get_active_row_number() == 1;
mtopspin_->set_sensitive(custom);
mbottomspin_->set_sensitive(custom);
minnerspin_->set_sensitive(custom);
mouterspin_->set_sensitive(custom);
mheadsepspin_->set_sensitive(custom);
mheadheightspin_->set_sensitive(custom);
mfootskipspin_->set_sensitive(custom);
mtopunitcombo_.set_sensitive(custom);
mbottomunitcombo_.set_sensitive(custom);
minnerunitcombo_.set_sensitive(custom);
mouterunitcombo_.set_sensitive(custom);
mheadsepunitcombo_.set_sensitive(custom);
mheadheightunitcombo_.set_sensitive(custom);
mfootskipunitcombo_.set_sensitive(custom);
}
} // namespace frontend } // namespace frontend
} // namespace lyx } // namespace lyx

View File

@ -4,7 +4,7 @@
* This file is part of LyX, the document processor. * This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING. * Licence details can be found in the file COPYING.
* *
* \auther John Spray * \author John Spray
* *
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
*/ */
@ -51,14 +51,59 @@ private:
Gtk::RadioButton * indentradio_; Gtk::RadioButton * indentradio_;
Gtk::RadioButton * vspaceradio_; Gtk::RadioButton * vspaceradio_;
Gtk::ComboBoxText vspacesizecombo_; Gtk::ComboBoxText vspacesizecombo_;
std::map<int, std::string> fontsizemap_;
std::map<int, VSpace::vspace_kind> vspacesizemap_; std::map<int, VSpace::vspace_kind> vspacesizemap_;
Gtk::ComboBoxText vspaceunitcombo_; Gtk::ComboBoxText vspaceunitcombo_;
Gtk::SpinButton * vspacelengthspin_; Gtk::SpinButton * vspacelengthspin_;
Gtk::Adjustment * vspacelengthadj_; Gtk::Adjustment * vspacelengthadj_;
void updateParagraphSeparationSensitivity(); void updateParagraphSeparationSensitivity();
void classChanged();
// *** End "Document" Page *** // *** End "Document" Page ***
// *** Begin "Page" Page ***
Gtk::SpinButton * pagewidthspin_;
Gtk::SpinButton * pageheightspin_;
Gtk::ComboBoxText pagewidthunitscombo_;
Gtk::ComboBoxText pageheightunitscombo_;
Gtk::ComboBoxText pagesizecombo_;
Gtk::RadioButton * portraitradio_;
Gtk::RadioButton * landscaperadio_;
Gtk::ComboBoxText pagestylecombo_;
Gtk::ToggleButton * doublesidedtoggle_;
Gtk::ToggleButton * twocolumnstoggle_;
void pageSizeChanged();
// *** End "Page" Page ***
// *** Begin "Margins" Page ***
Gtk::ComboBoxText marginscombo_;
Gtk::SpinButton * mtopspin_;
Gtk::SpinButton * mbottomspin_;
Gtk::SpinButton * minnerspin_;
Gtk::SpinButton * mouterspin_;
Gtk::SpinButton * mheadsepspin_;
Gtk::SpinButton * mheadheightspin_;
Gtk::SpinButton * mfootskipspin_;
Gtk::ComboBoxText mtopunitcombo_;
Gtk::ComboBoxText mbottomunitcombo_;
Gtk::ComboBoxText minnerunitcombo_;
Gtk::ComboBoxText mouterunitcombo_;
Gtk::ComboBoxText mheadsepunitcombo_;
Gtk::ComboBoxText mheadheightunitcombo_;
Gtk::ComboBoxText mfootskipunitcombo_;
void populateMargins();
void marginsChanged();
// *** End "Margins" Page ***
// *** Start "Language" Page ***
Gtk::ComboBoxText languagecombo_;
Gtk::ComboBoxText encodingcombo_;
Gtk::RadioButton * qenglishradio_;
Gtk::RadioButton * qswedishradio_;
Gtk::RadioButton * qgermanradio_;
Gtk::RadioButton * qpolishradio_;
Gtk::RadioButton * qfrenchradio_;
Gtk::RadioButton * qdanishradio_;
std::vector<std::string> lang_;
// *** End "Language" Page ***
}; };
} // namespace frontend } // namespace frontend

File diff suppressed because it is too large Load Diff