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.
Abdel.
Index: GuiImplementation.h
===================================================================
--- GuiImplementation.h (revision 14165)
+++ GuiImplementation.h (working copy)
@@ -13,19 +13,22 @@
#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 @@
class GuiImplementation: public lyx::frontend::Gui
{
public:
- GuiImplementation(LyXView & owner): owner_(owner)
+ GuiImplementation()
{
}
@@ -48,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;
}
@@ -77,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: GuiWorkArea.h
===================================================================
--- GuiWorkArea.h (revision 14165)
+++ 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: lyx_gui.C
===================================================================
--- lyx_gui.C (revision 14165)
+++ lyx_gui.C (working copy)
@@ -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 @@
{
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 @@
}
#endif
+LQApplication * theApp;
namespace lyx_gui {
@@ -167,6 +178,7 @@
FontLoader::initFontPath();
LQApplication app(argc, argv);
+ theApp = &app;
#if QT_VERSION >= 0x030200
// install translation file for Qt built-in dialogs
@@ -227,10 +239,11 @@
// this can't be done before because it needs the Languages object
initEncodings();
- boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
- LyX::ref().addLyXView(view_ptr);
+ int view_id = theApp->gui().newView(width, height);
+ QtView & view = static_cast<QtView &> (theApp->gui().view(view_id));
+ int workArea_id_ = theApp->gui().newWorkArea(width, height, 0);
- QtView & view = *view_ptr.get();
+ LyX::ref().addLyXView(&view);
if (posx != -1 && posy != -1)
view.move(QPoint(posx, posy));
Index: QContentPane.C
===================================================================
--- QContentPane.C (revision 14175)
+++ QContentPane.C (working copy)
@@ -343,9 +343,11 @@
void QContentPane::paintEvent(QPaintEvent * e)
{
+ BufferView * buffer_view_ = wa_->view().view();
+
if (!pixmap_.get()) {
pixmap_.reset(new QPixmap(width(), height()));
- wa_->view().view()->workAreaResize(width(), height());
+ buffer_view_->workAreaResize(width(), height());
return;
}
@@ -354,6 +356,14 @@
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: QtView.C
===================================================================
--- QtView.C (revision 14165)
+++ QtView.C (working copy)
@@ -55,15 +55,13 @@
-QtView::QtView(unsigned int width, unsigned int height)
- : QMainWindow(), LyXView(), commandbuffer_(0), frontend_(*this)
+QtView::QtView(Gui & owner, unsigned int width, unsigned int height)
+ : QMainWindow(), LyXView(owner), commandbuffer_(0)
{
resize(width, height);
qApp->setMainWidget(this);
- bufferview_.reset(new BufferView(this, width, height));
-
menubar_.reset(new QLMenubar(this, menubackend));
getToolbars().init();
Index: QtView.h
===================================================================
--- QtView.h (revision 14165)
+++ QtView.h (working copy)
@@ -13,13 +13,10 @@
#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>
@@ -39,7 +36,7 @@
Q_OBJECT
public:
/// create a main window of the given dimensions
- QtView(unsigned int w, unsigned int h);
+ QtView(Gui & owner, unsigned int w, unsigned int h);
~QtView();
@@ -64,9 +61,6 @@
// returns true if this view has the focus.
virtual bool hasFocus() const;
- //
- lyx::frontend::Gui & gui() { return frontend_; }
-
public slots:
/// idle timeout
void update_view_state_qt();
@@ -91,9 +85,6 @@
/// command buffer
QCommandBuffer * commandbuffer_;
-
- ///
- GuiImplementation frontend_;
};
} // namespace frontend