Control's geometry

Control does not directly adjust its size

Instead of adjust self size directly Control can announce 3 parameters per direction (horizontal/vertical):

The following restriction applies to these parameters: minimum ≤ best ≤ maximum.

GUI geometry hypervisor (special algorithm implemented by window) takes these parameters and after computation sets appropriate width and height for Control. When Control draw itself it uses these width and height as an available region, but can decide (especially if region is larger than announced maximum size) to draw itself only on some part of available region, in center for example.

Width has priority over height

Width is a primary dimension and height is secondary dimension. This is because in most cases text is horizontal oriented and people prefer vertical scroll over horizontal. Priority of width means: height is a function of width. For example, we have some long text and want to draw it, then height will depend on available width (how much line breaks required).

Algorithm

Following algorithm used to achieve “Control does not directly adjust its size” and “Width has priority over height” (Control's point of view):

  1. Geometry hypervisor (GH) asks Control about minimal, best and maximum width. Control computes requested parameter based on what exactly and how it would draw.
  2. GH set Control's width (and horizontal position in window coordinates).
  3. GH asks Control about minimal, best and maximum height. Here Control can use width from previous step to compute requested parameters.
  4. GH set Control's height (and vertical position in window coordinates).
  5. GH request Control to draw. Control draw itself somewhere in region defined by step 2 & 4 of this algorithm.

Events

Events can be categorized by how Controls receive them:

Event Receiving
Keyboard events
(press/release non-modifier key)
Control which is focused receives this event.
Control must decide does it accept event or not.
If event is not accepted by Control, then it will be sent to Control's parent (iterating up to window).
Pointer button press events
(press mouse button)
Topmost (in term of Z index) Control under pointer receives this event.
Control must decide whether to accept the event or not.
If event is not accepted by Control then it will be sent to “less topmost” Control under pointer (iterating up to window).
Scroll event
(scroll mouse wheel)
Pointer button other events
(release/click mouse button)
Control that received (and accepted) the corresponding pointer button press event receives this event.
Event will not be sent to other Controls even if it was not accepted.
Pointer drag events
(drag using mouse button)
Modifiers events
(press/release keyboard modifier key)
All Controls which have previously subscribed to this type of events.
Window main state event
(window becomes main/background)
Window display state event
(relates to minimized/maximized/full screen state)