class CONTAINER

All features

A CONTAINER is designed to contain many widgets (called children). Children are arranged in the container using some LAYOUT, and painted. The CONTAINER may be seen as a shell: if the container is not shrinkable, it will not shrink any of it's children. If the container is shrinkable, it may shrink children that are shrinkable but never shrink not shrinkable children (it's like a shell again).

The LAYOUT is an algorithm attached to the container. It has to decide size and position for children.

Direct parents

conformant parents

DRAWABLE, SENSITIVE

Known children

conformant children

WINDOW

Summary

creation features

exported features

Details

default_create

Default creation method. It is used when no creation method is specified if allowed. Note it may be renamed.

make_layout (p: CONTAINER, lo: LAYOUT)

require

  • p /= Void
  • lo /= Void
  • lo.container = Void

ensure

  • parent = p
  • layout = lo

default_create

Default creation method. It is used when no creation method is specified if allowed. Note it may be renamed.

make_layout (p: CONTAINER, lo: LAYOUT)

require

  • p /= Void
  • lo /= Void
  • lo.container = Void

ensure

  • parent = p
  • layout = lo

container_init
layout: LAYOUT
width: INTEGER
height: INTEGER
min_width: INTEGER
min_height: INTEGER
std_width: INTEGER
std_height: INTEGER
child: FAST_ARRAY[WIDGET]
layout_update_paused: BOOLEAN

TODO: suppress. Handle this with mapped

set_layout (l: LAYOUT)

Change the layout for the container (layout choose children position and size). The layout has to be free (not used by another container).

require

  • l /= Void
  • l.container = Void

ensure

  • layout = l
  • layout.container = Current
  • not layout_update_paused implies layout_ready

layout_pause

TODO: remove when mapped ready

require

  • not layout_update_paused

ensure

  • layout_update_paused

layout_continue

TODO: remove when mapped ready

require

  • layout_update_paused

ensure

  • layout_ready
  • not layout_update_paused

child_attach (w: WIDGET)

Add widget w in this container.

require

  • layout /= Void
  • w /= Void
  • w.parent = Void
  • not has_child(w)

ensure

  • w.parent = Current
  • has_child(w)
  • last_child = w
  • not layout_update_paused implies layout_ready or not done

    TODO: not mapped implies not layout_ready???

child_dettach (w: WIDGET)
This feature is obsolete: Use `child_detach' instead.
child_detach (w: WIDGET)

Remove widget w from this container.

require

  • w /= Void
  • has_child(w)

ensure

  • child.count = old child.count - 1
  • not has_child(w)
  • w.parent = Void
  • not layout_update_paused implies layout_ready

    TODO: not mapped implies not layout_ready???

has_child (w: WIDGET): BOOLEAN
last_child: WIDGET

require

  • not is_empty

is_empty: BOOLEAN
clear_area (x: INTEGER, y: INTEGER, w: INTEGER, h: INTEGER)

clear area and emit expose event (contents will be drawn) x and y are relative to current object

require

  • w > 0
  • h > 0
  • area.include(x, y)
  • area.include(x + w - 1, y + h - 1)

clear_without_expose

clear the all the drawable area. WARNING: don't redraw the content (no expose event)

refresh

clear and update entire object (sub_window(s) are not updated).

clear

clear and update entire object (sub_window(s) are not updated).

as_x_root (x: INTEGER): INTEGER

require

  • x >= pos_x
  • x < pos_x + width

as_y_root (y: INTEGER): INTEGER

require

  • y >= pos_y
  • y < pos_y + height

done: BOOLEAN

TODO: suppress. Handle this with mapped

child_requisition_changed

require

  • layout /= Void

ensure

  • not layout_update_paused implies layout_ready or not done

expose_paint

expose_paint paint with depth limited to the first window Containers have to propagate, with special attention to windows where expose_paint do nothing.

require

  • layout /= Void

set_geometry (x: INTEGER, y: INTEGER, w: INTEGER, h: INTEGER)

Warning: do not redraw content if not window subtype

require

  • x >= 0
  • y >= 0
  • w >= min_width
  • h >= min_height

ensure

  • width = w
  • height = h

set_requisition (min_w: INTEGER, min_h: INTEGER, std_w: INTEGER, std_h: INTEGER)

require

  • min_w.in_range(0, std_w)
  • min_h.in_range(0, std_h)

ensure

  • not layout_update_paused implies layout_ready or not done

layout_ready: BOOLEAN
set_parent (p: CONTAINER)

require

  • p = Void implies parent /= Void
  • p /= Void implies parent = Void
  • p /= Void implies p.has_child(Current)

ensure

  • parent = p

requisition_changed: BOOLEAN
invalidate_layout

ensure

  • not layout_ready

computing_size: BOOLEAN

This is only used for invariant defined in widget. Sizes may be invalid while they are computed

update_decoration
resize (w: INTEGER, h: INTEGER)

Warning: do not redraw content if not window subtype

require

  • w >= min_width
  • h >= min_height

ensure

  • width = w
  • height = h

dispatch

Should be called only from set_geometry and set_requisition.

require

  • not layout_ready
  • layout /= Void

ensure

  • layout_ready

basic_window_clear_area (window: POINTER, x: INTEGER, y: INTEGER, w: INTEGER, h: INTEGER)

TODO: invalid for pixmap. Redefine allowed ?

basic_window_clear_area_no_expose (window: POINTER, x: INTEGER, y: INTEGER, w: INTEGER, h: INTEGER)

TODO: invalid for pixmap. Redefine allowed ?

drawing_widget: POINTER

Because Windows can not paint on widgets like windows or bitmaps, it needs another object (Device Context) attached to the widget. For X11, it is the same value as widget.

parent: CONTAINER
pos_x: INTEGER
pos_y: INTEGER
x_shrink_allowed: BOOLEAN
x_expand_allowed: BOOLEAN
y_shrink_allowed: BOOLEAN
y_expand_allowed: BOOLEAN
valid_width (w: INTEGER): BOOLEAN
valid_height (h: INTEGER): BOOLEAN
area: RECT
root_area: RECT
set_x_shrink (b: BOOLEAN)
set_x_expand (b: BOOLEAN)
set_y_shrink (b: BOOLEAN)
set_y_expand (b: BOOLEAN)
set_shrink (b: BOOLEAN)

change both x and y shrink state

set_expand (b: BOOLEAN)

change both x and y expand state

state: INTEGER

use values from STATE_CONSTANTS

frozen is_state_normal: BOOLEAN
frozen is_state_active: BOOLEAN
frozen is_state_prelight: BOOLEAN
frozen is_state_selected: BOOLEAN
frozen is_state_insensitive: BOOLEAN
frozen set_state_normal
frozen set_state_active
frozen set_state_prelight
frozen set_state_selected
frozen set_state_insensitive
set_state (n: INTEGER)
renderer: RENDERER
state_normal: INTEGER
state_active: INTEGER
state_prelight: INTEGER
state_selected: INTEGER
state_insensitive: INTEGER
deferred hash_code: INTEGER

The hash-code value of Current.

ensure

  • good_hash_value: Result >= 0

deferred is_equal (other: CONTAINER): BOOLEAN

Is other attached to an object considered equal to current object ?

require

  • other /= Void

ensure

  • Result implies hash_code = other.hash_code
  • commutative: generating_type = other.generating_type implies Result = other.is_equal(Current)

widget: POINTER

widget identifier from the native graphic API.

Class invariant