From 457a930f47c3d66c4d28fe8a3c14b695cd5c1c65 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 16 Mar 2009 22:25:45 +0000 Subject: [PATCH] Added panel grip handles --- src/gui/widgets/panel-bar.cpp | 41 +++++++++++++++++++++++++++++++++++ src/gui/widgets/panel-bar.hpp | 17 +++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/gui/widgets/panel-bar.cpp b/src/gui/widgets/panel-bar.cpp index 8ae1754cd..6243bd16c 100644 --- a/src/gui/widgets/panel-bar.cpp +++ b/src/gui/widgets/panel-bar.cpp @@ -21,12 +21,16 @@ * *****************************************************/ #include "panel-bar.hpp" +#include "../util/rectangle.hpp" #include using namespace Gtk; +using namespace Glib; using namespace sigc; +const int DragHandleSize = 10; + namespace gui { namespace widgets { @@ -40,5 +44,42 @@ PanelBar::PanelBar(const gchar *stock_id) : pack_start(panelButton, PACK_SHRINK); } +bool +PanelBar::on_expose_event(GdkEventExpose* event) +{ + HBox::on_expose_event(event); + + RefPtr style = get_style(); + REQUIRE(style); + + const Allocation allocation(get_allocation()); + const Gdk::Rectangle rect( + allocation.get_x() - DragHandleSize, allocation.get_y(), + DragHandleSize, allocation.get_height()); + + style->paint_handle(get_window(), STATE_NORMAL, SHADOW_NONE, + rect, *this, "handlebox", rect.get_x(), rect.get_y(), + rect.get_width(), rect.get_height(), ORIENTATION_VERTICAL); + + return true; +} + +void +PanelBar::on_size_allocate(Gtk::Allocation& allocation) +{ + allocation.set_x(allocation.get_x() + DragHandleSize); + HBox::on_size_allocate(allocation); +} + +void +PanelBar::on_size_request(Gtk::Requisition* requisition) +{ + REQUIRE(requisition); + + HBox::on_size_request(requisition); + + requisition->width += DragHandleSize; +} + } // widgets } // gui diff --git a/src/gui/widgets/panel-bar.hpp b/src/gui/widgets/panel-bar.hpp index 09e697c7b..2289ba088 100644 --- a/src/gui/widgets/panel-bar.hpp +++ b/src/gui/widgets/panel-bar.hpp @@ -45,6 +45,23 @@ public: * panel. **/ PanelBar(const gchar *stock_id); + +private: + + /** + * An override to intercept expose events. + **/ + bool on_expose_event(GdkEventExpose* event); + + /** + * An override to intercept size allocate events. + **/ + void on_size_allocate(Gtk::Allocation& allocation); + + /** + * An override to intercept size request events. + **/ + void on_size_request(Gtk::Requisition* requisition); private: