2003-09-02 10:29:05 +00:00
|
|
|
/**
|
2003-10-08 11:31:51 +00:00
|
|
|
* \file gtk/GView.C
|
2003-09-02 10:29:05 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Huang Ying
|
|
|
|
*
|
2003-09-02 17:02:32 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-09-02 10:29:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "GView.h"
|
|
|
|
#include "GMenubar.h"
|
2004-04-27 14:48:13 +00:00
|
|
|
#include "GMiniBuffer.h"
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
#include "BufferView.h"
|
|
|
|
#include "lyx_cb.h"
|
|
|
|
#include "lyxfunc.h"
|
2004-04-27 14:48:13 +00:00
|
|
|
#include "MenuBackend.h"
|
|
|
|
|
2004-04-29 09:54:59 +00:00
|
|
|
#include "frontends/Toolbars.h"
|
|
|
|
|
2004-04-27 14:48:13 +00:00
|
|
|
#include "support/filetools.h"
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
2004-04-27 14:48:13 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2004-04-27 14:48:13 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
|
|
|
|
{
|
|
|
|
Gtk::PackOptions const packing =
|
|
|
|
shrink ? Gtk::PACK_SHRINK : Gtk::PACK_EXPAND_WIDGET;
|
|
|
|
list.push_back(Gtk::Box_Helpers::Element(box, packing));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
GView::GView()
|
|
|
|
{
|
2004-04-27 14:48:13 +00:00
|
|
|
// The physical store for the boxes making up the layout.
|
2004-10-06 09:22:52 +00:00
|
|
|
box_store_.push_back(BoxPtr(new Gtk::VBox));
|
|
|
|
box_store_.push_back(BoxPtr(new Gtk::HBox));
|
|
|
|
box_store_.push_back(BoxPtr(new Gtk::VBox));
|
|
|
|
box_store_.push_back(BoxPtr(new Gtk::HBox));
|
|
|
|
box_store_.push_back(BoxPtr(new Gtk::HBox));
|
|
|
|
box_store_.push_back(BoxPtr(new Gtk::HBox));
|
2004-04-27 14:48:13 +00:00
|
|
|
|
|
|
|
// Lay them out correctly.
|
|
|
|
add(top_box_);
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
Gtk::Box::BoxList & layout1 = top_box_.children();
|
2004-04-27 14:48:13 +00:00
|
|
|
add_el(layout1, *box_store_[0], true);
|
2004-10-06 09:22:52 +00:00
|
|
|
add_el(layout1, *box_store_[1], false);
|
2004-04-27 14:48:13 +00:00
|
|
|
add_el(layout1, *box_store_[2], true);
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
Gtk::Box::BoxList & layout2 = box_store_[1]->children();
|
2004-04-27 14:48:13 +00:00
|
|
|
add_el(layout2, *box_store_[3], true);
|
|
|
|
add_el(layout2, *box_store_[4], false);
|
|
|
|
add_el(layout2, *box_store_[5], true);
|
|
|
|
|
|
|
|
// Define accessors to the various Boxes.
|
|
|
|
box_map_[Top] = box_store_[0];
|
|
|
|
box_map_[Bottom] = box_store_[2];
|
|
|
|
box_map_[Left] = box_store_[3];
|
|
|
|
box_map_[Center] = box_store_[4];
|
|
|
|
box_map_[Right] = box_store_[5];
|
|
|
|
|
|
|
|
// Make all Boxes visible.
|
2004-09-27 19:04:17 +00:00
|
|
|
top_box_.show_all();
|
2004-04-27 14:48:13 +00:00
|
|
|
|
|
|
|
// Define the components making up the window.
|
2003-09-02 10:29:05 +00:00
|
|
|
menubar_.reset(new GMenubar(this, menubackend));
|
2004-04-29 09:54:59 +00:00
|
|
|
getToolbars().init();
|
2004-04-28 17:22:05 +00:00
|
|
|
bufferview_.reset(new BufferView(this, 300, 300));
|
2003-09-02 10:29:05 +00:00
|
|
|
minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
|
2004-04-27 14:48:13 +00:00
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
focus_command_buffer.connect(
|
|
|
|
boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
|
|
|
|
view_state_changed.connect(boost::bind(&GView::showViewState, this));
|
2004-09-26 16:48:30 +00:00
|
|
|
signal_focus_in_event().connect(sigc::mem_fun(*this, &GView::onFocusIn));
|
2004-10-06 09:22:52 +00:00
|
|
|
set_default_size(620, 550);
|
2003-09-02 10:29:05 +00:00
|
|
|
// Make sure the buttons are disabled if needed.
|
2004-04-29 09:54:59 +00:00
|
|
|
updateToolbars();
|
2003-09-09 18:27:24 +00:00
|
|
|
string const iconName =
|
2004-05-19 15:11:37 +00:00
|
|
|
support::LibFileSearch("images", "lyx", "xpm");
|
2003-09-02 10:29:05 +00:00
|
|
|
if (!iconName.empty())
|
|
|
|
set_icon_from_file(iconName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GView::~GView()
|
2004-04-27 14:48:13 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Box & GView::getBox(Position pos)
|
2003-09-02 10:29:05 +00:00
|
|
|
{
|
2004-04-27 14:48:13 +00:00
|
|
|
return *box_map_[pos];
|
2003-09-02 10:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GView::on_delete_event(GdkEventAny * /*event*/)
|
|
|
|
{
|
|
|
|
QuitLyX();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GView::onFocusIn(GdkEventFocus * /*event*/)
|
|
|
|
{
|
|
|
|
workArea_->grab_focus();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GView::prohibitInput() const
|
|
|
|
{
|
|
|
|
view()->hideCursor();
|
|
|
|
const_cast<GView*>(this)->set_sensitive(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GView::allowInput() const
|
|
|
|
{
|
|
|
|
const_cast<GView*>(this)->set_sensitive(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GView::message(string const & msg)
|
|
|
|
{
|
|
|
|
minibuffer_->message(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GView::showViewState()
|
|
|
|
{
|
2004-02-20 08:44:11 +00:00
|
|
|
message(getLyXFunc().viewStatusMessage());
|
2003-09-02 10:29:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GView::setWindowTitle(string const & t, string const & /*it*/)
|
|
|
|
{
|
|
|
|
set_title(Glib::locale_to_utf8(t));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GView::busy(bool yes) const
|
|
|
|
{
|
|
|
|
if (yes ) {
|
|
|
|
view()->hideCursor();
|
|
|
|
Gdk::Cursor cursor(Gdk::WATCH);
|
2004-02-20 08:44:11 +00:00
|
|
|
const_cast<GView *>(this)->get_window()->set_cursor(cursor);
|
|
|
|
const_cast<GView *>(this)->set_sensitive(false);
|
2003-09-02 10:29:05 +00:00
|
|
|
} else {
|
2004-02-20 08:44:11 +00:00
|
|
|
const_cast<GView *>(this)->get_window()->set_cursor();
|
|
|
|
const_cast<GView *>(this)->set_sensitive(true);
|
2003-09-02 10:29:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GView::clearMessage()
|
|
|
|
{
|
2004-02-20 08:44:11 +00:00
|
|
|
message(getLyXFunc().viewStatusMessage());
|
2003-09-02 10:29:05 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
2004-11-16 10:46:23 +00:00
|
|
|
|
|
|
|
bool GView::hasFocus() const
|
|
|
|
{
|
|
|
|
// No real implementation needed for now
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|