From: John Spray Date: Mon, 15 Nov 2004 16:02:57 +0000 (+0000) Subject: GTK Float dialog and Note dialog. Today is rhyming dialog day! X-Git-Tag: 1.6.10~14829 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=facb7e89de6808ae4850726b794d13d08587ec69;p=lyx.git GTK Float dialog and Note dialog. Today is rhyming dialog day! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9254 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 63f3c2ede5..272f673df5 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,5 +1,9 @@ 2004-11-15 John Spray + * The Note Dialog: + Dialogs.C, Makefile.am, GNote.C, GNote.h + * The Float Dialog: + Dialogs.C, Makefile.am, GFloat.C, GFloat.h * ghelpers.[Ch]: getGTKStockIcon added to choose gtk stock icons for FuncRequests * GToolbar.C: use getGTKStockIcon for toolbutton icons diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 7d7460d112..7d5b4d1222 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -63,7 +63,7 @@ #include "GErrorList.h" #include "GERT.h" #include "FormExternal.h" -#include "FormFloat.h" +#include "GFloat.h" #include "GGraphics.h" #include "FormInclude.h" #include "GLog.h" @@ -72,7 +72,7 @@ #include "GMathsMatrix.h" #include "FormMathsSpace.h" #include "FormMathsStyle.h" -#include "FormNote.h" +#include "GNote.h" #include "GParagraph.h" #include "FormPreamble.h" #include "FormPreferences.h" @@ -237,8 +237,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GSearch(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "float") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlFloat(*dialog)); - dialog->setView(new FormFloat(*dialog)); + dialog->setView(new GFloat(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "graphics") { dialog->bc().view(new GBC(dialog->bc())); @@ -452,8 +453,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new FormMathsStyle(*dialog)); dialog->bc().bp(new IgnorantPolicy); } else if (name == "note") { + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlNote(*dialog)); - dialog->setView(new FormNote(*dialog)); + dialog->setView(new GNote(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "branch") { dialog->setController(new ControlBranch(*dialog)); diff --git a/src/frontends/gtk/GFloat.C b/src/frontends/gtk/GFloat.C new file mode 100644 index 0000000000..1596a9ff4c --- /dev/null +++ b/src/frontends/gtk/GFloat.C @@ -0,0 +1,219 @@ +/** + * \file GFloat.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 "GFloat.h" +#include "ControlFloat.h" + +#include "ghelpers.h" + +#include "insets/insetfloat.h" + +#include "support/lstrings.h" + +#include + +using std::string; + +namespace lyx { + +using support::contains; + +namespace frontend { + +GFloat::GFloat(Dialog & parent) + : GViewCB(parent, _("Float Settings"), false) +{} + + +void GFloat::doBuild() +{ + string const gladeName = findGladeFile("float"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * cancelbutton; + xml_->get_widget("Close", cancelbutton); + setCancel(cancelbutton); + + xml_->get_widget("Default", defaultradio_); + xml_->get_widget("HereDefinitely", heredefinitelyradio_); + xml_->get_widget("Alternative", alternativeradio_); + xml_->get_widget("Top", topcheck_); + xml_->get_widget("Bottom", bottomcheck_); + xml_->get_widget("PageOfFloats", pageoffloatscheck_); + xml_->get_widget("HereIfPossible", hereifpossiblecheck_); + xml_->get_widget("IgnoreRules", ignorerulescheck_); + xml_->get_widget("SpanColumns", spancolumnscheck_); + xml_->get_widget("RotateSideways", rotatesidewayscheck_); + + defaultradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + heredefinitelyradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + alternativeradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + topcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + bottomcheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + pageoffloatscheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + hereifpossiblecheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + ignorerulescheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + spancolumnscheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + rotatesidewayscheck_->signal_toggled().connect( + sigc::mem_fun(*this, &GFloat::apply)); + + bcview().addReadOnly(defaultradio_); + bcview().addReadOnly(heredefinitelyradio_); + bcview().addReadOnly(alternativeradio_); + bcview().addReadOnly(topcheck_); + bcview().addReadOnly(bottomcheck_); + bcview().addReadOnly(pageoffloatscheck_); + bcview().addReadOnly(hereifpossiblecheck_); + bcview().addReadOnly(ignorerulescheck_); + bcview().addReadOnly(spancolumnscheck_); + bcview().addReadOnly(rotatesidewayscheck_); +} + + +void GFloat::update() +{ + applylock_ = true; + + bc().refreshReadOnly(); + + string placement(controller().params().placement); + bool const wide = controller().params().wide; + bool const sideways = controller().params().sideways; + + bool const here_definitely = contains(placement, 'H'); + + bool const top = contains(placement, 't'); + bool const bottom = contains(placement, 'b'); + bool const page = contains(placement, 'p'); + bool const here = contains(placement, 'h'); + bool const force = contains(placement, '!'); + bool const alternatives = top || bottom || page || (here && !wide); + + if (alternatives) { + alternativeradio_->set_active(true); + } else if (here_definitely) { + heredefinitelyradio_->set_active(true); + } else { + defaultradio_->set_active(true); + } + ignorerulescheck_->set_active(force); + topcheck_->set_active(top); + bottomcheck_->set_active(bottom); + pageoffloatscheck_->set_active(page); + hereifpossiblecheck_->set_active(here); + spancolumnscheck_->set_active(wide); + rotatesidewayscheck_->set_active(sideways); + + updateSensitivity(); + + applylock_ = false; +} + + +void GFloat::updateSensitivity() +{ + bool const wide = spancolumnscheck_->get_active(); + bool const sideways = rotatesidewayscheck_->get_active(); + bool const sideways_possible = (controller().params().type == "figure" + || controller().params().type == "table"); + bool const alternatives = alternativeradio_->get_active(); + bool const readonly = readOnly(); + + heredefinitelyradio_->set_sensitive(!wide && !sideways && !readonly); + ignorerulescheck_->set_sensitive(alternatives && !sideways && !readonly); + topcheck_->set_sensitive(alternatives && !sideways && !readonly); + bottomcheck_->set_sensitive(alternatives && !sideways && !readonly); + pageoffloatscheck_->set_sensitive(alternatives && !sideways && !readonly); + hereifpossiblecheck_->set_sensitive(alternatives && !wide && !sideways && !readonly); + spancolumnscheck_->set_sensitive(!sideways && !readonly); + defaultradio_->set_sensitive(!sideways && !readonly); + alternativeradio_->set_sensitive(!sideways && !readonly); + rotatesidewayscheck_->set_sensitive(sideways_possible && !readonly); +} + + +void GFloat::apply() +{ + if (applylock_) + return; + + updateSensitivity(); + + bool const wide = spancolumnscheck_->get_active(); + bool const sideways = rotatesidewayscheck_->get_active(); + + int placementmode = 0; //default + if (heredefinitelyradio_->get_active()) + placementmode = 1; // "Here, definitely" + else if (alternativeradio_->get_active()) + placementmode = 2; // "Alternative" + + string placement; + switch (placementmode) { + case 2: + // "Alternative" + if (ignorerulescheck_->get_active()) { + // Ignore internal LaTeX rules + placement += '!'; + } + if (topcheck_->get_active()) { + // Top of page + placement += 't'; + } + if (bottomcheck_->get_active()) { + // Bottom of page + placement += 'b'; + } + if (pageoffloatscheck_->get_active()) { + // Page of floats + placement += 'p'; + } + // ignore if wide is selected + if (!wide && hereifpossiblecheck_->get_active()) { + // Here, if possible + placement += 'h'; + } + if (placement == "!") { + // ignore placement if only force is selected. + placement.erase(); + } + break; + + case 1: + // Here, definitely + placement = "H"; + break; + + case 0: + // default, do nothing. + break; + } + + controller().params().placement = placement; + controller().params().wide = wide; + controller().params().sideways = sideways; + + controller().dispatchParams(); +} + +} // namespace frontend +} // namespace lyx + diff --git a/src/frontends/gtk/GFloat.h b/src/frontends/gtk/GFloat.h new file mode 100644 index 0000000000..b30f24b228 --- /dev/null +++ b/src/frontends/gtk/GFloat.h @@ -0,0 +1,52 @@ +// -*- C++ -*- +/** + * \file GFloat.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 GFLOAT_H +#define GFLOAT_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlFloat; + +/** This class provides a GTK+ implementation of the ERT Dialog. + */ +class GFloat : public GViewCB { +public: + GFloat(Dialog & parent); +private: + virtual void apply(); + virtual void doBuild(); + virtual void update(); + + void updateSensitivity(); + + // apply() won't act when this is true + bool applylock_; + + Gtk::RadioButton * defaultradio_; + Gtk::RadioButton * heredefinitelyradio_; + Gtk::RadioButton * alternativeradio_; + Gtk::CheckButton * topcheck_; + Gtk::CheckButton * bottomcheck_; + Gtk::CheckButton * pageoffloatscheck_; + Gtk::CheckButton * hereifpossiblecheck_; + Gtk::CheckButton * ignorerulescheck_; + Gtk::CheckButton * spancolumnscheck_; + Gtk::CheckButton * rotatesidewayscheck_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GFLOAT_H diff --git a/src/frontends/gtk/GNote.C b/src/frontends/gtk/GNote.C new file mode 100644 index 0000000000..6fe76ddee3 --- /dev/null +++ b/src/frontends/gtk/GNote.C @@ -0,0 +1,98 @@ +/** + * \file GNote.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 "GNote.h" +#include "ControlNote.h" +#include "ghelpers.h" + +#include "insets/insetnote.h" + +#include + +using std::string; + +namespace lyx { +namespace frontend { + +GNote::GNote(Dialog & parent) + : GViewCB(parent, _("Note Settings"), false) +{} + + +void GNote::doBuild() +{ + string const gladeName = findGladeFile("note"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * cancelbutton; + xml_->get_widget("Close", cancelbutton); + setCancel(cancelbutton); + + xml_->get_widget("LyXNote", lyxnoteradio_); + xml_->get_widget("Comment", commentradio_); + xml_->get_widget("GreyedOut", greyedoutradio_); + + lyxnoteradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GNote::apply)); + commentradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GNote::apply)); + greyedoutradio_->signal_toggled().connect( + sigc::mem_fun(*this, &GNote::apply)); + + bcview().addReadOnly(lyxnoteradio_); + bcview().addReadOnly(commentradio_); + bcview().addReadOnly(greyedoutradio_); +} + + +void GNote::update() +{ + applylock_ = true; + + bc().refreshReadOnly(); + + switch (controller().params().type) { + case InsetNoteParams::Note: + lyxnoteradio_->set_active(true); + break; + case InsetNoteParams::Comment: + commentradio_->set_active(true); + break; + case InsetNoteParams::Greyedout: + greyedoutradio_->set_active(true); + break; + } + + applylock_ = false; +} + + +void GNote::apply() +{ + if (applylock_) + return; + + InsetNoteParams::Type type; + + if (lyxnoteradio_->get_active()) + type = InsetNoteParams::Note; + else if (greyedoutradio_->get_active()) + type = InsetNoteParams::Greyedout; + else + type = InsetNoteParams::Comment; + + controller().params().type = type; + controller().dispatchParams(); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GNote.h b/src/frontends/gtk/GNote.h new file mode 100644 index 0000000000..8b03455cbc --- /dev/null +++ b/src/frontends/gtk/GNote.h @@ -0,0 +1,43 @@ +// -*- C++ -*- +/** + * \file GNote.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 GNOTE_H +#define GNOTE_H + +#include "GViewBase.h" + +namespace lyx { +namespace frontend { + +class ControlNote; + +/** This class provides a GTK+ implementation of the Note Dialog. + */ +class GNote : public GViewCB { +public: + GNote(Dialog & parent); +private: + virtual void apply(); + virtual void doBuild(); + virtual void update(); + + // apply() won't act when this is true + bool applylock_; + + Gtk::RadioButton * lyxnoteradio_; + Gtk::RadioButton * commentradio_; + Gtk::RadioButton * greyedoutradio_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GNOTE_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index a5274cf42c..f8997542db 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -34,6 +34,8 @@ libgtk_la_SOURCES = \ GErrorList.h \ GERT.C \ GERT.h \ + GFloat.C \ + GFloat.h \ GGraphics.C \ GGraphics.h \ GLog.C \ @@ -50,6 +52,8 @@ libgtk_la_SOURCES = \ GMenubar.h \ GMiniBuffer.C \ GMiniBuffer.h \ + GNote.C \ + GNote.h \ GPainter.C \ GPainter.h \ GParagraph.C \ @@ -119,13 +123,11 @@ xforms_objects = \ ../xforms/FormDialogView.lo \ ../xforms/FormDocument.lo \ ../xforms/FormExternal.lo \ - ../xforms/FormFloat.lo \ ../xforms/FormInclude.lo \ ../xforms/FormMathsBitmap.lo \ ../xforms/FormMathsDelim.lo \ ../xforms/FormMathsSpace.lo \ ../xforms/FormMathsStyle.lo \ - ../xforms/FormNote.lo \ ../xforms/FormPreamble.lo \ ../xforms/FormPreferences.lo \ ../xforms/FormRef.lo \ diff --git a/src/frontends/gtk/glade/float.glade b/src/frontends/gtk/glade/float.glade new file mode 100644 index 0000000000..f291c08130 --- /dev/null +++ b/src/frontends/gtk/glade/float.glade @@ -0,0 +1,391 @@ + + + + + + + True + 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-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + False + 0 + + + + True + <b>Placement</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 0 + + + + True + True + _Document Default + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Here, definitely + True + GTK_RELIEF_NORMAL + True + False + False + True + Default + + + 0 + False + False + + + + + + True + True + _Alternative: + True + GTK_RELIEF_NORMAL + True + False + False + True + Default + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 11 + 0 + + + + True + False + 0 + + + + True + False + True + _Top of page + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + True + _Bottom of page + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + True + _Page of floats + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + True + He_re, if possible + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + True + _Ignore LaTeX rules + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + + 0 + True + True + + + + + + + 0 + True + True + + + + + + True + <b>Other</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 0 + + + + True + True + _Span columns + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + R_otate sideways + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + diff --git a/src/frontends/gtk/glade/note.glade b/src/frontends/gtk/glade/note.glade new file mode 100644 index 0000000000..bd1cc5d16c --- /dev/null +++ b/src/frontends/gtk/glade/note.glade @@ -0,0 +1,175 @@ + + + + + + + True + 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-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + 0 + False + True + GTK_PACK_END + + + + + + 12 + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 0 + + + + True + Display note in LyX only + True + LyX _Note + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + Export to LaTeX/Docbook but don't print + True + C_omment + True + GTK_RELIEF_NORMAL + True + False + False + True + LyXNote + + + 0 + False + False + + + + + + True + Print as gray text + True + _Grayed out + True + GTK_RELIEF_NORMAL + True + False + False + True + LyXNote + + + 0 + False + False + + + + + + + + + + True + <b>Type</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + +