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>
33 BufferView * current_view;
35 GView * GView::view_ = 0;
40 void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
42 Gtk::PackOptions const packing =
43 shrink ? Gtk::PACK_SHRINK : Gtk::PACK_EXPAND_WIDGET;
44 list.push_back(Gtk::Box_Helpers::Element(box, packing));
54 // The physical store for the boxes making up the layout.
55 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
56 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
57 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
58 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
59 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
60 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
62 // Lay them out correctly.
65 Gtk::Box::BoxList & layout1 = top_box_.children();
66 add_el(layout1, *box_store_[0], true);
67 add_el(layout1, *box_store_[1], true);
68 add_el(layout1, *box_store_[2], true);
70 Gtk::Box::BoxList & layout2 = box_store_[1]->children();
71 add_el(layout2, *box_store_[3], true);
72 add_el(layout2, *box_store_[4], false);
73 add_el(layout2, *box_store_[5], true);
75 // Define accessors to the various Boxes.
76 box_map_[Top] = box_store_[0];
77 box_map_[Bottom] = box_store_[2];
78 box_map_[Left] = box_store_[3];
79 box_map_[Center] = box_store_[4];
80 box_map_[Right] = box_store_[5];
82 // Make all Boxes visible.
84 BoxStore::iterator it = box_store_.begin();
85 BoxStore::iterator const end = box_store_.end();
86 for (; it != end; ++it)
89 // Define the components making up the window.
90 menubar_.reset(new GMenubar(this, menubackend));
91 toolbar_.reset(new GToolbar(this, 0, 0));
93 bufferview_.reset(new BufferView(this, 0, 0, 300, 300));
94 ::current_view = bufferview_.get();
95 minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
97 focus_command_buffer.connect(
98 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
99 view_state_changed.connect(boost::bind(&GView::showViewState, this));
100 signal_focus_in_event().connect(SigC::slot(*this, &GView::onFocusIn));
101 set_default_size(500, 550);
102 // Make sure the buttons are disabled if needed.
104 string const iconName =
105 lyx::support::LibFileSearch("images", "lyx", "xpm");
106 if (!iconName.empty())
107 set_icon_from_file(iconName);
115 Gtk::Box & GView::getBox(Position pos)
117 return *box_map_[pos];
121 bool GView::on_delete_event(GdkEventAny * /*event*/)
128 bool GView::onFocusIn(GdkEventFocus * /*event*/)
130 workArea_->grab_focus();
135 void GView::prohibitInput() const
137 view()->hideCursor();
138 const_cast<GView*>(this)->set_sensitive(false);
142 void GView::allowInput() const
144 const_cast<GView*>(this)->set_sensitive(true);
148 void GView::message(string const & msg)
150 minibuffer_->message(msg);
154 void GView::showViewState()
156 message(getLyXFunc().viewStatusMessage());
160 void GView::setWindowTitle(string const & t, string const & /*it*/)
162 set_title(Glib::locale_to_utf8(t));
166 void GView::busy(bool yes) const
169 view()->hideCursor();
170 Gdk::Cursor cursor(Gdk::WATCH);
171 const_cast<GView *>(this)->get_window()->set_cursor(cursor);
172 const_cast<GView *>(this)->set_sensitive(false);
174 const_cast<GView *>(this)->get_window()->set_cursor();
175 const_cast<GView *>(this)->set_sensitive(true);
180 void GView::clearMessage()
182 message(getLyXFunc().viewStatusMessage());