wResizable

wResizable is the superclass of wWindow to handle layout DSL. It is based on yglukhov's constraint solving library - kiwi.

wNim's layout DSL looking like this:

panel.layout:
  button1:
    top = panel.top
    left = panel.left
  button2:
    centerX = panel.centerX
    centerY = panel.centerY
    height = panel.height / 2
    width = panel.width / 2

Following identifiers can be used in the layout DSL as attributes:

IdentifiersDescription
leftLeft margin.
rightRight margin.
topTop margin.
bottomBottom margin.
widthWidth of object.
heightHeight of object.
upAlias for top.
downAlias for bottom.
centerXCenter of X-axis.
centerYCenter of Y-axis.
defaultWidthDefault width of object.
defaultHeightDefault height of object.
bestWidthBest width of object.
bestHeightBest height of object.
innerLeftLeft margin of sibling's client area.
innerTopTop margin of sibling's client area.
innerRightRight margin of sibling's client area.
innerBottomBottom margin of sibling's client area.
innerUpAlias for innerTop.
innerDownAlias for innerBottom.
innerWidthWidth of sibling's client area.
innerHeightHeight of sibling's client area.

wNim also support Visual Format Language. For example:

panel.autolayout """
  V:|-{col1:[child1(child2)]-[child2]}-|
  V:|-{col2:[child3(child4,child5)]-[child4]-[child5]}-|
  H:|-[col1(col2)]-[col2]-|
"""

See autolayout module for details.

Subclass:wWindow
Seealso:wResizer autolayout

Procs

proc getLayoutSize(self: wResizable): wSize {...}{.raises: [], tags: [].}
Returns the current layout size.
proc getLayoutRect(self: wResizable): wRect {...}{.raises: [], tags: [].}
Returns the current layout rect.
proc setLayoutSize(self: wResizable; size: wSize) {...}{.raises: [], tags: [].}
Sets the layout size.
proc setLayoutRect(self: wResizable; rect: wRect) {...}{.raises: [], tags: [].}
Sets the layout rect.
proc final(self: wResizable) {...}{.raises: [], tags: [].}
Default finalizer for wResizable.
proc init(self: wResizable) {...}{.raises: [], tags: [].}
Initializer.
proc Resizable(): wResizable {...}{.inline, discardable, raises: [], tags: [].}
Constructor.

Macros

macro autolayout(parent: wResizable; input: static[string]): untyped
Parses the layout VFL (Visual Format Language), and then use layout function to deal with the result.
macro autorelayout(parent: wResizable; input: static[string]): untyped
Parses the layout VFL (Visual Format Language), and then use relayout function to deal with the result.
macro autoplan(parent: wResizable; input: static[string]): untyped
Parses the layout VFL (Visual Format Language), and then use plan function to deal with the result.
macro autoreplan(parent: wResizable; input: static[string]): untyped
Parses the layout VFL (Visual Format Language), and then use replan function to deal with the result.
macro layoutDebug(parent: wResizable; x: untyped): untyped
Parses the layout DSL and returns the constraints in string literal for debugging.
macro layoutDump(parent: wResizable; x: untyped): untyped
Parses the layout DSL and displays the constraints at compile time for debugging.
macro autolayoutDebug(parent: wResizable; input: static[string]): untyped
Parses the VFL (Visual Format Language) and returns the result in string literal for debugging.
macro autolayoutDump(parent: wResizable; input: static[string]): untyped
Parses the VFL (Visual Format Language) and displays the result at compile time for debugging.

Templates

template layout(parent: wResizable; x: untyped)
Parses the layout DSL and rearrange the objects. This function only evaluate the DSL and creates the constraints once.
template relayout(parent: wResizable; x: untyped)
Parses the layout DSL and rearrange the objects. This function evaluate the DSL and creates the constraints every time. If the value in the constraints is not constant (For example, if there is object.bestWidth in DSL and the label of the object will change every time), use this function instead of layout.
template plan(parent: wResizable; x: untyped): untyped
Similar to layout, but return the wResizer object. Calls wResizer.resolve() and then wResizer.rearrange() to change the layout in reality later. This function provides a chance to modify the resolved values.
template replan(parent: wResizable; x: untyped): untyped
Similar to relayout, but return the wResizer object. Calls wResizer.resolve() and then wResizer.rearrange() to change the layout in reality later. This function provides a chance to modify the resolved values.