+2004-04-27 Angus Leeming <leeming@lyx.org>
+
+ * GView.[Ch]: split the window into 'top', 'left', 'center',
+ 'right' and 'bottom' boxes.
+ (getBox): accessor for a particular box.
+
+ * GMenubar.C (c-tor):
+ * GMiniBuffer.C (c-tor):
+ * GWorkArea.C (c-tor):
+ * GToolbar.C (add): access the correct Box in GView.
+
+ * GToolbar.[Ch] (add, displayToolbar): show only those toolbars that
+ are flagged as 'ON'.
+
2004-04-27 Angus Leeming <leeming@lyx.org>
* ghelpers.[Ch]: new files.
view_(lyxView)
{
GView * gview = static_cast<GView*>(lyxView);
- Gtk::VBox& vbox = gview->getVBox();
Menu const & menu = menubackend.getMenubar();
Menu::const_iterator i = menu.begin();
Menu::const_iterator end = menu.end();
mainMenuNames_.push_back(i->submenuname());
}
menubar_.show();
- vbox.children().push_back(Gtk::Box_Helpers::Element(menubar_,
- Gtk::PACK_SHRINK));
+ gview->getBox(GView::Top).children().push_back(
+ Gtk::Box_Helpers::Element(menubar_, Gtk::PACK_SHRINK));
}
listSel_ = listView_.get_selection();
listSel_->signal_changed().connect(
SigC::slot(*this, &GMiniBuffer::onSelected));
+
listView_.show();
scrolledWindow_.set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
scrolledWindow_.set_size_request(300, 150);
scrolledWindow_.add(listView_);
- view_->getVBox().children().push_back(
- Gtk::Box_Helpers::Element(scrolledWindow_,
- Gtk::PACK_SHRINK));
+
+ view_->getBox(GView::Bottom).children().push_back(
+ Gtk::Box_Helpers::Element(scrolledWindow_,Gtk::PACK_SHRINK));
+
entry_.signal_key_press_event().connect(
SigC::slot(*this, &GMiniBuffer::onKeyPress));
entry_.signal_focus_in_event().connect(
entry_.signal_activate().connect(
SigC::slot(*this, &GMiniBuffer::onCommit));
entry_.show();
- view_->getVBox().children().push_back(
- Gtk::Box_Helpers::Element(entry_,
- Gtk::PACK_SHRINK));
+
+ view_->getBox(GView::Bottom).children().push_back(
+ Gtk::Box_Helpers::Element(entry_, Gtk::PACK_SHRINK));
+
infoTimer_.reset(new Timeout(1500));
idleTimer_.reset(new Timeout(6000));
focusTimer_.reset(new Timeout(50));
namespace
{
+GView::Position getPosition(ToolbarBackend::Flags const & flags)
+ {
+ if (flags & ToolbarBackend::TOP)
+ return GView::Top;
+ if (flags & ToolbarBackend::BOTTOM)
+ return GView::Bottom;
+ if (flags & ToolbarBackend::LEFT)
+ return GView::Left;
+ if (flags & ToolbarBackend::RIGHT)
+ return GView::Right;
+ return GView::Top;
+}
+
+
+LyXTextClass const & getTextClass(LyXView const & lv)
+{
+ return lv.buffer()->params().getLyXTextClass();
+}
+
char const * gToolData = "tool_data";
combo_.get_entry()->signal_changed().connect(
SigC::slot(*this,
>oolbar::onLayoutSelected));
- GView * gview = static_cast<GView*>(lyxView);
- vbox_.show();
- Gtk::VBox & vbox = gview->getVBox();
- vbox.children().push_back(Gtk::Box_Helpers::Element(vbox_,
- Gtk::PACK_SHRINK));
}
GToolbar::~GToolbar()
-{
-}
+{}
-void GToolbar::add(ToolbarBackend::Toolbar const & tb)
+void GToolbar::add(ToolbarBackend::Toolbar const & tbb)
{
Gtk::Toolbar * toolbar = manage(new Gtk::Toolbar);
- ToolbarBackend::item_iterator it = tb.items.begin();
- ToolbarBackend::item_iterator end = tb.items.end();
+ ToolbarBackend::item_iterator it = tbb.items.begin();
+ ToolbarBackend::item_iterator end = tbb.items.end();
for (; it != end; ++it)
add(toolbar, *it);
toolbar->set_toolbar_style(Gtk::TOOLBAR_ICONS);
- toolbar->show();
- vbox_.children().push_back(
- Gtk::Box_Helpers::Element(*toolbar,
- Gtk::PACK_SHRINK));
- toolbars_.push_back(toolbar);
+
+ GView::Position const position = getPosition(tbb.flags);
+
+ if (position == GView::Left || position == GView::Right)
+ toolbar->set_orientation(Gtk::ORIENTATION_VERTICAL);
+
+ GView * gview = static_cast<GView*>(view_);
+ gview->getBox(position).children().push_back(
+ Gtk::Box_Helpers::Element(*toolbar, Gtk::PACK_SHRINK));
+
+ if (tbb.flags & ToolbarBackend::ON)
+ toolbar->show();
+
+ toolbars_[tbb.name] = toolbar;
}
// we get two signal, one of it is empty and useless
if (layoutGuiName.empty())
return;
- LyXTextClass const & tc =
- view_->buffer()->params().getLyXTextClass();
+ LyXTextClass const & tc = getTextClass(*view_);
LyXTextClass::const_iterator end = tc.end();
for (LyXTextClass::const_iterator cit = tc.begin();
}
-void GToolbar::displayToolbar(ToolbarBackend::Toolbar const & /*tb*/, bool /*show*/)
+void GToolbar::displayToolbar(ToolbarBackend::Toolbar const & tbb, bool show_it)
{
+ ToolbarMap::iterator it = toolbars_.find(tbb.name);
+ BOOST_ASSERT(it != toolbars_.end());
+
+ if (show_it)
+ it->second->show();
+ else
+ it->second->hide();
}
void GToolbar::update()
{
- std::vector<Gtk::Toolbar*>::iterator itToolbar;
+ ToolbarMap::iterator itToolbar;
for (itToolbar = toolbars_.begin();
itToolbar != toolbars_.end(); ++itToolbar) {
- Gtk::Toolbar * toolbar = *itToolbar;
+ Gtk::Toolbar * toolbar = itToolbar->second;
Gtk::Toolbar_Helpers::ToolList::iterator it;
for (it = toolbar->tools().begin();
it != toolbar->tools().end(); ++it) {
void GToolbar::setLayout(string const & layout)
{
- LyXTextClass const & tc =
- view_->buffer()->params().getLyXTextClass();
+ LyXTextClass const & tc = getTextClass(*view_);
internal_ = true;
combo_.get_entry()->set_text(tc[layout]->name());
internal_ = false;
void GToolbar::updateLayoutList()
{
- LyXTextClass const & tc =
- view_->buffer()->params().getLyXTextClass();
+ LyXTextClass const & tc = getTextClass(*view_);
LyXTextClass::const_iterator end = tc.end();
std::vector<Glib::ustring> strings;
for (LyXTextClass::const_iterator cit = tc.begin();
#include <gtkmm.h>
#include "frontends/Toolbar.h"
#include "ToolbarBackend.h"
+#include <map>
class GToolbar : public Toolbar, public SigC::Object
private:
void onButtonClicked(FuncRequest);
void onLayoutSelected();
- Gtk::VBox vbox_;
- std::vector<Gtk::Toolbar*> toolbars_;
+ typedef std::map<std::string, Gtk::Toolbar*> ToolbarMap;
+ ToolbarMap toolbars_;
Gtk::Combo combo_;
LyXView * view_;
bool internal_;
#include <gtkmm.h>
#include "GView.h"
-#include "MenuBackend.h"
-#include "support/filetools.h"
#include "GMenubar.h"
+#include "GMiniBuffer.h"
#include "GToolbar.h"
+#include "GWorkArea.h"
+
#include "BufferView.h"
-#include "XWorkArea.h"
#include "lyx_cb.h"
-#include "GMiniBuffer.h"
#include "lyxfunc.h"
+#include "MenuBackend.h"
+
+#include "support/filetools.h"
+
#include <boost/bind.hpp>
+#include <vector>
+
using std::string;
GView * GView::view_ = 0;
+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
+
+
GView::GView()
{
view_ = this;
- vbox_.reset(new Gtk::VBox);
- add(*vbox_.get());
+
+ // The physical store for the boxes making up the layout.
+ box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
+ box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
+ box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::VBox));
+ box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
+ box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
+ box_store_.push_back(boost::shared_ptr<Gtk::Box>(new Gtk::HBox));
+
+ // Lay them out correctly.
+ add(top_box_);
+
+ Gtk::Box::BoxList & layout1 = top_box_.children();
+ add_el(layout1, *box_store_[0], true);
+ add_el(layout1, *box_store_[1], true);
+ add_el(layout1, *box_store_[2], true);
+
+ Gtk::Box::BoxList & layout2 = box_store_[1]->children();
+ 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.
+ top_box_.show();
+ BoxStore::iterator it = box_store_.begin();
+ BoxStore::iterator const end = box_store_.end();
+ for (; it != end; ++it)
+ (*it)->show();
+
+ // Define the components making up the window.
menubar_.reset(new GMenubar(this, menubackend));
toolbar_.reset(new GToolbar(this, 0, 0));
toolbar_->init();
bufferview_.reset(new BufferView(this, 0, 0, 300, 300));
::current_view = bufferview_.get();
minibuffer_.reset(new GMiniBuffer(this, *controlcommand_));
- vbox_->show();
+
focus_command_buffer.connect(
boost::bind(&GMiniBuffer::editMode, minibuffer_.get()));
view_state_changed.connect(boost::bind(&GView::showViewState, this));
GView::~GView()
+{}
+
+
+Gtk::Box & GView::getBox(Position pos)
{
+ return *box_map_[pos];
}
#include "frontends/LyXView.h"
#include "bufferview_funcs.h"
-#include <memory>
+#include <map>
+
class GMiniBuffer;
class GView : public LyXView, public Gtk::Window
{
public:
- virtual ~GView();
+ enum Position {
+ Top,
+ Bottom,
+ Left,
+ Right,
+ Center
+ };
+
+ GView();
+ ~GView();
+
+ Gtk::Box & getBox(Position pos);
virtual void prohibitInput() const;
virtual void allowInput() const;
virtual void message(std::string const &);
- Gtk::VBox & getVBox() { return *vbox_.get(); }
- GView();
+
bool on_delete_event(GdkEventAny * event);
void focusWorkArea() { workArea_->grab_focus(); }
void setGWorkArea(Gtk::Widget * w) { workArea_ = w; }
+
static GView * instance() { return view_; }
/// show busy cursor
virtual void busy(bool) const;
bool onFocusIn(GdkEventFocus * event);
virtual void setWindowTitle(std::string const & t, std::string const & it);
static GView * view_;
- std::auto_ptr<Gtk::VBox> vbox_;
+
+ // The top-most box containing all other boxes.
+ Gtk::VBox top_box_;
+
+ // The physical store for the boxes making up the layout.
+ typedef boost::shared_ptr<Gtk::Box> BoxPtr;
+ typedef std::vector<BoxPtr> BoxStore;
+ BoxStore box_store_;
+
+ // Accessors to the various Boxes.
+ std::map<Position, BoxPtr> box_map_;
+
boost::scoped_ptr<GMiniBuffer> minibuffer_;
Gtk::Widget * workArea_;
};
hbox_.children().push_back(
Gtk::Box_Helpers::Element(vscrollbar_,Gtk::PACK_SHRINK));
hbox_.show();
- GView::instance()->getVBox().children().push_back(
+
+ GView::instance()->getBox(GView::Center).children().push_back(
Gtk::Box_Helpers::Element(hbox_));
+
workArea_.set_flags(workArea_.get_flags() | Gtk::CAN_DEFAULT |
Gtk::CAN_FOCUS);
workArea_.grab_default();