From d07928baf54d26934730afbaaaa95756d21ffe84 Mon Sep 17 00:00:00 2001 From: John Spray Date: Sat, 28 Jan 2006 16:42:18 +0000 Subject: [PATCH] add GTK wrap dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10788 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/gtk/ChangeLog | 1 + src/frontends/gtk/Dialogs.C | 7 +- src/frontends/gtk/GWrap.C | 116 +++++++++++++++++++ src/frontends/gtk/GWrap.h | 44 +++++++ src/frontends/gtk/Makefile.am | 2 + src/frontends/gtk/glade/Makefile.am | 3 +- src/frontends/gtk/glade/wrap.glade | 170 ++++++++++++++++++++++++++++ 7 files changed, 338 insertions(+), 5 deletions(-) create mode 100644 src/frontends/gtk/GWrap.C create mode 100644 src/frontends/gtk/GWrap.h create mode 100644 src/frontends/gtk/glade/wrap.glade diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 181062a82d..87c01e8bb9 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,6 +1,7 @@ 2006-01-28 John Spray * GtkLengthEntry.[Ch]: implement signal_changed, setup spin limits + * GWrap.[Ch], glade/wrap.glade: Add Wrap dialog 2006-01-27 Bernhard Reiter diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index c62c4b6b5a..27da3849ee 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -94,14 +94,13 @@ #include "GToc.h" #include "GUrl.h" #include "GVSpace.h" -//#include "FormWrap.h" +#include "GWrap.h" #ifdef HAVE_LIBAIKSAURUS #include "ControlThesaurus.h" #include "GThesaurus.h" #endif -//#include "xformsBC.h" #include "ButtonController.h" #include "arrows.xbm" @@ -561,9 +560,9 @@ Dialogs::DialogPtr Dialogs::build(string const & name) dialog->setView(new GVSpace(*dialog)); dialog->bc().bp(new OkApplyCancelReadOnlyPolicy); } else if (name == "wrap") { -// dialog->bc().view(new xformsBC(dialog->bc())); + dialog->bc().view(new GBC(dialog->bc())); dialog->setController(new ControlWrap(*dialog)); -// dialog->setView(new FormWrap(*dialog)); + dialog->setView(new GWrap(*dialog)); dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } diff --git a/src/frontends/gtk/GWrap.C b/src/frontends/gtk/GWrap.C new file mode 100644 index 0000000000..0860e68ee4 --- /dev/null +++ b/src/frontends/gtk/GWrap.C @@ -0,0 +1,116 @@ +/** + * \file GWrap.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 + +// 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 "GWrap.h" +#include "ControlWrap.h" +#include "insets/insetwrap.h" + +#include "ghelpers.h" + +#include + +using std::string; + +namespace lyx { +namespace frontend { + +GWrap::GWrap(Dialog & parent) + : GViewCB(parent, _("Text Wrap Settings"), false) +{} + + +void GWrap::doBuild() +{ + string const gladeName = findGladeFile("wrap"); + xml_ = Gnome::Glade::Xml::create(gladeName); + + Gtk::Button * cancelbutton; + xml_->get_widget("Close", cancelbutton); + setCancel(cancelbutton); + + xml_->get_widget_derived ("Width", widthlengthentry_); + xml_->get_widget ("Placement", placementcombo_); + + widthlengthentry_->signal_changed().connect( + sigc::mem_fun(*this, &GWrap::apply)); + placementcombo_->signal_changed().connect( + sigc::mem_fun(*this, &GWrap::apply)); + + bcview().addReadOnly(widthlengthentry_); + bcview().addReadOnly(placementcombo_); +} + + +void GWrap::update() +{ + applylock_ = true; + + InsetWrapParams & params = controller().params(); + + widthlengthentry_->set_length (params.width); + + int item; + if (params.placement == "l") + item = 1; + else if (params.placement == "r") + item = 2; + else if (params.placement == "p") + item = 3; + + placementcombo_->set_active (item); + + bc().refreshReadOnly(); + + applylock_ = false; +} + + +void GWrap::apply() +{ + if (applylock_) + return; + + InsetWrapParams & params = controller().params(); + + params.width = widthlengthentry_->get_length(); + + int const placementrow = placementcombo_->get_active_row_number(); + BOOST_ASSERT (0 <= placementrow <= 3); + switch (placementrow) { + case 1: + params.placement = 'l'; + break; + case 2: + params.placement = 'r'; + break; + case 3: + params.placement = 'p'; + break; + case 0: + default: + params.placement.erase(); + break; + } + + controller().dispatchParams(); +} + +} // namespace frontend +} // namespace lyx diff --git a/src/frontends/gtk/GWrap.h b/src/frontends/gtk/GWrap.h new file mode 100644 index 0000000000..e88d5e0823 --- /dev/null +++ b/src/frontends/gtk/GWrap.h @@ -0,0 +1,44 @@ +// -*- C++ -*- +/** + * \file GWrap.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 GWRAPH +#define GWRAP_H + +#include "GViewBase.h" + +#include "GtkLengthEntry.h" + +namespace lyx { +namespace frontend { + +class ControlWrap; + +/** This class provides a GTK+ implementation of the Wrap Dialog. + */ +class GWrap : public GViewCB { +public: + GWrap(Dialog & parent); +private: + virtual void apply(); + virtual void doBuild(); + virtual void update(); + + // apply() won't act when this is true + bool applylock_; + + Gtk::ComboBox *placementcombo_; + GtkLengthEntry *widthlengthentry_; +}; + +} // namespace frontend +} // namespace lyx + +#endif // GWRAP_H diff --git a/src/frontends/gtk/Makefile.am b/src/frontends/gtk/Makefile.am index 5d8da42405..118d25fc5a 100644 --- a/src/frontends/gtk/Makefile.am +++ b/src/frontends/gtk/Makefile.am @@ -113,6 +113,8 @@ libgtk_la_SOURCES = \ GVSpace.h \ GWorkArea.C \ GWorkArea.h \ + GWrap.C \ + GWrap.h \ GXpmBtnTbl.C \ GXpmBtnTbl.h \ LyXGdkImage.C \ diff --git a/src/frontends/gtk/glade/Makefile.am b/src/frontends/gtk/glade/Makefile.am index 0a2c6b0726..0d21e43693 100644 --- a/src/frontends/gtk/glade/Makefile.am +++ b/src/frontends/gtk/glade/Makefile.am @@ -36,4 +36,5 @@ dist_glade_DATA = \ thesaurus.glade \ toc.glade \ url.glade \ - vspace.glade + vspace.glade \ + wrap.glade diff --git a/src/frontends/gtk/glade/wrap.glade b/src/frontends/gtk/glade/wrap.glade new file mode 100644 index 0000000000..28a70cd790 --- /dev/null +++ b/src/frontends/gtk/glade/wrap.glade @@ -0,0 +1,170 @@ + + + + + + + True + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + 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 + 2 + 2 + False + 6 + 12 + + + + True + _Width: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _Placement: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + False + 0 + + + + + + + 1 + 2 + 0 + 1 + fill + + + + + + True + Default +Left +Right +Outer + False + True + + + 1 + 2 + 1 + 2 + fill + fill + + + + + 0 + True + True + + + + + + +