Controls - ZvontyFlugence/NiGui GitHub Wiki

Here you can find all the information about NiGui's Control type.

Control Properties

Here is the declaration of the Control type.

type Control* = ref object of RootObj
    fdisposed: bool
    fParentControl: Control
    fParentWindow: Window
    fIndex: int
    fVisible: bool
    fWidth, fHeight: int
    fX, fY: int
    fWidthMode: WidthMode
    fHeightMode: HeightMode
    fMinWidth, fMinHeight: int
    fMaxWidth, fMaxHeight: int
    fXScrollEnabled, fYScrollEnabled: bool
    fXScrollPos, fYScrollPos: int
    fScrollableWidth, fScrollableHeight: int
    fFontFamily: string
    fFontSize: int
    fTextColor: Color
    fBackgroundColor: Color
    fUseDefaultFontFamily: bool
    fUseDefaultFontSize: bool
    fUseDefaultTextColor: bool
    fUseDefaultBackgroundColor: bool
    fCanvas: Canvas
    fOnDispose: ControlDisposeProc
    fOnDraw: DrawProc
    fOnMouseButtonDown: MouseButtonProc
    fOnMouseButtonUp: MouseButtonProc
    fOnClick: ClickProc
    fOnKeyDown: ControlKeyProc
    fOnTextChange: TextChangeProc
    tag*: string

Control Procs and Methods

Here are all of the currently supported methods and procedures for the NiGui Control type:

proc newControl*(): Control

proc init*(control: Control)
proc init*(control: ControlImpl)

proc dispose*(control: var Control)
method dispose*(control: Control)

proc disposed*(control: Control): bool

method visible*(control: Control): bool
method `visible=`*(control: Control, visible: bool)
method show*(control: Control)
method hide*(control: Control)

method childControls*(control: Control): seq[Control]

method parentControl*(control: Control): Control

method parentWindow*(control: Control): WindowImpl

method width*(control: Control): int
method `width=`*(control: Control, width: int)

method height*(control: Control): int
method `height=`*(control: Control, height: int)

method minWidth*(control: Control): int
method `minWidth=`*(control: Control, minWidth: int)

method minHeight*(control: Control): int
method `minHeight=`*(control: Control, minHeight: int)

method maxWidth*(control: Control): int
method `maxWidth=`*(control: Control, maxWidth: int)

method setSize*(control: Control, width, height: int)

method x*(control: Control): int
method `x=`*(control: Control, x: int)

method y*(control: Control): int
method `y=`*(control: Control, y: int)

method setPosition*(control: Control, x, y: int)

method naturalWidth*(control: Control): int

method naturalHeight*(control: Control): int

method wantedWidth*(control: Control): int

method wantedHeight*(control: Control): int

method focus*(control: Control)

method getTextLineWidth*(control: Control, text: string): int

method getTextLineHeight*(control: Control): int

method getTextWidth*(control: Control, text: string): int

method widthMode*(control: Control): WidthMode
method `widthMode=`*(control: Control, mode: WidthMode)

method heigthMode*(control: Control): HeightMoe
method `heightMode=`*(control: Control, mode: HeightMode)

method visibleWidth*(control: Control): int

method visibleHeight*(control: Control): int

method xScrollPos*(control: Control): int
method `xScrollPos=`*(control: Control, xScrollPos: int)

method yScrollPos*(control: Control): int
method `yScrollPos=`*(control: Control, yScrollPos: int)

method scrollableWidth*(control: Control): int
method `scrollableWidth=`*(control: Control, scrollableWidth: int)

method scrollableHeight*(control: Control): int
method `scrollableHeight=`*(control: Control, scrollableHeight: int)

method fontFamily*(control: Control): string
method `fontFamily=`*(control: Control, fontFamily: string)
method setFontFamily*(control: Control, fontFamily: string)
method resetFontFamily*(control: Control)

method fontSize*(control: Control): int
method `fontSize=`*(control: Control, fontSize: int)
method setFontSize*(control: Control, fontSize: int)
method resetFontSize*(control: Control)

method backgroundColor*(control: Control): Color
method `backgroundColor=`*(control: Control, color: Color)
method setBackgroundColor*(control: Control, color: Color)
method resetBackgroundColor*(control: Control)

method textColor*(control: Control): Color
method `textColor=`*(control: Control, color: Color)
method setTextColor*(control: Control, color: Color)
method resetTextColor*(control: Control)

method forceRedraw*(control: Control)

method canvas*(control: Control): Canvas

method handleDrawEvent*(control: Control, event: DrawEvent)

method handleMouseButtonDownEvent*(control: Control, event: MouseButtonEvent)

method handleMouseButtonUpEvent*(control: Control, event: MouseButtonEvent)

method handleClickEvent*(control: Control, event: ClickEvent)

method handleKeyDownEvent*(control: Control, event: ControlKeyEvent)

method handleTextChangeEvent*(control: Control, event: TextChangeEvent)

method onDispose*(control: Control): ControlDisposeProc
method `onDispose=`*(control: Control, callback: ControlDisposeProc)

method onDraw*(control: Control): DrawProc
method `onDraw=`*(control: Control, callback: DrawProc)

method onMouseButtonDown*(control: Control): MouseButtonProc
method `onMouseButtonDown=`*(control: Control, callback: MouseButtonProc)

method onMouseButtonUp*(control: Control): MouseButtonProc
method `onMouseButtonUp=`*(control: Control, callback: MouseButtonProc)

method onClick*(control: Control): ClickProc
method `onClick=`*(control: Control, callback: ClickProc)

method onKeyDown*(control: Control): ControlKeyProc
method `onKeyDown=`*(control: Control, callback: ControlKeyProc)

method onTextChange*(control: Control): TextChangeProc