store GtkPizza border width in GtkContainer.border_width, eliminate GtkPizza.shadow_type
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42027 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
02ae785a8a
commit
af05af4d87
@ -22,15 +22,6 @@ extern "C" {
|
||||
#define GTK_PIZZA(obj) GTK_CHECK_CAST (obj, gtk_pizza_get_type (), GtkPizza)
|
||||
#define GTK_IS_PIZZA(obj) GTK_CHECK_TYPE (obj, gtk_pizza_get_type ())
|
||||
|
||||
/* Shadow types */
|
||||
typedef enum
|
||||
{
|
||||
GTK_MYSHADOW_NONE,
|
||||
GTK_MYSHADOW_THIN,
|
||||
GTK_MYSHADOW_IN,
|
||||
GTK_MYSHADOW_OUT
|
||||
} GtkMyShadowType;
|
||||
|
||||
typedef struct _GtkPizzaChild GtkPizzaChild;
|
||||
typedef struct _GtkPizza GtkPizza;
|
||||
typedef struct _GtkPizzaClass GtkPizzaClass;
|
||||
@ -48,7 +39,6 @@ struct _GtkPizza
|
||||
{
|
||||
GtkContainer container;
|
||||
GList *children;
|
||||
GtkMyShadowType shadow_type;
|
||||
|
||||
guint m_xoffset;
|
||||
guint m_yoffset;
|
||||
@ -85,9 +75,6 @@ void gtk_pizza_set_yoffset (GtkPizza *pizza, gint yoffset);
|
||||
WXDLLIMPEXP_CORE
|
||||
gint gtk_pizza_get_rtl_offset (GtkPizza *pizza);
|
||||
|
||||
WXDLLIMPEXP_CORE
|
||||
void gtk_pizza_set_shadow_type (GtkPizza *pizza,
|
||||
GtkMyShadowType type);
|
||||
|
||||
WXDLLIMPEXP_CORE
|
||||
void gtk_pizza_scroll (GtkPizza *pizza,
|
||||
|
@ -185,8 +185,6 @@ gtk_pizza_init (GtkPizza *pizza)
|
||||
{
|
||||
GTK_WIDGET_UNSET_FLAGS (pizza, GTK_NO_WINDOW);
|
||||
|
||||
pizza->shadow_type = GTK_MYSHADOW_NONE;
|
||||
|
||||
pizza->children = NULL;
|
||||
|
||||
pizza->bin_window = NULL;
|
||||
@ -251,13 +249,7 @@ gint gtk_pizza_get_rtl_offset (GtkPizza *pizza)
|
||||
|
||||
gdk_window_get_geometry( pizza->bin_window, NULL, NULL, &width, NULL, NULL );
|
||||
|
||||
if (pizza->shadow_type == GTK_MYSHADOW_NONE)
|
||||
border = 0;
|
||||
else
|
||||
if (pizza->shadow_type == GTK_MYSHADOW_THIN)
|
||||
border = 1;
|
||||
else
|
||||
border = 2;
|
||||
border = pizza->container.border_width;
|
||||
|
||||
return width-border*2;
|
||||
}
|
||||
@ -271,25 +263,6 @@ gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
|
||||
/* We handle scrolling in the wxScrolledWindow, not here. */
|
||||
}
|
||||
|
||||
void
|
||||
gtk_pizza_set_shadow_type (GtkPizza *pizza,
|
||||
GtkMyShadowType type)
|
||||
{
|
||||
g_return_if_fail (pizza != NULL);
|
||||
g_return_if_fail (GTK_IS_PIZZA (pizza));
|
||||
|
||||
if (pizza->shadow_type != type)
|
||||
{
|
||||
pizza->shadow_type = type;
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (pizza))
|
||||
{
|
||||
gtk_widget_size_allocate (GTK_WIDGET (pizza), &(GTK_WIDGET (pizza)->allocation));
|
||||
gtk_widget_queue_draw (GTK_WIDGET (pizza));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_pizza_put (GtkPizza *pizza,
|
||||
GtkWidget *widget,
|
||||
@ -416,6 +389,7 @@ gtk_pizza_realize (GtkWidget *widget)
|
||||
gint attributes_mask;
|
||||
GtkPizzaChild *child;
|
||||
GList *children;
|
||||
int border;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_PIZZA (widget));
|
||||
@ -430,29 +404,11 @@ gtk_pizza_realize (GtkWidget *widget)
|
||||
attributes.width = widget->allocation.width;
|
||||
attributes.height = widget->allocation.height;
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
if (pizza->shadow_type == GTK_MYSHADOW_NONE)
|
||||
{
|
||||
/* no border, no changes to sizes */
|
||||
}
|
||||
else if (pizza->shadow_type == GTK_MYSHADOW_THIN)
|
||||
{
|
||||
/* GTK_MYSHADOW_THIN == wxSIMPLE_BORDER */
|
||||
attributes.x += 1;
|
||||
attributes.y += 1;
|
||||
attributes.width -= 2;
|
||||
attributes.height -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* GTK_MYSHADOW_IN == wxSUNKEN_BORDER */
|
||||
/* GTK_MYSHADOW_OUT == wxRAISED_BORDER */
|
||||
attributes.x += 2;
|
||||
attributes.y += 2;
|
||||
attributes.width -= 4;
|
||||
attributes.height -= 4;
|
||||
}
|
||||
#endif /* __WXUNIVERSAL__ */
|
||||
border = pizza->container.border_width;
|
||||
attributes.x += border;
|
||||
attributes.y += border;
|
||||
attributes.width -= 2 * border;
|
||||
attributes.height -= 2 * border;
|
||||
|
||||
/* minimal size */
|
||||
if (attributes.width < 2) attributes.width = 2;
|
||||
@ -584,14 +540,7 @@ gtk_pizza_size_allocate (GtkWidget *widget,
|
||||
(widget->allocation.y == allocation->y));
|
||||
widget->allocation = *allocation;
|
||||
|
||||
if (pizza->shadow_type == GTK_MYSHADOW_NONE)
|
||||
border = 0;
|
||||
else
|
||||
if (pizza->shadow_type == GTK_MYSHADOW_THIN)
|
||||
border = 1;
|
||||
else
|
||||
border = 2;
|
||||
|
||||
border = pizza->container.border_width;
|
||||
x = allocation->x + border;
|
||||
y = allocation->y + border;
|
||||
w = allocation->width - border*2;
|
||||
@ -749,14 +698,7 @@ gtk_pizza_allocate_child (GtkPizza *pizza,
|
||||
gint offset,border;
|
||||
|
||||
offset = GTK_WIDGET(pizza)->allocation.width;
|
||||
|
||||
if (pizza->shadow_type == GTK_MYSHADOW_NONE)
|
||||
border = 0;
|
||||
else
|
||||
if (pizza->shadow_type == GTK_MYSHADOW_THIN)
|
||||
border = 1;
|
||||
else
|
||||
border = 2;
|
||||
border = pizza->container.border_width;
|
||||
offset -= border*2;
|
||||
|
||||
allocation.x = offset - child->x - allocation.width - pizza->m_xoffset;
|
||||
|
@ -2318,24 +2318,10 @@ bool wxWindowGTK::Create( wxWindow *parent,
|
||||
m_wxwindow = gtk_pizza_new();
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
|
||||
|
||||
if (HasFlag(wxRAISED_BORDER))
|
||||
{
|
||||
gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_OUT );
|
||||
}
|
||||
else if (HasFlag(wxSUNKEN_BORDER))
|
||||
{
|
||||
gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_IN );
|
||||
}
|
||||
else if (HasFlag(wxSIMPLE_BORDER))
|
||||
{
|
||||
gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_THIN );
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_NONE );
|
||||
}
|
||||
if (HasFlag(wxSIMPLE_BORDER))
|
||||
gtk_container_set_border_width((GtkContainer*)m_wxwindow, 1);
|
||||
else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
|
||||
gtk_container_set_border_width((GtkContainer*)m_wxwindow, 2);
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
|
||||
@ -2812,20 +2798,9 @@ void wxWindowGTK::DoSetClientSize( int width, int height )
|
||||
GetScrollbarWidth(m_widget, dw, dh);
|
||||
}
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
|
||||
{
|
||||
// shadow border size is 2
|
||||
dw += 2 * 2;
|
||||
dh += 2 * 2;
|
||||
}
|
||||
if (HasFlag(wxSIMPLE_BORDER))
|
||||
{
|
||||
// simple border size is 1
|
||||
dw += 1 * 2;
|
||||
dh += 1 * 2;
|
||||
}
|
||||
#endif // __WXUNIVERSAL__
|
||||
const int border = GTK_CONTAINER(m_wxwindow)->border_width;
|
||||
dw += 2 * border;
|
||||
dh += 2 * border;
|
||||
|
||||
width += dw;
|
||||
height += dh;
|
||||
@ -2849,20 +2824,9 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
|
||||
if (m_hasScrolling)
|
||||
GetScrollbarWidth(m_widget, dw, dh);
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
|
||||
{
|
||||
// shadow border size is 2
|
||||
dw += 2 * 2;
|
||||
dh += 2 * 2;
|
||||
}
|
||||
if (HasFlag(wxSIMPLE_BORDER))
|
||||
{
|
||||
// simple border size is 1
|
||||
dw += 1 * 2;
|
||||
dh += 1 * 2;
|
||||
}
|
||||
#endif // __WXUNIVERSAL__
|
||||
const int border = GTK_CONTAINER(m_wxwindow)->border_width;
|
||||
dw += 2 * border;
|
||||
dh += 2 * border;
|
||||
|
||||
w -= dw;
|
||||
h -= dh;
|
||||
|
Loading…
Reference in New Issue
Block a user