2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
15 #pragma implementation
19 #include "minibuffer.h"
25 #include "MenuBackend.h"
26 #include "lyx_gui_misc.h" // [update,Close,Redraw]AllBufferRelatedDialogs
27 #include "bufferview_funcs.h" // CurrentState()
30 #include "BufferView.h"
32 #include "frontends/Dialogs.h"
33 #include "frontends/Toolbar.h"
34 #include "frontends/Menubar.h"
36 #include "support/filetools.h" // OnlyFilename()
42 using lyx::layout_type;
44 extern void AutoSave(BufferView *);
45 extern void QuitLyX();
47 layout_type current_layout = 0;
52 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
53 lyxfunc = new LyXFunc(this);
57 dialogs_ = new Dialogs(this);
58 // temporary until all dialogs moved into Dialogs.
59 dialogs_->updateBufferDependent
60 .connect(SigC::slot(&updateAllVisibleBufferRelatedDialogs));
61 dialogs_->hideBufferDependent
62 .connect(SigC::slot(&CloseAllBufferRelatedDialogs));
63 Dialogs::redrawGUI.connect(SigC::slot(this, &LyXView::redraw));
64 Dialogs::redrawGUI.connect(SigC::slot(&RedrawAllBufferRelatedDialogs));
80 void LyXView::resize()
86 /// returns the buffer currently shown in the main form.
87 Buffer * LyXView::buffer() const
89 return bufferview->buffer();
93 BufferView * LyXView::view() const
99 Toolbar * LyXView::getToolbar() const
105 void LyXView::setLayout(layout_type layout)
107 toolbar->setLayout(layout);
111 void LyXView::updateToolbar()
117 LyXFunc * LyXView::getLyXFunc() const
123 MiniBuffer * LyXView::getMiniBuffer() const
129 void LyXView::message(string const & str)
131 minibuffer->message(str);
135 void LyXView::messagePush(string const & str)
137 minibuffer->messagePush(str);
141 void LyXView::messagePop()
143 minibuffer->messagePop();
147 Menubar * LyXView::getMenubar() const
153 void LyXView::updateMenubar()
155 if ((!view() || !view()->buffer())
156 && menubackend.hasMenu("main_nobuffer"))
157 menubar->set("main_nobuffer");
159 menubar->set("main");
164 Intl * LyXView::getIntl() const
170 // Callback for autosave timer
171 void LyXView::AutoSave()
173 lyxerr[Debug::INFO] << "Running AutoSave()" << endl;
174 if (view()->available())
179 /// Reset autosave timer
180 void LyXView::resetAutosaveTimer()
183 autosave_timeout.restart();
187 void LyXView::invalidateLayoutChoice()
193 void LyXView::updateLayoutChoice()
195 // This has a side-effect that the layouts are not showed when no
196 // document is loaded.
197 if (!view() || !view()->buffer()) {
198 toolbar->clearLayoutList();
202 // Update the layout display
203 if (last_textclass != int(buffer()->params.textclass)) {
204 toolbar->updateLayoutList(true);
205 last_textclass = int(buffer()->params.textclass);
208 toolbar->updateLayoutList(false);
211 layout_type layout = bufferview->getLyXText()->cursor.par()->getLayout();
213 if (layout != current_layout) {
214 toolbar->setLayout(layout);
215 current_layout = layout;
220 // Updates the title of the window with the filename of the current document
221 void LyXView::updateWindowTitle()
223 static string last_title = "LyX";
224 string title = "LyX";
225 string icon_title = "LyX";
227 if (view()->available()) {
228 string const cur_title = buffer()->fileName();
229 if (!cur_title.empty()){
230 title += ": " + MakeDisplayPath(cur_title, 30);
231 if (!buffer()->isLyxClean())
232 title += _(" (Changed)");
233 if (buffer()->isReadonly())
234 title += _(" (read only)");
235 /* Show only the filename if it's available. */
236 icon_title = OnlyFilename(cur_title);
239 if (title != last_title) {
240 setWindowTitle(title, icon_title);
246 void LyXView::showState()
248 message(currentState(view()));