Also, use gtk_widget_set_allocation and gtk_cairo_transform_to_window.
(widget (* GtkWidget))
(allocation (* GtkAllocation)))
+(extern void gtk_widget_set_allocation
+ (widget (* GtkWidget))
+ (allocation (* GtkAllocation)))
+
(extern void gtk_widget_error_bell
(widget (* GtkWidget)))
(widget (* GtkWidget))
(text (* (const gchar))))
+(extern void gtk_cairo_transform_to_window
+ (cr (* cairo_t))
+ (widget (* GtkWidget))
+ (window (* GdkWindow)))
+
(extern (* GtkStyleContext)
gtk_widget_get_style_context
(width (* GtkWidget)))
\ No newline at end of file
(let ((alien (gobject-alien widget)))
(let ((w (->requisition-fixnum width))
(h (->requisition-fixnum height)))
- (C-call "gtk_widget_set_size_request" alien w h)
+ (set-scm-widget-size-request! widget 0 0 w h)
;; Init. size, for a realize signal arriving before an allocation.
(set-fix-rect-size! (fix-widget-geometry widget) w h))
- (C-call "gtk_widget_set_has_window" alien 1)) ; WILL have when realized
+ (C-call "gtk_widget_set_has_window" alien 1))
(set-gtk-widget-realize-callback! widget fix-widget-realize-callback)
(set-gtk-widget-size-allocate-callback! widget allocate-callback)
(height (C-> GtkAllocation "GtkAllocation height"))
(rect (fix-widget-geometry widget)))
(%trace "; allocated "width"x"height" at "x","y" for "widget"\n")
+ (C-call "gtk_widget_set_allocation" (gobject-alien widget) GtkAllocation)
(set-fix-rect! rect x y width height)
(if (fix-widget-realized? widget)
(C-call "gdk_window_move_resize"
(view (fix-layout-view layout)))
(let ((offx (fix-rect-x view))
(offy (fix-rect-y view)))
+ (C-call "gtk_cairo_transform_to_window" cr (gobject-alien layout) window)
(fix:clip-region
cr (lambda (x y w h)
(if drawing
(define (resizer-draw-callback resizer cr)
(let ((geom (fix-widget-geometry resizer))
(style (gtk-widget-style-context resizer)))
+ (C-call "gtk_cairo_transform_to_window" cr (gobject-alien resizer)
+ (fix-widget-window resizer))
(C-call "gtk_render_handle" style cr
(->flonum (fix-rect-x geom))
(->flonum (fix-rect-y geom))
(let ((w (fix:+ (car w.h-before) dx))
(h (fix:+ (cdr w.h-before) dy)))
(%trace "; resizing "before" to "w"x"h"\n")
- (gtk-widget-set-size-request before w h))
+ (set-scm-widget-size-request! (gtk-bin-child before)
+ 0 0 w h))
(let ((w (fix:- (car w.h-after) dx))
(h (fix:- (cdr w.h-after) dy)))
(%trace "; resizing "after" to "w"x"h"\n")
- (gtk-widget-set-size-request after w h))))))
+ (set-scm-widget-size-request! after 0 0 w h))))))
(if (fix-resizer-stack-vertical? resizer)
(y (->flonum (fix:- (fix-rect-y extent) (fix-rect-y view))))
(width (->flonum (fix-rect-width extent)))
(height (->flonum (fix-rect-height extent))))
- (C-call "gtk_render_background" style cr x y width height)
(C-call "gtk_render_focus" style cr x y width height))))
(define-method fix-ink-move! ((ink <box-ink>) dx dy)
(typedef ScmWidget
(struct _ScmWidget
(widget GtkWidget)
+ (minimum_width gint)
+ (minimum_height gint)
+ (natural_width gint)
+ (natural_height gint)
(hadjustment (* GtkAdjustment))
(vadjustment (* GtkAdjustment))
(hscroll_policy guint)
set-gtk-widget-destroy-callback!)
(export (gtk)
<scm-widget>
- set-scm-widget-set-scroll-adjustments-callback!))
+ set-scm-widget-set-scroll-adjustments-callback!
+ set-scm-widget-size-request!))
(define-package (gtk fix-layout)
(parent (gtk))
(define (set-scm-widget-set-scroll-adjustments-callback! widget callback)
(guarantee-scm-widget widget 'set-scm-widget-set-scroll-adjustments-callback!)
(guarantee-procedure-of-arity callback 3 'set-scm-widget-set-scroll-adjustments-callback!)
- (g-signal-connect widget (C-callback "set_scroll_adjustments") callback))
\ No newline at end of file
+ (g-signal-connect widget (C-callback "set_scroll_adjustments") callback))
+
+(define (set-scm-widget-size-request! widget
+ minimum-width minimum-height
+ natural-width natural-height)
+ (guarantee-scm-widget widget 'set-scm-widget-size-request!)
+ (guarantee-non-negative-fixnum minimum-width 'set-scm-widget-size-request!)
+ (guarantee-non-negative-fixnum minimum-height 'set-scm-widget-size-request!)
+ (guarantee-non-negative-fixnum natural-width 'set-scm-widget-size-request!)
+ (guarantee-non-negative-fixnum natural-height 'set-scm-widget-size-request!)
+ (let ((a (gobject-alien widget)))
+ (C->= a "ScmWidget minimum_width" minimum-width)
+ (C->= a "ScmWidget minimum_height" minimum-height)
+ (C->= a "ScmWidget natural_width" natural-width)
+ (C->= a "ScmWidget natural_height" natural-height)))
\ No newline at end of file
static void scm_widget_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec);
static void scm_widget_realize (GtkWidget *widget);
+static void scm_widget_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
+static void scm_widget_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size);
static guint set_scroll_adjustments_signal_id;
static void
scm_widget_init (ScmWidget *widget)
{
+ widget->minimum_width = 0;
+ widget->minimum_height = 0;
+ widget->natural_width = 0;
+ widget->natural_height = 0;
widget->hadjustment = NULL;
widget->vadjustment = NULL;
widget->hscroll_policy = GTK_SCROLL_NATURAL;
gobject_class->get_property = scm_widget_get_property;
widget_class->realize = scm_widget_realize;
+ widget_class->get_preferred_width = scm_widget_get_preferred_width;
+ widget_class->get_preferred_height = scm_widget_get_preferred_height;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_VIEWPORT);
gtk_widget_set_realized (widget, TRUE);
}
+
+static void
+scm_widget_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ ScmWidget *scm_widget = SCM_WIDGET (widget);
+
+ if (minimum_size)
+ *minimum_size = scm_widget->minimum_width;
+
+ if (natural_size)
+ *natural_size = scm_widget->natural_width;
+}
+
+static void
+scm_widget_get_preferred_height (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ ScmWidget *scm_widget = SCM_WIDGET (widget);
+
+ if (minimum_size)
+ *minimum_size = scm_widget->minimum_height;
+
+ if (natural_size)
+ *natural_size = scm_widget->natural_height;
+}
struct _ScmWidget
{
GtkWidget widget;
+ gint minimum_width;
+ gint minimum_height;
+ gint natural_width;
+ gint natural_height;
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
guint hscroll_policy;