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.
81 // Define the components making up the window.
82 menubar_.reset(new GMenubar(this, menubackend));
84 bufferview_.reset(new BufferView(this, 300, 300));
85 minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
87 focus_command_buffer.connect(
88 boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
89 view_state_changed.connect(boost::bind(&GView::showViewState, this));
90 signal_focus_in_event().connect(sigc::mem_fun(*this, &GView::onFocusIn));
91 set_default_size(620, 550);
92 // Make sure the buttons are disabled if needed.
94 string const iconName =
95 support::LibFileSearch("images", "lyx", "xpm");
96 if (!iconName.empty())
97 set_icon_from_file(iconName);
105 Gtk::Box & GView::getBox(Position pos)
107 return *box_map_[pos];
111 bool GView::on_delete_event(GdkEventAny * /*event*/)
118 bool GView::onFocusIn(GdkEventFocus * /*event*/)
120 workArea_->grab_focus();
125 void GView::prohibitInput() const
127 view()->hideCursor();
128 const_cast<GView*>(this)->set_sensitive(false);
132 void GView::allowInput() const
134 const_cast<GView*>(this)->set_sensitive(true);
138 void GView::message(string const & msg)
140 minibuffer_->message(msg);
144 void GView::showViewState()
146 message(getLyXFunc().viewStatusMessage());
150 void GView::setWindowTitle(string const & t, string const & /*it*/)
152 set_title(Glib::locale_to_utf8(t));
156 void GView::busy(bool yes) const
159 view()->hideCursor();
160 Gdk::Cursor cursor(Gdk::WATCH);
161 const_cast<GView *>(this)->get_window()->set_cursor(cursor);
162 const_cast<GView *>(this)->set_sensitive(false);
164 const_cast<GView *>(this)->get_window()->set_cursor();
165 const_cast<GView *>(this)->set_sensitive(true);
170 void GView::clearMessage()
172 message(getLyXFunc().viewStatusMessage());
175 } // namespace frontend