From: John Spray Date: Fri, 1 Oct 2004 18:59:36 +0000 (+0000) Subject: Add GParagraph dialog, make GViewBase update() when it show()s X-Git-Tag: 1.6.10~14985 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4e0607242f929d66dc0358499d058c2e6d576517;p=features.git Add GParagraph dialog, make GViewBase update() when it show()s git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9032 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 9c1afc06fe..1b20f19217 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,8 @@ +2004-09-29 John Spray + + * The Paragraph dialog + * Dialogs.C, GParagraph.C, GParagraph.h, Makefile.am + 2004-09-28 John Spray * GToolbar.[Ch]: Use ComboBox instead of deprecated Combo for diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 8b6780ca1c..c06bcfc8b1 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -73,7 +73,7 @@ #include "FormMathsSpace.h" #include "FormMathsStyle.h" #include "FormNote.h" -#include "FormParagraph.h" +#include "GParagraph.h" #include "FormPreamble.h" #include "FormPreferences.h" #include "GPrint.h" @@ -452,8 +452,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new FormBranch(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "paragraph") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlParagraph(*dialog)); - dialog->setView(new FormParagraph(*dialog)); + dialog->setView(new GParagraph(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "preamble") { dialog->setController(new ControlPreamble(*dialog)); diff --git a/src/frontends/gtk/GParagraph.C b/src/frontends/gtk/GParagraph.C new file mode 100644 index 0000000000..d5d325109d --- /dev/null +++ b/src/frontends/gtk/GParagraph.C @@ -0,0 +1,192 @@ +/** + * \file GParagraph.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 "GParagraph.h" +#include "ghelpers.h" + +#include "ControlParagraph.h" +#include "controllers/helper_funcs.h" + +#include "ParagraphParameters.h" +#include "Spacing.h" +#include "support/lstrings.h" +#include "support/tostr.h" + +using std::string; + +namespace lyx { + +namespace frontend { + +namespace { + +} // namespace anon + + +GParagraph::GParagraph(Dialog & parent) + : GViewCB(parent, _("Paragraph Settings"), false) +{} + +void GParagraph::doBuild() +{ + string const gladeName = findGladeFile("paragraph"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + xml_->get_widget("LineSpacing", spacingspin_); + xml_->get_widget("DefaultLineSpacing", defaultspacingcheck_); + xml_->get_widget("MaxLabelWidth", maxlabelwidthentry_); + xml_->get_widget("Indent", indentcheck_); + xml_->get_widget("AlignBlock", blockradio_); + xml_->get_widget("AlignLeft", leftradio_); + xml_->get_widget("AlignRight", rightradio_); + xml_->get_widget("AlignCenter", centerradio_); + + // Manage the Close button + Gtk::Button * button; + xml_->get_widget("Close", button); + setCancel(button); + + // Make the main hbox sensitive to readonly + Gtk::HBox * controlbox; + xml_->get_widget("ControlBox", controlbox); + bcview().addReadOnly(controlbox); + + spacingadj_ = spacingspin_->get_adjustment(); + + defaultspacingcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GParagraph::onDefaultSpacingToggled)); + indentcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GParagraph::onIndentToggled)); + spacingadj_->signal_value_changed().connect( + sigc::mem_fun(*this, &GParagraph::onSpacingChanged)); + maxlabelwidthentry_->signal_changed().connect( + sigc::mem_fun(*this, &GParagraph::onMaxLabelWidthChanged)); + + blockradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GParagraph::onAlignToggled)); + leftradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GParagraph::onAlignToggled)); + rightradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GParagraph::onAlignToggled)); + centerradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GParagraph::onAlignToggled)); +} + + +void GParagraph::update() +{ + // label width + string const labelwidth = controller().params().labelWidthString(); + maxlabelwidthentry_->set_text(labelwidth); + maxlabelwidthentry_->set_sensitive( + labelwidth != _("Senseless with this layout!")); + + // alignment + LyXAlignment const current_alignment = controller().params().align(); + switch (current_alignment) { + case LYX_ALIGN_BLOCK: + blockradio_->set_active(true); + break; + case LYX_ALIGN_LEFT: + leftradio_->set_active(true); + break; + case LYX_ALIGN_RIGHT: + rightradio_->set_active(true); + break; + case LYX_ALIGN_CENTER: + centerradio_->set_active(true); + break; + default: + // LYX_ALIGN_SPECIAL or so? Don't ask, don't tell. + centerradio_->set_active(false); + blockradio_->set_active(false); + rightradio_->set_active(false); + leftradio_->set_active(false); + } + + //Find out which alignments options are available + LyXAlignment alignpos = controller().alignPossible(); + blockradio_->set_sensitive(bool(alignpos & LYX_ALIGN_BLOCK)); + centerradio_->set_sensitive(bool(alignpos & LYX_ALIGN_CENTER)); + leftradio_->set_sensitive(bool(alignpos & LYX_ALIGN_LEFT)); + rightradio_->set_sensitive(bool(alignpos & LYX_ALIGN_RIGHT)); + + // We give the user a checkbox with an affirmative description, so + // invert the setting + indentcheck_->set_active(!controller().params().noindent()); + + // linespacing + Spacing const space = controller().params().spacing(); + + // This emits the toggled signal, setting up sensitivities + defaultspacingcheck_->set_active( + space.getSpace() == Spacing::Default); + + spacingadj_->set_value(space.getValue()); +} + + +void GParagraph::onDefaultSpacingToggled() +{ + if (defaultspacingcheck_->get_active()) { + spacingspin_->set_sensitive(false); + Spacing const spacing(Spacing::Default, spacingadj_->get_value()); + controller().params().spacing(spacing); + } else { + spacingspin_->set_sensitive(true); + Spacing const spacing(Spacing::Other, spacingadj_->get_value()); + controller().params().spacing(spacing); + } + controller().dispatchParams(); +} + + +void GParagraph::onIndentToggled() +{ + controller().params().noindent(!indentcheck_->get_active()); + controller().dispatchParams(); +} + + +void GParagraph::onSpacingChanged() +{ + Spacing const spacing(Spacing::Other, spacingadj_->get_value()); + controller().params().spacing(spacing); + controller().dispatchParams(); +} + + +void GParagraph::onMaxLabelWidthChanged() +{ + controller().params().labelWidthString( + maxlabelwidthentry_->get_text()); + controller().dispatchParams(); +} + + +void GParagraph::onAlignToggled() +{ + if (blockradio_->get_active()) + controller().params().align(LYX_ALIGN_BLOCK); + else if (leftradio_->get_active()) + controller().params().align(LYX_ALIGN_LEFT); + else if (rightradio_->get_active()) + controller().params().align(LYX_ALIGN_RIGHT); + else if (centerradio_->get_active()) + controller().params().align(LYX_ALIGN_CENTER); + + controller().dispatchParams(); +} + + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GParagraph.h b/src/frontends/gtk/GParagraph.h new file mode 100644 index 0000000000..24eeb4a8d0 --- /dev/null +++ b/src/frontends/gtk/GParagraph.h @@ -0,0 +1,59 @@ +// -*- C++ -*- +/** + * \file GParagraph.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 GPARAGRAPH_H +#define GPARAGRAPH_H + +#include "GViewBase.h" + +#include + +namespace lyx { +namespace frontend { + +class ControlParagraph; + +/** This class provides a gtk implementation of the paragraph dialog. + */ +class GParagraph + : public GViewCB { +public: + GParagraph(Dialog &); +private: + /// Build the dialog + virtual void doBuild(); + /// Apply from dialog + virtual void apply() {} + /// Update the dialog + virtual void update(); + + Gtk::SpinButton * spacingspin_; + Gtk::Entry * maxlabelwidthentry_; + Gtk::CheckButton * indentcheck_; + Gtk::CheckButton * defaultspacingcheck_; + Gtk::RadioButton * blockradio_; + Gtk::RadioButton * leftradio_; + Gtk::RadioButton * rightradio_; + Gtk::RadioButton * centerradio_; + + Gtk::Adjustment * spacingadj_; + + void onDefaultSpacingToggled(); + void onMaxLabelWidthChanged(); + void onSpacingChanged(); + void onIndentToggled(); + void onAlignToggled(); +}; + +} // namespace frontend +} // namespace lyx + +#endif diff --git a/src/frontends/gtk/GViewBase.C b/src/frontends/gtk/GViewBase.C index 43642e848a..6e88009e22 100644 --- a/src/frontends/gtk/GViewBase.C +++ b/src/frontends/gtk/GViewBase.C @@ -53,6 +53,7 @@ void GViewBase::show() if (!window()) { build(); } + update(); window()->show(); } diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index d1e50f55a8..6157276489 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -38,6 +38,8 @@ libgtk_la_SOURCES = \ GMiniBuffer.h \ GPainter.C \ GPainter.h \ + GParagraph.C \ + GParagraph.h \ GPrint.C \ GPrint.h \ GScreen.C \ @@ -109,7 +111,6 @@ xforms_objects = \ ../xforms/FormMathsSpace.lo \ ../xforms/FormMathsStyle.lo \ ../xforms/FormNote.lo \ - ../xforms/FormParagraph.lo \ ../xforms/FormPreamble.lo \ ../xforms/FormPreferences.lo \ ../xforms/FormRef.lo \ diff --git a/src/frontends/gtk/glade/paragraph.glade b/src/frontends/gtk/glade/paragraph.glade new file mode 100644 index 0000000000..6c21443ef5 --- /dev/null +++ b/src/frontends/gtk/glade/paragraph.glade @@ -0,0 +1,597 @@ + + + + + + + True + Paragraph + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + True + 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 + True + gtk-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + 0 + False + True + GTK_PACK_END + + + + + + 8 + True + False + 0 + + + + True + 4 + 2 + False + 5 + 4 + + + + True + _Max. label width: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + MaxLabelWidth + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + False + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + + + + + + + True + False + True + 1 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 1 0 20 0.1 10 10 + + + 1 + 2 + 0 + 1 + + + + + + + True + True + Use _Default Line Spacing + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + Line _spacing: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + LineSpacing + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + _Indent Paragraph + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 3 + 4 + 4 + fill + + + + + + 0 + True + True + + + + + + True + + + 8 + True + True + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 4 + 0 + + + + True + False + 0 + + + + True + <b>Align</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 2 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-justify-fill + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Justify + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + False + False + True + AlignBlock + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-justify-left + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Left + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + False + False + True + AlignBlock + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-justify-right + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + _Right + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + True + False + False + True + AlignBlock + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-justify-center + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + C_enter + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + 0 + False + False + + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + +