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:
@@ -22,15 +22,6 @@ extern "C" {
|
|||||||
#define GTK_PIZZA(obj) GTK_CHECK_CAST (obj, gtk_pizza_get_type (), GtkPizza)
|
#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 ())
|
#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 _GtkPizzaChild GtkPizzaChild;
|
||||||
typedef struct _GtkPizza GtkPizza;
|
typedef struct _GtkPizza GtkPizza;
|
||||||
typedef struct _GtkPizzaClass GtkPizzaClass;
|
typedef struct _GtkPizzaClass GtkPizzaClass;
|
||||||
@@ -48,7 +39,6 @@ struct _GtkPizza
|
|||||||
{
|
{
|
||||||
GtkContainer container;
|
GtkContainer container;
|
||||||
GList *children;
|
GList *children;
|
||||||
GtkMyShadowType shadow_type;
|
|
||||||
|
|
||||||
guint m_xoffset;
|
guint m_xoffset;
|
||||||
guint m_yoffset;
|
guint m_yoffset;
|
||||||
@@ -85,9 +75,6 @@ void gtk_pizza_set_yoffset (GtkPizza *pizza, gint yoffset);
|
|||||||
WXDLLIMPEXP_CORE
|
WXDLLIMPEXP_CORE
|
||||||
gint gtk_pizza_get_rtl_offset (GtkPizza *pizza);
|
gint gtk_pizza_get_rtl_offset (GtkPizza *pizza);
|
||||||
|
|
||||||
WXDLLIMPEXP_CORE
|
|
||||||
void gtk_pizza_set_shadow_type (GtkPizza *pizza,
|
|
||||||
GtkMyShadowType type);
|
|
||||||
|
|
||||||
WXDLLIMPEXP_CORE
|
WXDLLIMPEXP_CORE
|
||||||
void gtk_pizza_scroll (GtkPizza *pizza,
|
void gtk_pizza_scroll (GtkPizza *pizza,
|
||||||
|
@@ -185,8 +185,6 @@ gtk_pizza_init (GtkPizza *pizza)
|
|||||||
{
|
{
|
||||||
GTK_WIDGET_UNSET_FLAGS (pizza, GTK_NO_WINDOW);
|
GTK_WIDGET_UNSET_FLAGS (pizza, GTK_NO_WINDOW);
|
||||||
|
|
||||||
pizza->shadow_type = GTK_MYSHADOW_NONE;
|
|
||||||
|
|
||||||
pizza->children = NULL;
|
pizza->children = NULL;
|
||||||
|
|
||||||
pizza->bin_window = 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 );
|
gdk_window_get_geometry( pizza->bin_window, NULL, NULL, &width, NULL, NULL );
|
||||||
|
|
||||||
if (pizza->shadow_type == GTK_MYSHADOW_NONE)
|
border = pizza->container.border_width;
|
||||||
border = 0;
|
|
||||||
else
|
|
||||||
if (pizza->shadow_type == GTK_MYSHADOW_THIN)
|
|
||||||
border = 1;
|
|
||||||
else
|
|
||||||
border = 2;
|
|
||||||
|
|
||||||
return width-border*2;
|
return width-border*2;
|
||||||
}
|
}
|
||||||
@@ -271,25 +263,6 @@ gtk_pizza_scroll_set_adjustments (GtkPizza *pizza,
|
|||||||
/* We handle scrolling in the wxScrolledWindow, not here. */
|
/* 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
|
void
|
||||||
gtk_pizza_put (GtkPizza *pizza,
|
gtk_pizza_put (GtkPizza *pizza,
|
||||||
GtkWidget *widget,
|
GtkWidget *widget,
|
||||||
@@ -416,6 +389,7 @@ gtk_pizza_realize (GtkWidget *widget)
|
|||||||
gint attributes_mask;
|
gint attributes_mask;
|
||||||
GtkPizzaChild *child;
|
GtkPizzaChild *child;
|
||||||
GList *children;
|
GList *children;
|
||||||
|
int border;
|
||||||
|
|
||||||
g_return_if_fail (widget != NULL);
|
g_return_if_fail (widget != NULL);
|
||||||
g_return_if_fail (GTK_IS_PIZZA (widget));
|
g_return_if_fail (GTK_IS_PIZZA (widget));
|
||||||
@@ -430,29 +404,11 @@ gtk_pizza_realize (GtkWidget *widget)
|
|||||||
attributes.width = widget->allocation.width;
|
attributes.width = widget->allocation.width;
|
||||||
attributes.height = widget->allocation.height;
|
attributes.height = widget->allocation.height;
|
||||||
|
|
||||||
#ifndef __WXUNIVERSAL__
|
border = pizza->container.border_width;
|
||||||
if (pizza->shadow_type == GTK_MYSHADOW_NONE)
|
attributes.x += border;
|
||||||
{
|
attributes.y += border;
|
||||||
/* no border, no changes to sizes */
|
attributes.width -= 2 * border;
|
||||||
}
|
attributes.height -= 2 * border;
|
||||||
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__ */
|
|
||||||
|
|
||||||
/* minimal size */
|
/* minimal size */
|
||||||
if (attributes.width < 2) attributes.width = 2;
|
if (attributes.width < 2) attributes.width = 2;
|
||||||
@@ -584,14 +540,7 @@ gtk_pizza_size_allocate (GtkWidget *widget,
|
|||||||
(widget->allocation.y == allocation->y));
|
(widget->allocation.y == allocation->y));
|
||||||
widget->allocation = *allocation;
|
widget->allocation = *allocation;
|
||||||
|
|
||||||
if (pizza->shadow_type == GTK_MYSHADOW_NONE)
|
border = pizza->container.border_width;
|
||||||
border = 0;
|
|
||||||
else
|
|
||||||
if (pizza->shadow_type == GTK_MYSHADOW_THIN)
|
|
||||||
border = 1;
|
|
||||||
else
|
|
||||||
border = 2;
|
|
||||||
|
|
||||||
x = allocation->x + border;
|
x = allocation->x + border;
|
||||||
y = allocation->y + border;
|
y = allocation->y + border;
|
||||||
w = allocation->width - border*2;
|
w = allocation->width - border*2;
|
||||||
@@ -749,14 +698,7 @@ gtk_pizza_allocate_child (GtkPizza *pizza,
|
|||||||
gint offset,border;
|
gint offset,border;
|
||||||
|
|
||||||
offset = GTK_WIDGET(pizza)->allocation.width;
|
offset = GTK_WIDGET(pizza)->allocation.width;
|
||||||
|
border = pizza->container.border_width;
|
||||||
if (pizza->shadow_type == GTK_MYSHADOW_NONE)
|
|
||||||
border = 0;
|
|
||||||
else
|
|
||||||
if (pizza->shadow_type == GTK_MYSHADOW_THIN)
|
|
||||||
border = 1;
|
|
||||||
else
|
|
||||||
border = 2;
|
|
||||||
offset -= border*2;
|
offset -= border*2;
|
||||||
|
|
||||||
allocation.x = offset - child->x - allocation.width - pizza->m_xoffset;
|
allocation.x = offset - child->x - allocation.width - pizza->m_xoffset;
|
||||||
|
@@ -2318,24 +2318,10 @@ bool wxWindowGTK::Create( wxWindow *parent,
|
|||||||
m_wxwindow = gtk_pizza_new();
|
m_wxwindow = gtk_pizza_new();
|
||||||
|
|
||||||
#ifndef __WXUNIVERSAL__
|
#ifndef __WXUNIVERSAL__
|
||||||
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
|
if (HasFlag(wxSIMPLE_BORDER))
|
||||||
|
gtk_container_set_border_width((GtkContainer*)m_wxwindow, 1);
|
||||||
if (HasFlag(wxRAISED_BORDER))
|
else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
|
||||||
{
|
gtk_container_set_border_width((GtkContainer*)m_wxwindow, 2);
|
||||||
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 );
|
|
||||||
}
|
|
||||||
#endif // __WXUNIVERSAL__
|
#endif // __WXUNIVERSAL__
|
||||||
|
|
||||||
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
|
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);
|
GetScrollbarWidth(m_widget, dw, dh);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __WXUNIVERSAL__
|
const int border = GTK_CONTAINER(m_wxwindow)->border_width;
|
||||||
if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
|
dw += 2 * border;
|
||||||
{
|
dh += 2 * 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__
|
|
||||||
|
|
||||||
width += dw;
|
width += dw;
|
||||||
height += dh;
|
height += dh;
|
||||||
@@ -2849,20 +2824,9 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const
|
|||||||
if (m_hasScrolling)
|
if (m_hasScrolling)
|
||||||
GetScrollbarWidth(m_widget, dw, dh);
|
GetScrollbarWidth(m_widget, dw, dh);
|
||||||
|
|
||||||
#ifndef __WXUNIVERSAL__
|
const int border = GTK_CONTAINER(m_wxwindow)->border_width;
|
||||||
if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER))
|
dw += 2 * border;
|
||||||
{
|
dh += 2 * 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__
|
|
||||||
|
|
||||||
w -= dw;
|
w -= dw;
|
||||||
h -= dh;
|
h -= dh;
|
||||||
|
Reference in New Issue
Block a user