[Commit] twin ChangeLog, 1.25, 1.26 Makefile.am, 1.12, 1.13 twin.h, 1.18, 1.19 twin_box.c, 1.1, 1.2 twin_button.c, 1.3, 1.4 twin_calc.c, NONE, 1.1 twin_calc.h, NONE, 1.1 twin_label.c, 1.2, 1.3 twin_toplevel.c, 1.1, 1.2 twin_widget.c, 1.3, 1.4 twinint.h, 1.16, 1.17 xtwin.c, 1.22, 1.23

Keith Packard commit at keithp.com
Wed Oct 27 13:09:39 PDT 2004


Committed by: keithp

Update of /local/src/CVS/twin
In directory home.keithp.com:/tmp/cvs-serv9801

Modified Files:
	ChangeLog Makefile.am twin.h twin_box.c twin_button.c 
	twin_label.c twin_toplevel.c twin_widget.c twinint.h xtwin.c 
Added Files:
	twin_calc.c twin_calc.h 
Log Message:
2004-10-27  Keith Packard  <keithp at keithp.com>

	* Makefile.am:
	Add calculator and missing header files
	
	* twin.h:
	* twin_box.c: (_twin_box_init), (_twin_box_query_geometry),
	(_twin_box_configure), (_twin_box_dispatch), (twin_box_create):
	* twin_button.c: (_twin_button_dispatch), (_twin_button_init):
	* twin_toplevel.c: (_twin_toplevel_init):
	* twin_widget.c: (_twin_widget_dispatch), (_twin_widget_init),
	* twin_label.c: (_twin_label_query_geometry),
	(_twin_label_dispatch), (_twin_label_init):
	* twinint.h:
	(twin_widget_create):
	Change type name from twin_layout_t to twin_box_dir_t
	Create new twin_widget_layout_t holding layout preferences.
	Add copy_geom field to widget to make widgets look the same
	Add button signals and signal proc.
	Fix box layout to sum stretch along axis and minimize normal
	
	* twin_calc.c: (_twin_calc_button_to_id),
	(_twin_calc_update_value), (_twin_calc_push), (_twin_calc_pop),
	(_twin_calc_digit), (_twin_calc_button_signal), (twin_calc_start):
	* twin_calc.h:
	* xtwin.c: (main):
	Add calculator demo


Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/twin/ChangeLog,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- ChangeLog	27 Oct 2004 06:07:35 -0000	1.25
+++ ChangeLog	27 Oct 2004 20:09:36 -0000	1.26
@@ -1,3 +1,31 @@
+2004-10-27  Keith Packard  <keithp at keithp.com>
+
+	* Makefile.am:
+	Add calculator and missing header files
+	
+	* twin.h:
+	* twin_box.c: (_twin_box_init), (_twin_box_query_geometry),
+	(_twin_box_configure), (_twin_box_dispatch), (twin_box_create):
+	* twin_button.c: (_twin_button_dispatch), (_twin_button_init):
+	* twin_toplevel.c: (_twin_toplevel_init):
+	* twin_widget.c: (_twin_widget_dispatch), (_twin_widget_init),
+	* twin_label.c: (_twin_label_query_geometry),
+	(_twin_label_dispatch), (_twin_label_init):
+	* twinint.h:
+	(twin_widget_create):
+	Change type name from twin_layout_t to twin_box_dir_t
+	Create new twin_widget_layout_t holding layout preferences.
+	Add copy_geom field to widget to make widgets look the same
+	Add button signals and signal proc.
+	Fix box layout to sum stretch along axis and minimize normal
+	
+	* twin_calc.c: (_twin_calc_button_to_id),
+	(_twin_calc_update_value), (_twin_calc_push), (_twin_calc_pop),
+	(_twin_calc_digit), (_twin_calc_button_signal), (twin_calc_start):
+	* twin_calc.h:
+	* xtwin.c: (main):
+	Add calculator demo
+
 2004-10-26  Keith Packard  <keithp at keithp.com>
 
 	* twin_button.c: (_twin_button_paint):

Index: Makefile.am
===================================================================
RCS file: /local/src/CVS/twin/Makefile.am,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- Makefile.am	26 Oct 2004 19:56:18 -0000	1.12
+++ Makefile.am	27 Oct 2004 20:09:36 -0000	1.13
@@ -44,11 +44,18 @@
 	twin_window.c \
 	twin_work.c \
 	twin_x11.c \
+	twin_x11.h \
 	twinint.h \
 	twin_clock.c \
+	twin_clock.h \
+	twin_calc.c \
+	twin_calc.h \
 	twin_text.c \
+	twin_text.h \
 	twin_demo.c \
+	twin_demo.h \
 	twin_hello.c \
+	twin_hello.h \
 	xtwin.c
 
 xtwin_LDADD = @X_LIBS@ -lm

Index: twin.h
===================================================================
RCS file: /local/src/CVS/twin/twin.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- twin.h	26 Oct 2004 19:56:18 -0000	1.18
+++ twin.h	27 Oct 2004 20:09:36 -0000	1.19
@@ -372,37 +372,42 @@
 #define _twin_widget_height(w)	(((twin_widget_t *)(w))->extents.bottom - \
 				 ((twin_widget_t *)(w))->extents.top)
 
+typedef enum _twin_box_dir {
+    TwinBoxHorz, TwinBoxVert
+} twin_box_dir_t;
+
 typedef enum _twin_dispatch_result {
-    TwinDispatchNone,
-    TwinDispatchPaint,
-    TwinDispatchConfigure,
+    TwinDispatchDone,
+    TwinDispatchContinue
 } twin_dispatch_result_t;
 
-typedef enum _twin_layout {
-    TwinLayoutHorz, TwinLayoutVert
-} twin_layout_t;
-
 typedef twin_dispatch_result_t (*twin_dispatch_proc_t) (twin_widget_t *widget,
 							twin_event_t *event);
 		       
+typedef struct _twin_widget_layout {
+    twin_coord_t	    width;
+    twin_coord_t	    height;
+    twin_stretch_t	    stretch_width;
+    twin_stretch_t	    stretch_height;
+} twin_widget_layout_t;
+
 struct _twin_widget {
     twin_window_t	    *window;
     twin_widget_t	    *next;
     twin_box_t		    *parent;
+    twin_widget_t	    *copy_geom;
     twin_bool_t		    paint;
     twin_bool_t		    layout;
     twin_bool_t		    want_focus;
     twin_argb32_t	    background;
     twin_rect_t		    extents;	/* current geometry */
-    twin_rect_t		    preferred;	/* desired geometry */
-    twin_stretch_t    	    hstretch;	/* stretch ratio in horizontal dir */
-    twin_stretch_t    	    vstretch;	/* stretch ratio in vertical dir */
+    twin_widget_layout_t    preferred;
     twin_dispatch_proc_t    dispatch;
 };
 
 struct _twin_box {
     twin_widget_t	widget;
-    twin_layout_t	layout;
+    twin_box_dir_t	dir;
     twin_widget_t	*children;
     twin_widget_t	*button_down;
     twin_widget_t	*focus;
@@ -421,15 +426,42 @@
     twin_point_t	offset;
 } twin_label_t;
 
-typedef void	(*twin_callback_t) (twin_widget_t *widget, void *closure);
+typedef enum _twin_button_signal {
+    TwinButtonSignalDown,   /* sent when button pressed */
+    TwinButtonSignalUp,	    /* send when button released inside widget */
+} twin_button_signal_t;
 
-typedef struct _twin_button {
-    twin_label_t	label;
-    twin_bool_t		pressed;
-    twin_bool_t		active;
-    twin_callback_t	callback;
-    void		*closure;
-} twin_button_t;
+typedef struct _twin_button twin_button_t;
+
+typedef void	(*twin_button_signal_proc_t) (twin_button_t	    *button,
+					      twin_button_signal_t  signal,
+					      void		    *closure);
+
+struct _twin_button {
+    twin_label_t		label;
+    twin_bool_t			pressed;
+    twin_bool_t			active;
+    twin_button_signal_proc_t	signal;
+    void			*closure;
+};
+
+typedef enum _twin_scroll_signal {
+    TwinScrollSignalUpArrow,
+    TwinScrollSignalDownArrow,
+    TwinScrollSignalThumb,
+    TwinScrollSignalAboveThumb,
+    TwinScrollSignalBelowThumb,
+} twin_scroll_signal_t;
+
+typedef struct _twin_scroll twin_scroll_t;
+
+typedef void	(*twin_scroll_signal_proc_t) (twin_scroll_t	    *scroll,
+					      twin_scroll_signal_t  signal,
+					      void		    *closure);
+
+struct _twin_scroll {
+    twin_widget_t		widget;
+};
 
 /*
  * twin_box.c
@@ -437,7 +469,7 @@
 
 twin_box_t *
 twin_box_create (twin_box_t	*parent,
-		 twin_layout_t	layout);
+		 twin_box_dir_t	dir);
 
 /*
  * twin_button.c

Index: twin_box.c
===================================================================
RCS file: /local/src/CVS/twin/twin_box.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- twin_box.c	26 Oct 2004 06:15:42 -0000	1.1
+++ twin_box.c	27 Oct 2004 20:09:36 -0000	1.2
@@ -28,58 +28,74 @@
 _twin_box_init (twin_box_t		*box,
 		twin_box_t		*parent,
 		twin_window_t		*window,
-		twin_layout_t		layout,
+		twin_box_dir_t		dir,
 		twin_dispatch_proc_t	dispatch)
 {
-    static twin_rect_t	preferred = { 0, 0, 0, 0 };
-    _twin_widget_init (&box->widget, parent, window, preferred, 0, 0, dispatch);
-    box->layout = layout;
-    box->children = 0;
+    static twin_widget_layout_t	preferred = { 0, 0, 0, 0 };
+    _twin_widget_init (&box->widget, parent, window, preferred, dispatch);
+    box->dir = dir;
+    box->children = NULL;
+    box->button_down = NULL;
+    box->focus = NULL;
 }
 
 static twin_dispatch_result_t
 _twin_box_query_geometry (twin_box_t *box)
 {
-    twin_widget_t   *widget;
-    twin_event_t    ev;
-    twin_coord_t    w, h;
-    twin_coord_t    c_w, c_h;
+    twin_widget_t	    *child;
+    twin_event_t	    ev;
+    twin_widget_layout_t    preferred;
 
-    w = 0; h = 0;
+    preferred.width = 0;
+    preferred.height = 0;
+    if (box->dir == TwinBoxHorz)
+    {
+	preferred.stretch_width = 0;
+	preferred.stretch_height = 10000;
+    }
+    else
+    {
+	preferred.stretch_width = 10000;
+	preferred.stretch_height = 0;
+    }
     /*
      * Find preferred geometry
      */
-    for (widget = box->children; widget; widget = widget->next)
+    for (child = box->children; child; child = child->next)
     {
-	ev.kind = TwinEventQueryGeometry;
-	(*widget->dispatch) (widget, &ev);
-	c_w = widget->preferred.right - widget->preferred.left;
-	c_h = widget->preferred.bottom - widget->preferred.top;
-	if (box->layout == TwinLayoutHorz)
+	if (child->layout)
 	{
-	    w += c_w;
-	    if (c_h > h)
-		h = c_h;
+	    ev.kind = TwinEventQueryGeometry;
+	    (*child->dispatch) (child, &ev);
+	}
+	if (box->dir == TwinBoxHorz)
+	{
+	    preferred.width += child->preferred.width;
+	    preferred.stretch_width += child->preferred.stretch_width;
+	    if (child->preferred.height > preferred.height)
+		preferred.height = child->preferred.height;
+	    if (child->preferred.stretch_height < preferred.stretch_height)
+		preferred.stretch_height = child->preferred.stretch_height;
 	}
 	else
 	{
-	    h += c_h;
-	    if (c_w > w)
-		w = c_w;
+	    preferred.height += child->preferred.height;
+	    preferred.stretch_height += child->preferred.stretch_height;
+	    if (child->preferred.width > preferred.width)
+		preferred.width = child->preferred.width;
+	    if (child->preferred.stretch_width < preferred.stretch_width)
+		preferred.stretch_width = child->preferred.stretch_width;
 	}
     }
-    box->widget.preferred.left = 0;
-    box->widget.preferred.top = 0;
-    box->widget.preferred.right = w;
-    box->widget.preferred.bottom = h;
-    return TwinDispatchNone;
+    box->widget.preferred = preferred;
+    return TwinDispatchContinue;
 }
 
 static twin_dispatch_result_t
 _twin_box_configure (twin_box_t *box)
 {
-    twin_coord_t    w = box->widget.extents.right - box->widget.extents.left;
-    twin_coord_t    h = box->widget.extents.bottom - box->widget.extents.top;
+    twin_coord_t    width = _twin_widget_width (box);
+    twin_coord_t    height = _twin_widget_height (box);
     twin_coord_t    actual;
     twin_coord_t    pref;
     twin_coord_t    delta;
@@ -87,21 +103,18 @@
     twin_coord_t    stretch = 0;
     twin_coord_t    pos = 0;
     twin_widget_t   *child;
-    twin_dispatch_result_t  result = TwinDispatchNone;
     
-    if (box->layout == TwinLayoutHorz)
+    if (box->dir == TwinBoxHorz)
     {
-	for (child = box->children; child; child = child->next)
-	    stretch += child->hstretch;
-	actual = w;
-	pref = box->widget.preferred.right - box->widget.preferred.left;
+	stretch = box->widget.preferred.stretch_width;
+	actual = width;
+	pref = box->widget.preferred.width;
     }
     else
     {
-	for (child = box->children; child; child = child->next)
-	    stretch += child->vstretch;
-	actual = h;
-	pref = box->widget.preferred.bottom - box->widget.preferred.top;
+	stretch = box->widget.preferred.stretch_height;
+	actual = height;
+	pref = box->widget.preferred.height;
     }
     if (!stretch) stretch = 1;
     delta = delta_remain = actual - pref;
@@ -116,10 +129,10 @@
 	    delta_this = delta_remain;
 	else
 	{
-	    if (box->layout == TwinLayoutHorz)
-		stretch_this = child->hstretch;
+	    if (box->dir == TwinBoxHorz)
+		stretch_this = child->preferred.stretch_width;
 	    else
-		stretch_this = child->vstretch;
+		stretch_this = child->preferred.stretch_height;
 	    delta_this = delta * stretch_this / stretch;
 	}
 	if (delta_remain < 0)
@@ -133,30 +146,33 @@
 		delta_this = delta_remain;
 	}
 	delta_remain -= delta_this;
-	if (box->layout == TwinLayoutHorz)
+	if (box->dir == TwinBoxHorz)
 	{
-	    twin_coord_t    child_w = (child->preferred.right -
-				       child->preferred.left);
+	    twin_coord_t    child_w = child->preferred.width;
 	    extents.top = 0;
-	    extents.bottom = h;
+	    extents.bottom = height;
 	    extents.left = pos;
 	    pos = extents.right = pos + child_w + delta_this;
 	}
 	else
 	{
-	    twin_coord_t    child_h = (child->preferred.bottom -
-				       child->preferred.top);
+	    twin_coord_t    child_h = child->preferred.height;
 	    extents.left = 0;
-	    extents.right = w;
+	    extents.right = width;
 	    extents.top = pos;
 	    pos = extents.bottom = pos + child_h + delta_this;
 	}
-	ev.kind = TwinEventConfigure;
-	ev.u.configure.extents = extents;
-	(*child->dispatch) (child, &ev);
-	result = TwinDispatchPaint;
+	if (extents.left != ev.u.configure.extents.left ||
+	    extents.top != ev.u.configure.extents.top ||
+	    extents.right != ev.u.configure.extents.right ||
+	    extents.bottom != ev.u.configure.extents.bottom)
+	{
+	    ev.kind = TwinEventConfigure;
+	    ev.u.configure.extents = extents;
+	    (*child->dispatch) (child, &ev);
+	}
     }
-    return result;
+    return TwinDispatchContinue;
 }
 
 static twin_widget_t *
@@ -180,11 +196,12 @@
     twin_event_t    ev;
     twin_widget_t   *child;
 
+    if (_twin_widget_dispatch (widget, event) == TwinDispatchDone)
+	return TwinDispatchDone;
     switch (event->kind) {
     case TwinEventQueryGeometry:
 	return _twin_box_query_geometry (box);
     case TwinEventConfigure:
-	_twin_widget_dispatch (widget, event);
 	return _twin_box_configure (box);
     case TwinEventButtonDown:
 	box->button_down = _twin_box_xy_to_widget (box, 
@@ -227,17 +244,17 @@
     default:
 	break;
     }
-    return TwinDispatchNone;
+    return TwinDispatchContinue;
 }
 
 twin_box_t *
 twin_box_create (twin_box_t	*parent,
-		 twin_layout_t	layout)
+		 twin_box_dir_t	dir)
 {
     twin_box_t	*box = malloc (sizeof (twin_box_t));
     if (!box)
 	return 0;
-    _twin_box_init (box, parent, 0, layout, _twin_box_dispatch);
+    _twin_box_init (box, parent, 0, dir, _twin_box_dispatch);
     return box;
 }
 

Index: twin_button.c
===================================================================
RCS file: /local/src/CVS/twin/twin_button.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- twin_button.c	27 Oct 2004 06:07:35 -0000	1.3
+++ twin_button.c	27 Oct 2004 20:09:36 -0000	1.4
@@ -52,16 +52,19 @@
 {
     twin_button_t    *button = (twin_button_t *) widget;
 
-    _twin_label_dispatch (widget, event);
+    if (_twin_label_dispatch (widget, event) == TwinDispatchDone)
+	return TwinDispatchDone;
     switch (event->kind) {
     case TwinEventPaint:
 	_twin_button_paint (button);
-	return TWIN_TRUE;
+	break;
     case TwinEventButtonDown:
 	button->pressed = TWIN_TRUE;
 	button->active = TWIN_TRUE;
 	_twin_button_set_label_offset (button);
-	return TWIN_TRUE;
+	if (button->signal)
+	    (*button->signal) (button, TwinButtonSignalDown, button->closure);
+	break;
     case TwinEventMotion:
 	if (button->pressed)
 	{
@@ -74,21 +77,21 @@
 		_twin_button_set_label_offset (button);
 	    }
 	}
-	return TWIN_TRUE;
+	break;
     case TwinEventButtonUp:
 	button->pressed = TWIN_FALSE;
 	if (button->active)
 	{
-	    if (button->callback)
-		(*button->callback) (&button->label.widget, button->closure);
 	    button->active = TWIN_FALSE;
 	    _twin_button_set_label_offset (button);
+	    if (button->signal)
+		(*button->signal) (button, TwinButtonSignalUp, button->closure);
 	}
-	return TWIN_TRUE;
+	break;
     default:
 	break;
     }
-    return TwinDispatchNone;
+    return TwinDispatchContinue;
 }
 
 void
@@ -103,6 +106,9 @@
     _twin_label_init (&button->label, parent, value,
 		      foreground, font_size, font_style, dispatch);
     button->pressed = TWIN_FALSE;
+    button->active = TWIN_FALSE;
+    button->signal = NULL;
+    button->closure = NULL;
     _twin_button_set_label_offset (button);
 }
 

--- NEW FILE: twin_calc.c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: twin_calc.h ---
(This appears to be a binary file; contents omitted.)

Index: twin_label.c
===================================================================
RCS file: /local/src/CVS/twin/twin_label.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- twin_label.c	26 Oct 2004 19:56:19 -0000	1.2
+++ twin_label.c	27 Oct 2004 20:09:36 -0000	1.3
@@ -30,16 +30,14 @@
     twin_path_t		*path = twin_path_create ();
     twin_text_metrics_t	m;
     
-    label->widget.preferred.left = 0;
-    label->widget.preferred.top = 0;
-    label->widget.preferred.right = twin_fixed_to_int (label->font_size);
-    label->widget.preferred.bottom = twin_fixed_to_int (label->font_size) * 2;
+    label->widget.preferred.width = twin_fixed_to_int (label->font_size) * 2;
+    label->widget.preferred.height = twin_fixed_to_int (label->font_size) * 2;
     if (path)
     {
 	twin_path_set_font_size (path, label->font_size);
 	twin_path_set_font_style (path, label->font_style);
 	twin_text_metrics_utf8 (path, label->label, &m);
-	label->widget.preferred.right += twin_fixed_to_int (m.width);
+	label->widget.preferred.width += twin_fixed_to_int (m.width);
 	twin_path_destroy (path);
     }
 }
@@ -74,18 +72,19 @@
 {
     twin_label_t    *label = (twin_label_t *) widget;
 
-    _twin_widget_dispatch (widget, event);
+    if (_twin_widget_dispatch (widget, event) == TwinDispatchDone)
+	return TwinDispatchDone;
     switch (event->kind) {
     case TwinEventPaint:
 	_twin_label_paint (label);
-	return TwinDispatchNone;
+	break;
     case TwinEventQueryGeometry:
 	_twin_label_query_geometry (label);
 	break;
     default:
 	break;
     }
-    return TwinDispatchNone;
+    return TwinDispatchContinue;
 }
 
 void
@@ -122,9 +121,8 @@
 		  twin_style_t		font_style,
 		  twin_dispatch_proc_t	dispatch)
 {
-    static const twin_rect_t	empty = { 0, 0, 0, 0 };
-    _twin_widget_init (&label->widget, parent, 0, 
-		       empty, 1, 1, dispatch);
+    static const twin_widget_layout_t	preferred = { 0, 0, 1, 1 };
+    _twin_widget_init (&label->widget, parent, 0, preferred, dispatch);
     label->label = NULL;
     label->offset.x = 0;
     label->offset.y = 0;

Index: twin_toplevel.c
===================================================================
RCS file: /local/src/CVS/twin/twin_toplevel.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- twin_toplevel.c	26 Oct 2004 06:15:42 -0000	1.1
+++ twin_toplevel.c	27 Oct 2004 20:09:36 -0000	1.2
@@ -91,7 +91,7 @@
     window->destroy = _twin_toplevel_destroy;
     window->event = _twin_toplevel_event;
     window->client_data = toplevel;
-    _twin_box_init (&toplevel->box, 0, window, TwinLayoutVert, dispatch);
+    _twin_box_init (&toplevel->box, 0, window, TwinBoxVert, dispatch);
 }
 
 twin_toplevel_t *

Index: twin_widget.c
===================================================================
RCS file: /local/src/CVS/twin/twin_widget.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- twin_widget.c	27 Oct 2004 06:07:35 -0000	1.3
+++ twin_widget.c	27 Oct 2004 20:09:36 -0000	1.4
@@ -41,9 +41,19 @@
 _twin_widget_dispatch (twin_widget_t *widget, twin_event_t *event)
 {
     switch (event->kind) {
+    case TwinEventQueryGeometry:
+	widget->layout = TWIN_FALSE;
+	if (widget->copy_geom)
+	{
+	    twin_widget_t   *copy = widget->copy_geom;
+	    if (copy->layout)
+		(*copy->dispatch) (copy, event);
+	    widget->preferred = copy->preferred;
+	    return TwinDispatchDone;
+	}
+	break;
     case TwinEventConfigure:
 	widget->extents = event->u.configure.extents;
-	widget->layout = TWIN_FALSE;
 	break;
     case TwinEventPaint:
 	_twin_widget_paint (widget);
@@ -52,16 +62,14 @@
     default:
 	break;
     }
-    return TwinDispatchNone;
+    return TwinDispatchContinue;
 }
 
 void
 _twin_widget_init (twin_widget_t	*widget,
 		   twin_box_t		*parent,
 		   twin_window_t	*window,
-		   twin_rect_t		preferred,
-		   twin_stretch_t	hstretch,
-		   twin_stretch_t	vstretch,
+		   twin_widget_layout_t	preferred,
 		   twin_dispatch_proc_t	dispatch)
 {
     if (parent)
@@ -77,13 +85,15 @@
 	widget->next = NULL;
     widget->window = window;
     widget->parent = parent;
+    widget->copy_geom = NULL;
     widget->paint = TWIN_TRUE;
+    widget->layout = TWIN_TRUE;
+    widget->want_focus = TWIN_FALSE;
+    widget->background = 0x00000000;
+    widget->extents.left = widget->extents.top = 0;
+    widget->extents.right = widget->extents.bottom = 0;
     widget->preferred = preferred;
-    widget->extents = preferred;
-    widget->hstretch = hstretch;
-    widget->vstretch = vstretch;
     widget->dispatch = dispatch;
-    widget->background = 0x00000000;
 }
 
 void
@@ -171,20 +181,19 @@
 		    twin_argb32_t   background,
 		    twin_coord_t    width,
 		    twin_coord_t    height,
-		    twin_stretch_t  hstretch,
-		    twin_stretch_t  vstretch)
+		    twin_stretch_t  stretch_width,
+		    twin_stretch_t  stretch_height)
 {
-    twin_widget_t   *widget = malloc (sizeof (twin_widget_t));
-    twin_rect_t	    extents;
+    twin_widget_t	    *widget = malloc (sizeof (twin_widget_t));
+    twin_widget_layout_t    preferred;
 
     if (!widget)
 	return NULL;
-    extents.left = 0;
-    extents.top = 0;
-    extents.right = width;
-    extents.bottom = height;
-    _twin_widget_init (widget, parent, 0, extents, hstretch, vstretch, 
-		       _twin_widget_dispatch);
+    preferred.width = width;
+    preferred.height = height;
+    preferred.stretch_width = stretch_width;
+    preferred.stretch_height = stretch_height;
+    _twin_widget_init (widget, parent, 0, preferred, _twin_widget_dispatch);
     widget->background = background;
     return widget;
 }

Index: twinint.h
===================================================================
RCS file: /local/src/CVS/twin/twinint.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- twinint.h	27 Oct 2004 06:07:35 -0000	1.16
+++ twinint.h	27 Oct 2004 20:09:36 -0000	1.17
@@ -455,7 +455,7 @@
 _twin_box_init (twin_box_t		*box,
 		twin_box_t		*parent,
 		twin_window_t		*window,
-		twin_layout_t		layout,
+		twin_box_dir_t		dir,
 		twin_dispatch_proc_t	dispatch);
 
 twin_dispatch_result_t
@@ -465,9 +465,7 @@
 _twin_widget_init (twin_widget_t	*widget,
 		   twin_box_t		*parent,
 		   twin_window_t	*window,
-		   twin_rect_t		preferred,
-		   twin_stretch_t	hstretch,
-		   twin_stretch_t	vstretch,
+		   twin_widget_layout_t	preferred,
 		   twin_dispatch_proc_t	dispatch);
 
 twin_dispatch_result_t

Index: xtwin.c
===================================================================
RCS file: /local/src/CVS/twin/xtwin.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- xtwin.c	26 Oct 2004 19:56:19 -0000	1.22
+++ xtwin.c	27 Oct 2004 20:09:36 -0000	1.23
@@ -33,6 +33,7 @@
 #include <twin_text.h>
 #include <twin_demo.h>
 #include <twin_hello.h>
+#include <twin_calc.h>
 
 #define WIDTH	512
 #define HEIGHT	512
@@ -49,9 +50,11 @@
     twin_clock_start (x11->screen, "Clock", 10, 10, 200, 200);
     twin_text_start (x11->screen,  "Gettysburg Address",
 		     0, 0, 300, 300);
-#endif
     twin_hello_start (x11->screen, "Hello, World",
 		      0, 0, 200, 200);
+#endif
+    twin_calc_start (x11->screen, "Calculator",
+		     100, 100, 200, 200);
     twin_dispatch ();
     return 0;
 }




More information about the Commit mailing list