libeek: make eek_container_find_by_position() as non-virtual

This commit is contained in:
Daiki Ueno
2010-06-18 14:58:48 +09:00
parent 74ea63fbed
commit f7399786a3

View File

@ -105,43 +105,6 @@ eek_container_real_find (EekContainer *self,
return NULL;
}
struct _FbpData
{
EekKey *key;
gint x, y;
};
typedef struct _FbpData FbpData;
static gint
compare_element_by_position (EekElement *element, gpointer user_data)
{
EekBounds bounds;
FbpData *data = user_data;
eek_element_get_bounds (element, &bounds);
if (bounds.x <= data->x && bounds.y <= data->y &&
data->x <= (bounds.x + bounds.width) &&
data->y <= (bounds.y + bounds.height))
return 0;
return -1;
}
static EekElement *
eek_container_real_find_by_position (EekContainer *self,
gdouble x,
gdouble y)
{
EekBounds bounds;
FbpData data;
eek_element_get_bounds (EEK_ELEMENT(self), &bounds);
data.x = x - bounds.x;
data.y = y - bounds.y;
return eek_container_find (self,
compare_element_by_position,
&data);
}
static void
eek_container_dispose (GObject *object)
{
@ -178,7 +141,6 @@ eek_container_class_init (EekContainerClass *klass)
klass->remove_child = eek_container_real_remove_child;
klass->foreach_child = eek_container_real_foreach_child;
klass->find = eek_container_real_find;
klass->find_by_position = eek_container_real_find_by_position;
gobject_class->finalize = eek_container_finalize;
gobject_class->dispose = eek_container_dispose;
@ -269,13 +231,40 @@ eek_container_find (EekContainer *container,
user_data);
}
struct _FbpData
{
EekKey *key;
gint x, y;
};
typedef struct _FbpData FbpData;
static gint
compare_element_by_position (EekElement *element, gpointer user_data)
{
EekBounds bounds;
FbpData *data = user_data;
eek_element_get_bounds (element, &bounds);
if (bounds.x <= data->x && bounds.y <= data->y &&
data->x <= (bounds.x + bounds.width) &&
data->y <= (bounds.y + bounds.height))
return 0;
return -1;
}
EekElement *
eek_container_find_by_position (EekContainer *container,
gdouble x,
gdouble y)
{
EekBounds bounds;
FbpData data;
g_return_val_if_fail (EEK_IS_CONTAINER(container), NULL);
return EEK_CONTAINER_GET_CLASS(container)->find_by_position (container,
x,
y);
eek_element_get_bounds (EEK_ELEMENT(container), &bounds);
data.x = x - bounds.x;
data.y = y - bounds.y;
return eek_container_find (container,
compare_element_by_position,
&data);
}