3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * \author Abdelrazak Younes
11 * Full author contact details are available in file CREDITS.
18 #include "GuiImplementation.h"
19 #include "GuiWorkArea.h"
20 #include "GuiKeySymbol.h"
21 #include "GuiMenubar.h"
22 #include "GuiToolbar.h"
23 #include "GuiToolbars.h"
24 #include "qt_helpers.h"
26 #include "frontends/Application.h"
27 #include "frontends/Dialogs.h"
28 #include "frontends/Gui.h"
29 #include "frontends/WorkArea.h"
31 #include "support/filetools.h"
32 #include "support/convert.h"
33 #include "support/lstrings.h"
34 #include "support/os.h"
37 #include "BufferParams.h"
38 #include "BufferView.h"
39 #include "BufferList.h"
41 #include "FuncRequest.h"
46 #include "MenuBackend.h"
47 #include "Paragraph.h"
51 #include <boost/current_function.hpp>
54 #include <QApplication>
55 #include <QCloseEvent>
56 #include <QDesktopWidget>
57 #include <QDragEnterEvent>
63 #include <QPushButton>
64 #include <QStackedWidget>
77 using support::FileName;
78 using support::libFileSearch;
79 using support::makeDisplayPath;
87 int const statusbar_timer_value = 3000;
89 class BackgroundWidget : public QWidget
92 BackgroundWidget(QString const & file, QString const & text)
94 splash_ = new QPixmap(file);
96 lyxerr << "could not load splash screen: '" << fromqstr(file) << "'" << endl;
100 QPainter pain(splash_);
101 pain.setPen(QColor(255, 255, 0));
103 // The font used to display the version info
104 font.setStyleHint(QFont::SansSerif);
105 font.setWeight(QFont::Bold);
106 font.setPointSize(convert<int>(lyxrc.font_sizes[Font::SIZE_LARGE]));
108 pain.drawText(260, 270, text);
111 void paintEvent(QPaintEvent *)
116 int x = (width() - splash_->width()) / 2;
117 int y = (height() - splash_->height()) / 2;
119 pain.drawPixmap(x, y, *splash_);
127 class TabWidget : public QTabWidget {
129 void showBar(bool show) { tabBar()->setVisible(show); }
136 struct GuiViewBase::GuiViewPrivate
143 TabWidget * tab_widget_;
144 QStackedWidget * stack_widget_;
145 BackgroundWidget * bg_widget_;
147 GuiMenubar * menubar_;
149 GuiToolbars * toolbars_;
151 docstring current_layout;
153 GuiViewPrivate() : posx_offset(0), posy_offset(0) {}
155 unsigned int smallIconSize;
156 unsigned int normalIconSize;
157 unsigned int bigIconSize;
158 // static needed by "New Window"
159 static unsigned int lastIconSize;
161 QMenu * toolBarPopup(GuiViewBase * parent)
163 // FIXME: translation
164 QMenu * menu = new QMenu(parent);
165 QActionGroup * iconSizeGroup = new QActionGroup(parent);
167 QAction * smallIcons = new QAction(iconSizeGroup);
168 smallIcons->setText(qt_("Small-sized icons"));
169 smallIcons->setCheckable(true);
170 QObject::connect(smallIcons, SIGNAL(triggered()), parent, SLOT(smallSizedIcons()));
171 menu->addAction(smallIcons);
173 QAction * normalIcons = new QAction(iconSizeGroup);
174 normalIcons->setText(qt_("Normal-sized icons"));
175 normalIcons->setCheckable(true);
176 QObject::connect(normalIcons, SIGNAL(triggered()), parent, SLOT(normalSizedIcons()));
177 menu->addAction(normalIcons);
179 QAction * bigIcons = new QAction(iconSizeGroup);
180 bigIcons->setText(qt_("Big-sized icons"));
181 bigIcons->setCheckable(true);
182 QObject::connect(bigIcons, SIGNAL(triggered()), parent, SLOT(bigSizedIcons()));
183 menu->addAction(bigIcons);
185 unsigned int cur = parent->iconSize().width();
186 if ( cur == parent->d.smallIconSize)
187 smallIcons->setChecked(true);
188 else if (cur == parent->d.normalIconSize)
189 normalIcons->setChecked(true);
190 else if (cur == parent->d.bigIconSize)
191 bigIcons->setChecked(true);
196 void initBackground()
199 LYXERR(Debug::GUI) << "show banner: " << lyxrc.show_banner << endl;
200 /// The text to be written on top of the pixmap
201 QString const text = lyx_version ? QString(lyx_version) : qt_("unknown version");
202 FileName const file = support::libFileSearch("images", "banner", "png");
206 bg_widget_ = new BackgroundWidget(toqstr(file.absFilename()), text);
214 stack_widget_->setCurrentWidget(bg_widget_);
215 bg_widget_->setUpdatesEnabled(true);
220 unsigned int GuiViewBase::GuiViewPrivate::lastIconSize = 0;
223 GuiViewBase::GuiViewBase(int id)
224 : QMainWindow(), LyXView(id), quitting_by_menu_(false),
225 d(*new GuiViewPrivate)
227 // Qt bug? signal lastWindowClosed does not work
228 setAttribute(Qt::WA_QuitOnClose, false);
229 setAttribute(Qt::WA_DeleteOnClose, true);
231 // hardcode here the platform specific icon size
232 d.smallIconSize = 14; // scaling problems
233 d.normalIconSize = 20; // ok, default
234 d.bigIconSize = 26; // better for some math icons
237 // assign an icon to main form. We do not do it under Qt/Mac,
238 // since the icon is provided in the application bundle.
239 FileName const iconname = libFileSearch("images", "lyx", "png");
240 if (!iconname.empty())
241 setWindowIcon(QPixmap(toqstr(iconname.absFilename())));
244 d.tab_widget_ = new TabWidget;
246 QPushButton * closeTabButton = new QPushButton(this);
247 FileName const file = support::libFileSearch("images", "closetab", "png");
249 QPixmap pm(toqstr(file.absFilename()));
250 closeTabButton->setIcon(QIcon(pm));
251 closeTabButton->setMaximumSize(pm.size());
252 closeTabButton->setFlat(true);
254 closeTabButton->setText("Close");
256 closeTabButton->setCursor(Qt::ArrowCursor);
257 closeTabButton->setToolTip(tr("Close tab"));
258 closeTabButton->setEnabled(true);
260 QObject::connect(d.tab_widget_, SIGNAL(currentChanged(int)),
261 this, SLOT(currentTabChanged(int)));
262 QObject::connect(closeTabButton, SIGNAL(clicked()),
263 this, SLOT(closeCurrentTab()));
265 d.tab_widget_->setCornerWidget(closeTabButton);
266 #if QT_VERSION >= 0x040200
267 d.tab_widget_->setUsesScrollButtons(true);
272 LYXERR(Debug::GUI) << "stack widget!" << endl;
273 d.stack_widget_ = new QStackedWidget;
274 d.stack_widget_->addWidget(d.bg_widget_);
275 d.stack_widget_->addWidget(d.tab_widget_);
276 setCentralWidget(d.stack_widget_);
279 setCentralWidget(d.tab_widget_);
283 setAcceptDrops(true);
287 GuiViewBase::~GuiViewBase()
295 void GuiViewBase::close()
297 quitting_by_menu_ = true;
298 while (d.tab_widget_->count()) {
299 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(0));
301 d.tab_widget_->removeTab(0);
304 QMainWindow::close();
305 quitting_by_menu_ = false;
309 void GuiViewBase::setFocus()
311 if (d.tab_widget_->count())
312 d.tab_widget_->currentWidget()->setFocus();
316 QMenu* GuiViewBase::createPopupMenu()
318 return d.toolBarPopup(this);
322 void GuiViewBase::init()
324 // GuiToolbars *must* be initialised before GuiMenubar.
325 d.toolbars_ = new GuiToolbars(*this);
326 // FIXME: GuiToolbars::init() cannot be integrated in the ctor
327 // because LyXFunc::getStatus() needs a properly initialized
328 // GuiToolbars object (for LFUN_TOOLBAR_TOGGLE).
330 d.menubar_ = new GuiMenubar(this, menubackend);
332 statusBar()->setSizeGripEnabled(true);
334 QObject::connect(&statusbar_timer_, SIGNAL(timeout()),
335 this, SLOT(update_view_state_qt()));
338 d.stack_widget_->setCurrentWidget(d.bg_widget_);
342 void GuiViewBase::closeEvent(QCloseEvent * close_event)
344 // we may have been called through the close window button
345 // which bypasses the LFUN machinery.
346 if (!quitting_by_menu_ && theApp()->gui().viewIds().size() == 1) {
347 if (!theBufferList().quitWriteAll()) {
348 close_event->ignore();
353 // Make sure that no LFUN use this close to be closed View.
354 theLyXFunc().setLyXView(0);
355 // Make sure the timer time out will not trigger a statusbar update.
356 statusbar_timer_.stop();
358 theApp()->gui().unregisterView(id());
359 if (!theApp()->gui().viewIds().empty()) {
360 // Just close the window and do nothing else if this is not the
362 close_event->accept();
368 // this is the place where we leave the frontend.
369 // it is the only point at which we start quitting.
371 close_event->accept();
372 // quit the event loop
377 void GuiViewBase::dragEnterEvent(QDragEnterEvent * event)
379 if (event->mimeData()->hasUrls())
381 /// \todo Ask lyx-devel is this is enough:
382 /// if (event->mimeData()->hasFormat("text/plain"))
383 /// event->acceptProposedAction();
387 void GuiViewBase::dropEvent(QDropEvent* event)
389 QList<QUrl> files = event->mimeData()->urls();
393 LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
394 << " got URLs!" << endl;
395 for (int i = 0; i != files.size(); ++i) {
396 string const file = support::os::internal_path(fromqstr(
397 files.at(i).toLocalFile()));
399 dispatch(FuncRequest(LFUN_FILE_OPEN, file));
404 void GuiViewBase::saveGeometry()
406 static bool done = false;
413 // change the ifdef to 'geometry = normalGeometry();' only
414 // when Trolltech has fixed the broken normalGeometry on X11:
415 // http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
416 // Then also the moveEvent, resizeEvent, and the
417 // code for floatingGeometry_ can be removed;
418 // adjust GuiViewBase::setGeometry()
420 QRect normal_geometry;
423 normal_geometry = normalGeometry();
425 maximized = CompletelyMaximized;
427 maximized = NotMaximized;
430 normal_geometry = updateFloatingGeometry();
432 QDesktopWidget& dw = *qApp->desktop();
433 QRect desk = dw.availableGeometry(dw.primaryScreen());
434 // Qt bug on Linux: load completely maximized, vert max. save-> frameGeometry().height() is wrong
435 if (isMaximized() && desk.width() <= frameGeometry().width() && desk.height() <= frameGeometry().height()) {
436 maximized = CompletelyMaximized;
437 // maximizing does not work when the window is allready hor. or vert. maximized
438 // Tested only on KDE
439 int dh = frameGeometry().height() - height();
440 if (desk.height() <= normal_geometry.height() + dh)
441 normal_geometry.setHeight(normal_geometry.height() - 1);
442 int dw = frameGeometry().width() - width();
443 if (desk.width() <= normal_geometry.width() + dw)
444 normal_geometry.setWidth(normal_geometry.width() - 1);
445 } else if (desk.height() <= frameGeometry().height()) {
446 maximized = VerticallyMaximized;
447 } else if (desk.width() <= frameGeometry().width()) {
448 maximized = HorizontallyMaximized;
450 maximized = NotMaximized;
455 // save windows size and position
456 Session & session = LyX::ref().session();
457 session.sessionInfo().save("WindowWidth", convert<string>(normal_geometry.width()));
458 session.sessionInfo().save("WindowHeight", convert<string>(normal_geometry.height()));
459 session.sessionInfo().save("WindowMaximized", convert<string>(maximized));
460 session.sessionInfo().save("IconSizeXY", convert<string>(iconSize().width()));
461 if (lyxrc.geometry_xysaved) {
462 session.sessionInfo().save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset));
463 session.sessionInfo().save("WindowPosY", convert<string>(normal_geometry.y() + d.posy_offset));
465 d.toolbars_->saveToolbarInfo();
469 void GuiViewBase::setGeometry(unsigned int width,
473 unsigned int iconSizeXY,
474 const string & geometryArg)
476 // use last value (not at startup)
477 if (d.lastIconSize != 0)
478 setIconSize(d.lastIconSize);
479 else if (iconSizeXY != 0)
480 setIconSize(iconSizeXY);
482 setIconSize(d.normalIconSize);
484 // only true when the -geometry option was NOT used
485 if (width != 0 && height != 0) {
486 if (posx != -1 && posy != -1) {
487 // if there are startup positioning problems:
488 // http://doc.trolltech.com/4.2/qdesktopwidget.html
489 QDesktopWidget& dw = *qApp->desktop();
490 if (dw.isVirtualDesktop()) {
491 if(!dw.geometry().contains(posx, posy)) {
496 // Which system doesn't use a virtual desktop?
497 // TODO save also last screen number and check if it is still availabe.
500 // FIXME: use setGeometry only when Trolltech has fixed the qt4/X11 bug
501 QWidget::setGeometry(posx, posy, width, height);
503 resize(width, height);
507 resize(width, height);
510 // remember original size
511 floatingGeometry_ = QRect(posx, posy, width, height);
513 if (maximized != NotMaximized) {
514 if (maximized == CompletelyMaximized) {
515 setWindowState(Qt::WindowMaximized);
518 // TODO How to set by the window manager?
519 // setWindowState(Qt::WindowVerticallyMaximized);
521 QDesktopWidget& dw = *qApp->desktop();
522 QRect desk = dw.availableGeometry(dw.primaryScreen());
523 if (maximized == VerticallyMaximized)
524 resize(width, desk.height());
525 if (maximized == HorizontallyMaximized)
526 resize(desk.width(), height);
533 // FIXME: move this code into parse_geometry() (LyX.cpp)
537 QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" );
538 re.indexIn(toqstr(geometryArg.c_str()));
539 w = re.cap(1).toInt();
540 h = re.cap(2).toInt();
541 x = re.cap(3).toInt();
542 y = re.cap(4).toInt();
543 QWidget::setGeometry( x, y, w, h );
554 // For an unknown reason, the Window title update is not effective for
555 // the second windows up until it is shown on screen (Qt bug?).
558 // after show geometry() has changed (Qt bug?)
559 // we compensate the drift when storing the position
562 if (width != 0 && height != 0)
563 if (posx != -1 && posy != -1) {
565 d.posx_offset = posx - normalGeometry().x();
566 d.posy_offset = posy - normalGeometry().y();
569 if (maximized == NotMaximized) {
570 d.posx_offset = posx - geometry().x();
571 d.posy_offset = posy - geometry().y();
579 void GuiViewBase::setWindowTitle(docstring const & t, docstring const & it)
581 QString title = windowTitle();
582 QString new_title = toqstr(t);
583 if (title != new_title) {
584 QMainWindow::setWindowTitle(new_title);
585 QMainWindow::setWindowIconText(toqstr(it));
587 if (Buffer const * buf = buffer())
588 d.tab_widget_->setTabText(d.tab_widget_->currentIndex(),
589 toqstr(makeDisplayPath(buf->fileName(), 30)));
593 void GuiViewBase::message(docstring const & str)
595 statusBar()->showMessage(toqstr(str));
596 statusbar_timer_.stop();
597 statusbar_timer_.start(statusbar_timer_value);
601 void GuiViewBase::clearMessage()
603 update_view_state_qt();
607 void GuiViewBase::setIconSize(unsigned int size)
609 d.lastIconSize = size;
610 QMainWindow::setIconSize(QSize(size, size));
614 void GuiViewBase::smallSizedIcons()
616 setIconSize(d.smallIconSize);
620 void GuiViewBase::normalSizedIcons()
622 setIconSize(d.normalIconSize);
626 void GuiViewBase::bigSizedIcons()
628 setIconSize(d.bigIconSize);
632 void GuiViewBase::update_view_state_qt()
636 theLyXFunc().setLyXView(this);
637 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
638 statusbar_timer_.stop();
642 void GuiViewBase::closeCurrentTab()
644 dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
648 void GuiViewBase::currentTabChanged(int i)
651 disconnectBufferView();
652 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
654 BufferView & bv = wa->bufferView();
655 connectBufferView(bv);
656 connectBuffer(bv.buffer());
657 bv.updateMetrics(false);
658 bv.cursor().fixIfBroken();
659 wa->setUpdatesEnabled(true);
664 // Buffer-dependent dialogs should be updated or
665 // hidden. This should go here because some dialogs (eg ToC)
666 // require bv_->text.
667 getDialogs().updateBufferDependent(true);
669 updateLayoutChoice();
673 LYXERR(Debug::GUI) << "currentTabChanged " << i
674 << "File" << bv.buffer().fileName() << endl;
678 void GuiViewBase::updateStatusBar()
680 // let the user see the explicit message
681 if (statusbar_timer_.isActive())
684 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
688 void GuiViewBase::activated(FuncRequest const & func)
694 bool GuiViewBase::hasFocus() const
696 return qApp->activeWindow() == this;
700 QRect GuiViewBase::updateFloatingGeometry()
702 QDesktopWidget& dw = *qApp->desktop();
703 QRect desk = dw.availableGeometry(dw.primaryScreen());
704 // remember only non-maximized sizes
705 if (!isMaximized() && desk.width() > frameGeometry().width() && desk.height() > frameGeometry().height()) {
706 floatingGeometry_ = QRect(x(), y(), width(), height());
708 return floatingGeometry_;
712 void GuiViewBase::resizeEvent(QResizeEvent *)
714 updateFloatingGeometry();
718 void GuiViewBase::moveEvent(QMoveEvent *)
720 updateFloatingGeometry();
724 bool GuiViewBase::event(QEvent * e)
728 // Useful debug code:
729 //case QEvent::ActivationChange:
730 //case QEvent::WindowDeactivate:
731 //case QEvent::Paint:
732 //case QEvent::Enter:
733 //case QEvent::Leave:
734 //case QEvent::HoverEnter:
735 //case QEvent::HoverLeave:
736 //case QEvent::HoverMove:
737 //case QEvent::StatusTip:
738 //case QEvent::DragEnter:
739 //case QEvent::DragLeave:
743 case QEvent::WindowActivate:
744 theApp()->setCurrentView(*this);
745 if (d.tab_widget_->count()) {
746 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(
747 d.tab_widget_->currentWidget());
749 BufferView & bv = wa->bufferView();
750 connectBufferView(bv);
751 connectBuffer(bv.buffer());
752 // The document structure, name and dialogs might have
753 // changed in another view.
756 getDialogs().updateBufferDependent(true);
758 return QMainWindow::event(e);
760 case QEvent::ShortcutOverride: {
761 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
762 if (d.tab_widget_->count() == 0) {
763 theLyXFunc().setLyXView(this);
765 setKeySymbol(&sym, ke);
766 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
770 if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
772 setKeySymbol(&sym, ke);
773 currentWorkArea()->processKeySym(sym, NoModifier);
779 return QMainWindow::event(e);
784 bool GuiViewBase::focusNextPrevChild(bool /*next*/)
791 void GuiViewBase::showView()
793 QMainWindow::setWindowTitle(qt_("LyX"));
795 updateFloatingGeometry();
799 void GuiViewBase::busy(bool yes)
801 if (d.tab_widget_->count()) {
802 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
804 wa->setUpdatesEnabled(!yes);
806 wa->stopBlinkingCursor();
808 wa->startBlinkingCursor();
812 QApplication::setOverrideCursor(Qt::WaitCursor);
814 QApplication::restoreOverrideCursor();
818 GuiToolbar * GuiViewBase::makeToolbar(ToolbarInfo const & tbinfo, bool newline)
820 GuiToolbar * toolBar = new GuiToolbar(tbinfo, *this);
822 if (tbinfo.flags & ToolbarInfo::TOP) {
824 addToolBarBreak(Qt::TopToolBarArea);
825 addToolBar(Qt::TopToolBarArea, toolBar);
828 if (tbinfo.flags & ToolbarInfo::BOTTOM) {
829 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
830 #if (QT_VERSION >= 0x040202)
832 addToolBarBreak(Qt::BottomToolBarArea);
834 addToolBar(Qt::BottomToolBarArea, toolBar);
837 if (tbinfo.flags & ToolbarInfo::LEFT) {
838 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
839 #if (QT_VERSION >= 0x040202)
841 addToolBarBreak(Qt::LeftToolBarArea);
843 addToolBar(Qt::LeftToolBarArea, toolBar);
846 if (tbinfo.flags & ToolbarInfo::RIGHT) {
847 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
848 #if (QT_VERSION >= 0x040202)
850 addToolBarBreak(Qt::RightToolBarArea);
852 addToolBar(Qt::RightToolBarArea, toolBar);
855 // The following does not work so I cannot restore to exact toolbar location
857 ToolbarSection::ToolbarInfo & tbinfo = LyX::ref().session().toolbars().load(tbinfo.name);
858 toolBar->move(tbinfo.posx, tbinfo.posy);
865 WorkArea * GuiViewBase::workArea(Buffer & buffer)
867 for (int i = 0; i != d.tab_widget_->count(); ++i) {
868 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
870 if (&wa->bufferView().buffer() == &buffer)
877 WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
879 GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
880 wa->setUpdatesEnabled(false);
881 d.tab_widget_->addTab(wa, toqstr(makeDisplayPath(buffer.fileName(), 30)));
882 wa->bufferView().updateMetrics(false);
884 d.stack_widget_->setCurrentWidget(d.tab_widget_);
885 // Hide tabbar if there's only one tab.
886 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
891 WorkArea * GuiViewBase::currentWorkArea()
893 if (d.tab_widget_->count() == 0)
895 BOOST_ASSERT(dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget()));
896 return dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
900 WorkArea const * GuiViewBase::currentWorkArea() const
902 if (d.tab_widget_->count() == 0)
904 BOOST_ASSERT(dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget()));
905 return dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget());
909 void GuiViewBase::setCurrentWorkArea(WorkArea * work_area)
911 BOOST_ASSERT(work_area);
913 // Changing work area can result from opening a file so
914 // update the toc in any case.
917 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(work_area);
919 if (wa != d.tab_widget_->currentWidget())
920 // Switch to the work area.
921 d.tab_widget_->setCurrentWidget(wa);
923 // Make sure the work area is up to date.
924 currentTabChanged(d.tab_widget_->currentIndex());
929 void GuiViewBase::removeWorkArea(WorkArea * work_area)
931 BOOST_ASSERT(work_area);
932 if (work_area == currentWorkArea()) {
934 disconnectBufferView();
937 // removing a work area often results from closing a file so
938 // update the toc in any case.
941 GuiWorkArea * gwa = dynamic_cast<GuiWorkArea *>(work_area);
942 gwa->setUpdatesEnabled(false);
944 int index = d.tab_widget_->indexOf(gwa);
945 d.tab_widget_->removeTab(index);
949 if (d.tab_widget_->count()) {
950 // make sure the next work area is enabled.
951 d.tab_widget_->currentWidget()->setUpdatesEnabled(true);
952 // Hide tabbar if there's only one tab.
953 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
957 getDialogs().hideBufferDependent();
958 if (d.stack_widget_) {
959 // No more work area, switch to the background widget.
965 void GuiViewBase::showMiniBuffer(bool visible)
967 d.toolbars_->showCommandBuffer(visible);
971 void GuiViewBase::openMenu(docstring const & name)
973 d.menubar_->openByName(toqstr(name));
977 void GuiViewBase::openLayoutList()
979 d.toolbars_->openLayoutList();
983 void GuiViewBase::updateLayoutChoice()
985 // Don't show any layouts without a buffer
987 d.toolbars_->clearLayoutList();
991 // Update the layout display
992 if (d.toolbars_->updateLayoutList(buffer()->params().getTextClassPtr())) {
993 d.current_layout = buffer()->params().getTextClass().defaultLayoutName();
996 docstring const & layout = currentWorkArea()->bufferView().cursor().
997 innerParagraph().layout()->name();
999 if (layout != d.current_layout) {
1000 d.toolbars_->setLayout(layout);
1001 d.current_layout = layout;
1006 bool GuiViewBase::isToolbarVisible(std::string const & id)
1008 return d.toolbars_->visible(id);
1011 void GuiViewBase::updateToolbars()
1013 WorkArea * wa = currentWorkArea();
1016 wa->bufferView().cursor().inMathed();
1018 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
1020 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
1021 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1023 d.toolbars_->update(math, table, review);
1025 d.toolbars_->update(false, false, false);
1027 // update read-only status of open dialogs.
1028 getDialogs().checkStatus();
1032 ToolbarInfo * GuiViewBase::getToolbarInfo(string const & name)
1034 return d.toolbars_->getToolbarInfo(name);
1038 void GuiViewBase::toggleToolbarState(string const & name, bool allowauto)
1040 // it is possible to get current toolbar status like this,...
1041 // but I decide to obey the order of ToolbarBackend::flags
1042 // and disregard real toolbar status.
1043 // toolbars_->saveToolbarInfo();
1045 // toggle state on/off/auto
1046 d.toolbars_->toggleToolbarState(name, allowauto);
1052 } // namespace frontend
1055 #include "GuiView_moc.cpp"