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"
41 extern void AutoSave(BufferView *);
42 extern void QuitLyX();
44 LyXTextClass::size_type current_layout = 0;
49 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
50 lyxfunc = new LyXFunc(this);
54 dialogs_ = new Dialogs(this);
55 // temporary until all dialogs moved into Dialogs.
56 dialogs_->updateBufferDependent
57 .connect(SigC::slot(&updateAllVisibleBufferRelatedDialogs));
58 dialogs_->hideBufferDependent
59 .connect(SigC::slot(&CloseAllBufferRelatedDialogs));
60 Dialogs::redrawGUI.connect(SigC::slot(this, &LyXView::redraw));
61 Dialogs::redrawGUI.connect(SigC::slot(&RedrawAllBufferRelatedDialogs));
77 void LyXView::resize()
83 /// returns the buffer currently shown in the main form.
84 Buffer * LyXView::buffer() const
86 return bufferview->buffer();
90 BufferView * LyXView::view() const
96 Toolbar * LyXView::getToolbar() const
102 void LyXView::setLayout(LyXTextClass::size_type layout)
104 toolbar->setLayout(layout);
108 void LyXView::updateToolbar()
115 LyXFunc * LyXView::getLyXFunc() const
121 MiniBuffer * LyXView::getMiniBuffer() const
127 void LyXView::message(string const & str)
129 minibuffer->message(str);
133 void LyXView::messagePush(string const & str)
135 minibuffer->messagePush(str);
139 void LyXView::messagePop()
141 minibuffer->messagePop();
145 Menubar * LyXView::getMenubar() const
151 void LyXView::updateMenubar()
153 if ((!view() || !view()->buffer())
154 && menubackend.hasMenu("main_nobuffer"))
155 menubar->set("main_nobuffer");
157 menubar->set("main");
161 Intl * LyXView::getIntl() const
167 // Callback for autosave timer
168 void LyXView::AutoSave()
170 lyxerr[Debug::INFO] << "Running AutoSave()" << endl;
171 if (view()->available())
176 /// Reset autosave timer
177 void LyXView::resetAutosaveTimer()
180 autosave_timeout.restart();
184 void LyXView::invalidateLayoutChoice()
190 void LyXView::updateLayoutChoice()
192 // This has a side-effect that the layouts are not showed when no
193 // document is loaded.
194 if (!view() || !view()->buffer()) {
195 toolbar->clearLayoutList();
199 // Update the layout display
200 if (last_textclass != int(buffer()->params.textclass)) {
201 toolbar->updateLayoutList(true);
202 last_textclass = int(buffer()->params.textclass);
205 toolbar->updateLayoutList(false);
208 LyXTextClass::size_type layout =
209 bufferview->text->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();