mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
* 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() * git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15183 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ca5411f913
commit
3a1f656e4e
@ -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 @@ void Application::setBufferView(BufferView * buffer_view)
|
||||
}
|
||||
|
||||
|
||||
// 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));
|
||||
|
@ -20,6 +20,7 @@ class BufferView;
|
||||
class LyXFunc;
|
||||
class LyXServer;
|
||||
class LyXServerSocket;
|
||||
class LyXView;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
@ -71,6 +72,11 @@ public:
|
||||
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:
|
||||
|
@ -71,7 +71,12 @@ LyXView::LyXView()
|
||||
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 @@ WorkArea * LyXView::workArea()
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
@ -69,7 +69,13 @@ public:
|
||||
* 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;
|
||||
|
@ -131,6 +131,22 @@ GView::~GView()
|
||||
{}
|
||||
|
||||
|
||||
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];
|
||||
|
@ -38,6 +38,16 @@ public:
|
||||
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;
|
||||
|
@ -110,28 +110,5 @@ void GuiApplication::exit(int /*status*/)
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
@ -190,21 +190,6 @@ LyXView & GuiApplication::createView(unsigned int width,
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,27 @@ void QtView::init()
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,14 @@ public:
|
||||
~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();
|
||||
|
@ -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,54 +164,6 @@ void GuiApplication::exit(int status)
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -65,10 +65,6 @@ public:
|
||||
///
|
||||
FontLoader & fontLoader() { return font_loader_; }
|
||||
|
||||
///
|
||||
LyXView & createView(unsigned int width, unsigned int height,
|
||||
int posx, int posy, bool maximize);
|
||||
|
||||
private:
|
||||
///
|
||||
GuiImplementation gui_;
|
||||
|
@ -104,10 +104,39 @@ void GuiView::init()
|
||||
|
||||
// make sure the buttons are disabled if needed
|
||||
updateToolbars();
|
||||
|
||||
LyXView::init();
|
||||
updateLayoutChoice();
|
||||
updateMenubar();
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
@ -54,6 +54,13 @@ public:
|
||||
/// 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();
|
||||
|
||||
|
@ -338,6 +338,7 @@ int LyX::exec2(int & argc, char * argv[])
|
||||
}
|
||||
// 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(),
|
||||
|
Loading…
Reference in New Issue
Block a user