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
22 #include "minibuffer.h"
26 #include "support/filetools.h" // OnlyFilename()
29 #include "frontends/Dialogs.h"
30 #include "frontends/Toolbar.h"
31 #include "frontends/Menubar.h"
32 #include "MenuBackend.h"
33 #include "lyx_gui_misc.h" // [update,Close,Redraw]AllBufferRelatedDialogs
34 #include "bufferview_funcs.h" // CurrentState()
37 #include "BufferView.h"
40 using lyx::layout_type;
42 extern void AutoSave(BufferView *);
43 extern void QuitLyX();
45 layout_type current_layout = 0;
50 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
51 lyxfunc = new LyXFunc(this);
55 dialogs_ = new Dialogs(this);
56 // temporary until all dialogs moved into Dialogs.
57 dialogs_->updateBufferDependent
58 .connect(SigC::slot(&updateAllVisibleBufferRelatedDialogs));
59 dialogs_->hideBufferDependent
60 .connect(SigC::slot(&CloseAllBufferRelatedDialogs));
61 Dialogs::redrawGUI.connect(SigC::slot(this, &LyXView::redraw));
62 Dialogs::redrawGUI.connect(SigC::slot(&RedrawAllBufferRelatedDialogs));
78 void LyXView::resize()
84 /// returns the buffer currently shown in the main form.
85 Buffer * LyXView::buffer() const
87 return bufferview->buffer();
91 BufferView * LyXView::view() const
97 Toolbar * LyXView::getToolbar() const
103 void LyXView::setLayout(layout_type layout)
105 toolbar->setLayout(layout);
109 void LyXView::updateToolbar()
116 LyXFunc * LyXView::getLyXFunc() const
122 MiniBuffer * LyXView::getMiniBuffer() const
128 void LyXView::message(string const & str)
130 minibuffer->message(str);
134 void LyXView::messagePush(string const & str)
136 minibuffer->messagePush(str);
140 void LyXView::messagePop()
142 minibuffer->messagePop();
146 Menubar * LyXView::getMenubar() const
152 void LyXView::updateMenubar()
154 if ((!view() || !view()->buffer())
155 && menubackend.hasMenu("main_nobuffer"))
156 menubar->set("main_nobuffer");
158 menubar->set("main");
162 Intl * LyXView::getIntl() const
168 // Callback for autosave timer
169 void LyXView::AutoSave()
171 lyxerr[Debug::INFO] << "Running AutoSave()" << endl;
172 if (view()->available())
177 /// Reset autosave timer
178 void LyXView::resetAutosaveTimer()
181 autosave_timeout.restart();
185 void LyXView::invalidateLayoutChoice()
191 void LyXView::updateLayoutChoice()
193 // This has a side-effect that the layouts are not showed when no
194 // document is loaded.
195 if (!view() || !view()->buffer()) {
196 toolbar->clearLayoutList();
200 // Update the layout display
201 if (last_textclass != int(buffer()->params.textclass)) {
202 toolbar->updateLayoutList(true);
203 last_textclass = int(buffer()->params.textclass);
206 toolbar->updateLayoutList(false);
209 layout_type layout = bufferview->getLyXText()->cursor.par()->getLayout();
211 if (layout != current_layout) {
212 toolbar->setLayout(layout);
213 current_layout = layout;
218 // Updates the title of the window with the filename of the current document
219 void LyXView::updateWindowTitle()
221 static string last_title = "LyX";
222 string title = "LyX";
224 if (view()->available()) {
225 string const cur_title = buffer()->fileName();
226 if (!cur_title.empty()){
227 title += ": " + MakeDisplayPath(cur_title, 30);
228 if (!buffer()->isLyxClean())
229 title += _(" (Changed)");
230 if (buffer()->isReadonly())
231 title += _(" (read only)");
234 if (title != last_title) {
235 setWindowTitle(title);
242 void LyXView::showState()
244 message(currentState(view()));
245 getToolbar()->update();