use a GtkAlignment to set size of toolbar controls, instead of trying to "correct" size_allocate
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49252 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -24,19 +24,14 @@
|
|||||||
#include "wx/toolbar.h"
|
#include "wx/toolbar.h"
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/frame.h"
|
#include "wx/menu.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME: Use GtkImage instead of GtkPixmap. Use the new toolbar API for when gtk runtime is new enough?
|
// FIXME: Use GtkImage instead of GtkPixmap. Use the new toolbar API for when gtk runtime is new enough?
|
||||||
// Beware that the new and old toolbar API may not be mixed in usage.
|
// Beware that the new and old toolbar API may not be mixed in usage.
|
||||||
#include <gtk/gtkversion.h>
|
|
||||||
#ifdef GTK_DISABLE_DEPRECATED
|
|
||||||
#undef GTK_DISABLE_DEPRECATED
|
#undef GTK_DISABLE_DEPRECATED
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/gtk/private.h"
|
#include "wx/gtk/private.h"
|
||||||
#include "wx/menu.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* XPM */
|
/* XPM */
|
||||||
static const char *arrow_down_xpm[] = {
|
static const char *arrow_down_xpm[] = {
|
||||||
@@ -338,27 +333,6 @@ static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
static
|
|
||||||
void gtktoolwidget_size_callback( GtkWidget *widget,
|
|
||||||
GtkAllocation *alloc,
|
|
||||||
wxWindow *win )
|
|
||||||
{
|
|
||||||
// this shouldn't happen...
|
|
||||||
if (win->GetParent()->m_wxwindow) return;
|
|
||||||
|
|
||||||
wxSize size = win->GetEffectiveMinSize();
|
|
||||||
if (size.y != alloc->height)
|
|
||||||
{
|
|
||||||
GtkAllocation alloc2;
|
|
||||||
alloc2.x = alloc->x;
|
|
||||||
alloc2.y = (alloc->height - size.y + 3) / 2;
|
|
||||||
alloc2.width = alloc->width;
|
|
||||||
alloc2.height = size.y;
|
|
||||||
gtk_widget_size_allocate( widget, &alloc2 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// InsertChild callback for wxToolBar
|
// InsertChild callback for wxToolBar
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -646,20 +620,18 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case wxTOOL_STYLE_CONTROL:
|
case wxTOOL_STYLE_CONTROL:
|
||||||
|
GtkWidget* align = gtk_alignment_new(0.5, 0.5, 0, 0);
|
||||||
|
gtk_widget_show(align);
|
||||||
|
gtk_container_add((GtkContainer*)align, tool->GetControl()->m_widget);
|
||||||
gtk_toolbar_insert_widget(
|
gtk_toolbar_insert_widget(
|
||||||
m_toolbar,
|
m_toolbar,
|
||||||
tool->GetControl()->m_widget,
|
align,
|
||||||
(const char *) NULL,
|
(const char *) NULL,
|
||||||
(const char *) NULL,
|
(const char *) NULL,
|
||||||
posGtk
|
posGtk
|
||||||
);
|
);
|
||||||
// release reference obtained by wxInsertChildInToolBar
|
// release reference obtained by wxInsertChildInToolBar
|
||||||
g_object_unref(tool->GetControl()->m_widget);
|
g_object_unref(tool->GetControl()->m_widget);
|
||||||
|
|
||||||
// connect after in order to correct size_allocate events
|
|
||||||
g_signal_connect_after (tool->GetControl()->m_widget, "size_allocate",
|
|
||||||
G_CALLBACK (gtktoolwidget_size_callback), tool->GetControl());
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user