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"
18 #include "GWorkArea.h"
20 #include "BufferView.h"
23 #include "MenuBackend.h"
25 #include "support/filetools.h"
27 #include <boost/bind.hpp>
34 BufferView * current_view;
36 GView * GView::view_ = 0;
41 void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
43 Gtk::PackOptions const packing =
44 shrink ? Gtk::PACK_SHRINK : Gtk::PACK_EXPAND_WIDGET;
45 list.push_back(Gtk::Box_Helpers::Element(box, packing));
55 // The physical store for the boxes making up the layout.
56 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
57 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
58 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
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));
61 box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
63 // Lay them out correctly.
66 Gtk::Box::BoxList & layout1 = top_box_.children();
67 add_el(layout1, *box_store_[0], true);
68 add_el(layout1, *box_store_[1], true);
69 add_el(layout1, *box_store_[2], true);
71 Gtk::Box::BoxList & layout2 = box_store_[1]->children();
72 add_el(layout2, *box_store_[3], true);
73 add_el(layout2, *box_store_[4], false);
74 add_el(layout2, *box_store_[5], true);
76 // Define accessors to the various Boxes.
77 box_map_[Top] = box_store_[0];
78 box_map_[Bottom] = box_store_[2];
79 box_map_[Left] = box_store_[3];
80 box_map_[Center] = box_store_[4];
81 box_map_[Right] = box_store_[5];
83 // Make all Boxes visible.
85 BoxStore::iterator it = box_store_.begin();
86 BoxStore::iterator const end = box_store_.end();
87 for (; it != end; ++it)
90 // Define the components making up the window.
91 menubar_.reset(new GMenubar(this, menubackend));
92 toolbar_.reset(new GToolbar(this, 0, 0));
94 bufferview_.reset(new BufferView(this, 0, 0, 300, 300));
95 ::current_view = bufferview_.get();
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::slot(*this, &GView::onFocusIn));
102 set_default_size(500, 550);
103 // Make sure the buttons are disabled if needed.
105 string const iconName =
106 lyx::support::LibFileSearch("images", "lyx", "xpm");
107 if (!iconName.empty())
108 set_icon_from_file(iconName);
116 Gtk::Box & GView::getBox(Position pos)
118 return *box_map_[pos];
122 bool GView::on_delete_event(GdkEventAny * /*event*/)
129 bool GView::onFocusIn(GdkEventFocus * /*event*/)
131 workArea_->grab_focus();
136 void GView::prohibitInput() const
138 view()->hideCursor();
139 const_cast<GView*>(this)->set_sensitive(false);
143 void GView::allowInput() const
145 const_cast<GView*>(this)->set_sensitive(true);
149 void GView::message(string const & msg)
151 minibuffer_->message(msg);
155 void GView::showViewState()
157 message(getLyXFunc().viewStatusMessage());
161 void GView::setWindowTitle(string const & t, string const & /*it*/)
163 set_title(Glib::locale_to_utf8(t));
167 void GView::busy(bool yes) const
170 view()->hideCursor();
171 Gdk::Cursor cursor(Gdk::WATCH);
172 const_cast<GView *>(this)->get_window()->set_cursor(cursor);
173 const_cast<GView *>(this)->set_sensitive(false);
175 const_cast<GView *>(this)->get_window()->set_cursor();
176 const_cast<GView *>(this)->set_sensitive(true);
181 void GView::clearMessage()
183 message(getLyXFunc().viewStatusMessage());