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
23 #include "GMiniBuffer.h"
25 #include "BufferView.h"
31 #include "MenuBackend.h"
32 #include "funcrequest.h"
34 #include "frontends/Toolbars.h"
36 #include "support/filetools.h"
37 #include "support/convert.h"
39 #include <boost/bind.hpp>
50 void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
52 Gtk::PackOptions const packing =
53 shrink ? Gtk::PACK_SHRINK : Gtk::PACK_EXPAND_WIDGET;
54 list.push_back(Gtk::Box_Helpers::Element(box, packing));
60 GView::GView(Gui & owner) : LyXView(owner)
62 // The physical store for the boxes making up the layout.
63 box_store_.push_back(BoxPtr(new Gtk::VBox));
64 box_store_.push_back(BoxPtr(new Gtk::HBox));
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::HBox));
68 box_store_.push_back(BoxPtr(new Gtk::HBox));
70 // Lay them out correctly.
73 Gtk::Box::BoxList & layout1 = top_box_.children();
74 add_el(layout1, *box_store_[0], true);
75 add_el(layout1, *box_store_[1], false);
76 add_el(layout1, *box_store_[2], true);
78 Gtk::Box::BoxList & layout2 = box_store_[1]->children();
79 add_el(layout2, *box_store_[3], true);
80 add_el(layout2, *box_store_[4], false);
81 add_el(layout2, *box_store_[5], true);
83 // Define accessors to the various Boxes.
84 box_map_[Top] = box_store_[0];
85 box_map_[Bottom] = box_store_[2];
86 box_map_[Left] = box_store_[3];
87 box_map_[Center] = box_store_[4];
88 box_map_[Right] = box_store_[5];
90 // Make all Boxes visible.
93 // Define the components making up the window.
94 menubar_.reset(new GMenubar(this, menubackend));
96 minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
98 focus_command_buffer.connect(
99 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
100 view_state_changed.connect(boost::bind(&GView::showViewState, this));
101 signal_focus_in_event().connect(sigc::mem_fun(*this, &GView::onFocusIn));
106 if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
107 width = lyxrc.geometry_width;
108 height = lyxrc.geometry_height;
110 // if lyxrc returns (0,0), then use session info
112 string val = LyX::ref().session().loadSessionInfo("WindowWidth");
114 width = convert<unsigned int>(val);
115 val = LyX::ref().session().loadSessionInfo("WindowHeight");
117 height = convert<unsigned int>(val);
119 set_default_size(width, height);
120 // Make sure the buttons are disabled if needed.
122 string const iconName =
123 support::libFileSearch("images", "lyx", "xpm");
124 if (!iconName.empty())
125 set_icon_from_file(iconName);
133 Gtk::Box & GView::getBox(Position pos)
135 return *box_map_[pos];
139 bool GView::on_delete_event(GdkEventAny * /*event*/)
141 // save windows size and position
142 Gtk::Requisition req = workArea_->size_request();
143 LyX::ref().session().saveSessionInfo("WindowWidth", convert<string>(req.width));
144 LyX::ref().session().saveSessionInfo("WindowHeight", convert<string>(req.height));
145 // trigger LFUN_LYX_QUIT instead of quit directly
146 // since LFUN_LYX_QUIT may have more cleanup stuff
148 getLyXFunc().dispatch(FuncRequest(LFUN_LYX_QUIT));
153 bool GView::onFocusIn(GdkEventFocus * /*event*/)
155 workArea_->grab_focus();
160 void GView::prohibitInput() const
162 view()->hideCursor();
163 const_cast<GView*>(this)->set_sensitive(false);
167 void GView::allowInput() const
169 const_cast<GView*>(this)->set_sensitive(true);
173 void GView::message(string const & msg)
175 minibuffer_->message(msg);
179 void GView::showViewState()
181 message(getLyXFunc().viewStatusMessage());
185 void GView::setWindowTitle(string const & t, string const & /*it*/)
187 set_title(Glib::locale_to_utf8(t));
191 void GView::busy(bool yes) const
194 view()->hideCursor();
195 Gdk::Cursor cursor(Gdk::WATCH);
196 const_cast<GView *>(this)->get_window()->set_cursor(cursor);
197 const_cast<GView *>(this)->set_sensitive(false);
199 const_cast<GView *>(this)->get_window()->set_cursor();
200 const_cast<GView *>(this)->set_sensitive(true);
205 void GView::clearMessage()
207 message(getLyXFunc().viewStatusMessage());
211 bool GView::hasFocus() const
213 // No real implementation needed for now
218 } // namespace frontend