From dd01380a27d763a3006bb79c36d7229d36001681 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 28 Apr 2004 11:33:27 +0000 Subject: [PATCH] Pass LyxView & to the WorkArea. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8703 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 2 +- src/ChangeLog | 4 ++++ src/frontends/WorkAreaFactory.h | 3 ++- src/frontends/gtk/ChangeLog | 9 +++++++++ src/frontends/gtk/GView.C | 8 -------- src/frontends/gtk/GView.h | 2 -- src/frontends/gtk/GWorkArea.C | 7 ++++--- src/frontends/gtk/GWorkArea.h | 3 ++- src/frontends/gtk/WorkAreaFactory.C | 4 ++-- src/frontends/qt2/ChangeLog | 6 ++++++ src/frontends/qt2/QWorkArea.C | 2 +- src/frontends/qt2/QWorkArea.h | 3 ++- src/frontends/qt2/WorkAreaFactory.C | 4 ++-- src/frontends/xforms/ChangeLog | 6 ++++++ src/frontends/xforms/WorkAreaFactory.C | 4 ++-- src/frontends/xforms/XWorkArea.C | 2 +- src/frontends/xforms/XWorkArea.h | 3 ++- 17 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 8144d511db..f9adcc0cf2 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -121,7 +121,7 @@ BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner, { xsel_cache_.set = false; - workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height)); + workarea_.reset(WorkAreaFactory::create(*owner_, xpos, ypos, width, height)); screen_.reset(LyXScreenFactory::create(workarea())); // Setup the signals diff --git a/src/ChangeLog b/src/ChangeLog index b65a681ce6..eed92477a0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2004-04-28 Angus Leeming + + * BufferView_pimpl.C (c-tor): pass LyXView & to WorkArea generator. + 2004-04-26 Georg Baum * LaTeXFeatures.C, lyx_sty.[Ch]: add \lyxdot macro diff --git a/src/frontends/WorkAreaFactory.h b/src/frontends/WorkAreaFactory.h index ea08b70839..12d8d76ae9 100644 --- a/src/frontends/WorkAreaFactory.h +++ b/src/frontends/WorkAreaFactory.h @@ -13,13 +13,14 @@ #define WORKAREAFACTORY_H class WorkArea; +class LyXView; namespace WorkAreaFactory { /** * Make a work area. Used because we want to generate * a toolkit-specific instance. */ - WorkArea * create(int x, int y, int w, int h); + WorkArea * create(LyXView & owner, int x, int y, int w, int h); } #endif // WORKAREA_FACTORY_H diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index a57c88b2a3..69113690cb 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,12 @@ +2004-04-28 Angus Leeming + + * WorkAreaFactory.C (create): pass a LyXView & to GWorkArea c-tor. + + * GWorkArea.[Ch] (c-tor): now receives a LyXView &. Use it instead + of GView::instance. + + * GView.[Ch] (instance): removed. + 2004-04-27 Angus Leeming * GView.[Ch]: split the window into 'top', 'left', 'center', diff --git a/src/frontends/gtk/GView.C b/src/frontends/gtk/GView.C index 5592bf94d7..b9b22248a1 100644 --- a/src/frontends/gtk/GView.C +++ b/src/frontends/gtk/GView.C @@ -30,11 +30,6 @@ using std::string; -BufferView * current_view; - -GView * GView::view_ = 0; - - namespace { void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink) @@ -49,8 +44,6 @@ void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink) GView::GView() { - view_ = this; - // The physical store for the boxes making up the layout. box_store_.push_back(boost::shared_ptr(new Gtk::VBox)); box_store_.push_back(boost::shared_ptr(new Gtk::HBox)); @@ -91,7 +84,6 @@ GView::GView() toolbar_.reset(new GToolbar(this, 0, 0)); toolbar_->init(); bufferview_.reset(new BufferView(this, 0, 0, 300, 300)); - ::current_view = bufferview_.get(); minibuffer_.reset(new GMiniBuffer(this, *controlcommand_)); focus_command_buffer.connect( diff --git a/src/frontends/gtk/GView.h b/src/frontends/gtk/GView.h index a5b238bf70..d04a0ab329 100644 --- a/src/frontends/gtk/GView.h +++ b/src/frontends/gtk/GView.h @@ -42,7 +42,6 @@ public: void focusWorkArea() { workArea_->grab_focus(); } void setGWorkArea(Gtk::Widget * w) { workArea_ = w; } - static GView * instance() { return view_; } /// show busy cursor virtual void busy(bool) const; /// clear any temporary message and replace with current status @@ -51,7 +50,6 @@ private: void showViewState(); bool onFocusIn(GdkEventFocus * event); virtual void setWindowTitle(std::string const & t, std::string const & it); - static GView * view_; // The top-most box containing all other boxes. Gtk::VBox top_box_; diff --git a/src/frontends/gtk/GWorkArea.C b/src/frontends/gtk/GWorkArea.C index 42ba3bd2ef..4af3c59646 100644 --- a/src/frontends/gtk/GWorkArea.C +++ b/src/frontends/gtk/GWorkArea.C @@ -149,7 +149,7 @@ void inputCommitRelay(GtkIMContext */*imcontext*/, gchar * str, GWorkArea * area } -GWorkArea::GWorkArea(int width, int height) +GWorkArea::GWorkArea(LyXView & owner, int width, int height) : workAreaPixmap_(0), painter_(*this), draw_(0), colorHandler_(*this) { workArea_.set_size_request(width, height); @@ -178,13 +178,14 @@ GWorkArea::GWorkArea(int width, int height) Gtk::Box_Helpers::Element(vscrollbar_,Gtk::PACK_SHRINK)); hbox_.show(); - GView::instance()->getBox(GView::Center).children().push_back( + GView & gview = static_cast(owner); + gview.getBox(GView::Center).children().push_back( Gtk::Box_Helpers::Element(hbox_)); workArea_.set_flags(workArea_.get_flags() | Gtk::CAN_DEFAULT | Gtk::CAN_FOCUS); workArea_.grab_default(); - GView::instance()->setGWorkArea(&workArea_); + gview.setGWorkArea(&workArea_); imContext_ = GTK_IM_CONTEXT(gtk_im_multicontext_new()); g_signal_connect(G_OBJECT(imContext_), "commit", G_CALLBACK(&inputCommitRelay), diff --git a/src/frontends/gtk/GWorkArea.h b/src/frontends/gtk/GWorkArea.h index a2182329d0..14fe4e8211 100644 --- a/src/frontends/gtk/GWorkArea.h +++ b/src/frontends/gtk/GWorkArea.h @@ -21,6 +21,7 @@ #include class LColor_color; +class LyXView; class ColorCache { @@ -56,7 +57,7 @@ private: class GWorkArea : public WorkArea, public SigC::Object { public: - GWorkArea(int width, int height); + GWorkArea(LyXView & owner, int width, int height); ~GWorkArea(); virtual Painter & getPainter(); diff --git a/src/frontends/gtk/WorkAreaFactory.C b/src/frontends/gtk/WorkAreaFactory.C index 39921c930d..7d8dcc18e3 100644 --- a/src/frontends/gtk/WorkAreaFactory.C +++ b/src/frontends/gtk/WorkAreaFactory.C @@ -19,9 +19,9 @@ namespace WorkAreaFactory { -WorkArea * create(int /*x*/, int /*y*/, int w, int h) +WorkArea * create(LyXView & owner, int /*x*/, int /*y*/, int w, int h) { - return new GWorkArea(w, h); + return new GWorkArea(owner, w, h); } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 014a0556d5..0b5055eb70 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,9 @@ +2004-04-28 Angus Leeming + + * WorkAreaFactory.C (create): pass a LyXView & to QWorkArea c-tor. + + * QWorkArea.[Ch] (c-tor): now receives a LyXView &. + 2004-04-21 John Levon * QLToolbar.C: use GUI name for tooltip diff --git a/src/frontends/qt2/QWorkArea.C b/src/frontends/qt2/QWorkArea.C index 8070c266c3..4426ca1f32 100644 --- a/src/frontends/qt2/QWorkArea.C +++ b/src/frontends/qt2/QWorkArea.C @@ -39,7 +39,7 @@ namespace { QWorkArea const * wa_ptr = 0; } -QWorkArea::QWorkArea(int, int, int, int) +QWorkArea::QWorkArea(LyXView &, int, int, int, int) : WorkArea(), QWidget(qApp->mainWidget()), painter_(*this) { scrollbar_ = new QScrollBar(QScrollBar::Vertical, this); diff --git a/src/frontends/qt2/QWorkArea.h b/src/frontends/qt2/QWorkArea.h index b0c2c44664..3f241c20ba 100644 --- a/src/frontends/qt2/QWorkArea.h +++ b/src/frontends/qt2/QWorkArea.h @@ -19,6 +19,7 @@ #include +class LyXView; class QPixmap; class QWidget; @@ -34,7 +35,7 @@ class QWorkArea : public WorkArea, public QWidget { public: friend class QContentPane; - QWorkArea(int x, int y, int w, int h); + QWorkArea(LyXView & owner, int x, int y, int w, int h); virtual ~QWorkArea(); /// return this widget's painter diff --git a/src/frontends/qt2/WorkAreaFactory.C b/src/frontends/qt2/WorkAreaFactory.C index cc86dc237a..477e5eae53 100644 --- a/src/frontends/qt2/WorkAreaFactory.C +++ b/src/frontends/qt2/WorkAreaFactory.C @@ -15,9 +15,9 @@ namespace WorkAreaFactory { -WorkArea * create(int x, int y, int w, int h) +WorkArea * create(LyXView & owner, int x, int y, int w, int h) { - return new QWorkArea(x, y, w, h); + return new QWorkArea(owner, x, y, w, h); } } // namespace WorkAreaFactory diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 72ed677d35..80771c5d13 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,9 @@ +2004-04-28 Angus Leeming + + * WorkAreaFactory.C (create): pass a LyXView & to QWorkArea c-tor. + + * XWorkArea.[Ch] (c-tor): now receives a LyXView &. + 2004-04-28 Angus Leeming * combox.c (combox_handle): reset the x,y data for the sub-objects diff --git a/src/frontends/xforms/WorkAreaFactory.C b/src/frontends/xforms/WorkAreaFactory.C index 4f194df64f..49513a13ad 100644 --- a/src/frontends/xforms/WorkAreaFactory.C +++ b/src/frontends/xforms/WorkAreaFactory.C @@ -16,9 +16,9 @@ namespace WorkAreaFactory { -WorkArea * create(int x, int y, int w, int h) +WorkArea * create(LyXView & owner, int x, int y, int w, int h) { - return new XWorkArea(x, y, w, h); + return new XWorkArea(owner, x, y, w, h); } } diff --git a/src/frontends/xforms/XWorkArea.C b/src/frontends/xforms/XWorkArea.C index 379e1d82e8..444e532111 100644 --- a/src/frontends/xforms/XWorkArea.C +++ b/src/frontends/xforms/XWorkArea.C @@ -96,7 +96,7 @@ int C_event_cb(FL_FORM * form, void * xev) } // namespace anon -XWorkArea::XWorkArea(int x, int y, int w, int h) +XWorkArea::XWorkArea(LyXView & owner, int x, int y, int w, int h) : workareapixmap(0), painter_(*this) { if (lyxerr.debugging(Debug::WORKAREA)) { diff --git a/src/frontends/xforms/XWorkArea.h b/src/frontends/xforms/XWorkArea.h index b1337d8a09..9afc1ba5c7 100644 --- a/src/frontends/xforms/XWorkArea.h +++ b/src/frontends/xforms/XWorkArea.h @@ -18,12 +18,13 @@ #include "lyx_forms.h" +class LyXView; /// class XWorkArea : public WorkArea { public: /// - XWorkArea(int xpos, int ypos, int width, int height); + XWorkArea(LyXView & owner, int xpos, int ypos, int width, int height); /// ~XWorkArea(); ///