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"
42 #include "FuncRequest.h"
47 #include "MenuBackend.h"
48 #include "Paragraph.h"
52 #include <boost/current_function.hpp>
55 #include <QApplication>
56 #include <QCloseEvent>
57 #include <QDesktopWidget>
58 #include <QDragEnterEvent>
64 #include <QPushButton>
65 #include <QStackedWidget>
78 using support::FileName;
79 using support::libFileSearch;
80 using support::makeDisplayPath;
86 int const statusbar_timer_value = 3000;
88 class BackgroundWidget : public QWidget
91 BackgroundWidget(QString const & file, QString const & text)
93 splash_ = new QPixmap(file);
95 lyxerr << "could not load splash screen: '" << fromqstr(file) << "'" << endl;
99 QPainter pain(splash_);
100 pain.setPen(QColor(255, 255, 0));
102 // The font used to display the version info
103 font.setStyleHint(QFont::SansSerif);
104 font.setWeight(QFont::Bold);
105 font.setPointSize(convert<int>(lyxrc.font_sizes[Font::SIZE_LARGE]));
107 pain.drawText(260, 270, text);
110 void paintEvent(QPaintEvent *)
115 int x = (width() - splash_->width()) / 2;
116 int y = (height() - splash_->height()) / 2;
118 pain.drawPixmap(x, y, *splash_);
126 class TabWidget : public QTabWidget {
128 void showBar(bool show) { tabBar()->setVisible(show); }
135 struct GuiViewBase::GuiViewPrivate
142 TabWidget * tab_widget_;
143 QStackedWidget * stack_widget_;
144 BackgroundWidget * bg_widget_;
146 GuiMenubar * menubar_;
148 GuiToolbars * toolbars_;
150 docstring current_layout;
152 GuiViewPrivate() : posx_offset(0), posy_offset(0) {}
154 unsigned int smallIconSize;
155 unsigned int normalIconSize;
156 unsigned int bigIconSize;
157 // static needed by "New Window"
158 static unsigned int lastIconSize;
160 QMenu * toolBarPopup(GuiViewBase * parent)
162 // FIXME: translation
163 QMenu * menu = new QMenu(parent);
164 QActionGroup * iconSizeGroup = new QActionGroup(parent);
166 QAction * smallIcons = new QAction(iconSizeGroup);
167 smallIcons->setText(qt_("Small-sized icons"));
168 smallIcons->setCheckable(true);
169 QObject::connect(smallIcons, SIGNAL(triggered()), parent, SLOT(smallSizedIcons()));
170 menu->addAction(smallIcons);
172 QAction * normalIcons = new QAction(iconSizeGroup);
173 normalIcons->setText(qt_("Normal-sized icons"));
174 normalIcons->setCheckable(true);
175 QObject::connect(normalIcons, SIGNAL(triggered()), parent, SLOT(normalSizedIcons()));
176 menu->addAction(normalIcons);
178 QAction * bigIcons = new QAction(iconSizeGroup);
179 bigIcons->setText(qt_("Big-sized icons"));
180 bigIcons->setCheckable(true);
181 QObject::connect(bigIcons, SIGNAL(triggered()), parent, SLOT(bigSizedIcons()));
182 menu->addAction(bigIcons);
184 unsigned int cur = parent->iconSize().width();
185 if ( cur == parent->d.smallIconSize)
186 smallIcons->setChecked(true);
187 else if (cur == parent->d.normalIconSize)
188 normalIcons->setChecked(true);
189 else if (cur == parent->d.bigIconSize)
190 bigIcons->setChecked(true);
195 void initBackground()
198 LYXERR(Debug::GUI) << "show banner: " << lyxrc.show_banner << endl;
199 /// The text to be written on top of the pixmap
200 QString const text = lyx_version ? QString(lyx_version) : qt_("unknown version");
201 FileName const file = support::libFileSearch("images", "banner", "png");
205 bg_widget_ = new BackgroundWidget(toqstr(file.absFilename()), text);
213 stack_widget_->setCurrentWidget(bg_widget_);
214 bg_widget_->setUpdatesEnabled(true);
219 unsigned int GuiViewBase::GuiViewPrivate::lastIconSize = 0;
222 GuiViewBase::GuiViewBase(int id)
223 : QMainWindow(), LyXView(id), quitting_by_menu_(false),
224 d(*new GuiViewPrivate)
226 // Qt bug? signal lastWindowClosed does not work
227 setAttribute(Qt::WA_QuitOnClose, false);
228 setAttribute(Qt::WA_DeleteOnClose, true);
230 // hardcode here the platform specific icon size
231 d.smallIconSize = 14; // scaling problems
232 d.normalIconSize = 20; // ok, default
233 d.bigIconSize = 26; // better for some math icons
236 // assign an icon to main form. We do not do it under Qt/Mac,
237 // since the icon is provided in the application bundle.
238 FileName const iconname = libFileSearch("images", "lyx", "png");
239 if (!iconname.empty())
240 setWindowIcon(QPixmap(toqstr(iconname.absFilename())));
243 d.tab_widget_ = new TabWidget;
245 QPushButton * closeTabButton = new QPushButton(this);
246 FileName const file = support::libFileSearch("images", "closetab", "png");
248 QPixmap pm(toqstr(file.absFilename()));
249 closeTabButton->setIcon(QIcon(pm));
250 closeTabButton->setMaximumSize(pm.size());
251 closeTabButton->setFlat(true);
253 closeTabButton->setText("Close");
255 closeTabButton->setCursor(Qt::ArrowCursor);
256 closeTabButton->setToolTip(tr("Close tab"));
257 closeTabButton->setEnabled(true);
259 QObject::connect(d.tab_widget_, SIGNAL(currentChanged(int)),
260 this, SLOT(currentTabChanged(int)));
261 QObject::connect(closeTabButton, SIGNAL(clicked()),
262 this, SLOT(closeCurrentTab()));
264 d.tab_widget_->setCornerWidget(closeTabButton);
265 #if QT_VERSION >= 0x040200
266 d.tab_widget_->setUsesScrollButtons(true);
271 LYXERR(Debug::GUI) << "stack widget!" << endl;
272 d.stack_widget_ = new QStackedWidget;
273 d.stack_widget_->addWidget(d.bg_widget_);
274 d.stack_widget_->addWidget(d.tab_widget_);
275 setCentralWidget(d.stack_widget_);
278 setCentralWidget(d.tab_widget_);
282 setAcceptDrops(true);
286 GuiViewBase::~GuiViewBase()
294 void GuiViewBase::close()
296 quitting_by_menu_ = true;
297 QMainWindow::close();
298 quitting_by_menu_ = false;
302 void GuiViewBase::setFocus()
304 if (d.tab_widget_->count())
305 d.tab_widget_->currentWidget()->setFocus();
309 QMenu* GuiViewBase::createPopupMenu()
311 return d.toolBarPopup(this);
315 void GuiViewBase::init()
317 // GuiToolbars *must* be initialised before GuiMenubar.
318 d.toolbars_ = new GuiToolbars(*this);
319 // FIXME: GuiToolbars::init() cannot be integrated in the ctor
320 // because LyXFunc::getStatus() needs a properly initialized
321 // GuiToolbars object (for LFUN_TOOLBAR_TOGGLE).
323 d.menubar_ = new GuiMenubar(this, menubackend);
325 statusBar()->setSizeGripEnabled(true);
327 QObject::connect(&statusbar_timer_, SIGNAL(timeout()),
328 this, SLOT(update_view_state_qt()));
331 d.stack_widget_->setCurrentWidget(d.bg_widget_);
335 void GuiViewBase::closeEvent(QCloseEvent * close_event)
337 // we may have been called through the close window button
338 // which bypasses the LFUN machinery.
339 if (!quitting_by_menu_ && theApp()->gui().viewIds().size() == 1) {
340 if (!theBufferList().quitWriteAll()) {
341 close_event->ignore();
346 // Make sure that no LFUN use this close to be closed View.
347 theLyXFunc().setLyXView(0);
348 // Make sure the timer time out will not trigger a statusbar update.
349 statusbar_timer_.stop();
351 theApp()->gui().unregisterView(id());
352 if (!theApp()->gui().viewIds().empty()) {
353 // Just close the window and do nothing else if this is not the
355 close_event->accept();
361 // this is the place where we leave the frontend.
362 // it is the only point at which we start quitting.
364 close_event->accept();
365 // quit the event loop
370 void GuiViewBase::dragEnterEvent(QDragEnterEvent * event)
372 if (event->mimeData()->hasUrls())
374 /// \todo Ask lyx-devel is this is enough:
375 /// if (event->mimeData()->hasFormat("text/plain"))
376 /// event->acceptProposedAction();
380 void GuiViewBase::dropEvent(QDropEvent* event)
382 QList<QUrl> files = event->mimeData()->urls();
386 LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
387 << " got URLs!" << endl;
388 for (int i = 0; i != files.size(); ++i) {
389 string const file = support::os::internal_path(fromqstr(
390 files.at(i).toLocalFile()));
392 dispatch(FuncRequest(LFUN_FILE_OPEN, file));
397 void GuiViewBase::saveGeometry()
399 static bool done = false;
406 // change the ifdef to 'geometry = normalGeometry();' only
407 // when Trolltech has fixed the broken normalGeometry on X11:
408 // http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
409 // Then also the moveEvent, resizeEvent, and the
410 // code for floatingGeometry_ can be removed;
411 // adjust GuiViewBase::setGeometry()
413 QRect normal_geometry;
416 normal_geometry = normalGeometry();
418 maximized = CompletelyMaximized;
420 maximized = NotMaximized;
423 normal_geometry = updateFloatingGeometry();
425 QDesktopWidget& dw = *qApp->desktop();
426 QRect desk = dw.availableGeometry(dw.primaryScreen());
427 // Qt bug on Linux: load completely maximized, vert max. save-> frameGeometry().height() is wrong
428 if (isMaximized() && desk.width() <= frameGeometry().width() && desk.height() <= frameGeometry().height()) {
429 maximized = CompletelyMaximized;
430 // maximizing does not work when the window is allready hor. or vert. maximized
431 // Tested only on KDE
432 int dh = frameGeometry().height() - height();
433 if (desk.height() <= normal_geometry.height() + dh)
434 normal_geometry.setHeight(normal_geometry.height() - 1);
435 int dw = frameGeometry().width() - width();
436 if (desk.width() <= normal_geometry.width() + dw)
437 normal_geometry.setWidth(normal_geometry.width() - 1);
438 } else if (desk.height() <= frameGeometry().height()) {
439 maximized = VerticallyMaximized;
440 } else if (desk.width() <= frameGeometry().width()) {
441 maximized = HorizontallyMaximized;
443 maximized = NotMaximized;
448 // save windows size and position
449 Session & session = LyX::ref().session();
450 session.sessionInfo().save("WindowWidth", convert<string>(normal_geometry.width()));
451 session.sessionInfo().save("WindowHeight", convert<string>(normal_geometry.height()));
452 session.sessionInfo().save("WindowMaximized", convert<string>(maximized));
453 session.sessionInfo().save("IconSizeXY", convert<string>(iconSize().width()));
454 if (lyxrc.geometry_xysaved) {
455 session.sessionInfo().save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset));
456 session.sessionInfo().save("WindowPosY", convert<string>(normal_geometry.y() + d.posy_offset));
458 d.toolbars_->saveToolbarInfo();
462 void GuiViewBase::setGeometry(unsigned int width,
466 unsigned int iconSizeXY,
467 const string & geometryArg)
469 // use last value (not at startup)
470 if (d.lastIconSize != 0)
471 setIconSize(d.lastIconSize);
472 else if (iconSizeXY != 0)
473 setIconSize(iconSizeXY);
475 setIconSize(d.normalIconSize);
477 // only true when the -geometry option was NOT used
478 if (width != 0 && height != 0) {
479 if (posx != -1 && posy != -1) {
480 // if there are startup positioning problems:
481 // http://doc.trolltech.com/4.2/qdesktopwidget.html
482 QDesktopWidget& dw = *qApp->desktop();
483 if (dw.isVirtualDesktop()) {
484 if(!dw.geometry().contains(posx, posy)) {
489 // Which system doesn't use a virtual desktop?
490 // TODO save also last screen number and check if it is still availabe.
493 // FIXME: use setGeometry only when Trolltech has fixed the qt4/X11 bug
494 QWidget::setGeometry(posx, posy, width, height);
496 resize(width, height);
500 resize(width, height);
503 // remember original size
504 floatingGeometry_ = QRect(posx, posy, width, height);
506 if (maximized != NotMaximized) {
507 if (maximized == CompletelyMaximized) {
508 setWindowState(Qt::WindowMaximized);
511 // TODO How to set by the window manager?
512 // setWindowState(Qt::WindowVerticallyMaximized);
514 QDesktopWidget& dw = *qApp->desktop();
515 QRect desk = dw.availableGeometry(dw.primaryScreen());
516 if (maximized == VerticallyMaximized)
517 resize(width, desk.height());
518 if (maximized == HorizontallyMaximized)
519 resize(desk.width(), height);
526 // FIXME: move this code into parse_geometry() (LyX.cpp)
530 QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" );
531 re.indexIn(toqstr(geometryArg.c_str()));
532 w = re.cap(1).toInt();
533 h = re.cap(2).toInt();
534 x = re.cap(3).toInt();
535 y = re.cap(4).toInt();
536 QWidget::setGeometry( x, y, w, h );
547 // For an unknown reason, the Window title update is not effective for
548 // the second windows up until it is shown on screen (Qt bug?).
551 // after show geometry() has changed (Qt bug?)
552 // we compensate the drift when storing the position
555 if (width != 0 && height != 0)
556 if (posx != -1 && posy != -1) {
558 d.posx_offset = posx - normalGeometry().x();
559 d.posy_offset = posy - normalGeometry().y();
562 if (maximized == NotMaximized) {
563 d.posx_offset = posx - geometry().x();
564 d.posy_offset = posy - geometry().y();
572 void GuiViewBase::setWindowTitle(docstring const & t, docstring const & it)
574 QString title = windowTitle();
575 QString new_title = toqstr(t);
576 if (title != new_title) {
577 QMainWindow::setWindowTitle(new_title);
578 QMainWindow::setWindowIconText(toqstr(it));
583 void GuiViewBase::message(docstring const & str)
585 statusBar()->showMessage(toqstr(str));
586 statusbar_timer_.stop();
587 statusbar_timer_.start(statusbar_timer_value);
591 void GuiViewBase::clearMessage()
593 update_view_state_qt();
597 void GuiViewBase::setIconSize(unsigned int size)
599 d.lastIconSize = size;
600 QMainWindow::setIconSize(QSize(size, size));
604 void GuiViewBase::smallSizedIcons()
606 setIconSize(d.smallIconSize);
610 void GuiViewBase::normalSizedIcons()
612 setIconSize(d.normalIconSize);
616 void GuiViewBase::bigSizedIcons()
618 setIconSize(d.bigIconSize);
622 void GuiViewBase::update_view_state_qt()
626 theLyXFunc().setLyXView(this);
627 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
628 statusbar_timer_.stop();
632 void GuiViewBase::closeCurrentTab()
634 dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
638 void GuiViewBase::currentTabChanged(int i)
641 disconnectBufferView();
642 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
644 BufferView & bv = wa->bufferView();
645 connectBufferView(bv);
646 connectBuffer(bv.buffer());
647 bv.updateMetrics(false);
648 bv.cursor().fixIfBroken();
649 wa->setUpdatesEnabled(true);
654 // Buffer-dependent dialogs should be updated or
655 // hidden. This should go here because some dialogs (eg ToC)
656 // require bv_->text.
657 getDialogs().updateBufferDependent(true);
659 updateLayoutChoice();
663 LYXERR(Debug::GUI) << "currentTabChanged " << i
664 << "File" << bv.buffer().fileName() << endl;
668 void GuiViewBase::updateStatusBar()
670 // let the user see the explicit message
671 if (statusbar_timer_.isActive())
674 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
678 void GuiViewBase::activated(FuncRequest const & func)
684 bool GuiViewBase::hasFocus() const
686 return qApp->activeWindow() == this;
690 QRect GuiViewBase::updateFloatingGeometry()
692 QDesktopWidget& dw = *qApp->desktop();
693 QRect desk = dw.availableGeometry(dw.primaryScreen());
694 // remember only non-maximized sizes
695 if (!isMaximized() && desk.width() > frameGeometry().width() && desk.height() > frameGeometry().height()) {
696 floatingGeometry_ = QRect(x(), y(), width(), height());
698 return floatingGeometry_;
702 void GuiViewBase::resizeEvent(QResizeEvent *)
704 updateFloatingGeometry();
708 void GuiViewBase::moveEvent(QMoveEvent *)
710 updateFloatingGeometry();
714 bool GuiViewBase::event(QEvent * e)
718 // Useful debug code:
719 //case QEvent::WindowActivate:
720 //case QEvent::ActivationChange:
721 //case QEvent::WindowDeactivate:
722 //case QEvent::Paint:
723 //case QEvent::Enter:
724 //case QEvent::Leave:
725 //case QEvent::HoverEnter:
726 //case QEvent::HoverLeave:
727 //case QEvent::HoverMove:
728 //case QEvent::StatusTip:
729 //case QEvent::DragEnter:
730 //case QEvent::DragLeave:
734 case QEvent::ShortcutOverride: {
735 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
736 if (d.tab_widget_->count() == 0) {
737 theLyXFunc().setLyXView(this);
739 setKeySymbol(&sym, ke);
740 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
744 if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
746 setKeySymbol(&sym, ke);
747 currentWorkArea()->processKeySym(sym, key_modifier::none);
753 return QMainWindow::event(e);
758 bool GuiViewBase::focusNextPrevChild(bool /*next*/)
765 void GuiViewBase::showView()
767 QMainWindow::setWindowTitle(qt_("LyX"));
769 updateFloatingGeometry();
773 void GuiViewBase::busy(bool yes)
775 if (d.tab_widget_->count()) {
776 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
778 wa->setUpdatesEnabled(!yes);
780 wa->stopBlinkingCursor();
782 wa->startBlinkingCursor();
786 QApplication::setOverrideCursor(Qt::WaitCursor);
788 QApplication::restoreOverrideCursor();
792 GuiToolbar * GuiViewBase::makeToolbar(ToolbarInfo const & tbinfo, bool newline)
794 GuiToolbar * toolBar = new GuiToolbar(tbinfo, *this);
796 if (tbinfo.flags & ToolbarInfo::TOP) {
798 addToolBarBreak(Qt::TopToolBarArea);
799 addToolBar(Qt::TopToolBarArea, toolBar);
802 if (tbinfo.flags & ToolbarInfo::BOTTOM) {
803 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
804 #if (QT_VERSION >= 0x040202)
806 addToolBarBreak(Qt::BottomToolBarArea);
808 addToolBar(Qt::BottomToolBarArea, toolBar);
811 if (tbinfo.flags & ToolbarInfo::LEFT) {
812 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
813 #if (QT_VERSION >= 0x040202)
815 addToolBarBreak(Qt::LeftToolBarArea);
817 addToolBar(Qt::LeftToolBarArea, toolBar);
820 if (tbinfo.flags & ToolbarInfo::RIGHT) {
821 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
822 #if (QT_VERSION >= 0x040202)
824 addToolBarBreak(Qt::RightToolBarArea);
826 addToolBar(Qt::RightToolBarArea, toolBar);
829 // The following does not work so I cannot restore to exact toolbar location
831 ToolbarSection::ToolbarInfo & tbinfo = LyX::ref().session().toolbars().load(tbinfo.name);
832 toolBar->move(tbinfo.posx, tbinfo.posy);
839 WorkArea * GuiViewBase::workArea(Buffer & buffer)
841 for (int i = 0; i != d.tab_widget_->count(); ++i) {
842 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
844 if (&wa->bufferView().buffer() == &buffer)
851 WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
853 GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
854 wa->setUpdatesEnabled(false);
855 d.tab_widget_->addTab(wa, toqstr(makeDisplayPath(buffer.fileName(), 30)));
856 wa->bufferView().updateMetrics(false);
858 d.stack_widget_->setCurrentWidget(d.tab_widget_);
859 // Hide tabbar if there's only one tab.
860 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
865 WorkArea * GuiViewBase::currentWorkArea()
867 if (d.tab_widget_->count() == 0)
869 BOOST_ASSERT(dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget()));
870 return dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
874 WorkArea const * GuiViewBase::currentWorkArea() const
876 if (d.tab_widget_->count() == 0)
878 BOOST_ASSERT(dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget()));
879 return dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget());
883 void GuiViewBase::setCurrentWorkArea(WorkArea * work_area)
885 BOOST_ASSERT(work_area);
887 // Changing work area can result from opening a file so
888 // update the toc in any case.
891 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(work_area);
893 if (wa != d.tab_widget_->currentWidget())
894 // Switch to the work area.
895 d.tab_widget_->setCurrentWidget(wa);
897 // Make sure the work area is up to date.
898 currentTabChanged(d.tab_widget_->currentIndex());
903 void GuiViewBase::removeWorkArea(WorkArea * work_area)
905 BOOST_ASSERT(work_area);
906 if (work_area == currentWorkArea()) {
908 disconnectBufferView();
911 // removing a work area often results from closing a file so
912 // update the toc in any case.
915 GuiWorkArea * gwa = dynamic_cast<GuiWorkArea *>(work_area);
916 gwa->setUpdatesEnabled(false);
918 int index = d.tab_widget_->indexOf(gwa);
919 d.tab_widget_->removeTab(index);
923 if (d.tab_widget_->count()) {
924 // make sure the next work area is enabled.
925 d.tab_widget_->currentWidget()->setUpdatesEnabled(true);
926 // Hide tabbar if there's only one tab.
927 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
931 getDialogs().hideBufferDependent();
932 if (d.stack_widget_) {
933 // No more work area, switch to the background widget.
939 void GuiViewBase::showMiniBuffer(bool visible)
941 d.toolbars_->showCommandBuffer(visible);
945 void GuiViewBase::openMenu(docstring const & name)
947 d.menubar_->openByName(toqstr(name));
951 void GuiViewBase::openLayoutList()
953 d.toolbars_->openLayoutList();
957 void GuiViewBase::updateLayoutChoice()
959 // Don't show any layouts without a buffer
961 d.toolbars_->clearLayoutList();
965 // Update the layout display
966 if (d.toolbars_->updateLayoutList(buffer()->params().getTextClassPtr())) {
967 d.current_layout = buffer()->params().getTextClass().defaultLayoutName();
970 docstring const & layout = currentWorkArea()->bufferView().cursor().
971 innerParagraph().layout()->name();
973 if (layout != d.current_layout) {
974 d.toolbars_->setLayout(layout);
975 d.current_layout = layout;
980 bool GuiViewBase::isToolbarVisible(std::string const & id)
982 return d.toolbars_->visible(id);
985 void GuiViewBase::updateToolbars()
987 WorkArea * wa = currentWorkArea();
990 wa->bufferView().cursor().inMathed();
992 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
994 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
995 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
997 d.toolbars_->update(math, table, review);
999 d.toolbars_->update(false, false, false);
1001 // update read-only status of open dialogs.
1002 getDialogs().checkStatus();
1006 ToolbarInfo * GuiViewBase::getToolbarInfo(string const & name)
1008 return d.toolbars_->getToolbarInfo(name);
1012 void GuiViewBase::toggleToolbarState(string const & name, bool allowauto)
1014 // it is possible to get current toolbar status like this,...
1015 // but I decide to obey the order of ToolbarBackend::flags
1016 // and disregard real toolbar status.
1017 // toolbars_->saveToolbarInfo();
1019 // toggle state on/off/auto
1020 d.toolbars_->toggleToolbarState(name, allowauto);
1026 } // namespace frontend
1029 #include "GuiView_moc.cpp"