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.
15 #include "GMiniBuffer.h"
17 #include "BufferView.h"
20 #include "MenuBackend.h"
22 #include "frontends/Toolbars.h"
24 #include "support/filetools.h"
26 #include <boost/bind.hpp>
37 void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
39 Gtk::PackOptions const packing =
40 shrink ? Gtk::PACK_SHRINK : Gtk::PACK_EXPAND_WIDGET;
41 list.push_back(Gtk::Box_Helpers::Element(box, packing));
49 // The physical store for the boxes making up the layout.
50 box_store_.push_back(BoxPtr(new Gtk::VBox));
51 box_store_.push_back(BoxPtr(new Gtk::HBox));
52 box_store_.push_back(BoxPtr(new Gtk::VBox));
53 box_store_.push_back(BoxPtr(new Gtk::HBox));
54 box_store_.push_back(BoxPtr(new Gtk::HBox));
55 box_store_.push_back(BoxPtr(new Gtk::HBox));
57 // Lay them out correctly.
60 Gtk::Box::BoxList & layout1 = top_box_.children();
61 add_el(layout1, *box_store_[0], true);
62 add_el(layout1, *box_store_[1], false);
63 add_el(layout1, *box_store_[2], true);
65 Gtk::Box::BoxList & layout2 = box_store_[1]->children();
66 add_el(layout2, *box_store_[3], true);
67 add_el(layout2, *box_store_[4], false);
68 add_el(layout2, *box_store_[5], true);
70 // Define accessors to the various Boxes.
71 box_map_[Top] = box_store_[0];
72 box_map_[Bottom] = box_store_[2];
73 box_map_[Left] = box_store_[3];
74 box_map_[Center] = box_store_[4];
75 box_map_[Right] = box_store_[5];
77 // Make all Boxes visible.
80 // Define the components making up the window.
81 menubar_.reset(new GMenubar(this, menubackend));
83 bufferview_.reset(new BufferView(this, 300, 300));
84 minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
86 focus_command_buffer.connect(
87 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
88 view_state_changed.connect(boost::bind(&GView::showViewState, this));
89 signal_focus_in_event().connect(sigc::mem_fun(*this, &GView::onFocusIn));
90 set_default_size(620, 550);
91 // Make sure the buttons are disabled if needed.
93 string const iconName =
94 support::LibFileSearch("images", "lyx", "xpm");
95 if (!iconName.empty())
96 set_icon_from_file(iconName);
104 Gtk::Box & GView::getBox(Position pos)
106 return *box_map_[pos];
110 bool GView::on_delete_event(GdkEventAny * /*event*/)
117 bool GView::onFocusIn(GdkEventFocus * /*event*/)
119 workArea_->grab_focus();
124 void GView::prohibitInput() const
126 view()->hideCursor();
127 const_cast<GView*>(this)->set_sensitive(false);
131 void GView::allowInput() const
133 const_cast<GView*>(this)->set_sensitive(true);
137 void GView::message(string const & msg)
139 minibuffer_->message(msg);
143 void GView::showViewState()
145 message(getLyXFunc().viewStatusMessage());
149 void GView::setWindowTitle(string const & t, string const & /*it*/)
151 set_title(Glib::locale_to_utf8(t));
155 void GView::busy(bool yes) const
158 view()->hideCursor();
159 Gdk::Cursor cursor(Gdk::WATCH);
160 const_cast<GView *>(this)->get_window()->set_cursor(cursor);
161 const_cast<GView *>(this)->set_sensitive(false);
163 const_cast<GView *>(this)->get_window()->set_cursor();
164 const_cast<GView *>(this)->set_sensitive(true);
169 void GView::clearMessage()
171 message(getLyXFunc().viewStatusMessage());
174 } // namespace frontend