[gtk+/extended-layout-jhs: 24/64] Rudimentary implementation of GtkExtendLayout.
- From: Johannes Schmid <jhs src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/extended-layout-jhs: 24/64] Rudimentary implementation of GtkExtendLayout.
- Date: Wed, 25 Nov 2009 11:20:55 +0000 (UTC)
commit 1482789257ccd2e62d2ea3d3706c39494d57e47f
Author: Mathias Hasselmann <mathias hasselmann gmx de>
Date: Sun Jul 1 09:11:47 2007 +0000
Rudimentary implementation of GtkExtendLayout.
2007-07-01 Mathias Hasselmann <mathias hasselmann gmx de>
* gtk/gtkhbox.c: Rudimentary implementation of GtkExtendLayout.
svn path=/branches/extended-layout/; revision=18320
ChangeLog.gtk-extended-layout | 4 ++
gtk/gtkhbox.c | 91 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 94 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog.gtk-extended-layout b/ChangeLog.gtk-extended-layout
index e00f262..9ea3265 100644
--- a/ChangeLog.gtk-extended-layout
+++ b/ChangeLog.gtk-extended-layout
@@ -1,3 +1,7 @@
+2007-07-01 Mathias Hasselmann <mathias hasselmann gmx de>
+
+ * gtk/gtkhbox.c: Rudimentary implementation of GtkExtendLayout.
+
2007-06-30 Mathias Hasselmann <mathias hasselmann gmx de>
* tests/testextendedlayout.c: Provide button variant of the
diff --git a/gtk/gtkhbox.c b/gtk/gtkhbox.c
index cbb9140..62615f1 100644
--- a/gtk/gtkhbox.c
+++ b/gtk/gtkhbox.c
@@ -62,7 +62,11 @@ static void gtk_hbox_size_request (GtkWidget *widget,
static void gtk_hbox_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-G_DEFINE_TYPE (GtkHBox, gtk_hbox, GTK_TYPE_BOX)
+static void gtk_hbox_extended_layout_interface_init (GtkExtendedLayoutIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkHBox, gtk_hbox, GTK_TYPE_BOX,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+ gtk_hbox_extended_layout_interface_init))
static void
gtk_hbox_class_init (GtkHBoxClass *class)
@@ -472,5 +476,90 @@ gtk_hbox_set_baseline_policy (GtkHBox *hbox,
g_object_set (hbox, "baseline-policy", policy, NULL);
}
+static GtkExtendedLayoutFeatures
+gtk_hbox_extended_layout_get_features (GtkExtendedLayout *layout)
+{
+ return
+ GTK_EXTENDED_LAYOUT_NATURAL_SIZE |
+ GTK_EXTENDED_LAYOUT_BASELINES;
+}
+
+static void
+gtk_hbox_extended_layout_get_natural_size (GtkExtendedLayout *layout,
+ GtkRequisition *requisition)
+{
+ GtkBox *box = GTK_BOX (layout);
+
+ GtkRequisition child_requisition;
+ GtkBoxChild *child;
+ GList *children;
+
+ requisition->width = 0;
+ requisition->height = 0;
+
+ children = box->children;
+ while (children)
+ {
+ child = children->data;
+ children = children->next;
+
+ if (GTK_WIDGET_VISIBLE (child->widget))
+ {
+ if (GTK_IS_EXTENDED_LAYOUT (child->widget) &&
+ GTK_EXTENDED_LAYOUT_HAS_NATURAL_SIZE (child->widget))
+ gtk_extended_layout_get_natural_size (GTK_EXTENDED_LAYOUT (child->widget),
+ &child_requisition);
+ else
+ gtk_widget_size_request (child->widget, &child_requisition);
+
+ requisition->width += child_requisition.width;
+ requisition->height = MAX (child_requisition.height, requisition->height);
+ }
+ }
+}
+
+static gint
+gtk_hbox_extended_layout_get_baselines (GtkExtendedLayout *layout,
+ gint **baselines)
+{
+ GtkBox *box = GTK_BOX (layout);
+
+ gint hbox_baseline = 0;
+ gint child_baseline;
+
+ GtkBoxChild *child;
+ GList *children;
+
+ children = box->children;
+
+ while (children)
+ {
+ child = children->data;
+ children = children->next;
+
+ if (GTK_WIDGET_VISIBLE (child->widget) &&
+ GTK_IS_EXTENDED_LAYOUT (child->widget) &&
+ GTK_EXTENDED_LAYOUT_HAS_BASELINES (child->widget))
+ {
+ child_baseline = gtk_extended_layout_get_single_baseline (
+ GTK_EXTENDED_LAYOUT (child->widget), GTK_BASELINE_FIRST);
+ hbox_baseline = MAX (hbox_baseline, child_baseline);
+ }
+ }
+
+ *baselines = g_new (gint, 1);
+ *baselines[0] = hbox_baseline;
+
+ return 1;
+}
+
+static void
+gtk_hbox_extended_layout_interface_init (GtkExtendedLayoutIface *iface)
+{
+ iface->get_features = gtk_hbox_extended_layout_get_features;
+ iface->get_natural_size = gtk_hbox_extended_layout_get_natural_size;
+ iface->get_baselines = gtk_hbox_extended_layout_get_baselines;
+}
+
#define __GTK_HBOX_C__
#include "gtkaliasdef.c"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]