Aggressive code pruning.
Note: Default event handlers for Gtk::Box appear to be working better than our previous overrides. Subject to re-implementation
This commit is contained in:
parent
53124624f0
commit
ed86ab0807
2 changed files with 0 additions and 171 deletions
|
|
@ -93,158 +93,6 @@ PanelBar::setup_panel_button()
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
PanelBar::on_realize()
|
||||
{
|
||||
set_has_window(false);
|
||||
|
||||
// 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);
|
||||
set_has_window(false);
|
||||
|
||||
//unset_bg(STATE_NORMAL);
|
||||
}
|
||||
|
||||
void
|
||||
PanelBar::on_size_request(Gtk::Requisition* requisition)
|
||||
{
|
||||
#if 0
|
||||
REQUIRE(requisition);
|
||||
|
||||
requisition->width = 0;
|
||||
requisition->height = 0;
|
||||
|
||||
Box::BoxList &list = children();
|
||||
Box::BoxList::const_iterator i;
|
||||
for(i = list.begin(); i != list.end(); i++)
|
||||
{
|
||||
Widget *widget = (*i).get_widget();
|
||||
REQUIRE(widget);
|
||||
|
||||
Requisition child_requisition = widget->size_request();
|
||||
requisition->width += child_requisition.width;
|
||||
requisition->height = max(requisition->height,
|
||||
child_requisition.height);
|
||||
}
|
||||
|
||||
const int border_width = get_border_width();
|
||||
requisition->width += border_width * 2;
|
||||
requisition->height += border_width * 2 ;
|
||||
|
||||
ENSURE(requisition->width >= 0);
|
||||
ENSURE(requisition->height >= 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
PanelBar::on_size_allocate(Gtk::Allocation& allocation)
|
||||
{
|
||||
struct RequestResult
|
||||
{
|
||||
Requisition requisition;
|
||||
Widget *widget;
|
||||
};
|
||||
|
||||
const int border_width = get_border_width();
|
||||
|
||||
// Use the offered allocation for this container
|
||||
set_allocation(allocation);
|
||||
|
||||
// Requisition each widget
|
||||
int index = 0;
|
||||
int total_width = 0;
|
||||
|
||||
const int child_count = get_children().size();
|
||||
RequestResult *requestResults = new RequestResult[child_count];
|
||||
REQUIRE(requestResults);
|
||||
|
||||
BOOST_FOREACH (Widget *widget, get_children())
|
||||
{
|
||||
REQUIRE(widget);
|
||||
Requisition req;
|
||||
req.width = widget->get_width();
|
||||
req.height = widget->get_height();
|
||||
RequestResult result = {req, widget};
|
||||
total_width += result.requisition.width;
|
||||
requestResults[index++] = result;
|
||||
}
|
||||
|
||||
total_width = max(min(allocation.get_width(), total_width), 0);
|
||||
|
||||
// Lay out the child widgets
|
||||
int offset = 0;
|
||||
for(index = 0; index < child_count; index++)
|
||||
{
|
||||
RequestResult &result = requestResults[index];
|
||||
|
||||
Gtk::Allocation child_allocation(
|
||||
offset + border_width,
|
||||
(allocation.get_height() - result.requisition.height) / 2,
|
||||
min(result.requisition.width, allocation.get_width() - offset),
|
||||
result.requisition.height);
|
||||
|
||||
offset += result.requisition.width;
|
||||
|
||||
if(get_direction() == TEXT_DIR_RTL)
|
||||
{
|
||||
child_allocation.set_x(total_width -
|
||||
child_allocation.get_x() - child_allocation.get_width());
|
||||
}
|
||||
|
||||
if(child_allocation.get_width() <= 0)
|
||||
result.widget->set_child_visible(false);
|
||||
else
|
||||
{
|
||||
result.widget->size_allocate(child_allocation);
|
||||
result.widget->set_child_visible(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Tidy up
|
||||
delete[] requestResults;
|
||||
|
||||
// Resize the window
|
||||
if(window)
|
||||
{
|
||||
if(get_direction() != TEXT_DIR_RTL)
|
||||
{
|
||||
window->move_resize(allocation.get_x(), allocation.get_y(),
|
||||
total_width + border_width * 2, allocation.get_height());
|
||||
}
|
||||
else
|
||||
{
|
||||
window->move_resize(
|
||||
allocation.get_x() + allocation.get_width() - total_width,
|
||||
allocation.get_y(),
|
||||
total_width + border_width * 2, allocation.get_height());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PanelBar::on_panel_type(int type_index)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,25 +61,6 @@ private:
|
|||
*/
|
||||
void setup_panel_button();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* An override to intercept realize events.
|
||||
*/
|
||||
void on_realize();
|
||||
|
||||
/**
|
||||
* An event handler that is called to offer an allocation to this
|
||||
* widget.
|
||||
* @param requisition The area offered for this widget.
|
||||
*/
|
||||
void on_size_request(Gtk::Requisition* requisition);
|
||||
|
||||
/**
|
||||
* An override to intercept size allocate events.
|
||||
*/
|
||||
void on_size_allocate(Gtk::Allocation& allocation);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue