3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
24 #include "GMiniBuffer.h"
26 #include "BufferView.h"
32 #include "MenuBackend.h"
33 #include "funcrequest.h"
35 #include "frontends/Toolbars.h"
36 #include "frontends/WorkArea.h"
38 #include "support/filetools.h"
39 #include "support/convert.h"
41 #include <boost/bind.hpp>
52 void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
54 Gtk::PackOptions const packing =
55 shrink ? Gtk::PACK_SHRINK : Gtk::PACK_EXPAND_WIDGET;
56 list.push_back(Gtk::Box_Helpers::Element(box, packing));
62 GView::GView(Gui & owner) : LyXView(owner)
64 // The physical store for the boxes making up the layout.
65 box_store_.push_back(BoxPtr(new Gtk::VBox));
66 box_store_.push_back(BoxPtr(new Gtk::HBox));
67 box_store_.push_back(BoxPtr(new Gtk::VBox));
68 box_store_.push_back(BoxPtr(new Gtk::HBox));
69 box_store_.push_back(BoxPtr(new Gtk::HBox));
70 box_store_.push_back(BoxPtr(new Gtk::HBox));
72 // Lay them out correctly.
75 Gtk::Box::BoxList & layout1 = top_box_.children();
76 add_el(layout1, *box_store_[0], true);
77 add_el(layout1, *box_store_[1], false);
78 add_el(layout1, *box_store_[2], true);
80 Gtk::Box::BoxList & layout2 = box_store_[1]->children();
81 add_el(layout2, *box_store_[3], true);
82 add_el(layout2, *box_store_[4], false);
83 add_el(layout2, *box_store_[5], true);
85 // Define accessors to the various Boxes.
86 box_map_[Top] = box_store_[0];
87 box_map_[Bottom] = box_store_[2];
88 box_map_[Left] = box_store_[3];
89 box_map_[Center] = box_store_[4];
90 box_map_[Right] = box_store_[5];
92 // Make all Boxes visible.
95 // Define the components making up the window.
96 menubar_.reset(new GMenubar(this, menubackend));
98 minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
100 focus_command_buffer.connect(
101 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
102 signal_focus_in_event().connect(sigc::mem_fun(*this, &GView::onFocusIn));
107 if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
108 width = lyxrc.geometry_width;
109 height = lyxrc.geometry_height;
111 // if lyxrc returns (0,0), then use session info
113 string val = LyX::ref().session().loadSessionInfo("WindowWidth");
115 width = convert<unsigned int>(val);
116 val = LyX::ref().session().loadSessionInfo("WindowHeight");
118 height = convert<unsigned int>(val);
120 set_default_size(width, height);
121 // Make sure the buttons are disabled if needed.
123 string const iconName =
124 support::libFileSearch("images", "lyx", "xpm");
125 if (!iconName.empty())
126 set_icon_from_file(iconName);
134 Gtk::Box & GView::getBox(Position pos)
136 return *box_map_[pos];
140 bool GView::on_delete_event(GdkEventAny * /*event*/)
142 // save windows size and position
143 Gtk::Requisition req = workArea_->size_request();
144 LyX::ref().session().saveSessionInfo("WindowWidth", convert<string>(req.width));
145 LyX::ref().session().saveSessionInfo("WindowHeight", convert<string>(req.height));
146 // trigger LFUN_LYX_QUIT instead of quit directly
147 // since LFUN_LYX_QUIT may have more cleanup stuff
149 getLyXFunc().dispatch(FuncRequest(LFUN_LYX_QUIT));
154 bool GView::onFocusIn(GdkEventFocus * /*event*/)
156 workArea_->grab_focus();
161 void GView::prohibitInput() const
163 // FIXME: Why is prohibitInput const?
164 // FIXME: hideCursor is protected
165 //const_cast<GView*>(this)->workArea()->hideCursor();
166 const_cast<GView*>(this)->set_sensitive(false);
170 void GView::allowInput() const
172 const_cast<GView*>(this)->set_sensitive(true);
176 void GView::message(docstring const & msg)
178 minibuffer_->message(msg);
182 void GView::updateStatusBar()
184 message(getLyXFunc().viewStatusMessage());
188 void GView::setWindowTitle(docstring const & t, docstring const & /*it*/)
190 set_title(Glib::locale_to_utf8(t));
194 void GView::busy(bool yes) const
196 // FIXME: Why is busy const?
198 // FIXME: hideCursor is protected
199 //const_cast<GView*>(this)->workArea()->hideCursor();
200 Gdk::Cursor cursor(Gdk::WATCH);
201 const_cast<GView *>(this)->get_window()->set_cursor(cursor);
202 const_cast<GView *>(this)->set_sensitive(false);
204 const_cast<GView *>(this)->get_window()->set_cursor();
205 const_cast<GView *>(this)->set_sensitive(true);
210 void GView::clearMessage()
212 message(getLyXFunc().viewStatusMessage());
216 bool GView::hasFocus() const
218 // No real implementation needed for now
223 Toolbars::ToolbarPtr GView::makeToolbar(ToolbarBackend::Toolbar const & tbb)
225 return make_toolbar(tbb, *this);
228 } // namespace frontend