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(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
51 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
52 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
53 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
54 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
55 box_store_.push_back(boost::shared_ptr<Gtk::Box>(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], true);
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.
79 BoxStore::iterator it = box_store_.begin();
80 BoxStore::iterator const end = box_store_.end();
81 for (; it != end; ++it)
84 // Define the components making up the window.
85 menubar_.reset(new GMenubar(this, menubackend));
87 bufferview_.reset(new BufferView(this, 300, 300));
88 minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
90 focus_command_buffer.connect(
91 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
92 view_state_changed.connect(boost::bind(&GView::showViewState, this));
93 signal_focus_in_event().connect(sigc::mem_fun(*this, &GView::onFocusIn));
94 set_default_size(500, 550);
95 // Make sure the buttons are disabled if needed.
97 string const iconName =
98 support::LibFileSearch("images", "lyx", "xpm");
99 if (!iconName.empty())
100 set_icon_from_file(iconName);
108 Gtk::Box & GView::getBox(Position pos)
110 return *box_map_[pos];
114 bool GView::on_delete_event(GdkEventAny * /*event*/)
121 bool GView::onFocusIn(GdkEventFocus * /*event*/)
123 workArea_->grab_focus();
128 void GView::prohibitInput() const
130 view()->hideCursor();
131 const_cast<GView*>(this)->set_sensitive(false);
135 void GView::allowInput() const
137 const_cast<GView*>(this)->set_sensitive(true);
141 void GView::message(string const & msg)
143 minibuffer_->message(msg);
147 void GView::showViewState()
149 message(getLyXFunc().viewStatusMessage());
153 void GView::setWindowTitle(string const & t, string const & /*it*/)
155 set_title(Glib::locale_to_utf8(t));
159 void GView::busy(bool yes) const
162 view()->hideCursor();
163 Gdk::Cursor cursor(Gdk::WATCH);
164 const_cast<GView *>(this)->get_window()->set_cursor(cursor);
165 const_cast<GView *>(this)->set_sensitive(false);
167 const_cast<GView *>(this)->get_window()->set_cursor();
168 const_cast<GView *>(this)->set_sensitive(true);
173 void GView::clearMessage()
175 message(getLyXFunc().viewStatusMessage());
178 } // namespace frontend