Abdelrazak Younes wrote:
Hello,

This patch make the qt3 frontend compile in the "younes" branches. It also update th scrollbar in the QContent::paintEvent(). I still have to read the Qt3 doc to see how to disable tracking in the scrollbar.

Once the qt3 support is in and works, it should be reasonably easy to complete the xforms and gtk frontend also.

The qt3 support is in and it works fine, the code for scrollbar tracking for qt4 turned out to be the same for qt3 :-).

Here is preliminar support for gtk and xforms. Don't know if it compiles but it goes in "younes" now... In case somebody is interested to complete the support. The scrollbar update is missing though in both gtk and xforms as I don't know where to put that. Basically one needs to translate this code from qt3 (in QContentPane::paintEvent()):

        BufferView * buffer_view_ = wa_->view().view();

        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);


Once I have sync my tree with trunk, I will be ready to merge.

Abdel.
Index: frontends/gtk/GuiImplementation.h
===================================================================
--- frontends/gtk/GuiImplementation.h   (revision 14165)
+++ frontends/gtk/GuiImplementation.h   (working copy)
@@ -28,6 +28,7 @@
 namespace lyx {
 namespace frontend {
 
+typedef GView FView;
 typedef GScreen FScreen;
 typedef GWorkArea FWorkArea;
 
@@ -37,7 +38,7 @@
 class GuiImplementation: public lyx::frontend::Gui
 {
 public:
-       GuiImplementation(LyXView & owner): owner_(owner)
+       GuiImplementation()
        {
        }
 
@@ -50,13 +51,36 @@
                return *clipboard_;
        }
 
-       int newWorkArea(int w, int h)
+       int newView(unsigned int w, unsigned int h)
        {
-               old_work_area_.reset(new FWorkArea(owner_, w, h));
+               view_.reset(new FView(*this, w, h));
+               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(*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;
        }
 
@@ -79,11 +103,11 @@
        ///
        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: frontends/gtk/GuiWorkArea.h
===================================================================
--- frontends/gtk/GuiWorkArea.h (revision 14165)
+++ frontends/gtk/GuiWorkArea.h (working copy)
@@ -29,10 +29,8 @@
  */
 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)
        {
        }
 
Index: frontends/gtk/GView.C
===================================================================
--- frontends/gtk/GView.C       (revision 14165)
+++ frontends/gtk/GView.C       (working copy)
@@ -57,7 +57,7 @@
 } // 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));
Index: frontends/gtk/GView.h
===================================================================
--- frontends/gtk/GView.h       (revision 14165)
+++ frontends/gtk/GView.h       (working copy)
@@ -16,8 +16,6 @@
 
 #include "frontends/LyXView.h"
 
-#include "GuiImplementation.h"
-
 #include <gtkmm.h>
 
 #include <map>
@@ -37,7 +35,7 @@
                Center
        };
 
-       GView();
+       GView(Gui & owner);
        ~GView();
 
        Gtk::Box & getBox(Position pos);
@@ -58,9 +56,6 @@
        // 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 @@
 
        boost::scoped_ptr<GMiniBuffer> minibuffer_;
        Gtk::Widget * workArea_;
-       ///
-       GuiImplementation frontend_;
 };
 
 } // namespace frontend
Index: frontends/gtk/lyx_gui.C
===================================================================
--- frontends/gtk/lyx_gui.C     (revision 14165)
+++ frontends/gtk/lyx_gui.C     (working copy)
@@ -43,6 +43,7 @@
 #include "lyxsocket.h"
 #include "BufferView.h"
 
+#include "GuiImplementation.h"
 #include "GView.h"
 #include "GtkmmX.h"
 
@@ -75,6 +76,8 @@
 using lyx::support::package;
 
 using lyx::frontend::colorCache;
+using lyx::frontend::Gui;
+using lyx::frontend::GuiImplementation;
 using lyx::frontend::GView;
 
 
@@ -99,10 +102,25 @@
 
 } // 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::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));
+       int workArea_id_ = theApp->gui().newWorkArea(width, height, 0);
 
-       GView & view = *view_ptr.get();
+       LyX::ref().addLyXView(&view);
+
        view.show();
        view.init();
 
@@ -146,7 +166,7 @@
                view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
        }
 
-       Gtk::Main::run();
+       theApp->run();
 
        // FIXME: breaks emergencyCleanup
        delete lyxsocket;
@@ -157,7 +177,7 @@
 void lyx_gui::exit(int /*status*/)
 {
        // FIXME: Don't ignore status
-       Gtk::Main::quit();
+       theApp->quit();
 }
 
 
Index: frontends/xforms/GuiImplementation.h
===================================================================
--- frontends/xforms/GuiImplementation.h        (revision 14165)
+++ frontends/xforms/GuiImplementation.h        (working copy)
@@ -28,6 +28,7 @@
 namespace lyx {
 namespace frontend {
 
+typedef XFormsView FView;
 typedef XScreen FScreen;
 typedef XWorkArea FWorkArea;
 
@@ -37,7 +38,7 @@
 class GuiImplementation: public lyx::frontend::Gui
 {
 public:
-       GuiImplementation(LyXView & owner): owner_(owner)
+       GuiImplementation()
        {
        }
 
@@ -50,13 +51,36 @@
                return *clipboard_;
        }
 
-       int newWorkArea(int w, int h)
+       int newView(unsigned int w, unsigned int h)
        {
-               old_work_area_.reset(new FWorkArea(owner_, w, h));
+               view_.reset(new FView(*this, w, h));
+               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(*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;
        }
 
@@ -79,11 +103,11 @@
        ///
        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: frontends/xforms/GuiWorkArea.h
===================================================================
--- frontends/xforms/GuiWorkArea.h      (revision 14165)
+++ frontends/xforms/GuiWorkArea.h      (working copy)
@@ -29,10 +29,8 @@
  */
 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)
        {
        }
 
Index: frontends/xforms/lyx_gui.C
===================================================================
--- frontends/xforms/lyx_gui.C  (revision 14165)
+++ frontends/xforms/lyx_gui.C  (working copy)
@@ -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::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 @@
        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<GView &> (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: frontends/xforms/XFormsView.C
===================================================================
--- frontends/xforms/XFormsView.C       (revision 14165)
+++ frontends/xforms/XFormsView.C       (working copy)
@@ -71,8 +71,8 @@
 }
 
 
-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)
 {
Index: frontends/xforms/XFormsView.h
===================================================================
--- frontends/xforms/XFormsView.h       (revision 14165)
+++ frontends/xforms/XFormsView.h       (working copy)
@@ -44,7 +44,7 @@
        };
 
        /// create a main window of the given dimensions
-       XFormsView(int w, int h);
+       XFormsView(Gui & owner, int w, int h);
 
        ~XFormsView();
 
@@ -83,9 +83,6 @@
        // returns true if this view has the focus.
        virtual bool hasFocus() const;
 
-       ///
-       Gui & gui() { return frontend_; }
-
 private:
        /**
         * setWindowTitle - set title of window
@@ -120,8 +117,6 @@
        Pixmap icon_pixmap_;
        ///
        Pixmap icon_mask_;
-       ///
-       GuiImplementation frontend_;
 };
 
 } // namespace frontend

Reply via email to