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"
30 #include "frontends/WorkAreaManager.h"
32 #include "support/filetools.h"
33 #include "support/convert.h"
34 #include "support/lstrings.h"
35 #include "support/os.h"
38 #include "BufferParams.h"
39 #include "BufferView.h"
40 #include "BufferList.h"
43 #include "FuncRequest.h"
48 #include "MenuBackend.h"
49 #include "Paragraph.h"
53 #include <boost/current_function.hpp>
56 #include <QApplication>
57 #include <QCloseEvent>
58 #include <QDesktopWidget>
59 #include <QDragEnterEvent>
65 #include <QPushButton>
66 #include <QStackedWidget>
79 using support::FileName;
80 using support::libFileSearch;
81 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 QMainWindow::close();
299 quitting_by_menu_ = false;
303 void GuiViewBase::setFocus()
305 if (d.tab_widget_->count())
306 d.tab_widget_->currentWidget()->setFocus();
310 QMenu* GuiViewBase::createPopupMenu()
312 return d.toolBarPopup(this);
316 void GuiViewBase::init()
318 // GuiToolbars *must* be initialised before GuiMenubar.
319 d.toolbars_ = new GuiToolbars(*this);
320 // FIXME: GuiToolbars::init() cannot be integrated in the ctor
321 // because LyXFunc::getStatus() needs a properly initialized
322 // GuiToolbars object (for LFUN_TOOLBAR_TOGGLE).
324 d.menubar_ = new GuiMenubar(this, menubackend);
326 statusBar()->setSizeGripEnabled(true);
328 QObject::connect(&statusbar_timer_, SIGNAL(timeout()),
329 this, SLOT(update_view_state_qt()));
332 d.stack_widget_->setCurrentWidget(d.bg_widget_);
336 void GuiViewBase::closeEvent(QCloseEvent * close_event)
338 // we may have been called through the close window button
339 // which bypasses the LFUN machinery.
340 if (!quitting_by_menu_ && theApp()->gui().viewIds().size() == 1) {
341 if (!theBufferList().quitWriteAll()) {
342 close_event->ignore();
347 // Make sure that no LFUN use this close to be closed View.
348 theLyXFunc().setLyXView(0);
349 // Make sure the timer time out will not trigger a statusbar update.
350 statusbar_timer_.stop();
352 theApp()->gui().unregisterView(id());
353 if (!theApp()->gui().viewIds().empty()) {
354 // Just close the window and do nothing else if this is not the
356 close_event->accept();
362 // this is the place where we leave the frontend.
363 // it is the only point at which we start quitting.
365 close_event->accept();
366 // quit the event loop
371 void GuiViewBase::dragEnterEvent(QDragEnterEvent * event)
373 if (event->mimeData()->hasUrls())
375 /// \todo Ask lyx-devel is this is enough:
376 /// if (event->mimeData()->hasFormat("text/plain"))
377 /// event->acceptProposedAction();
381 void GuiViewBase::dropEvent(QDropEvent* event)
383 QList<QUrl> files = event->mimeData()->urls();
387 LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
388 << " got URLs!" << endl;
389 for (int i = 0; i != files.size(); ++i) {
390 string const file = support::os::internal_path(fromqstr(
391 files.at(i).toLocalFile()));
393 dispatch(FuncRequest(LFUN_FILE_OPEN, file));
398 void GuiViewBase::saveGeometry()
400 static bool done = false;
407 // change the ifdef to 'geometry = normalGeometry();' only
408 // when Trolltech has fixed the broken normalGeometry on X11:
409 // http://www.trolltech.com/developer/task-tracker/index_html?id=119684+&method=entry
410 // Then also the moveEvent, resizeEvent, and the
411 // code for floatingGeometry_ can be removed;
412 // adjust GuiViewBase::setGeometry()
414 QRect normal_geometry;
417 normal_geometry = normalGeometry();
419 maximized = CompletelyMaximized;
421 maximized = NotMaximized;
424 normal_geometry = updateFloatingGeometry();
426 QDesktopWidget& dw = *qApp->desktop();
427 QRect desk = dw.availableGeometry(dw.primaryScreen());
428 // Qt bug on Linux: load completely maximized, vert max. save-> frameGeometry().height() is wrong
429 if (isMaximized() && desk.width() <= frameGeometry().width() && desk.height() <= frameGeometry().height()) {
430 maximized = CompletelyMaximized;
431 // maximizing does not work when the window is allready hor. or vert. maximized
432 // Tested only on KDE
433 int dh = frameGeometry().height() - height();
434 if (desk.height() <= normal_geometry.height() + dh)
435 normal_geometry.setHeight(normal_geometry.height() - 1);
436 int dw = frameGeometry().width() - width();
437 if (desk.width() <= normal_geometry.width() + dw)
438 normal_geometry.setWidth(normal_geometry.width() - 1);
439 } else if (desk.height() <= frameGeometry().height()) {
440 maximized = VerticallyMaximized;
441 } else if (desk.width() <= frameGeometry().width()) {
442 maximized = HorizontallyMaximized;
444 maximized = NotMaximized;
449 // save windows size and position
450 Session & session = LyX::ref().session();
451 session.sessionInfo().save("WindowWidth", convert<string>(normal_geometry.width()));
452 session.sessionInfo().save("WindowHeight", convert<string>(normal_geometry.height()));
453 session.sessionInfo().save("WindowMaximized", convert<string>(maximized));
454 session.sessionInfo().save("IconSizeXY", convert<string>(iconSize().width()));
455 if (lyxrc.geometry_xysaved) {
456 session.sessionInfo().save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset));
457 session.sessionInfo().save("WindowPosY", convert<string>(normal_geometry.y() + d.posy_offset));
459 d.toolbars_->saveToolbarInfo();
463 void GuiViewBase::setGeometry(unsigned int width,
467 unsigned int iconSizeXY,
468 const string & geometryArg)
470 // use last value (not at startup)
471 if (d.lastIconSize != 0)
472 setIconSize(d.lastIconSize);
473 else if (iconSizeXY != 0)
474 setIconSize(iconSizeXY);
476 setIconSize(d.normalIconSize);
478 // only true when the -geometry option was NOT used
479 if (width != 0 && height != 0) {
480 if (posx != -1 && posy != -1) {
481 // if there are startup positioning problems:
482 // http://doc.trolltech.com/4.2/qdesktopwidget.html
483 QDesktopWidget& dw = *qApp->desktop();
484 if (dw.isVirtualDesktop()) {
485 if(!dw.geometry().contains(posx, posy)) {
490 // Which system doesn't use a virtual desktop?
491 // TODO save also last screen number and check if it is still availabe.
494 // FIXME: use setGeometry only when Trolltech has fixed the qt4/X11 bug
495 QWidget::setGeometry(posx, posy, width, height);
497 resize(width, height);
501 resize(width, height);
504 // remember original size
505 floatingGeometry_ = QRect(posx, posy, width, height);
507 if (maximized != NotMaximized) {
508 if (maximized == CompletelyMaximized) {
509 setWindowState(Qt::WindowMaximized);
512 // TODO How to set by the window manager?
513 // setWindowState(Qt::WindowVerticallyMaximized);
515 QDesktopWidget& dw = *qApp->desktop();
516 QRect desk = dw.availableGeometry(dw.primaryScreen());
517 if (maximized == VerticallyMaximized)
518 resize(width, desk.height());
519 if (maximized == HorizontallyMaximized)
520 resize(desk.width(), height);
527 // FIXME: move this code into parse_geometry() (LyX.cpp)
531 QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)([+-][0-9]*)){0,1}" );
532 re.indexIn(toqstr(geometryArg.c_str()));
533 w = re.cap(1).toInt();
534 h = re.cap(2).toInt();
535 x = re.cap(3).toInt();
536 y = re.cap(4).toInt();
537 QWidget::setGeometry( x, y, w, h );
548 // For an unknown reason, the Window title update is not effective for
549 // the second windows up until it is shown on screen (Qt bug?).
552 // after show geometry() has changed (Qt bug?)
553 // we compensate the drift when storing the position
556 if (width != 0 && height != 0)
557 if (posx != -1 && posy != -1) {
559 d.posx_offset = posx - normalGeometry().x();
560 d.posy_offset = posy - normalGeometry().y();
563 if (maximized == NotMaximized) {
564 d.posx_offset = posx - geometry().x();
565 d.posy_offset = posy - geometry().y();
573 void GuiViewBase::setWindowTitle(docstring const & t, docstring const & it)
575 QString title = windowTitle();
576 QString new_title = toqstr(t);
577 if (title != new_title) {
578 QMainWindow::setWindowTitle(new_title);
579 QMainWindow::setWindowIconText(toqstr(it));
584 void GuiViewBase::message(docstring const & str)
586 statusBar()->showMessage(toqstr(str));
587 statusbar_timer_.stop();
588 statusbar_timer_.start(statusbar_timer_value);
592 void GuiViewBase::clearMessage()
594 update_view_state_qt();
598 void GuiViewBase::setIconSize(unsigned int size)
600 d.lastIconSize = size;
601 QMainWindow::setIconSize(QSize(size, size));
605 void GuiViewBase::smallSizedIcons()
607 setIconSize(d.smallIconSize);
611 void GuiViewBase::normalSizedIcons()
613 setIconSize(d.normalIconSize);
617 void GuiViewBase::bigSizedIcons()
619 setIconSize(d.bigIconSize);
623 void GuiViewBase::update_view_state_qt()
627 theLyXFunc().setLyXView(this);
628 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
629 statusbar_timer_.stop();
633 void GuiViewBase::closeCurrentTab()
635 dispatch(FuncRequest(LFUN_BUFFER_CLOSE));
639 void GuiViewBase::currentTabChanged(int i)
642 disconnectBufferView();
643 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
645 BufferView & bv = wa->bufferView();
646 connectBufferView(bv);
647 connectBuffer(bv.buffer());
648 bv.updateMetrics(false);
649 bv.cursor().fixIfBroken();
650 wa->setUpdatesEnabled(true);
655 // Buffer-dependent dialogs should be updated or
656 // hidden. This should go here because some dialogs (eg ToC)
657 // require bv_->text.
658 getDialogs().updateBufferDependent(true);
660 updateLayoutChoice();
664 LYXERR(Debug::GUI) << "currentTabChanged " << i
665 << "File" << bv.buffer().fileName() << endl;
669 void GuiViewBase::updateStatusBar()
671 // let the user see the explicit message
672 if (statusbar_timer_.isActive())
675 statusBar()->showMessage(toqstr(theLyXFunc().viewStatusMessage()));
679 void GuiViewBase::activated(FuncRequest const & func)
685 bool GuiViewBase::hasFocus() const
687 return qApp->activeWindow() == this;
691 QRect GuiViewBase::updateFloatingGeometry()
693 QDesktopWidget& dw = *qApp->desktop();
694 QRect desk = dw.availableGeometry(dw.primaryScreen());
695 // remember only non-maximized sizes
696 if (!isMaximized() && desk.width() > frameGeometry().width() && desk.height() > frameGeometry().height()) {
697 floatingGeometry_ = QRect(x(), y(), width(), height());
699 return floatingGeometry_;
703 void GuiViewBase::resizeEvent(QResizeEvent *)
705 updateFloatingGeometry();
709 void GuiViewBase::moveEvent(QMoveEvent *)
711 updateFloatingGeometry();
715 bool GuiViewBase::event(QEvent * e)
719 // Useful debug code:
720 //case QEvent::WindowActivate:
721 //case QEvent::ActivationChange:
722 //case QEvent::WindowDeactivate:
723 //case QEvent::Paint:
724 //case QEvent::Enter:
725 //case QEvent::Leave:
726 //case QEvent::HoverEnter:
727 //case QEvent::HoverLeave:
728 //case QEvent::HoverMove:
729 //case QEvent::StatusTip:
730 //case QEvent::DragEnter:
731 //case QEvent::DragLeave:
735 case QEvent::ShortcutOverride: {
736 QKeyEvent * ke = static_cast<QKeyEvent*>(e);
737 if (d.tab_widget_->count() == 0) {
738 theLyXFunc().setLyXView(this);
740 setKeySymbol(&sym, ke);
741 theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
745 if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
747 setKeySymbol(&sym, ke);
748 currentWorkArea()->processKeySym(sym, key_modifier::none);
754 return QMainWindow::event(e);
759 bool GuiViewBase::focusNextPrevChild(bool /*next*/)
766 void GuiViewBase::showView()
768 QMainWindow::setWindowTitle(qt_("LyX"));
770 updateFloatingGeometry();
774 void GuiViewBase::busy(bool yes)
776 if (d.tab_widget_->count()) {
777 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
779 wa->setUpdatesEnabled(!yes);
781 wa->stopBlinkingCursor();
783 wa->startBlinkingCursor();
787 QApplication::setOverrideCursor(Qt::WaitCursor);
789 QApplication::restoreOverrideCursor();
793 GuiToolbar * GuiViewBase::makeToolbar(ToolbarInfo const & tbinfo, bool newline)
795 GuiToolbar * toolBar = new GuiToolbar(tbinfo, *this);
797 if (tbinfo.flags & ToolbarInfo::TOP) {
799 addToolBarBreak(Qt::TopToolBarArea);
800 addToolBar(Qt::TopToolBarArea, toolBar);
803 if (tbinfo.flags & ToolbarInfo::BOTTOM) {
804 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
805 #if (QT_VERSION >= 0x040202)
807 addToolBarBreak(Qt::BottomToolBarArea);
809 addToolBar(Qt::BottomToolBarArea, toolBar);
812 if (tbinfo.flags & ToolbarInfo::LEFT) {
813 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
814 #if (QT_VERSION >= 0x040202)
816 addToolBarBreak(Qt::LeftToolBarArea);
818 addToolBar(Qt::LeftToolBarArea, toolBar);
821 if (tbinfo.flags & ToolbarInfo::RIGHT) {
822 // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
823 #if (QT_VERSION >= 0x040202)
825 addToolBarBreak(Qt::RightToolBarArea);
827 addToolBar(Qt::RightToolBarArea, toolBar);
830 // The following does not work so I cannot restore to exact toolbar location
832 ToolbarSection::ToolbarInfo & tbinfo = LyX::ref().session().toolbars().load(tbinfo.name);
833 toolBar->move(tbinfo.posx, tbinfo.posy);
840 WorkArea * GuiViewBase::workArea(Buffer & buffer)
842 for (int i = 0; i != d.tab_widget_->count(); ++i) {
843 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
845 if (&wa->bufferView().buffer() == &buffer)
852 WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
854 GuiWorkArea * wa = new GuiWorkArea(buffer, *this);
855 wa->setUpdatesEnabled(false);
856 d.tab_widget_->addTab(wa, toqstr(makeDisplayPath(buffer.fileName(), 30)));
857 wa->bufferView().updateMetrics(false);
859 d.stack_widget_->setCurrentWidget(d.tab_widget_);
860 // Hide tabbar if there's only one tab.
861 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
863 buffer.workAreaManager()->add(wa);
868 WorkArea * GuiViewBase::currentWorkArea()
870 if (d.tab_widget_->count() == 0)
872 BOOST_ASSERT(dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget()));
873 return dynamic_cast<GuiWorkArea *>(d.tab_widget_->currentWidget());
877 WorkArea const * GuiViewBase::currentWorkArea() const
879 if (d.tab_widget_->count() == 0)
881 BOOST_ASSERT(dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget()));
882 return dynamic_cast<GuiWorkArea const *>(d.tab_widget_->currentWidget());
886 void GuiViewBase::setCurrentWorkArea(WorkArea * work_area)
888 BOOST_ASSERT(work_area);
890 // Changing work area can result from opening a file so
891 // update the toc in any case.
894 GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(work_area);
896 if (wa != d.tab_widget_->currentWidget())
897 // Switch to the work area.
898 d.tab_widget_->setCurrentWidget(wa);
900 // Make sure the work area is up to date.
901 currentTabChanged(d.tab_widget_->currentIndex());
906 void GuiViewBase::removeWorkArea(WorkArea * work_area)
908 BOOST_ASSERT(work_area);
909 if (work_area == currentWorkArea()) {
911 disconnectBufferView();
914 // removing a work area often results from closing a file so
915 // update the toc in any case.
918 GuiWorkArea * gwa = dynamic_cast<GuiWorkArea *>(work_area);
919 gwa->setUpdatesEnabled(false);
921 int index = d.tab_widget_->indexOf(gwa);
922 d.tab_widget_->removeTab(index);
926 if (d.tab_widget_->count()) {
927 // make sure the next work area is enabled.
928 d.tab_widget_->currentWidget()->setUpdatesEnabled(true);
929 // Hide tabbar if there's only one tab.
930 d.tab_widget_->showBar(d.tab_widget_->count() > 1);
934 getDialogs().hideBufferDependent();
935 if (d.stack_widget_) {
936 // No more work area, switch to the background widget.
942 void GuiViewBase::showMiniBuffer(bool visible)
944 d.toolbars_->showCommandBuffer(visible);
948 void GuiViewBase::openMenu(docstring const & name)
950 d.menubar_->openByName(toqstr(name));
954 void GuiViewBase::openLayoutList()
956 d.toolbars_->openLayoutList();
960 void GuiViewBase::updateLayoutChoice()
962 // Don't show any layouts without a buffer
964 d.toolbars_->clearLayoutList();
968 // Update the layout display
969 if (d.toolbars_->updateLayoutList(buffer()->params().getTextClassPtr())) {
970 d.current_layout = buffer()->params().getTextClass().defaultLayoutName();
973 docstring const & layout = currentWorkArea()->bufferView().cursor().
974 innerParagraph().layout()->name();
976 if (layout != d.current_layout) {
977 d.toolbars_->setLayout(layout);
978 d.current_layout = layout;
983 bool GuiViewBase::isToolbarVisible(std::string const & id)
985 return d.toolbars_->visible(id);
988 void GuiViewBase::updateToolbars()
990 WorkArea * wa = currentWorkArea();
993 wa->bufferView().cursor().inMathed();
995 lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
997 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
998 lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
1000 d.toolbars_->update(math, table, review);
1002 d.toolbars_->update(false, false, false);
1004 // update read-only status of open dialogs.
1005 getDialogs().checkStatus();
1009 ToolbarInfo * GuiViewBase::getToolbarInfo(string const & name)
1011 return d.toolbars_->getToolbarInfo(name);
1015 void GuiViewBase::toggleToolbarState(string const & name, bool allowauto)
1017 // it is possible to get current toolbar status like this,...
1018 // but I decide to obey the order of ToolbarBackend::flags
1019 // and disregard real toolbar status.
1020 // toolbars_->saveToolbarInfo();
1022 // toggle state on/off/auto
1023 d.toolbars_->toggleToolbarState(name, allowauto);
1029 } // namespace frontend
1032 #include "GuiView_moc.cpp"