]> git.lyx.org Git - features.git/commitdiff
GUI API Cleanup step 2: merge of the "younes" branch.
authorAbdelrazak Younes <younes@lyx.org>
Mon, 26 Jun 2006 16:55:35 +0000 (16:55 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 26 Jun 2006 16:55:35 +0000 (16:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14231 a592a061-630c-0410-9148-cb99ea01b6c8

62 files changed:
src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/frontends/Gui.h
src/frontends/GuiCursor.C
src/frontends/GuiCursor.h
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/WorkArea.C
src/frontends/WorkArea.h
src/frontends/controllers/Kernel.C
src/frontends/gtk/GMiniBuffer.C
src/frontends/gtk/GPainter.C
src/frontends/gtk/GScreen.C
src/frontends/gtk/GScreen.h
src/frontends/gtk/GView.C
src/frontends/gtk/GView.h
src/frontends/gtk/GWorkArea.C
src/frontends/gtk/GWorkArea.h
src/frontends/gtk/GuiClipboard.h
src/frontends/gtk/GuiImplementation.C [new file with mode: 0644]
src/frontends/gtk/GuiImplementation.h
src/frontends/gtk/GuiWorkArea.h
src/frontends/gtk/Makefile.am
src/frontends/gtk/lyx_gui.C
src/frontends/qt3/GuiImplementation.h
src/frontends/qt3/GuiWorkArea.h
src/frontends/qt3/QContentPane.C
src/frontends/qt3/QtView.C
src/frontends/qt3/QtView.h
src/frontends/qt3/lyx_gui.C
src/frontends/qt3/qscreen.C
src/frontends/qt3/qscreen.h
src/frontends/qt4/Action.C
src/frontends/qt4/FontLoader.h
src/frontends/qt4/GuiImplementation.C
src/frontends/qt4/GuiImplementation.h
src/frontends/qt4/GuiView.C
src/frontends/qt4/GuiView.h
src/frontends/qt4/GuiWorkArea.C
src/frontends/qt4/GuiWorkArea.h
src/frontends/qt4/QLPainter.C
src/frontends/qt4/lyx_gui.C
src/frontends/qt4/qfont_metrics.C
src/frontends/xforms/GuiClipboard.h
src/frontends/xforms/GuiImplementation.C [new file with mode: 0644]
src/frontends/xforms/GuiImplementation.h
src/frontends/xforms/GuiWorkArea.h
src/frontends/xforms/Makefile.am
src/frontends/xforms/XFormsView.C
src/frontends/xforms/XFormsView.h
src/frontends/xforms/XWorkArea.C
src/frontends/xforms/XWorkArea.h
src/frontends/xforms/lyx_gui.C
src/frontends/xforms/xscreen.C
src/frontends/xforms/xscreen.h
src/importer.C
src/lyx_main.C
src/lyx_main.h
src/lyxfunc.C
src/text3.C

index d52233651d9ef724f31f30ba5b828a06051c37c8..baad2b98d193e32740be43901f1d596f19debb3a 100644 (file)
@@ -48,6 +48,7 @@
 #include "insets/insetcommand.h" // ChangeRefs
 #include "insets/insettext.h"
 
+
 using lyx::support::bformat;
 
 using lyx::cap::setSelectionRange;
@@ -61,8 +62,8 @@ using std::vector;
 extern BufferList bufferlist;
 
 
-BufferView::BufferView(LyXView * owner, int width, int height)
-       : pimpl_(new Pimpl(*this, owner, width, height))
+BufferView::BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea)
+       : pimpl_(new Pimpl(*this, owner, workArea))
 {}
 
 
@@ -147,6 +148,12 @@ void BufferView::updateScrollbar()
 }
 
 
+ScrollbarParameters const & BufferView::scrollbarParameters() const
+{
+       return pimpl_->scrollbarParameters();
+}
+
+
 void BufferView::scrollDocView(int value)
 {
        pimpl_->scrollDocView(value);
@@ -195,7 +202,7 @@ void BufferView::switchKeyMap()
 
 int BufferView::workWidth() const
 {
-       return pimpl_->workarea().width();
+       return pimpl_->width();
 }
 
 
@@ -241,9 +248,9 @@ void BufferView::selectionLost()
 }
 
 
-void BufferView::workAreaResize()
+void BufferView::workAreaResize(int width, int height)
 {
-        pimpl_->workAreaResize();
+        pimpl_->workAreaResize(width, height);
 }
 
 
@@ -339,7 +346,7 @@ void BufferView::haveSelection(bool sel)
 
 int BufferView::workHeight() const
 {
-       return pimpl_->workarea().height();
+       return pimpl_->height();
 }
 
 
index 5723cb72cd811925b704a2d8b75c755a5b02f1c7..357ab9acbb34c595d1ce888b8098641bd3abf711 100644 (file)
@@ -38,6 +38,7 @@ class ParIterator;
 namespace lyx {
 namespace frontend {
 class Painter;
+class WorkArea;
 }
 }
 
@@ -61,6 +62,23 @@ inline flags operator&(flags const f, flags const g)
 
 } // namespace
 
+/// Scrollbar Parameters
+struct ScrollbarParameters
+{
+       void reset(int h = 0, int p = 0, int l = 0)
+       {
+               height = h;
+               position = p;
+               lineScrollHeight = l;
+       }
+
+       /// The total document height in pixels
+       int height;
+       /// The current position in the document, in pixels
+       int position;
+       /// the line-scroll amount, in pixels
+       int lineScrollHeight;
+};
 
 /**
  * A buffer view encapsulates a view onto a particular
@@ -76,7 +94,7 @@ public:
         * Create a view with the given owner main window,
         * of the given dimensions.
         */
-       BufferView(LyXView * owner, int w, int h);
+       BufferView(LyXView * owner, lyx::frontend::WorkArea * workArea);
 
        ~BufferView();
 
@@ -114,6 +132,8 @@ public:
        bool fitCursor();
        /// reset the scrollbar to reflect current view position
        void updateScrollbar();
+       /// return the Scrollbar Parameters
+       ScrollbarParameters const & scrollbarParameters() const;
 
        /// FIXME
        bool available() const;
@@ -185,10 +205,10 @@ public:
        void selectionLost();
 
        ///
-       void workAreaResize();
+       void workAreaResize(int width, int height);
 
-        /// Receive a keypress
-        void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
+       /// Receive a keypress
+       void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
 
        /// a function should be executed from the workarea
        bool workAreaDispatch(FuncRequest const & ev);
index 0976075911e280142a4bf151d61567d60bd7dee4..709f702da6c9ea5e61070c7d2999da9ffb3bbfb3 100644 (file)
@@ -137,23 +137,19 @@ T * getInsetByCode(LCursor & cur, InsetBase::Code code)
 } // anon namespace
 
 
-BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner,
-                        int width, int height)
-       : bv_(&bv), owner_(owner), buffer_(0), wh_(0), cursor_timeout(400),
+BufferView::Pimpl::Pimpl(BufferView & bv, LyXView * owner, WorkArea * workArea)
+       : bv_(&bv), owner_(owner), workArea_(workArea), buffer_(0), wh_(0), cursor_timeout(400),
          using_xterm_cursor(false), cursor_(bv),
          anchor_ref_(0), offset_ref_(0)
 {
        xsel_cache_.set = false;
 
-       workAreaId_ = owner_->gui().newWorkArea(width, height);
-       workArea_ = & owner_->gui().workArea(workAreaId_);
-
        // Setup the signals
        timecon = cursor_timeout.timeout
                .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
-       
+
        cursor_timeout.start();
-        
+       
        saved_positions.resize(saved_positions_num);
        // load saved bookmarks
        lyx::Session::BookmarkList & bmList = LyX::ref().session().loadBookmarks();
@@ -341,6 +337,18 @@ lyx::frontend::Painter & BufferView::Pimpl::painter() const
 }
 
 
+int BufferView::Pimpl::width() const
+{
+       return width_;
+}
+
+
+int BufferView::Pimpl::height() const
+{
+       return height_;
+}
+
+
 void BufferView::Pimpl::setBuffer(Buffer * b)
 {
        lyxerr[Debug::INFO] << BOOST_CURRENT_FUNCTION
@@ -405,7 +413,6 @@ void BufferView::Pimpl::setBuffer(Buffer * b)
        }
 
        update();
-       updateScrollbar();
        owner_->updateMenubar();
        owner_->updateToolbars();
        owner_->updateLayoutChoice();
@@ -450,8 +457,6 @@ void BufferView::Pimpl::resizeCurrentBuffer()
 
        // Reset the "Formatting..." message
        owner_->clearMessage();
-
-       updateScrollbar();
 }
 
 
@@ -460,7 +465,7 @@ void BufferView::Pimpl::updateScrollbar()
        if (!bv_->text()) {
                lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
                                     << " no text in updateScrollbar" << endl;
-               workArea_->setScrollbarParams(0, 0, 0);
+               scrollbarParameters_.reset();
                return;
        }
 
@@ -482,7 +487,7 @@ void BufferView::Pimpl::updateScrollbar()
 
        // estimated average paragraph height:
        if (wh_ == 0)
-               wh_ = workArea_->height() / 4;
+               wh_ = height_ / 4;
        int h = t.getPar(anchor_ref_).height();
 
        // Normalize anchor/offset (MV):
@@ -495,7 +500,7 @@ void BufferView::Pimpl::updateScrollbar()
        int sumh = 0;
        int nh = 0;
        for (lyx::pit_type pit = anchor_ref_; pit <= parsize; ++pit) {
-               if (sumh > workArea_->height())
+               if (sumh > height_)
                        break;
                int const h2 = t.getPar(pit).height();
                sumh += h2;
@@ -506,9 +511,15 @@ void BufferView::Pimpl::updateScrollbar()
        if (hav > wh_)
                wh_ = hav;
 
-       workArea_->setScrollbarParams((parsize + 1) * wh_,
-               anchor_ref_ * wh_ + int(offset_ref_ * wh_ / float(h)),
-               int(wh_ * defaultRowHeight() / float(h)));
+       scrollbarParameters_.height = (parsize + 1) * wh_;
+       scrollbarParameters_.position = anchor_ref_ * wh_ + int(offset_ref_ * wh_ / float(h));
+       scrollbarParameters_.lineScrollHeight = int(wh_ * defaultRowHeight() / float(h));
+}
+
+
+ScrollbarParameters const & BufferView::Pimpl::scrollbarParameters() const
+{
+       return scrollbarParameters_;
 }
 
 
@@ -539,7 +550,7 @@ void BufferView::Pimpl::scrollDocView(int value)
 
        int const height = 2 * defaultRowHeight();
        int const first = height;
-       int const last = workArea_->height() - height;
+       int const last = height_ - height;
        LCursor & cur = cursor_;
 
        bv_funcs::CurStatus st = bv_funcs::status(bv_, cur);
@@ -583,7 +594,7 @@ void BufferView::Pimpl::scroll(int /*lines*/)
 //     scrollDocView(new_top_y);
 //
 //     // Update the scrollbar.
-//     workArea_->.setScrollbarParams(t->height(), top_y(), defaultRowHeight());
+//     workArea_->setScrollbarParams(t->height(), top_y(), defaultRowHeight());
 }
 
 
@@ -642,17 +653,14 @@ void BufferView::Pimpl::selectionLost()
 }
 
 
-void BufferView::Pimpl::workAreaResize()
+void BufferView::Pimpl::workAreaResize(int width, int height)
 {
-       static int workArea_width;
-       static int workArea_height;
-
-       bool const widthChange = workArea_->width() != workArea_width;
-       bool const heightChange = workArea_->height() != workArea_height;
+       bool const widthChange = width != width_;
+       bool const heightChange = height != height_;
 
        // Update from work area
-       workArea_width = workArea_->width();
-       workArea_height = workArea_->height();
+       width_ = width;
+       height_ = height;
 
        if (buffer_ && widthChange) {
                // The visible LyXView need a resize
@@ -662,8 +670,6 @@ void BufferView::Pimpl::workAreaResize()
        if (widthChange || heightChange)
                update();
 
-       // Always make sure that the scrollbar is sane.
-       updateScrollbar();
        owner_->updateLayoutChoice();
 }
 
@@ -675,7 +681,7 @@ bool BufferView::Pimpl::fitCursor()
                int const asc = font_metrics::maxAscent(font);
                int const des = font_metrics::maxDescent(font);
                Point const p = bv_funcs::getPos(cursor_, cursor_.boundary());
-               if (p.y_ - asc >= 0 && p.y_ + des < workArea_->height())
+               if (p.y_ - asc >= 0 && p.y_ + des < height_)
                        return false;
        }
        center();
@@ -739,8 +745,6 @@ void BufferView::Pimpl::update(Update::flags flags)
        } else
                workArea_->greyOut();
 
-       // And the scrollbar
-       updateScrollbar();
        owner_->view_state_changed();
 }
 
@@ -876,7 +880,7 @@ void BufferView::Pimpl::center()
        Paragraph const & par = bot.text()->paragraphs()[pit];
        anchor_ref_ = pit;
        offset_ref_ = bv_funcs::coordOffset(cursor_, cursor_.boundary()).y_
-               + par.ascent() - workArea_->height() / 2;
+               + par.ascent() - height_ / 2;
 }
 
 
@@ -1013,7 +1017,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
        // surrounding LyXText will handle this event.
 
        // Build temporary cursor.
-       cmd.y = min(max(cmd.y, -1), workArea_->height());
+       cmd.y = min(max(cmd.y, -1), height_);
        InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
        //lyxerr << BOOST_CURRENT_FUNCTION
        //       << " * hit inset at tip: " << inset << endl;
index bf66462773640890e5176e84f1d133932728db86..c5c74862f8450ceeb45ffaefc980cda8cfb91f6f 100644 (file)
@@ -57,7 +57,7 @@ class GuiCursor;
 class BufferView::Pimpl : public boost::signals::trackable {
 public:
        ///
-       Pimpl(BufferView & bv, LyXView * owner, int width, int height);
+       Pimpl(BufferView & bv, LyXView * owner, lyx::frontend::WorkArea * workArea);
        ///
        lyx::frontend::Painter & painter() const;
        ///
@@ -75,10 +75,12 @@ public:
        ///
        bool loadLyXFile(std::string const &, bool);
        ///
-       void workAreaResize();
+       void workAreaResize(int width, int height);
        ///
        void updateScrollbar();
        ///
+       ScrollbarParameters const & scrollbarParameters() const;
+       ///
        void scrollDocView(int value);
        /// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
        void scroll(int lines);
@@ -124,7 +126,25 @@ public:
        /// the clipboard
        lyx::frontend::Clipboard & clipboard() const;
 
+       /// Width and height of the BufferView in Pixels
+       /**
+       This is set externally by the workAreaResize method.
+       */
+       int width() const;
+       /// Height of the BufferView in Pixels
+       /**
+       This is set externally by the workAreaResize method.
+       */
+       int height() const;
+
 private:
+       ///
+       int width_;
+       ///
+       int height_;
+       ///
+       ScrollbarParameters scrollbarParameters_;
+
        /// An error list (replaces the error insets)
        ErrorList errorlist_;
        /// add an error to the list
@@ -192,7 +212,6 @@ private:
        void menuInsertLyXFile(std::string const & filen);
 
        lyx::frontend::WorkArea * workArea_;
-       int workAreaId_;
 
        /// this is used to handle XSelection events in the right manner
        struct {
index 2d1c9eee1ea4b3090d147cac9de5420ee1a103e7..9676e62f4947b210de58af98ccf361b61e200095 100644 (file)
 
 #include "frontends/GuiCursor.h"
 
+#include <boost/shared_ptr.hpp>
+
+#include <map>
+
+class LyXView;
+
 namespace lyx {
 namespace frontend {
 
@@ -32,18 +38,31 @@ public:
        virtual ~Gui() {}
 
        ///
-       virtual Clipboard& clipboard() = 0;
+       virtual Clipboard & clipboard() = 0;
+
+       ///
+       virtual int newView(unsigned int width, unsigned int height) = 0;
        ///
-       virtual int newWorkArea(int w, int h) = 0;
+       virtual LyXView & view(int id) = 0;
        ///
-       virtual WorkArea& workArea(int id) = 0;
+       virtual void destroyView(int id) = 0;
+
+       ///
+       virtual int newWorkArea(unsigned int width, unsigned int height, int view_id) = 0;
+       ///
+       virtual WorkArea & workArea(int id) = 0;
        ///
        virtual void destroyWorkArea(int id) = 0;
 
        ///
        GuiCursor & guiCursor() {return cursor_;}
 
+protected:
+       /// view of a buffer. Eventually there will be several.
+       std::map<int, boost::shared_ptr<BufferView> > buffer_views_;
+
 private:
+       ///
        GuiCursor cursor_;
 };
 
index 7187c497464ee3b88336f71ff179644b7894f317..77f6eaed086e51f1c43cd9c1bc12fa73cb420808 100644 (file)
 
 #include "support/filetools.h" // LibFileSearch
 
-#include <boost/utility.hpp>
-#include <boost/bind.hpp>
-#include <boost/signals/trackable.hpp>
-
 using lyx::support::libFileSearch;
 
 using std::endl;
@@ -57,7 +53,7 @@ namespace lyx {
 namespace frontend {
 
 GuiCursor::GuiCursor()
-       : cursor_visible_(false), work_area_(NULL)
+       : cursor_visible_(false), work_area_(0)
 {
 }
 
@@ -80,7 +76,7 @@ void GuiCursor::show(BufferView & bv)
        if (!bv.available())
                return;
 
-       Cursor_Shape shape = BAR_SHAPE;
+       CursorShape shape = BAR_SHAPE;
 
        LyXText const & text = *bv.getLyXText();
        LyXFont const & realfont = text.real_current_font;
@@ -146,4 +142,3 @@ void GuiCursor::prepare()
 
 } // namespace frontend
 } // namespace lyx
-
index cc45d8c143ab7b785288ee042f24be0811d49482..e6ee4674148b41fc94c68478dba3bfa90b8c79db 100644 (file)
  * Full author contact details are available in file CREDITS.
  */
 
+// X11 use a define called CursorShape, and we really want to use
+// that name our selves. Therefore we do something similar to what is done
+// in kde/fixx11h.h:
+namespace X {
+#ifdef CursorShape
+#ifndef FIXX11H_CursorShape
+#define FIXX11H_CursorShape
+int const XCursorShape = CursorShape;
+#undef CursorShape
+int const CursorShape = CursorShape;
+#endif
+#undef CursorShape
+#endif
+
+} // namespace X
+
 #ifndef GUI_CURSOR_H
 #define GUI_CURSOR_H
 
@@ -26,7 +42,7 @@ namespace frontend {
 class WorkArea;
 
 /// types of cursor in work area
-enum Cursor_Shape {
+enum CursorShape {
        /// normal I-beam
        BAR_SHAPE,
        /// L-shape for locked insets of a different language
index 2256cd1d97f54041318be2eb4374fbe45a934fb9..7f53e0ed5e95fb7ff608ca66ee307def77e773c4 100644 (file)
@@ -12,6 +12,7 @@
 #include <config.h>
 
 #include "LyXView.h"
+#include "Gui.h"
 #include "Dialogs.h"
 #include "Timeout.h"
 #include "Toolbars.h"
@@ -46,6 +47,8 @@
 # include <unistd.h>
 #endif
 
+using lyx::frontend::Gui;
+
 using lyx::support::makeDisplayPath;
 using lyx::support::onlyFilename;
 
@@ -56,18 +59,29 @@ using lyx::frontend::ControlCommandBuffer;
 
 string current_layout;
 
+Gui & LyXView::gui()
+{
+       return owner_;
+}
 
-LyXView::LyXView()
-       : toolbars_(new Toolbars(*this)),
+LyXView::LyXView(Gui & owner)
+       : owner_(owner),
+         toolbars_(new Toolbars(*this)),
          intl_(new Intl),
          autosave_timeout_(new Timeout(5000)),
          lyxfunc_(new LyXFunc(this)),
          dialogs_(new Dialogs(*this)),
-         controlcommand_(new ControlCommandBuffer(*this))
+         controlcommand_(new ControlCommandBuffer(*this)),
+         bufferview_(0)
 {
        lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
 }
 
+void LyXView::setBufferView(BufferView * buffer_view)
+{
+       bufferview_ = buffer_view;
+}
+
 
 LyXView::~LyXView()
 {
@@ -96,7 +110,7 @@ Buffer * LyXView::buffer() const
 }
 
 
-boost::shared_ptr<BufferView> const & LyXView::view() const
+BufferView * LyXView::view() const
 {
        return bufferview_;
 }
@@ -132,7 +146,7 @@ void LyXView::autoSave()
        lyxerr[Debug::INFO] << "Running autoSave()" << endl;
 
        if (view()->available()) {
-               ::autoSave(view().get());
+               ::autoSave(view());
        }
 }
 
index 29e51c1dbf103d7381b9f6460ef184192491686f..77316e612427bf051f2798d11092035e2f173dc3 100644 (file)
@@ -33,12 +33,8 @@ class Timeout;
 class FuncRequest;
 
 namespace lyx {
-
 namespace frontend {
 class Gui;
-} // namespace frontend
-
-namespace frontend {
 class ControlCommandBuffer;
 } // namespace frontend
 
@@ -60,10 +56,12 @@ class ControlCommandBuffer;
 class LyXView : public boost::signals::trackable, boost::noncopyable {
 public:
 
-       LyXView();
+       LyXView(lyx::frontend::Gui & owner);
 
        virtual ~LyXView();
 
+       void setBufferView(BufferView * buffer_view);
+
        /**
         * This is called after the concrete view has been created.
         * We have to have the toolbar and the other stuff created
@@ -80,7 +78,7 @@ public:
            Returned as a shared_ptr so that anything wanting to cache the
            buffer view can do so safely using a boost::weak_ptr.
         */
-       boost::shared_ptr<BufferView> const & view() const;
+       BufferView * view() const;
 
        /// return the buffer currently shown in this window
        Buffer * buffer() const;
@@ -148,19 +146,24 @@ public:
         */
        Buffer const * const updateInset(InsetBase const *) const;
 
-       // returns true if this view has the focus.
+       /// returns true if this view has the focus.
        virtual bool hasFocus() const = 0;
 
-       virtual lyx::frontend::Gui & gui() = 0;
+       ///
+       virtual lyx::frontend::Gui & gui();
 
 protected:
-       /// view of a buffer. Eventually there will be several.
-       boost::shared_ptr<BufferView> bufferview_;
+       /// current bufferview (view of a buffer).
+       /**
+       \todo FIXME: this should be moved out of LyXView.
+       */
+       BufferView * bufferview_;
 
        /// view's menubar
        boost::scoped_ptr<Menubar> menubar_;
 
 private:
+       lyx::frontend::Gui & owner_;
        /**
         * setWindowTitle - set title of window
         * @param t main window title
index 9f20119a5f62e9ca914b56aa5b8edcb8eba748d1..acc34663e30c10ebf2e11fbd965f61039593dd45 100644 (file)
@@ -118,8 +118,8 @@ SplashScreen::SplashScreen()
        loader_.reset(file);
 }
 
-WorkArea::WorkArea(LyXView & owner, int w, int h)
-       : greyed_out_(true)
+WorkArea::WorkArea(BufferView * buffer_view)
+       :  buffer_view_(buffer_view), greyed_out_(true)
 {
        // Start loading the pixmap as soon as possible
        if (lyxrc.show_banner) {
@@ -130,6 +130,12 @@ WorkArea::WorkArea(LyXView & owner, int w, int h)
 }
 
 
+void WorkArea::setBufferView(BufferView * buffer_view)
+{
+       buffer_view_ = buffer_view;
+}
+
+
 void WorkArea::checkAndGreyOut()
 {
        if (greyed_out_)
@@ -141,7 +147,7 @@ void WorkArea::redraw(BufferView & bv, ViewMetricsInfo const & vi)
 {
        greyed_out_ = false;
        getPainter().start();
-       paintText(bv, vi);
+       paintText(*buffer_view_, vi);
        lyxerr[Debug::DEBUG] << "Redraw screen" << endl;
        int const ymin = std::max(vi.y1, 0);
        int const ymax =
index b3ee602e57ff0982cc114d2d1ea47330effecf1a..113f2ce9367b3de3db08eb95b97db04c3c057261 100644 (file)
@@ -19,8 +19,6 @@
 #include "frontends/key_state.h"
 #include "frontends/LyXKeySym.h"
 
-class LyXView;
-class FuncRequest;
 class BufferView;
 class ViewMetricsInfo;
 
@@ -38,10 +36,12 @@ class Painter;
  */
 class WorkArea {
 public:
-       WorkArea(LyXView & owner, int w, int h);
+       WorkArea(BufferView * buffer_view = 0);
 
        virtual ~WorkArea() {}
 
+       void setBufferView(BufferView * buffer_view);
+
        /// return the painter object for this work area
        virtual Painter & getPainter() = 0;
 
@@ -66,7 +66,7 @@ public:
        void greyOut();
 
        /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h, Cursor_Shape shape) = 0;
+       virtual void showCursor(int x, int y, int h, CursorShape shape) = 0;
 
        /// hide the cursor
        virtual void removeCursor() = 0;
@@ -75,6 +75,9 @@ protected:
        /// cause the display of the given area of the work area
        virtual void expose(int x, int y, int w, int h) = 0;
 
+       ///
+       BufferView * buffer_view_;
+
 private:
        ///
        void checkAndGreyOut();
index b4a0e57c1fc43a198f7ae7f6027826b400e11e6b..e411c6c43deeb55c6aa924a2ac315368c938def8 100644 (file)
@@ -49,7 +49,7 @@ void Kernel::disconnect(string const & name) const
 
 bool Kernel::isBufferAvailable() const
 {
-       if (!lyxview_.view().get())
+       if (!lyxview_.view())
                return false;
        return lyxview_.view()->available();
 }
@@ -90,13 +90,13 @@ void Kernel::redrawGUI() const
 
 BufferView * Kernel::bufferview()
 {
-       return lyxview_.view().get();
+       return lyxview_.view();
 }
 
 
 BufferView const * Kernel::bufferview() const
 {
-       return lyxview_.view().get();
+       return lyxview_.view();
 }
 
 
index 9c920957de7580828553b1c553a1366d2b747c98..e22185baba86e3756bdb7a1d9dc14cad3cdcab3c 100644 (file)
@@ -82,7 +82,7 @@ GMiniBuffer::GMiniBuffer(GView * view, ControlCommandBuffer & control) :
        focusTimer_->timeout.connect(
                boost::bind(&GMiniBuffer::focusTimeout, this));
        idleTimer_->start();
-       messageMode();
+       //messageMode();
 }
 
 
index e39dade622fa7767b7677bd708436e9c7eea1310..2d38d771abc1a1167b43f66e5b4815b81e188899 100644 (file)
@@ -232,7 +232,7 @@ void GPainter::text(int x, int y, char const * s, size_t ls, LyXFont const & f)
                XftFont * fontS = getXftFont(smallfont);
                char c;
                int tmpx = x;
-               for (int i = 0; i < ls; ++i) {
+               for (unsigned int i = 0; i < ls; ++i) {
                        c = lyx::support::uppercase(s[i]);
                        if (c != s[i]) {
                                XftDrawString8(draw, xftClr, fontS, tmpx, y,
index 2014e734630c9571317ebdd10d80e20e540132a9..b5a48bab06888fbef2d2a3612dd47ec19b831446 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "frontends/font_metrics.h"
 #include "frontends/Painter.h"
+#include "frontends/GuiCursor.h"
 
 #include "insets/insettext.h"
 
@@ -64,7 +65,7 @@ void GScreen::setCursorColor(Glib::RefPtr<Gdk::GC> gc)
 }
 
 
-void GScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
+void GScreen::showCursor(int x, int y, int h, CursorShape shape)
 {
        // Update the cursor color.
        setCursorColor(owner_.getGC());
index 8e9a1694548b5036fa61b25235530292059d77c9..1aae24e9cb9b7b464bfd399221af1ac51db685f1 100644 (file)
@@ -39,7 +39,7 @@ public:
        ///
        virtual void removeCursor();
        ///
-       virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
+       virtual void showCursor(int x, int y, int h, CursorShape shape);
 
        /// Copies specified area of pixmap to screen
        virtual void expose(int x, int y, int w, int h);
index f07b198315b58011386f471551b00c4237f03364..edaa95f8537f98a7738cb9151d3b5ffee30cefdd 100644 (file)
@@ -57,7 +57,7 @@ void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
 } // namespace anon
 
 
-GView::GView() : frontend_(*this)
+GView::GView(Gui & owner) : LyXView(owner)
 {
        // The physical store for the boxes making up the layout.
        box_store_.push_back(BoxPtr(new Gtk::VBox));
@@ -93,7 +93,6 @@ GView::GView() : frontend_(*this)
        // Define the components making up the window.
        menubar_.reset(new GMenubar(this, menubackend));
        getToolbars().init();
-       bufferview_.reset(new BufferView(this, 300, 300));
        minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
 
        focus_command_buffer.connect(
@@ -119,7 +118,7 @@ GView::GView() : frontend_(*this)
        }
        set_default_size(width, height);
        // Make sure the buttons are disabled if needed.
-       updateToolbars();
+       //updateToolbars();
        string const iconName =
                support::libFileSearch("images", "lyx", "xpm");
        if (!iconName.empty())
index cc796a66f3772cbc1f44b3abfe179635df88549a..ce0c3be837a753b5a93fe1a61b9e2c84810a6640 100644 (file)
@@ -16,8 +16,6 @@
 
 #include "frontends/LyXView.h"
 
-#include "GuiImplementation.h"
-
 #include <gtkmm.h>
 
 #include <map>
@@ -37,7 +35,7 @@ public:
                Center
        };
 
-       GView();
+       GView(Gui & owner);
        ~GView();
 
        Gtk::Box & getBox(Position pos);
@@ -58,9 +56,6 @@ public:
        // returns true if this view has the focus.
        virtual bool hasFocus() const;
 
-       ///
-       Gui & gui() { return frontend_; }
-
 private:
        void showViewState();
        bool onFocusIn(GdkEventFocus * event);
@@ -79,8 +74,6 @@ private:
 
        boost::scoped_ptr<GMiniBuffer> minibuffer_;
        Gtk::Widget * workArea_;
-       ///
-       GuiImplementation frontend_;
 };
 
 } // namespace frontend
index 0b39199cb56b5a98dadcb223ee9fbb2c5afc6bdc..5eda32f7397ccbd0cb48b0b0135cfe0d58567715 100644 (file)
@@ -332,7 +332,7 @@ bool GWorkArea::onConfigure(GdkEventConfigure * /*event*/)
                gtk_im_context_set_client_window(
                        imContext_, workArea_.get_window()->gobj());
        }
-       view_.view()->workAreaResize();
+       view_.view()->workAreaResize(workArea_.get_width(), workArea_.get_height());
        return true;
 }
 
index eea296c85d6877e40766f921f6ab983664267103..46160aa451fae4c855fa37de7f656d5646105306 100644 (file)
@@ -58,7 +58,7 @@ private:
 class GWorkArea : public sigc::trackable {
 public:
        GWorkArea(LyXView & owner, int width, int height);
-       ~GWorkArea();
+       virtual ~GWorkArea();
 
        virtual Painter & getPainter();
        ///
@@ -97,7 +97,7 @@ private:
        bool onKeyPress(GdkEventKey * event);
        void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
        void onClipboardClear();
-        LyXView & view_;
+       LyXView & view_;
        Gtk::HBox hbox_;
        Gtk::DrawingArea workArea_;
        Gtk::VScrollbar vscrollbar_;
index f8bff111312f46146033a41e6a5fb2739475a8ac..36b264dc7c452c2234506fa792abce7d8b1a0276 100644 (file)
 namespace lyx {
 namespace frontend {
 
-typedef GWorkArea FWorkArea;
-
 /**
  * The GTK version of the Clipboard.
  */
 class GuiClipboard: public lyx::frontend::Clipboard
 {
 public:
-       GuiClipboard(FWorkArea * work_area)
+       GuiClipboard(GWorkArea * work_area)
                : old_work_area_(work_area)
        {
        }
@@ -54,7 +52,7 @@ public:
        //@}
 
 private:
-       FWorkArea * old_work_area_;
+       GWorkArea * old_work_area_;
 };
 
 } // namespace frontend
diff --git a/src/frontends/gtk/GuiImplementation.C b/src/frontends/gtk/GuiImplementation.C
new file mode 100644 (file)
index 0000000..98d4d87
--- /dev/null
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+/**
+ * \file gtk/GuiImplementation.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include "GuiImplementation.h"
+
+#include "GView.h"
+#include "BufferView.h"
+
+namespace lyx {
+namespace frontend {
+
+int GuiImplementation::newView(unsigned int /*w*/, unsigned int /*h*/)
+{
+       view_.reset(new GView(*this));
+       return 0;
+}
+
+
+int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id*/)
+{
+       old_work_area_.reset(new GWorkArea(*view_.get(), w, h));
+       old_screen_.reset(new GScreen(*old_work_area_.get()));
+       work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get()));
+       clipboard_.reset(new GuiClipboard(old_work_area_.get()));
+       guiCursor().connect(work_area_.get());
+       
+       // FIXME BufferView creation should be independant of WorkArea creation
+       buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get()));
+       work_area_->setBufferView(buffer_views_[0].get());
+       view_->setBufferView(buffer_views_[0].get());
+       return 0;
+}
+
+
+void GuiImplementation::destroyWorkArea(int /*id*/)
+{
+       clipboard_.reset();
+       work_area_.reset();
+       old_work_area_.reset();
+       old_screen_.reset();
+}
+
+} // namespace frontend
+} // namespace lyx
index 6113a803cf8e651fa96d19c89e4d9f24ffa89cf9..a0720d9a3bfb67e0f53b52fc88dffc1d5101cddc 100644 (file)
 
 #include <boost/shared_ptr.hpp>
 
-#include <map>
-
 namespace lyx {
 namespace frontend {
 
-typedef GScreen FScreen;
-typedef GWorkArea FWorkArea;
-
 /**
  * The Gui class is the interface to all GTK components.
  */
 class GuiImplementation: public lyx::frontend::Gui
 {
 public:
-       GuiImplementation(LyXView & owner): owner_(owner)
+       GuiImplementation()
        {
        }
 
@@ -45,45 +40,43 @@ public:
        {
        }
 
-       lyx::frontend::Clipboard& clipboard()
+       lyx::frontend::Clipboard & clipboard()
        {
                return *clipboard_;
        }
 
-       int newWorkArea(int w, int h)
+       int newView(unsigned int w, unsigned int h);
+
+       LyXView & view(int /*id*/)
        {
-               old_work_area_.reset(new FWorkArea(owner_, w, h));
-               old_screen_.reset(new FScreen(*old_work_area_.get()));
-               work_area_.reset(new GuiWorkArea(owner_, w, h, old_screen_.get(), old_work_area_.get()));
-               clipboard_.reset(new GuiClipboard(old_work_area_.get()));
-               guiCursor().connect(work_area_.get());
-               return 0;
+               return *view_;
        }
 
-       lyx::frontend::WorkArea& workArea(int id)
+       void destroyView(int /*id*/)
        {
-               return *work_area_;
+               view_.reset();
        }
 
-       void destroyWorkArea(int id)
+       int newWorkArea(unsigned int w, unsigned int h, int /*view_id*/);
+
+       lyx::frontend::WorkArea & workArea(int /*id*/)
        {
-               clipboard_.reset();
-               work_area_.reset();
-               old_work_area_.reset();
-               old_screen_.reset();
+               return *work_area_;
        }
 
+       void destroyWorkArea(int /*id*/);
+
 private:
        ///
        boost::shared_ptr<GuiClipboard> clipboard_;
        ///
        boost::shared_ptr<GuiWorkArea> work_area_;
        ///
-       boost::shared_ptr<FWorkArea> old_work_area_;
+       boost::shared_ptr<LyXView> view_;
        ///
-       boost::shared_ptr<FScreen> old_screen_;
+       boost::shared_ptr<GWorkArea> old_work_area_;
        ///
-       LyXView & owner_;
+       boost::shared_ptr<GScreen> old_screen_;
 };
 
 } // namespace frontend
index 8e6ca041f5bf231892b68301011b89d8326dccc7..d688888a2a22af885f91f9c58cb30f80854ca333 100644 (file)
 namespace lyx {
 namespace frontend {
 
-typedef GScreen FScreen;
-typedef GWorkArea FWorkArea;
-
 /**
  * Temporary wrapper around GWorkArea and GScreen.
  * Please refer to the Qt4 implementation for a proper cleanup of the API.
  */
 class GuiWorkArea: public lyx::frontend::WorkArea {
 public:
-       GuiWorkArea(LyXView & owner, int w, int h,
-               FScreen * screen, FWorkArea * work_area)
-               : lyx::frontend::WorkArea(owner, w, h),
-               old_screen_(screen), old_work_area_(work_area)
+       GuiWorkArea(GScreen * screen, GWorkArea * work_area)
+               : old_screen_(screen), old_work_area_(work_area)
        {
        }
 
@@ -69,7 +64,7 @@ public:
 
 
        /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h, Cursor_Shape shape)
+       virtual void showCursor(int x, int y, int h, CursorShape shape)
        {
                old_screen_->showCursor(x, y, h, shape);
        }
@@ -88,8 +83,8 @@ protected:
        }
 
 private:
-       FScreen * old_screen_;
-       FWorkArea * old_work_area_;
+       GScreen * old_screen_;
+       GWorkArea * old_work_area_;
 };
 
 } // namespace frontend
index 2ad37f86c50e81c203b7efe08eb60ee4a894436b..515d74b8a22bce6aa6f698b16d0b897130eb9e56 100644 (file)
@@ -138,10 +138,10 @@ libgtk_la_SOURCES = \
        ghelpers.C \
        ghelpers.h \
        GuiImplementation.h \
+       GuiImplementation.C \
        io_callback.C \
        io_callback.h \
        lyx_gui.C \
        xftFontLoader.C \
        xftFontLoader.h \
        xftFontMetrics.C
-
index 5aa788bdb0e810e37b5c59cd5f90173aa824d7a0..1f2bef7b6db25c4e9b5ebe859af3cc30aa269a0f 100644 (file)
@@ -43,6 +43,7 @@
 #include "lyxsocket.h"
 #include "BufferView.h"
 
+#include "GuiImplementation.h"
 #include "GView.h"
 #include "GtkmmX.h"
 
@@ -75,6 +76,8 @@ using std::string;
 using lyx::support::package;
 
 using lyx::frontend::colorCache;
+using lyx::frontend::Gui;
+using lyx::frontend::GuiImplementation;
 using lyx::frontend::GView;
 
 
@@ -99,10 +102,25 @@ int getDPI()
 
 } // namespace anon
 
+class Application: public Gtk::Main
+{
+public:
+       ///
+       Application(int & argc, char * argv[]): Gtk::Main(argc, argv)
+       {}
+       ///
+       Gui & gui() { return gui_; }
+
+private:
+       ///
+       GuiImplementation gui_;
+};
+
+Application * theApp;
 
 void lyx_gui::exec(int & argc, char * argv[])
 {
-       new Gtk::Main(argc, argv);
+       theApp = new Application(argc, argv);
 
        using namespace lyx::graphics;
        Image::newImage = boost::bind(&LyXGdkImage::newImage);
@@ -125,10 +143,12 @@ void lyx_gui::parse_lyxrc()
 void lyx_gui::start(string const & batch, std::vector<string> const & files,
                    unsigned int width, unsigned int height, int posx, int posy, bool)
 {
-       boost::shared_ptr<GView> view_ptr(new GView);
-       LyX::ref().addLyXView(view_ptr);
+       int view_id = theApp->gui().newView(width, height);
+       GView & view = static_cast<GView &> (theApp->gui().view(view_id));
+       theApp->gui().newWorkArea(width, height, 0);
+
+       LyX::ref().addLyXView(&view);
 
-       GView & view = *view_ptr.get();
        view.show();
        view.init();
 
@@ -146,7 +166,7 @@ void lyx_gui::start(string const & batch, std::vector<string> const & files,
                view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
        }
 
-       Gtk::Main::run();
+       theApp->run();
 
        // FIXME: breaks emergencyCleanup
        delete lyxsocket;
@@ -157,7 +177,7 @@ void lyx_gui::start(string const & batch, std::vector<string> const & files,
 void lyx_gui::exit(int /*status*/)
 {
        // FIXME: Don't ignore status
-       Gtk::Main::quit();
+       theApp->quit();
 }
 
 
index d210d14e432a982a9ee6145d8d9bab9e70da6800..adf345b7b660a24aebe83d4eaa29cda85a17cc9d 100644 (file)
 #define GUI_IMPLEMENTATION_H
 
 #include "frontends/Gui.h"
-#include "frontends/LyXView.h"
 
+#include "QtView.h"
 #include "qscreen.h"
 #include "QWorkArea.h"
 
 #include "GuiClipboard.h"
 #include "GuiWorkArea.h"
 
+#include "BufferView.h"
+
 #include <boost/shared_ptr.hpp>
 
 namespace lyx {
 namespace frontend {
 
+typedef QtView FView;
 typedef QScreen FScreen;
 typedef QWorkArea FWorkArea;
 
@@ -35,7 +38,7 @@ typedef QWorkArea FWorkArea;
 class GuiImplementation: public lyx::frontend::Gui
 {
 public:
-       GuiImplementation(LyXView & owner): owner_(owner)
+       GuiImplementation()
        {
        }
 
@@ -48,22 +51,45 @@ public:
                return *clipboard_;
        }
 
-       int newWorkArea(int w, int h)
+       int newView(unsigned int /*w*/, unsigned int /*h*/)
+       {
+               view_.reset(new FView(*this));
+               return 0;
+       }
+
+
+       LyXView& view(int /*id*/)
+       {
+               return *view_;
+       }
+
+
+       void destroyView(int /*id*/)
+       {
+               view_.reset();
+       }
+
+       int newWorkArea(unsigned int w, unsigned int h, int /*view_id*/)
        {
-               old_work_area_.reset(new FWorkArea(owner_, w, h));
+               old_work_area_.reset(new FWorkArea(*view_.get(), w, h));
                old_screen_.reset(new FScreen(*old_work_area_.get()));
-               work_area_.reset(new GuiWorkArea(owner_, w, h, old_screen_.get(), old_work_area_.get()));
+               work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get()));
                clipboard_.reset(new GuiClipboard(old_work_area_.get()));
                guiCursor().connect(work_area_.get());
+
+               // FIXME BufferView creation should be independant of WorkArea creation
+               buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get()));
+               work_area_->setBufferView(buffer_views_[0].get());
+               view_->setBufferView(buffer_views_[0].get());
                return 0;
        }
 
-       lyx::frontend::WorkArea& workArea(int id)
+       lyx::frontend::WorkArea& workArea(int /*id*/)
        {
                return *work_area_;
        }
 
-       void destroyWorkArea(int id)
+       void destroyWorkArea(int /*id*/)
        {
                clipboard_.reset();
                work_area_.reset();
@@ -77,11 +103,11 @@ private:
        ///
        boost::shared_ptr<GuiWorkArea> work_area_;
        ///
+       boost::shared_ptr<FView> view_;
+       ///
        boost::shared_ptr<FWorkArea> old_work_area_;
        ///
        boost::shared_ptr<FScreen> old_screen_;
-       ///
-       LyXView & owner_;
 };
 
 } // namespace frontend
index bdf3fc8ef5b554dd932df6f9575847ca50f9eabf..a4879d17b5b93f579812de6fdc2d36c28da8448a 100644 (file)
@@ -29,10 +29,8 @@ typedef QWorkArea FWorkArea;
  */
 class GuiWorkArea: public lyx::frontend::WorkArea {
 public:
-       GuiWorkArea(LyXView & owner, int w, int h,
-               FScreen * screen, FWorkArea * work_area)
-               : lyx::frontend::WorkArea(owner, w, h),
-               old_screen_(screen), old_work_area_(work_area)
+       GuiWorkArea(FScreen * screen, FWorkArea * work_area)
+               : old_screen_(screen), old_work_area_(work_area)
        {
        }
 
@@ -69,7 +67,7 @@ public:
 
 
        /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h, Cursor_Shape shape)
+       virtual void showCursor(int x, int y, int h, CursorShape shape)
        {
                old_screen_->showCursor(x, y, h, shape);
        }
index a9b16162edf2297b512a3105c12ca8a3ee4cc31b..a244db3734be27427b21e8e9b01b3320b4312921 100644 (file)
@@ -337,15 +337,17 @@ void QContentPane::resizeEvent(QResizeEvent *)
        }
 
        pixmap_->resize(width(), height());
-        wa_->view().view()->workAreaResize();
+       wa_->view().view()->workAreaResize(width(), height());
 }
 
 
 void QContentPane::paintEvent(QPaintEvent * e)
 {
+       BufferView * buffer_view_ = wa_->view().view();
+
        if (!pixmap_.get()) {
                pixmap_.reset(new QPixmap(width(), height()));
-                wa_->view().view()->workAreaResize();
+               buffer_view_->workAreaResize(width(), height());
                return;
        }
 
@@ -354,6 +356,14 @@ void QContentPane::paintEvent(QPaintEvent * e)
        QPainter q(this);
        q.drawPixmap(QPoint(r.x(), r.y()),
                *pixmap_.get(), r);
+
+       buffer_view_->updateScrollbar();
+       ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
+
+       wa_->scrollbar_->setTracking(false);
+       wa_->setScrollbarParams(scroll_.height, scroll_.position,
+               scroll_.lineScrollHeight);
+       wa_->scrollbar_->setTracking(true);
 }
 
 
index e79be58db63e7155c469fb7e544045a69c757b36..4b4847e98c634b2446f4ae714908b50d4c395df7 100644 (file)
@@ -37,8 +37,6 @@
 #include <qpixmap.h>
 #include <qstatusbar.h>
 
-#include <algorithm>
-
 using std::string;
 
 FontLoader fontloader;
@@ -56,14 +54,28 @@ int const statusbar_timer_value = 3000;
 } // namespace anon
 
 
-
-QtView::QtView()
-       : QMainWindow(), LyXView(), commandbuffer_(0), frontend_(*this)
+QtView::QtView(Gui & owner)
+       : QMainWindow(), LyXView(owner), commandbuffer_(0)
 {
        qApp->setMainWidget(this);
 
-       bufferview_.reset(new BufferView(this, width(), height()));
+#ifndef Q_WS_MACX
+       //  assign an icon to main form. We do not do it under Qt/Mac,
+       //  since the icon is provided in the application bundle.
+       string const iconname = libFileSearch("images", "lyx", "xpm");
+       if (!iconname.empty())
+               setIcon(QPixmap(toqstr(iconname)));
+#endif
+}
+
+
+QtView::~QtView()
+{
+}
+
 
+void QtView::init()
+{
        menubar_.reset(new QLMenubar(this, menubackend));
        getToolbars().init();
 
@@ -72,25 +84,14 @@ QtView::QtView()
        view_state_changed.connect(boost::bind(&QtView::update_view_state, this));
        connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
 
-#ifndef Q_WS_MACX
-       //  assign an icon to main form. We do not do it under Qt/Mac,
-       //  since the icon is provided in the application bundle.
-       string const iconname = libFileSearch("images", "lyx", "xpm");
-       if (!iconname.empty())
-               setIcon(QPixmap(toqstr(iconname)));
-#endif
-
        // make sure the buttons are disabled if needed
        updateToolbars();
 
        // allowing the toolbars to tear off is too easily done,
        // and we don't save their orientation anyway. Disable the handle.
        setToolBarsMovable(false);
-}
-
-
-QtView::~QtView()
-{
+       
+       LyXView::init();
 }
 
 
@@ -182,13 +183,13 @@ void QtView::resizeEvent(QResizeEvent *)
 
 void QtView::moveEvent(QMoveEvent *)
 {
-       updateFloatingGeometry();       
+       updateFloatingGeometry();
 }
 
 
 void QtView::closeEvent(QCloseEvent *)
 {
-       updateFloatingGeometry();       
+       updateFloatingGeometry();
        QRect geometry = floatingGeometry_;
 
        Session & session = LyX::ref().session();
index 75286f8d068fe7ba4eef6c9b3caed683ce1896dd..a87533b7c3f9bf430df94eb9d51b547abad384fb 100644 (file)
 #ifndef QTVIEW_H
 #define QTVIEW_H
 
-// Must be here because of moc.
 #include <config.h>
 
 #include "frontends/LyXView.h"
 
-#include "GuiImplementation.h"
-
 #include <qmainwindow.h>
 #include <qtimer.h>
 
@@ -38,11 +35,14 @@ class QCommandBuffer;
 class QtView : public QMainWindow, public LyXView {
        Q_OBJECT
 public:
-       /// create a main window
-       QtView();
+       /// create a main window of the given dimensions
+       QtView(Gui & owner);
 
        ~QtView();
 
+       /// initialise the object members (menubars, toolbars, etc..)
+       void init();
+
        /// show - display the top-level window
        void show();
 
@@ -64,9 +64,6 @@ public:
        // returns true if this view has the focus.
        virtual bool hasFocus() const;
 
-       //
-       lyx::frontend::Gui & gui() { return frontend_; }
-
        ///
        void initFloatingGeometry(QRect const &);
 
@@ -102,9 +99,6 @@ private:
        /// command buffer
        QCommandBuffer * commandbuffer_;
        
-       ///
-       GuiImplementation frontend_;
-
        ///
        void updateFloatingGeometry();
        ///
index 7336f7f616a3fcbaceeccec8055039c8f8cf5597..b0930f3da15423674c8bc532c972e1d4b407e6d4 100644 (file)
@@ -40,6 +40,7 @@
 #include <boost/bind.hpp>
 #include <boost/shared_ptr.hpp>
 
+#include "GuiImplementation.h"
 #include "QtView.h"
 #include "lcolorcache.h"
 #include "qfont_loader.h"
@@ -62,6 +63,8 @@
 using lyx::support::ltrim;
 using lyx::support::package;
 
+using lyx::frontend::Gui;
+using lyx::frontend::GuiImplementation;
 using lyx::frontend::QtView;
 
 namespace os = lyx::support::os;
@@ -121,12 +124,19 @@ class LQApplication : public QApplication
 {
 public:
        LQApplication(int & argc, char ** argv);
+       //
+       Gui & gui() { return gui_; }
+
 #ifdef Q_WS_X11
        bool x11EventFilter (XEvent * ev) { return lyxX11EventFilter(ev); }
 #endif
 #ifdef Q_WS_MACX
        bool macEventFilter(EventRef event);
 #endif
+
+private:
+       ///
+       GuiImplementation gui_;
 };
 
 
@@ -155,6 +165,7 @@ bool LQApplication::macEventFilter(EventRef event)
 }
 #endif
 
+LQApplication * theApp;
 
 namespace lyx_gui {
 
@@ -167,6 +178,7 @@ void exec(int & argc, char * argv[])
        FontLoader::initFontPath();
 
        LQApplication app(argc, argv);
+       theApp = &app;
 
 #if QT_VERSION >= 0x030200
        // install translation file for Qt built-in dialogs
@@ -227,14 +239,15 @@ void start(string const & batch, vector<string> const & files,
        // this can't be done before because it needs the Languages object
        initEncodings();
 
-       boost::shared_ptr<QtView> view_ptr(new QtView);
-       LyX::ref().addLyXView(view_ptr);
+       int view_id = theApp->gui().newView(width, height);
+       QtView & view = static_cast<QtView &> (theApp->gui().view(view_id));
+       theApp->gui().newWorkArea(width, height, 0);
 
-       QtView & view = *view_ptr.get();
+       LyX::ref().addLyXView(&view);
 
        view.init();
 
-       if (width != -1 && height != -1) { 
+       if (width != -1 && height != -1) {
                view.initFloatingGeometry(QRect(posx, posy, width, height));
                view.resize(width, height);
                if (posx != -1 && posy != -1)
index ba4cf89deaaf22cb9632e0a28ae1c6e5a1f7b9d9..4ca1498eed9d7f30c81f2eebdc1ed14944be567f 100644 (file)
@@ -60,7 +60,7 @@ void QScreen::expose(int x, int y, int w, int h)
 }
 
 
-void QScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
+void QScreen::showCursor(int x, int y, int h, CursorShape shape)
 {
        if (!qApp->focusWidget())
                return;
index fed647d2e85f1cd83356c5cdd025c838f80e6e58..f00efa7a9fb57283c5a135538dd0b3e7ba0e8786 100644 (file)
@@ -40,7 +40,7 @@ public:
        virtual void expose(int x, int y, int exp_width, int exp_height);
 
        /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h, lyx::frontend::Cursor_Shape shape);
+       virtual void showCursor(int x, int y, int h, lyx::frontend::CursorShape shape);
 
        /// hide the cursor
        virtual void removeCursor();
index 83381bdadf2b9d2841c7dc3c25482e5057efe784..edfc308f1958d9349b936065db6d1ffef9aed542 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <boost/bind.hpp>
 
-#include "LyXView.h"
+#include "frontends/LyXView.h"
 #include "qt_helpers.h"
 
 #include "Action.h"
index f0b4512ab45bfe24d78c0d81a158f35c03b06948..3dbf151c1dcdff946153b543633c4a785844340c 100644 (file)
@@ -97,6 +97,4 @@ private:
        QLFontInfo * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
 };
 
-extern FontLoader fontloader;
-
 #endif // QFONT_LOADER_H
index 459176d31a3077c2ec73be2b18a0d425cdb3b30d..d66aa4e9562c83b1c69fdcb35d6960a91db35993 100644 (file)
  * Full author contact details are available in file CREDITS.
  */
 
+// This include must be declared before everything else because
+// of boost/Qt/LyX clash...
+#include "GuiView.h"
+
 #include "GuiImplementation.h"
 #include "GuiWorkArea.h"
-#include "GuiView.h"
+
+#include "BufferView.h"
 
 using boost::shared_ptr;
 
 namespace lyx {
 namespace frontend {
 
-GuiImplementation::GuiImplementation(GuiView & owner): owner_(owner), max_id_(0)
+GuiImplementation::GuiImplementation(): max_view_id_(0), max_wa_id_(0)
 {
 }
 
@@ -30,20 +35,57 @@ Clipboard& GuiImplementation::clipboard()
 }
 
 
-int GuiImplementation::newWorkArea(int w, int h)
+int GuiImplementation::newView(unsigned int /*w*/, unsigned int /*h*/)
 {
-       size_t const id = max_id_;
-       ++max_id_;
-       work_areas_[id].reset(new GuiWorkArea(owner_, w, h));
+       size_t const id = max_view_id_;
+       ++max_view_id_;
+
+       views_[id].reset(new GuiView(*this));
+
        return id;
 }
 
-WorkArea& GuiImplementation::workArea(int id)
+
+LyXView& GuiImplementation::view(int id)
 {
-       BOOST_ASSERT(work_areas_.find(id) != work_areas_.end());
+       BOOST_ASSERT(views_.find(id) != views_.end());
+
+       return *views_[id].get();
+}
+
+
+void GuiImplementation::destroyView(int id)
+{
+       views_.erase(id);
+}
+
+
+int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int view_id)
+{
+       size_t const id = max_wa_id_;
+       ++max_wa_id_;
+
+       GuiView * view = views_[view_id].get();
+
+       work_areas_[id].reset(new GuiWorkArea(w, h, view));
+
+       // FIXME BufferView creation should be independant of WorkArea creation
+       buffer_views_[id].reset(new BufferView(view, work_areas_[id].get()));
+       work_areas_[id]->setBufferView(buffer_views_[id].get());
+       view->setBufferView(buffer_views_[id].get());
+
+       view->mainWidget()->setCentralWidget(work_areas_[id].get());
 
        guiCursor().connect(work_areas_[id].get());
 
+       return id;
+}
+
+
+WorkArea& GuiImplementation::workArea(int id)
+{
+       BOOST_ASSERT(work_areas_.find(id) != work_areas_.end());
+
        return *work_areas_[id].get();
 }
 
index 4cd8bfc817d0bf594088636bec10c61bc4213ef3..ad1ebc614b0ec5af316634306cdd77adb5bd0b6e 100644 (file)
@@ -10,8 +10,8 @@
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef GUI_IMPLEMENTATION_H
-#define GUI_IMPLEMENTATION_H
+#ifndef GUI_H
+#define GUI_H
 
 #include "frontends/Gui.h"
 #include "GuiClipboard.h"
@@ -20,6 +20,8 @@
 
 #include <map>
 
+class LyXView;
+
 namespace lyx {
 namespace frontend {
 
@@ -32,27 +34,34 @@ class GuiView;
 class GuiImplementation: public Gui
 {
 public:
-       GuiImplementation(GuiView & owner);
+       GuiImplementation();
        virtual ~GuiImplementation() {}
 
        Clipboard& clipboard();
 
+       int newView(unsigned int width, unsigned int height);
+       LyXView& view(int id);
+       void destroyView(int id);
+       int newWorkArea(unsigned int width, unsigned int height, int view_id);
        int newWorkArea(int w, int h);
        WorkArea& workArea(int id);
        void destroyWorkArea(int id);
 
+
 private:
        ///
        GuiClipboard clipboard_;
        ///
+       std::map<int, boost::shared_ptr<GuiView> > views_;
+       ///
        std::map<int, boost::shared_ptr<GuiWorkArea> > work_areas_;
        ///
-       GuiView & owner_;
+       size_t max_view_id_;
        ///
-       size_t max_id_;
+       size_t max_wa_id_;
 };
 
 } // namespace frontend
 } // namespace lyx
 
-#endif // GUI_IMPLEMENTATION_H
+#endif // GUI_H
index 07b77b3c7251d9db9de0aa0b384ba280b5e319e7..16d35c9748a4ccefd19a3f39f642a4220b9beff4 100644 (file)
@@ -34,6 +34,7 @@
 #include <boost/bind.hpp>
 
 #include "GuiView.h"
+#include "GuiImplementation.h"
 #include "QLMenubar.h"
 #include "FontLoader.h"
 #include "QCommandBuffer.h"
@@ -45,6 +46,8 @@
 #include <QToolBar>
 #include <QCloseEvent>
 #include <QAction>
+//#include <QMenu>
+//#include <QMenuBar>
 
 #include "support/lstrings.h"
 
@@ -52,8 +55,6 @@
 using std::string;
 using std::endl;
 
-FontLoader fontloader;
-
 namespace lyx {
 
 using support::subst;
@@ -68,26 +69,15 @@ int const statusbar_timer_value = 3000;
 } // namespace anon
 
 
-GuiView::GuiView()
-       : QMainWindow(), LyXView(), commandbuffer_(0), frontend_(*this)
+GuiView::GuiView(Gui & owner)
+       : QMainWindow(), LyXView(owner), commandbuffer_(0)
 {
        mainWidget_ = this;
 
 //     setToolButtonStyle(Qt::ToolButtonIconOnly);
 //     setIconSize(QSize(12,12));
 
-       // -geometry could set the width and hight
-       bufferview_.reset(new BufferView(this, geometry().width(), geometry().height()));
-
-       menubar_.reset(new QLMenubar(this, menubackend));
-       connect(menuBar(), SIGNAL(triggered(QAction *)), this, SLOT(updateMenu(QAction *)));
-
-       getToolbars().init();
-
-       statusBar()->setSizeGripEnabled(false);
-
-       view_state_changed.connect(boost::bind(&GuiView::update_view_state, this));
-       connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
+//     bufferview_.reset(new BufferView(this, width, height));
 
 #ifndef Q_WS_MACX
        //  assign an icon to main form. We do not do it under Qt/Mac,
@@ -96,9 +86,6 @@ GuiView::GuiView()
        if (!iconname.empty())
                setWindowIcon(QPixmap(toqstr(iconname)));
 #endif
-
-       // make sure the buttons are disabled if needed
-       updateToolbars();
 }
 
 
@@ -106,6 +93,25 @@ GuiView::~GuiView()
 {
 }
 
+
+void GuiView::init()
+{
+       menubar_.reset(new QLMenubar(this, menubackend));
+       QObject::connect(menuBar(), SIGNAL(triggered(QAction *)), this, SLOT(updateMenu(QAction *)));
+
+       getToolbars().init();
+
+       statusBar()->setSizeGripEnabled(false);
+
+       view_state_changed.connect(boost::bind(&GuiView::update_view_state, this));
+       QObject::connect(&statusbar_timer_, SIGNAL(timeout()), this, SLOT(update_view_state_qt()));
+
+       // make sure the buttons are disabled if needed
+       updateToolbars();
+       
+       LyXView::init();
+}
+
 void GuiView::updateMenu(QAction *action)
 {
        menubar_->update();
index f77fbc7989bfbd4c3c5ce8c46508e403bc028fdd..6173ac5fbb4102c1c0f8708e7c40f4c21b90892b 100644 (file)
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef GUIVIEW_H
-#define GUIVIEW_H
+#ifndef GUI_VIEW_H
+#define GUI_VIEW_H
 
 // Must be here because of moc.
 #include <config.h>
 
-#include "GuiImplementation.h"
-
 #include "frontends/LyXView.h"
 #include "funcrequest.h"
 
@@ -43,16 +41,19 @@ QWidget* mainWindow();
 /**
  * GuiView - Qt4 implementation of LyXView
  *
- * Qt-private implementation of the main LyX window.
+ * qt4-private implementation of the main LyX window.
  */
 class GuiView : public QMainWindow, public LyXView {
        Q_OBJECT
 public:
-       /// create a main window
-       GuiView();
+       /// create a main window of the given dimensions
+       GuiView(Gui & owner);
 
        ~GuiView();
 
+       /// initialize the object
+       virtual void init();
+
        /// show - display the top-level window
        void show();
 
@@ -71,12 +72,10 @@ public:
        /// menu item has been selected
        void activated(FuncRequest const &);
 
-       // returns true if this view has the focus.
+       /// returns true if this view has the focus.
        virtual bool hasFocus() const;
 
-       //
-       Gui & gui() { return frontend_; }
-
+       ///
        static QMainWindow* mainWidget();
 
 public slots:
@@ -118,8 +117,6 @@ private:
        ///
        static QMainWindow* mainWidget_;
 
-       GuiImplementation frontend_;
-
        ///
        void updateFloatingGeometry();
        ///
index 324a134cfa28aaffd14d82e60a1b3b95a34a41d9..31c12467b32f5f0e7e453b018d37219f7bece0b5 100644 (file)
 
 #include <boost/current_function.hpp>
 
+// This include must be declared before everything else because
+// of boost/Qt/LyX clash...
+#include "GuiView.h"
+
 #include "GuiWorkArea.h"
 #include "QLPainter.h"
 #include "QLyXKeySym.h"
-#include "GuiView.h"
 
 #include "ColorCache.h"
 #include "qt_helpers.h"
 
 #include <boost/bind.hpp>
 
-// Abdel (09/06/2006):
-// I want the drawing to be fast without Keyboard buffering so when working
-// on optimization, please set the following macro to 0:
-#define USE_KEY_BUFFERING 0
+// Abdel (26/06/2006):
+// On windows-XP the UserGuide PageDown scroll test is faster without event pruning (16 s)
+// than with it (23 s).
+#ifdef Q_WS_WIN
+ #define USE_EVENT_PRUNING 0
+#else
+ #define USE_EVENT_PRUNING 0
+#endif
 
 using std::endl;
 using std::string;
@@ -111,14 +118,12 @@ SyntheticMouseEvent::SyntheticMouseEvent()
 {}
 
 
-GuiWorkArea::GuiWorkArea(LyXView & owner, int w, int h)
-: QAbstractScrollArea(GuiView::mainWidget()), WorkArea(owner, w, h), view_(owner), painter_(this)
+GuiWorkArea::GuiWorkArea(int w, int h, QWidget * parent, BufferView * buffer_view)
+: QAbstractScrollArea(parent), WorkArea(buffer_view), painter_(this)
 {
        setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
-       GuiView::mainWidget()->setCentralWidget(this);
-
        setAcceptDrops(true);
 
        setMinimumSize(100, 70);
@@ -155,7 +160,7 @@ GuiWorkArea::GuiWorkArea(LyXView & owner, int w, int h)
                << "\n viewport height\t" << viewport()->height()
                << endl;
 
-       if (USE_KEY_BUFFERING) {
+       if (USE_EVENT_PRUNING) {
                // This is the keyboard buffering stuff...
                // I don't see any need for this under windows. The keyboard is reactive
                // enough...
@@ -168,20 +173,16 @@ GuiWorkArea::GuiWorkArea(LyXView & owner, int w, int h)
                step_timer_.start(50, true);
        }
 
-       ///////////////////////////////////////////////////////////////////////
-       // Specific stuff goes here...
-
-#if USE_INPUT_METHODS
-       // to make qt-immodule work
-       setInputMethodEnabled(true);
-#endif
-
+       // Enables input methods for asian languages.
+       // Must be set when creating custom text editing widgets.
+       setAttribute(Qt::WA_InputMethodEnabled, true);
 }
 
 GuiWorkArea::~GuiWorkArea()
 {
 }
 
+
 void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step)
 {
        // do what cursor movement does (some grey)
@@ -193,6 +194,7 @@ void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step
        verticalScrollBar()->setLineStep(scroll_line_step);
 }
 
+
 void GuiWorkArea::adjustViewWithScrollBar(int)
 {
        /*
@@ -205,7 +207,7 @@ void GuiWorkArea::adjustViewWithScrollBar(int)
                << " linestep=" << verticalScrollBar()->lineStep()
                << endl;
        */
-       view_.view()->scrollDocView(verticalScrollBar()->sliderPosition());
+       buffer_view_->scrollDocView(verticalScrollBar()->sliderPosition());
 }
 
 
@@ -229,7 +231,7 @@ void GuiWorkArea::dropEvent(QDropEvent* event)
        for (int i = 0; i!=files.size(); ++i) {
                string const file = os::internal_path(fromqstr(files.at(i).toString()));
                if (!file.empty())
-                       view_.view()->workAreaDispatch(FuncRequest(LFUN_FILE_OPEN, file));
+                       buffer_view_->workAreaDispatch(FuncRequest(LFUN_FILE_OPEN, file));
        }
 }
 
@@ -241,13 +243,13 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
                FuncRequest cmd(LFUN_MOUSE_TRIPLE,
                        dc_event_.x, dc_event_.y,
                        q_button_state(dc_event_.state));
-               view_.view()->workAreaDispatch(cmd);
+               buffer_view_->workAreaDispatch(cmd);
                return;
        }
 
        FuncRequest const cmd(LFUN_MOUSE_PRESS, e->x(), e->y(),
                              q_button_state(e->button()));
-       view_.view()->workAreaDispatch(cmd);
+       buffer_view_->workAreaDispatch(cmd);
 }
 
 
@@ -258,7 +260,7 @@ void GuiWorkArea::mouseReleaseEvent(QMouseEvent * e)
 
        FuncRequest const cmd(LFUN_MOUSE_RELEASE, e->x(), e->y(),
                              q_button_state(e->button()));
-       view_.view()->workAreaDispatch(cmd);
+       buffer_view_->workAreaDispatch(cmd);
 }
 
 
@@ -318,7 +320,7 @@ void GuiWorkArea::mouseMoveEvent(QMouseEvent * e)
                synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
 
                // ... and dispatch the event to the LyX core.
-               view_.view()->workAreaDispatch(cmd);
+               buffer_view_->workAreaDispatch(cmd);
        }
 }
 
@@ -348,7 +350,7 @@ void GuiWorkArea::generateSyntheticMouseEvent()
                synthetic_mouse_event_.scrollbar_value_old = scrollbar_value;
 
                // ... and dispatch the event to the LyX core.
-               view_.view()->workAreaDispatch(synthetic_mouse_event_.cmd);
+               buffer_view_->workAreaDispatch(synthetic_mouse_event_.cmd);
        }
 }
 
@@ -362,17 +364,18 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * e)
                << " key=" << e->key()
                << endl;
 
-       if (USE_KEY_BUFFERING) {
+       if (USE_EVENT_PRUNING) {
                keyeventQueue_.push(boost::shared_ptr<QKeyEvent>(new QKeyEvent(*e)));
        }
        else {
                boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
                sym->set(e);
-               view_.view()->workAreaKeyPress(sym, q_key_state(e->state()));
+               buffer_view_->workAreaKeyPress(sym, q_key_state(e->state()));
        }
 }
 
-// This is used only if USE_KEY_BUFFERING is defined...
+
+// This is used only if USE_EVENT_PRUNING is defined...
 void GuiWorkArea::keyeventTimeout()
 {
        bool handle_autos = true;
@@ -387,17 +390,17 @@ void GuiWorkArea::keyeventTimeout()
                        continue;
                }
 
-                boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
+               boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
                sym->set(ev.get());
 
-                lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
-                                   << " count=" << ev->count()
-                                   << " text=" << (const char *) ev->text()
-                                   << " isAutoRepeat=" << ev->isAutoRepeat()
-                                   << " key=" << ev->key()
-                                   << endl;
+               lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
+                                  << " count=" << ev->count()
+                                  << " text=" << (const char *) ev->text()
+                                  << " isAutoRepeat=" << ev->isAutoRepeat()
+                                  << " key=" << ev->key()
+                                  << endl;
 
-                view_.view()->workAreaKeyPress(sym, q_key_state(ev->state()));
+               buffer_view_->workAreaKeyPress(sym, q_key_state(ev->state()));
                keyeventQueue_.pop();
 
                handle_autos = false;
@@ -420,7 +423,7 @@ void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
        FuncRequest cmd(LFUN_MOUSE_DOUBLE,
                dc_event_.x, dc_event_.y,
                q_button_state(dc_event_.state));
-       view_.view()->workAreaDispatch(cmd);
+       buffer_view_->workAreaDispatch(cmd);
 }
 
 
@@ -435,7 +438,7 @@ void GuiWorkArea::resizeEvent(QResizeEvent *)
 //     paint_device_ = QImage(viewport()->width(), viewport()->height(), QImage::Format_RGB32);
        paint_device_ = QPixmap(viewport()->width(), viewport()->height());
 
-       view_.view()->workAreaResize();
+       buffer_view_->workAreaResize(viewport()->width(), viewport()->height());
 
        /*
        lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
@@ -484,6 +487,15 @@ void GuiWorkArea::paintEvent(QPaintEvent * e)
 
        if (show_hcursor_)
                q.drawPixmap(cursor_x_, cursor_y_ + cursor_h_ - 1, hcursor_);
+
+       buffer_view_->updateScrollbar();
+
+       ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
+
+       verticalScrollBar()->setTracking(false);
+       setScrollbarParams(scroll_.height, scroll_.position,
+               scroll_.lineScrollHeight);
+       verticalScrollBar()->setTracking(true);
 }
 
 
@@ -510,7 +522,7 @@ void GuiWorkArea::expose(int x, int y, int w, int h)
 }
 
 
-void GuiWorkArea::showCursor(int x, int y, int h, Cursor_Shape shape)
+void GuiWorkArea::showCursor(int x, int y, int h, CursorShape shape)
 {
        if (!qApp->focusWidget())
                return;
@@ -554,7 +566,7 @@ void GuiWorkArea::showCursor(int x, int y, int h, Cursor_Shape shape)
        // We cache two pixmaps:
        // 1 the vertical line of the cursor.
        // 2 the horizontal line of the L-shaped cursor (if necessary).
-       
+
        // Draw the new (vertical) cursor.
        vcursor_ = QPixmap(cursor_w_, cursor_h_);
        vcursor_.fill(cursor_color_);
@@ -578,20 +590,17 @@ void GuiWorkArea::removeCursor()
        viewport()->update(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
 }
 
-///////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////
-// Specific stuff
-
-////////////////////////////////////////////////////////////////////////
-// qt-immodule specific stuff goes here...
-
-#if USE_INPUT_METHODS
-// to make qt-immodule work
 
 void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
 {
-       QString const text = e->text();
+       QString const & text = e->commitString();
        if (!text.isEmpty()) {
+
+               lyxerr[Debug::KEY] << BOOST_CURRENT_FUNCTION
+                       << " preeditString =" << (const char *) e->preeditString()
+                       << " commitString  =" << (const char *) e->commitString()
+                       << endl;
+
                int key = 0;
                // needed to make math superscript work on some systems
                // ideally, such special coding should not be necessary
@@ -602,7 +611,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
        }
        e->accept();
 }
-#endif
+
 
 } // namespace frontend
 } // namespace lyx
index 9a041c00cc1aded6dc8050d11f670ffc55c99671..b44cad93c26589cddafe1d505c3de9e657256976 100644 (file)
 #ifndef WORKAREA_H
 #define WORKAREA_H
 
-#if (defined(Q_WS_X11) && QT_VERSION >= 0x030200)
-#define USE_INPUT_METHODS 1
-#endif
-
 #ifdef emit
 #undef emit
 #endif
 
-#include "frontends/LyXView.h"
 #include "frontends/WorkArea.h"
 
 #include "QLPainter.h"
@@ -52,6 +47,8 @@ class QMouseEvent;
 namespace lyx {
 namespace frontend {
 
+class GuiView;
+
 /// for emulating triple click
 class double_click {
 public:
@@ -104,7 +101,7 @@ class GuiWorkArea: public QAbstractScrollArea, public WorkArea {
 
 public:
 
-       GuiWorkArea(LyXView & owner, int w, int h);
+       GuiWorkArea(int width, int height, QWidget * parent, BufferView * buffer_view = 0);
 
        virtual ~GuiWorkArea();
        /// return the width of the content pane
@@ -138,14 +135,12 @@ public:
        QPixmap is implicitely shared so no need to pass by reference.
        */
        void drawScreen(int x, int y, QPixmap pixmap);
-       
-       LyXView & view() { return view_; }
 
        /// copies specified area of pixmap to screen
        virtual void expose(int x, int y, int exp_width, int exp_height);
 
        /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
+       virtual void showCursor(int x, int y, int h, CursorShape shape);
 
        /// hide the cursor
        virtual void removeCursor();
@@ -169,11 +164,9 @@ protected:
        /// key press
        void keyPressEvent(QKeyEvent * e);
 
-#if USE_INPUT_METHODS
 protected:
        /// IM events
        void inputMethodEvent(QInputMethodEvent * e);
-#endif
 
 public slots:
 
@@ -190,9 +183,6 @@ public slots:
        void adjustViewWithScrollBar(int action = 0);
 
 private:
-        ///
-        LyXView & view_;
-        
        /// Buffer view width.
        int workWidth_;
 
@@ -244,7 +234,7 @@ private:
        ///
        QColor cursor_color_;
        ///
-       Cursor_Shape cursor_shape_;
+       CursorShape cursor_shape_;
 };
 
 } // namespace frontend
index 1124a426c0834497dfa32a95259dac53aa2c20c8..8bc90f1d925305ba610079745fbec054c2eb3034 100644 (file)
 
 #include "GuiWorkArea.h"
 #include "QLImage.h"
-
 #include "ColorCache.h"
 #include "FontLoader.h"
 
+#include "Application.h"
+
+#include "debug.h"
 #include "language.h"
 #include "LColor.h"
 
@@ -212,8 +214,8 @@ void QLPainter::smallCapsText(int x, int y,
        LyXFont smallfont(f);
        smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
 
-       QFont const & qfont = fontloader.get(f);
-       QFont const & qsmallfont = fontloader.get(smallfont);
+       QFont const & qfont = theApp->fontLoader().get(f);
+       QFont const & qsmallfont = theApp->fontLoader().get(smallfont);
        QFontMetrics const & qfontm = QFontMetrics(qfont);
        QFontMetrics const & qsmallfontm = QFontMetrics(qsmallfont);
 
@@ -254,7 +256,7 @@ void QLPainter::text(int x, int y, char const * s, size_t ls,
 
        if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
                setQPainterPen(f.realColor());
-               qp_->setFont(fontloader.get(f));
+               qp_->setFont(theApp->fontLoader().get(f));
                // We need to draw the text as LTR as we use our own bidi code.
                qp_->setLayoutDirection(Qt::LeftToRight);
                qp_->drawText(x, y, str);
index 32ef21f94fa98dccd5eaca2c23b0990d06a3d72e..9c74df9a566dfa8ff17e7219b3ae10b5b6531632 100644 (file)
@@ -59,6 +59,7 @@
 using lyx::support::ltrim;
 using lyx::support::package;
 
+using lyx::frontend::GuiImplementation;
 using lyx::frontend::GuiView;
 using lyx::frontend::Application;
 
@@ -78,6 +79,8 @@ using std::string;
 LyXServer * lyxserver;
 LyXServerSocket * lyxsocket;
 
+lyx::frontend::Application * theApp;
+
 namespace {
 
 int getDPI()
@@ -133,6 +136,8 @@ void exec(int & argc, char * argv[])
        Application app(argc, argv);
 #endif
 
+       theApp = &app;
+
 
        // install translation file for Qt built-in dialogs
        // These are only installed since Qt 3.2.x
@@ -194,14 +199,17 @@ void start(string const & batch, vector<string> const & files,
        // this can't be done before because it needs the Languages object
        initEncodings();
 
-       boost::shared_ptr<GuiView> view_ptr(new GuiView);
+       int view_id = theApp->gui().newView(width, height);
+       GuiView & view = static_cast<GuiView &> (theApp->gui().view(view_id));
 
-       LyX::ref().addLyXView(view_ptr);
+       // FIXME: for now we assume that there is only one LyXView with id = 0.
+       int workArea_id_ = theApp->gui().newWorkArea(width, height, 0);
+       //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
 
-       GuiView & view = *view_ptr.get();
+       LyX::ref().addLyXView(&view);
 
        view.init();
-
+               
        // only true when the -geometry option was NOT used
        if (width != -1 && height != -1) {
                if (posx != -1 && posy != -1) {
@@ -317,13 +325,13 @@ void update_color(LColor_color)
 
 void update_fonts()
 {
-       fontloader.update();
+       theApp->fontLoader().update();
 }
 
 
 bool font_available(LyXFont const & font)
 {
-       return fontloader.available(font);
+       return theApp->fontLoader().available(font);
 }
 
 
index 378c55c668ad188dd6a994b1fa7e6ff4066fb784..04d0908315214dd6ddc7d1c29e80eb2c070506f2 100644 (file)
@@ -15,6 +15,7 @@
 #include "frontends/lyx_gui.h"
 
 #include "FontLoader.h"
+#include "Application.h"
 
 #include "language.h"
 
@@ -28,7 +29,7 @@ int maxAscent(LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       return fontloader.metrics(f).ascent();
+       return theApp->fontLoader().metrics(f).ascent();
 }
 
 
@@ -38,7 +39,7 @@ int maxDescent(LyXFont const & f)
                return 1;
        // We add 1 as the value returned by QT is different than X
        // See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
-       return fontloader.metrics(f).descent() + 1;
+       return theApp->fontLoader().metrics(f).descent() + 1;
 }
 
 
@@ -46,7 +47,7 @@ int ascent(char c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       QRect const & r = fontloader.metrics(f).boundingRect(c);
+       QRect const & r = theApp->fontLoader().metrics(f).boundingRect(c);
        // Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
        // value by the height: (x, -y-height, width, height).
        // Other versions return: (x, -y, width, height)
@@ -62,7 +63,7 @@ int descent(char c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       QRect const & r = fontloader.metrics(f).boundingRect(c);
+       QRect const & r = theApp->fontLoader().metrics(f).boundingRect(c);
        // Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
        // value by the height: (x, -y-height, width, height).
        // Other versions return: (x, -y, width, height)
@@ -78,7 +79,7 @@ int lbearing(char c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       return fontloader.metrics(f).leftBearing(c);
+       return theApp->fontLoader().metrics(f).leftBearing(c);
 }
 
 
@@ -86,7 +87,7 @@ int rbearing(char c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
-       QFontMetrics const & m = fontloader.metrics(f);
+       QFontMetrics const & m = theApp->fontLoader().metrics(f);
 
        // Qt rbearing is from the right edge of the char's width().
        return m.width(c) - m.rightBearing(c);
@@ -111,8 +112,8 @@ int smallcapswidth(char const * s, size_t ls, LyXFont const & f)
        LyXFont smallfont = f;
        smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
 
-       QFontMetrics const & qm = fontloader.metrics(f);
-       QFontMetrics const & qsmallm = fontloader.metrics(smallfont);
+       QFontMetrics const & qm = theApp->fontLoader().metrics(f);
+       QFontMetrics const & qsmallm = theApp->fontLoader().metrics(smallfont);
 
        Encoding const * encoding = fontencoding(f);
 
@@ -139,7 +140,7 @@ int width(char const * s, size_t ls, LyXFont const & f)
                return smallcapswidth(s, ls, f);
 
        Encoding const * encoding = fontencoding(f);
-       QLFontInfo & fi = fontloader.fontinfo(f);
+       QLFontInfo & fi = theApp->fontLoader().fontinfo(f);
 
        if (ls == 1)
                return fi.width(encoding->ucs(s[0]));
@@ -164,7 +165,7 @@ int signedWidth(string const & s, LyXFont const & f)
 void rectText(string const & str, LyXFont const & f,
        int & w, int & ascent, int & descent)
 {
-       QFontMetrics const & m = fontloader.metrics(f);
+       QFontMetrics const & m = theApp->fontLoader().metrics(f);
        static int const d = 2;
        w = width(str, f) + d * 2 + 2;
        ascent = m.ascent() + d;
@@ -176,7 +177,7 @@ void rectText(string const & str, LyXFont const & f,
 void buttonText(string const & str, LyXFont const & f,
        int & w, int & ascent, int & descent)
 {
-       QFontMetrics const & m = fontloader.metrics(f);
+       QFontMetrics const & m = theApp->fontLoader().metrics(f);
        static int const d = 3;
        w = width(str, f) + d * 2 + 2;
        ascent = m.ascent() + d;
index 04ab2f2a34e68ad443252a42af281c5d28be3c1c..34a45893458bab0bd8961ba50414d9cc729d969f 100644 (file)
 namespace lyx {
 namespace frontend {
 
-typedef XWorkArea FWorkArea;
-
 /**
  * The XForms version of the Clipboard.
  */
 class GuiClipboard: public lyx::frontend::Clipboard
 {
 public:
-       GuiClipboard(FWorkArea * work_area)
+       GuiClipboard(XWorkArea * work_area)
                : old_work_area_(work_area)
        {
        }
@@ -54,7 +52,7 @@ public:
        //@}
 
 private:
-       FWorkArea * old_work_area_;
+       XWorkArea * old_work_area_;
 };
 
 } // namespace frontend
diff --git a/src/frontends/xforms/GuiImplementation.C b/src/frontends/xforms/GuiImplementation.C
new file mode 100644 (file)
index 0000000..c8c8377
--- /dev/null
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+/**
+ * \file xforms/GuiImplementation.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include "GuiImplementation.h"
+
+#include "XFormsView.h"
+#include "BufferView.h"
+
+
+namespace lyx {
+namespace frontend {
+
+int GuiImplementation::newView(unsigned int w, unsigned int h)
+{
+       view_.reset(new XFormsView(*this, w, h));
+       return 0;
+}
+
+
+int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id*/)
+{
+       old_work_area_.reset(new XWorkArea(*view_.get(), w, h));
+       old_screen_.reset(new XScreen(*old_work_area_));
+       work_area_.reset(new GuiWorkArea(boost::static_pointer_cast<XScreen>(old_screen_).get(),
+                                        boost::static_pointer_cast<XWorkArea>(old_work_area_).get()));
+       clipboard_.reset(new GuiClipboard(boost::static_pointer_cast<XWorkArea>(old_work_area_).get()));
+       guiCursor().connect(work_area_.get());
+
+       // FIXME BufferView creation should be independant of WorkArea creation
+       buffer_views_[0].reset(new BufferView(view_.get(), work_area_.get()));
+       work_area_->setBufferView(buffer_views_[0].get());
+       view_->setBufferView(buffer_views_[0].get());
+       return 0;
+}
+
+
+void GuiImplementation::destroyWorkArea(int /*id*/)
+{
+       clipboard_.reset();
+       work_area_.reset();
+       old_work_area_.reset();
+       old_screen_.reset();
+}
+
+} // namespace frontend
+} // namespace lyx
index 3ecca0bdce98feb3edbee4c030b5145c11946d78..3f088ca3a92a6c27706f385183e985ef652ca737 100644 (file)
 
 #include <boost/shared_ptr.hpp>
 
-#include <map>
-
 namespace lyx {
 namespace frontend {
 
-typedef XScreen FScreen;
-typedef XWorkArea FWorkArea;
-
 /**
  * The Gui class is the interface to all XForms components.
  */
-class GuiImplementation: public lyx::frontend::Gui
+class GuiImplementation : public lyx::frontend::Gui
 {
 public:
-       GuiImplementation(LyXView & owner): owner_(owner)
+       GuiImplementation()
        {
        }
 
@@ -45,45 +40,45 @@ public:
        {
        }
 
-       lyx::frontend::Clipboard& clipboard()
+       lyx::frontend::Clipboard & clipboard()
        {
                return *clipboard_;
        }
 
-       int newWorkArea(int w, int h)
+       int newView(unsigned int w, unsigned int h);
+
+
+       LyXView & view(int /*id*/)
        {
-               old_work_area_.reset(new FWorkArea(owner_, w, h));
-               old_screen_.reset(new FScreen(*old_work_area_.get()));
-               work_area_.reset(new GuiWorkArea(owner_, w, h, old_screen_.get(), old_work_area_.get()));
-               clipboard_.reset(new GuiClipboard(old_work_area_.get()));
-               guiCursor().connect(work_area_.get());
-               return 0;
+               return *view_;
        }
 
-       lyx::frontend::WorkArea& workArea(int id)
+
+       void destroyView(int /*id*/)
        {
-               return *work_area_;
+               view_.reset();
        }
 
-       void destroyWorkArea(int id)
+       int newWorkArea(unsigned int w, unsigned int h, int view_id);
+
+       lyx::frontend::WorkArea & workArea(int /*id*/)
        {
-               clipboard_.reset();
-               work_area_.reset();
-               old_work_area_.reset();
-               old_screen_.reset();
+               return *work_area_;
        }
 
+       void destroyWorkArea(int id);
+
 private:
        ///
        boost::shared_ptr<GuiClipboard> clipboard_;
        ///
        boost::shared_ptr<GuiWorkArea> work_area_;
        ///
-       boost::shared_ptr<FWorkArea> old_work_area_;
+       boost::shared_ptr<LyXView> view_;
        ///
-       boost::shared_ptr<FScreen> old_screen_;
+       boost::shared_ptr<XWorkArea> old_work_area_;
        ///
-       LyXView & owner_;
+       boost::shared_ptr<XScreen> old_screen_;
 };
 
 } // namespace frontend
index a595e6fc7b93128721987540f3cad634e7cb63e9..a59c5731c13bf2af710e9ef23f71108662c8257c 100644 (file)
 namespace lyx {
 namespace frontend {
 
-typedef XScreen FScreen;
-typedef XWorkArea FWorkArea;
-
 /**
  * Temporary wrapper around XWorkArea and XScreen.
  * Please refer to the Qt4 implementation for a proper cleanup of the API.
  */
 class GuiWorkArea: public lyx::frontend::WorkArea {
 public:
-       GuiWorkArea(LyXView & owner, int w, int h,
-               FScreen * screen, FWorkArea * work_area)
-               : lyx::frontend::WorkArea(owner, w, h),
-               old_screen_(screen), old_work_area_(work_area)
+       GuiWorkArea(XScreen * screen, XWorkArea * work_area)
+               : old_screen_(screen), old_work_area_(work_area)
        {
        }
 
@@ -69,7 +64,7 @@ public:
 
 
        /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h, Cursor_Shape shape)
+       virtual void showCursor(int x, int y, int h, CursorShape shape)
        {
                old_screen_->showCursor(x, y, h, shape);
        }
@@ -88,8 +83,8 @@ protected:
        }
 
 private:
-       FScreen * old_screen_;
-       FWorkArea * old_work_area_;
+       XScreen * old_screen_;
+       XWorkArea * old_work_area_;
 };
 
 } // namespace frontend
index a7afd7cd64a2a5c96e25222796bf9ec375b61cdc..79548de620eaca305b99d0bfff08b520910f728f 100644 (file)
@@ -158,6 +158,7 @@ libxforms_la_SOURCES = \
        FormWrap.h \
        GuiClipboard.h \
        GuiImplementation.h \
+       GuiImplementation.C \
        GuiWorkArea.h \
        LayoutEngine.C \
        LayoutEngine.h \
index 62410a03e42536c324420f97a7aa65d768b8d18c..c6d0ee12dcf22c150ae716eb2aaebec7201982fd 100644 (file)
@@ -71,10 +71,10 @@ void print_metrics(std::ostream & os, std::string const & name, Box const & box)
 }
 
 
-XFormsView::XFormsView(int width, int height)
-       : LyXView(),
+XFormsView::XFormsView(Gui & owner, int width, int height)
+       : LyXView(owner),
          window_(Box(width, height)),
-         icon_pixmap_(0), icon_mask_(0), frontend_(*this)
+         icon_pixmap_(0), icon_mask_(0)
 {
        int const air = 2;
 
@@ -108,7 +108,6 @@ XFormsView::XFormsView(int width, int height)
 
        menubar_.reset(new XFormsMenubar(this, menubackend));
        getToolbars().init();
-       bufferview_.reset(new BufferView(this, width, height));
        minibuffer_.reset(new XMiniBuffer(*this, *controlcommand_));
 
        //  Assign an icon to the main form.
@@ -138,7 +137,7 @@ XFormsView::XFormsView(int width, int height)
                focus_command_buffer.connect(boost::bind(&XMiniBuffer::focus, minibuffer_.get()));
 
        // Make sure the buttons are disabled if needed.
-       updateToolbars();
+       //updateToolbars();
        redraw_con =
                getDialogs().redrawGUI().connect(boost::bind(&XFormsView::redraw, this));
 }
index 91099b00dbe05fbd4f47db3eb04495adb77351c1..79bb4f84b2ca46525d630f607d3fb0e5c672e379 100644 (file)
@@ -12,7 +12,6 @@
 #ifndef LyXView_H
 #define LyXView_H
 
-#include "GuiImplementation.h"
 #include "LayoutEngine.h"
 #include "forms_fwd.h"
 
@@ -44,7 +43,7 @@ public:
        };
 
        /// create a main window of the given dimensions
-       XFormsView(int w, int h);
+       XFormsView(Gui & owner, int w, int h);
 
        ~XFormsView();
 
@@ -83,9 +82,6 @@ public:
        // returns true if this view has the focus.
        virtual bool hasFocus() const;
 
-       ///
-       Gui & gui() { return frontend_; }
-
 private:
        /**
         * setWindowTitle - set title of window
@@ -120,8 +116,6 @@ private:
        Pixmap icon_pixmap_;
        ///
        Pixmap icon_mask_;
-       ///
-       GuiImplementation frontend_;
 };
 
 } // namespace frontend
index b4e131ef75f6f6d6ef89a085e5fe0dc0b78b1b2e..e329173abcf7f3fe7cde39c27798de093a9207b9 100644 (file)
@@ -109,13 +109,20 @@ int C_event_cb(FL_FORM * form, void * xev)
 
 
 XWorkArea::XWorkArea(LyXView & owner, int w, int h)
-        : view_(owner), workareapixmap(0), painter_(*this)
+       : view_(owner), workareapixmap(0), painter_(*this)
 {
        fl_freeze_all_forms();
 
        FL_OBJECT * obj;
        FL_OBJECT * frame;
 
+       XFormsView & xview = dynamic_cast<XFormsView &>(owner);
+
+       // Set the current form so that objects have something to get
+       // added to.
+       //fl_addto_form(fl_current_form);
+       fl_addto_form(xview.getForm());
+
        // A frame around the work area.
        frame = obj = fl_add_box(FL_BORDER_BOX, 0, 0, w, h, "");
        fl_set_object_resize(obj, FL_RESIZE_ALL);
@@ -150,7 +157,6 @@ XWorkArea::XWorkArea(LyXView & owner, int w, int h)
 
        // Hand control of the layout of these widgets to the
        // Layout Engine.
-       XFormsView & xview = dynamic_cast<XFormsView &>(owner);
        BoxList & boxlist = xview.getBox(XFormsView::Center)->children();
 
        wa_box_ = boxlist.push_back(Box(0,0));
@@ -179,6 +185,8 @@ XWorkArea::XWorkArea(LyXView & owner, int w, int h)
        val.function = GXcopy;
        copy_gc = XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
                            GCFunction, &val);
+
+       fl_end_form();
 }
 
 
@@ -220,7 +228,7 @@ void XWorkArea::redraw(int width, int height)
                                       height,
                                       fl_get_visual_depth());
 
-       view_.view()->workAreaResize();
+       view_.view()->workAreaResize(width, height);
 }
 
 
index 2f83c933a69aeb5bda2bf0a1290888492baab49d..23209825b7833525af0cea3525ab46633e5f21b0 100644 (file)
@@ -31,7 +31,7 @@ public:
        ///
        XWorkArea(LyXView & owner, int width, int height);
        ///
-       ~XWorkArea();
+       virtual ~XWorkArea();
        ///
        virtual Painter & getPainter() { return painter_; }
        ///
@@ -66,8 +66,8 @@ public:
        /// handles SelectionRequest X Event, to fill the clipboard
        int event_cb(XEvent * xev);
 private:
-        LyXView & view_;
-        
+       LyXView & view_;
+
        /// generate the pixmap, and copy backing pixmap to it,
        /// and send resize event if needed
        void redraw(int, int);
index c6c0bfb061e988d6c7e9c089dc60cc18505b7826..5e9a6b421dce06c8e8b606e3617aeba3acfa073e 100644 (file)
@@ -16,6 +16,7 @@
 #include "xfont_loader.h"
 #include "xforms_helpers.h"
 #include "xformsImage.h"
+#include "GuiImplementation.h"
 #include "XFormsView.h"
 
 #include "bufferlist.h"
@@ -54,6 +55,8 @@ using lyx::frontend::fontloader;
 using lyx::frontend::lyxColorHandler;
 using lyx::frontend::LyXColorHandler;
 using lyx::frontend::XformsColor;
+using lyx::frontend::Gui;
+using lyx::frontend::GuiImplementation;
 using lyx::frontend::XFormsView;
 
 namespace os = lyx::support::os;
@@ -280,25 +283,30 @@ void start(string const & batch, vector<string> const & files,
        lyxerr[Debug::GUI] << "Creating view: " << width << 'x' << height
                           << '+' << posx << '+' << posy << endl;
 
-       boost::shared_ptr<XFormsView> view(new XFormsView(width, height));
-       LyX::ref().addLyXView(view);
+       GuiImplementation * gui = new GuiImplementation;
 
-       view->show(posx == -1 ? (WidthOfScreen(s) - width) / 2 : posx, 
+       int view_id = gui->newView(width, height);
+       XFormsView & view = static_cast<XFormsView &> (gui->view(view_id));
+       int workArea_id_ = gui->newWorkArea(width, height, 0);
+
+       LyX::ref().addLyXView(&view);
+
+       view.show(posx == -1 ? (WidthOfScreen(s) - width) / 2 : posx, 
                       posy == -1 ? (HeightOfScreen(s) - height) / 2 : posy, "LyX");
-       view->init();
+       view.init();
 
        // FIXME: some code below needs moving
 
-       lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
-       lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
+       lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
+       lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
                          os::internal_path(package().temp_dir() + "/lyxsocket"));
 
        for_each(files.begin(), files.end(),
-               bind(&BufferView::loadLyXFile, view->view(), _1, true));
+               bind(&BufferView::loadLyXFile, view.view(), _1, true));
 
        // handle the batch commands the user asked for
        if (!batch.empty())
-               view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
+               view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
 
        // enter the event loop
        while (!finished) {
index 640b881f6364d5dbab61b141eb5456ebee971134..3051d350bc81b54c07b7aa10085479ac40edf022 100644 (file)
@@ -73,7 +73,7 @@ void XScreen::setCursorColor()
 }
 
 
-void XScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
+void XScreen::showCursor(int x, int y, int h, CursorShape shape)
 {
        // Update the cursor color. (a little slow doing it like this ??)
        setCursorColor();
index 27f1d2c3f4c92cef6af0359e1c243c898c6ff1ce..878bbc1b30078685fc513c66236925a0a2a7e498 100644 (file)
 #ifndef XSCREEN_H
 #define XSCREEN_H
 
-#include "frontends/GuiCursor.h"
-
 #include <X11/Xlib.h> // for Pixmap, GC
 
+#include "frontends/GuiCursor.h"
+
 class WorkArea;
 
 namespace lyx {
@@ -44,7 +44,7 @@ public:
        virtual void expose(int x, int y, int w, int h);
 
        /// paint the cursor and store the background
-       virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
+       virtual void showCursor(int x, int y, int h, CursorShape shape);
 
        /// hide the cursor
        virtual void removeCursor();
index 41aa3dd95406db097c089e253e81c51b97cd07b9..1c84d3d147e22eef988f5e8786daf435ff908c96 100644 (file)
@@ -76,7 +76,7 @@ bool Importer::Import(LyXView * lv, string const & filename,
                string filename2 = (loader_format == format) ? filename
                        : changeExtension(filename,
                                          formats.extension(loader_format));
-               insertAsciiFile(lv->view().get(), filename2, as_paragraphs);
+               insertAsciiFile(lv->view(), filename2, as_paragraphs);
                lv->dispatch(FuncRequest(LFUN_MARK_OFF));
        }
 
index 226bbb998f86dbd77a5b0a3860e6cb4b17b0cb5a..cd9d079844952b4cd60ea288cb38fdadda7f8c72 100644 (file)
@@ -188,7 +188,7 @@ lyx::Session const & LyX::session() const
 }
 
 
-void LyX::addLyXView(boost::shared_ptr<LyXView> const & lyxview)
+void LyX::addLyXView(LyXView * lyxview)
 {
        views_.push_back(lyxview);
 }
index 550619784aa5ed4f3d7564f6659533e9601e7372..d69e86a9d4e0342efd9ca1a0cc64494553d9bc6d 100644 (file)
@@ -58,7 +58,7 @@ public:
        lyx::Session & session();
        lyx::Session const & session() const;
 
-       void addLyXView(boost::shared_ptr<LyXView> const & lyxview);
+       void addLyXView(LyXView * lyxview);
 
        /** redraw \c inset in all the BufferViews in which it is currently
         *  visible. If successful return a pointer to the owning Buffer.
@@ -105,10 +105,10 @@ private:
        /// lyx session, containing lastfiles, lastfilepos, and lastopened
        boost::scoped_ptr<lyx::Session> session_;
        ///
-       typedef std::list<boost::shared_ptr<LyXView> > ViewList;
+       typedef std::list<LyXView *> ViewList;
        ViewList views_;
 
-       /// 
+       ///
        bool geometryOption_;
 
 };
index 41b04b281eff08f59b46dcb26f5fedb62b0cdba9..fa2ecf9cfc1a6fbb47c7e7c8955483db502b328a 100644 (file)
@@ -724,7 +724,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
        dispatch_buffer.erase();
 
        // redraw the screen at the end (first of the two drawing steps).
-       //This is done unless explicitely requested otherwise 
+       //This is done unless explicitely requested otherwise
        bool update = true;
        // also do the second redrawing step. Only done if requested.
        bool updateforce = false;
@@ -1157,7 +1157,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                        view()->center();
                        // see BufferView_pimpl::center()
-                       view()->updateScrollbar();
                        break;
                }
 
@@ -1950,7 +1949,7 @@ string const LyXFunc::viewStatusMessage()
 BufferView * LyXFunc::view() const
 {
        BOOST_ASSERT(owner);
-       return owner->view().get();
+       return owner->view();
 }
 
 
index 73604c8d50947e3ca7ed521293fbf8cd83f71919..d74494cefd20ef8c24eb90aa8f5c8092a9f2e174 100644 (file)
@@ -213,7 +213,6 @@ bool LyXText::cursorPrevious(LCursor & cur)
                updated |= cursorUp(cur);
        }
 
-       cur.bv().updateScrollbar();
        finishUndo();
        return updated;
 }
@@ -236,7 +235,6 @@ bool LyXText::cursorNext(LCursor & cur)
                updated |= cursorDown(cur);
        }
 
-       cur.bv().updateScrollbar();
        finishUndo();
        return updated;
 }
@@ -1167,7 +1165,6 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
 
                cur.resetAnchor();
                moveCursor(cur, false);
-               bv->updateScrollbar();
                break;
        }