Hello,
This is done by creating two new pure virtual method in LyXView:
init(): initialize menubars and toolbars
setGeometry(): guess what it does? :-)
I am not sure gtk and qt3 compiles but it should be close to.
Committing now...
Abdel.
Log:
* Application: new createView() method
* gtk/qt3/qt4/GuiApplication: createView() method deleted
* LyXView:
- init(): is now a pure virtual method. autoSave code transferred to
constructor and updates to the frontends.
- setGeometry(): new pure virtual method
* gtk/GView, qt3/QtView, qt4/GuiView: adapted to above change
- setGeometry(): code transfered from GuiApplication
* lyx_main.C: call LyX::ref().addLyXView() in there instead of in
Application::createView()
Index: frontends/Application.C
===================================================================
--- frontends/Application.C (revision 15182)
+++ frontends/Application.C (working copy)
@@ -14,11 +14,12 @@
#include "Application_pimpl.h"
#include "Gui.h"
+#include "LyXView.h"
+#include "WorkArea.h"
#include "LyXAction.h"
#include "lyxfunc.h"
#include "lyxrc.h"
-#include "LyXView.h"
#include "support/lstrings.h"
#include "support/os.h"
@@ -90,6 +91,34 @@
}
+// FIXME: this whole method needs to be moved to Application.
+LyXView & Application::createView(unsigned int width,
+ unsigned int
height,
+ int posx, int
posy,
+ bool maximize)
+{
+ // FIXME: please confirm: with unicode, I think initEncoding()
+ // is not needed anymore!
+
+ // this can't be done before because it needs the Languages object
+ //initEncodings();
+
+ int view_id = gui().newView(width, height);
+ LyXView & view = gui().view(view_id);
+
+ pimpl_->lyxfunc_.reset(new LyXFunc(&view));
+
+ // FIXME: for now we assume that there is only one LyXView with id = 0.
+ /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
+ //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
+
+ view.init();
+ view.setGeometry(width, height, posx, posy, maximize);
+
+ return view;
+}
+
+
int Application::start(std::string const & batch)
{
pimpl_->lyx_server_.reset(new LyXServer(pimpl_->lyxfunc_.get(),
lyxrc.lyxpipes));
Index: frontends/Application.h
===================================================================
--- frontends/Application.h (revision 15182)
+++ frontends/Application.h (working copy)
@@ -20,6 +20,7 @@
class LyXFunc;
class LyXServer;
class LyXServerSocket;
+class LyXView;
namespace lyx {
namespace frontend {
@@ -71,6 +72,11 @@
BufferList & bufferList();
BufferList const & bufferList() const;
+ ///
+ LyXView & createView(unsigned int width, unsigned int height,
+ int posx, int posy, bool maximize);
+
+ ///
void setBufferView(BufferView * buffer_view);
protected:
Index: frontends/gtk/GuiApplication.C
===================================================================
--- frontends/gtk/GuiApplication.C (revision 15182)
+++ frontends/gtk/GuiApplication.C (working copy)
@@ -110,28 +110,5 @@
}
-// FIXME: this whole method needs to be moved to Application.
-LyXView & GuiApplication::createView(unsigned int width,
-
unsigned int height,
- int
posx, int posy,
- bool
maximize)
-{
- // FIXME: for now we assume that there is only one LyXView with id = 0.
- /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
- //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
-
- int view_id = gui().newView(width, height);
- GView & view = static_cast<GView &>(gui().view(view_id));
-
- pimpl_->lyxfunc_.reset(new LyXFunc(&view));
-
- LyX::ref().addLyXView(&view);
-
- view.show();
- view.init();
-
- return view;
-}
-
} // namespace frontend
} // namespace lyx
Index: frontends/gtk/GView.C
===================================================================
--- frontends/gtk/GView.C (revision 15180)
+++ frontends/gtk/GView.C (working copy)
@@ -131,6 +131,22 @@
{}
+void GView::init()
+{
+ updateLayoutChoice();
+ updateMenubar();
+}
+
+
+void GView::setGeometry(unsigned int width,
+ unsigned int height,
+ int posx, int posy,
+ bool maximize)
+{
+// FIXME: do something here...
+}
+
+
Gtk::Box & GView::getBox(Position pos)
{
return *box_map_[pos];
Index: frontends/gtk/GView.h
===================================================================
--- frontends/gtk/GView.h (revision 15180)
+++ frontends/gtk/GView.h (working copy)
@@ -38,6 +38,16 @@
GView();
~GView();
+ /// initialize the object
+ virtual void init();
+
+ /// FIXME: not implemented!
+ virtual void setGeometry(
+ unsigned int width,
+ unsigned int height,
+ int posx, int posy,
+ bool maximize);
+
Gtk::Box & getBox(Position pos);
virtual void prohibitInput() const;
Index: frontends/LyXView.C
===================================================================
--- frontends/LyXView.C (revision 15182)
+++ frontends/LyXView.C (working copy)
@@ -71,7 +71,12 @@
dialogs_(new Dialogs(*this)),
controlcommand_(new ControlCommandBuffer(*this))
{
- lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
+ // Start autosave timer
+ if (lyxrc.autosave) {
+
autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
+ autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
+ autosave_timeout_->start();
+ }
}
@@ -99,20 +104,6 @@
}
-void LyXView::init()
-{
- updateLayoutChoice();
- updateMenubar();
-
- // Start autosave timer
- if (lyxrc.autosave) {
-
autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
- autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
- autosave_timeout_->start();
- }
-}
-
-
Buffer * LyXView::buffer() const
{
return work_area_->bufferView().buffer();
Index: frontends/LyXView.h
===================================================================
--- frontends/LyXView.h (revision 15182)
+++ frontends/LyXView.h (working copy)
@@ -69,8 +69,14 @@
* We have to have the toolbar and the other stuff created
* before we can populate it with this call.
*/
- void init();
+ virtual void init() = 0;
+ virtual void setGeometry(
+ unsigned int width,
+ unsigned int height,
+ int posx, int posy,
+ bool maximize) = 0;
+
/// show busy cursor
virtual void busy(bool) const = 0;
Index: frontends/qt3/GuiApplication.C
===================================================================
--- frontends/qt3/GuiApplication.C (revision 15182)
+++ frontends/qt3/GuiApplication.C (working copy)
@@ -190,21 +190,6 @@
view.init();
- // FIXME: put this initialisation code in GuiView accessible via
- // a pure virtual method in LyXView.
-
- // only true when the -geometry option was NOT used
- if (width != 0 && height != 0) {
- view.initFloatingGeometry(QRect(posx, posy, width, height));
- view.resize(width, height);
- if (posx != -1 && posy != -1)
- view.move(posx, posy);
- view.show();
- if (maximize)
- view.setWindowState(Qt::WindowMaximized);
- } else
- view.show();
-
return view;
}
Index: frontends/qt3/QtView.C
===================================================================
--- frontends/qt3/QtView.C (revision 15180)
+++ frontends/qt3/QtView.C (working copy)
@@ -91,10 +91,30 @@
// and we don't save their orientation anyway. Disable the handle.
setToolBarsMovable(false);
- LyXView::init();
+ updateLayoutChoice();
+ updateMenubar();
}
+void QtView::setGeometry(unsigned int width,
+ unsigned int height,
+ int posx, int posy,
+ bool maximize)
+{
+ // only true when the -geometry option was NOT used
+ if (width != 0 && height != 0) {
+ initFloatingGeometry(QRect(posx, posy, width, height));
+ resize(width, height);
+ if (posx != -1 && posy != -1)
+ move(posx, posy);
+ show();
+ if (maximize)
+ setWindowState(Qt::WindowMaximized);
+ } else
+ show();
+}
+
+
void QtView::setWindowTitle(docstring const & t, docstring const & it)
{
setCaption(toqstr(t));
Index: frontends/qt3/QtView.h
===================================================================
--- frontends/qt3/QtView.h (revision 15180)
+++ frontends/qt3/QtView.h (working copy)
@@ -41,8 +41,15 @@
~QtView();
/// initialise the object members (menubars, toolbars, etc..)
- void init();
+ virtual void init();
+ ///
+ virtual void setGeometry(
+ unsigned int width,
+ unsigned int height,
+ int posx, int posy,
+ bool maximize);
+
/// show - display the top-level window
void show();
Index: frontends/qt4/GuiApplication.C
===================================================================
--- frontends/qt4/GuiApplication.C (revision 15182)
+++ frontends/qt4/GuiApplication.C (working copy)
@@ -14,8 +14,6 @@
#include "GuiApplication.h"
-#include "GuiView.h"
-#include "GuiWorkArea.h"
#include "qt_helpers.h"
#include "QLImage.h"
@@ -42,6 +40,7 @@
#include <QLibraryInfo>
#include <QTextCodec>
#include <QTranslator>
+#include <QWidget>
#ifdef Q_WS_X11
#include <X11/Xlib.h>
@@ -165,56 +164,8 @@
}
-// FIXME: this whole method needs to be moved to Application.
-LyXView & GuiApplication::createView(unsigned int width,
-
unsigned int height,
- int
posx, int posy,
- bool
maximize)
-{
- // this can't be done before because it needs the Languages object
- initEncodings();
- int view_id = gui().newView(width, height);
- GuiView & view = static_cast<GuiView &> (gui().view(view_id));
- pimpl_->lyxfunc_.reset(new LyXFunc(&view));
-
- // FIXME: for now we assume that there is only one LyXView with id = 0.
- /*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
- //WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
-
- LyX::ref().addLyXView(&view);
-
- view.init();
-
- // FIXME: put this initialisation code in GuiView accessible via
- // a pure virtual method in LyXView.
-
- // only true when the -geometry option was NOT used
- if (width != 0 && height != 0) {
- if (posx != -1 && posy != -1) {
-#ifdef Q_OS_WIN32
- // FIXME: use only setGeoemtry when Trolltech has
- // fixed the qt4/X11 bug
- view.setGeometry(posx, posy,width, height);
-#else
- view.resize(width, height);
- view.move(posx, posy);
-#endif
- } else {
- view.resize(width, height);
- }
-
- if (maximize)
- view.setWindowState(Qt::WindowMaximized);
- }
-
- view.show();
-
- return view;
-}
-
-
////////////////////////////////////////////////////////////////////////
// X11 specific stuff goes here...
#ifdef Q_WS_X11
Index: frontends/qt4/GuiApplication.h
===================================================================
--- frontends/qt4/GuiApplication.h (revision 15180)
+++ frontends/qt4/GuiApplication.h (working copy)
@@ -65,10 +65,6 @@
///
FontLoader & fontLoader() { return font_loader_; }
- ///
- LyXView & createView(unsigned int width, unsigned int height,
- int posx, int posy, bool maximize);
-
private:
///
GuiImplementation gui_;
Index: frontends/qt4/GuiView.C
===================================================================
--- frontends/qt4/GuiView.C (revision 15180)
+++ frontends/qt4/GuiView.C (working copy)
@@ -104,10 +104,39 @@
// make sure the buttons are disabled if needed
updateToolbars();
+ updateLayoutChoice();
+ updateMenubar();
+}
- LyXView::init();
+
+void GuiView::setGeometry(unsigned int width,
+ unsigned int
height,
+ int posx, int
posy,
+ bool maximize)
+{
+ // only true when the -geometry option was NOT used
+ if (width != 0 && height != 0) {
+ if (posx != -1 && posy != -1) {
+#ifdef Q_OS_WIN32
+ // FIXME: use only setGeoemtry when Trolltech has
+ // fixed the qt4/X11 bug
+ QMainWindow::setGeometry(posx, posy,width, height);
+#else
+ resize(width, height);
+ move(posx, posy);
+#endif
+ } else {
+ resize(width, height);
+ }
+
+ if (maximize)
+ setWindowState(Qt::WindowMaximized);
+ }
+
+ show();
}
+
void GuiView::updateMenu(QAction * /*action*/)
{
menubar_->update();
Index: frontends/qt4/GuiView.h
===================================================================
--- frontends/qt4/GuiView.h (revision 15180)
+++ frontends/qt4/GuiView.h (working copy)
@@ -54,6 +54,13 @@
/// initialize the object
virtual void init();
+ ///
+ virtual void setGeometry(
+ unsigned int width,
+ unsigned int height,
+ int posx, int posy,
+ bool maximize);
+
/// show - display the top-level window
void show();
Index: lyx_main.C
===================================================================
--- lyx_main.C (revision 15182)
+++ lyx_main.C (working copy)
@@ -338,6 +338,7 @@
}
// create the main window
LyXView * view = lyx_gui::create_view(width, height, posx,
posy, maximize);
+ ref().addLyXView(view);
// load files
for_each(files.begin(), files.end(),