Put a window under the panel bar widgets to set the cursor to be an
arrow
This commit is contained in:
parent
ee50f55fa6
commit
c47c08650d
2 changed files with 74 additions and 3 deletions
|
|
@ -24,12 +24,12 @@
|
|||
#include "../util/rectangle.hpp"
|
||||
|
||||
#include <nobug.h>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace Glib;
|
||||
using namespace sigc;
|
||||
|
||||
const int DragHandleSize = 10;
|
||||
using namespace std;
|
||||
|
||||
namespace gui {
|
||||
namespace widgets {
|
||||
|
|
@ -44,5 +44,57 @@ PanelBar::PanelBar(const gchar *stock_id) :
|
|||
pack_start(panelButton, PACK_SHRINK);
|
||||
}
|
||||
|
||||
void
|
||||
PanelBar::on_realize()
|
||||
{
|
||||
set_flags(Gtk::NO_WINDOW);
|
||||
|
||||
// Call base class:
|
||||
Gtk::Container::on_realize();
|
||||
|
||||
// Create the GdkWindow:
|
||||
GdkWindowAttr attributes;
|
||||
memset(&attributes, 0, sizeof(attributes));
|
||||
|
||||
const Allocation allocation(get_allocation());
|
||||
|
||||
// Set initial position and size of the Gdk::Window:
|
||||
attributes.x = allocation.get_x();
|
||||
attributes.y = allocation.get_y();
|
||||
attributes.width = allocation.get_width();
|
||||
attributes.height = allocation.get_height();
|
||||
|
||||
attributes.event_mask = GDK_ALL_EVENTS_MASK;
|
||||
attributes.window_type = GDK_WINDOW_CHILD;
|
||||
attributes.wclass = GDK_INPUT_OUTPUT;
|
||||
|
||||
window = Gdk::Window::create(get_window(), &attributes,
|
||||
GDK_WA_X | GDK_WA_Y);
|
||||
|
||||
window->set_user_data(gobj());
|
||||
window->set_cursor(Gdk::Cursor(Gdk::LEFT_PTR));
|
||||
|
||||
set_window(window);
|
||||
unset_flags(Gtk::NO_WINDOW);
|
||||
|
||||
unset_bg(STATE_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
PanelBar::on_size_allocate(Gtk::Allocation& allocation)
|
||||
{
|
||||
if(window)
|
||||
{
|
||||
const Requisition requisition(get_requisition());
|
||||
const int width = max(min(requisition.width,
|
||||
allocation.get_width()), 0);
|
||||
window->move_resize(allocation.get_x(), allocation.get_y(),
|
||||
width, allocation.get_height());
|
||||
}
|
||||
|
||||
allocation.set_x(0);
|
||||
HBox::on_size_allocate(allocation);
|
||||
}
|
||||
|
||||
} // widgets
|
||||
} // gui
|
||||
|
|
|
|||
|
|
@ -45,7 +45,19 @@ public:
|
|||
* panel.
|
||||
**/
|
||||
PanelBar(const gchar *stock_id);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* An override to intercept realize events.
|
||||
**/
|
||||
void on_realize();
|
||||
|
||||
/**
|
||||
* An override to intercept size allocate events.
|
||||
**/
|
||||
void on_size_allocate(Gtk::Allocation& allocation);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
@ -53,6 +65,13 @@ private:
|
|||
* the corner of the bar.
|
||||
**/
|
||||
MenuButton panelButton;
|
||||
|
||||
/**
|
||||
* The bar window.
|
||||
* @remarks This window is used only to set the cursor as an arrow for
|
||||
* any child widgets.
|
||||
**/
|
||||
Glib::RefPtr<Gdk::Window> window;
|
||||
};
|
||||
|
||||
} // gui
|
||||
|
|
|
|||
Loading…
Reference in a new issue