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.
16 #include "GMiniBuffer.h"
19 #include "BufferView.h"
22 #include "MenuBackend.h"
24 #include "support/filetools.h"
26 #include <boost/bind.hpp>
35 void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
37 Gtk::PackOptions const packing =
38 shrink ? Gtk::PACK_SHRINK : Gtk::PACK_EXPAND_WIDGET;
39 list.push_back(Gtk::Box_Helpers::Element(box, packing));
47 // The physical store for the boxes making up the layout.
48 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
49 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
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::HBox));
53 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
55 // Lay them out correctly.
58 Gtk::Box::BoxList & layout1 = top_box_.children();
59 add_el(layout1, *box_store_[0], true);
60 add_el(layout1, *box_store_[1], true);
61 add_el(layout1, *box_store_[2], true);
63 Gtk::Box::BoxList & layout2 = box_store_[1]->children();
64 add_el(layout2, *box_store_[3], true);
65 add_el(layout2, *box_store_[4], false);
66 add_el(layout2, *box_store_[5], true);
68 // Define accessors to the various Boxes.
69 box_map_[Top] = box_store_[0];
70 box_map_[Bottom] = box_store_[2];
71 box_map_[Left] = box_store_[3];
72 box_map_[Center] = box_store_[4];
73 box_map_[Right] = box_store_[5];
75 // Make all Boxes visible.
77 BoxStore::iterator it = box_store_.begin();
78 BoxStore::iterator const end = box_store_.end();
79 for (; it != end; ++it)
82 // Define the components making up the window.
83 menubar_.reset(new GMenubar(this, menubackend));
84 toolbar_.reset(new GToolbar(this, 0, 0));
86 bufferview_.reset(new BufferView(this, 300, 300));
87 minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
89 focus_command_buffer.connect(
90 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
91 view_state_changed.connect(boost::bind(&GView::showViewState, this));
92 signal_focus_in_event().connect(SigC::slot(*this, &GView::onFocusIn));
93 set_default_size(500, 550);
94 // Make sure the buttons are disabled if needed.
96 string const iconName =
97 lyx::support::LibFileSearch("images", "lyx", "xpm");
98 if (!iconName.empty())
99 set_icon_from_file(iconName);
107 Gtk::Box & GView::getBox(Position pos)
109 return *box_map_[pos];
113 bool GView::on_delete_event(GdkEventAny * /*event*/)
120 bool GView::onFocusIn(GdkEventFocus * /*event*/)
122 workArea_->grab_focus();
127 void GView::prohibitInput() const
129 view()->hideCursor();
130 const_cast<GView*>(this)->set_sensitive(false);
134 void GView::allowInput() const
136 const_cast<GView*>(this)->set_sensitive(true);
140 void GView::message(string const & msg)
142 minibuffer_->message(msg);
146 void GView::showViewState()
148 message(getLyXFunc().viewStatusMessage());
152 void GView::setWindowTitle(string const & t, string const & /*it*/)
154 set_title(Glib::locale_to_utf8(t));
158 void GView::busy(bool yes) const
161 view()->hideCursor();
162 Gdk::Cursor cursor(Gdk::WATCH);
163 const_cast<GView *>(this)->get_window()->set_cursor(cursor);
164 const_cast<GView *>(this)->set_sensitive(false);
166 const_cast<GView *>(this)->get_window()->set_cursor();
167 const_cast<GView *>(this)->set_sensitive(true);
172 void GView::clearMessage()
174 message(getLyXFunc().viewStatusMessage());