nim-cocoa/doc/NSFunctions.md
2021-07-29 21:34:52 -04:00

4.7 KiB

Const

NSWindowStyleMask constants are used to determine the type of window that is created via then newWindow() proc, and should be self explanatory.

StyleMasks are typically or'd together

NSWindowStyleMaskBorderless*             = 0
NSWindowStyleMaskTitled*                 = 1 shl 0
NSWindowStyleMaskClosable*               = 1 shl 1
NSWindowStyleMaskMiniaturizable*         = 1 shl 2
NSWindowStyleMaskResizable*              = 1 shl 3
NSWindowStyleMaskUtilityWindow*          = 1 shl 4
NSWindowStyleMaskDocModalWindow*         = 1 shl 6
NSWindowStyleMaskNonactivatingPanel*     = 1 shl 7
NSWindowStyleMaskUnifiedTitleAndToolbar* = 1 shl 12
NSWindowStyleMaskHUDWindow*              = 1 shl 13
NSWindowStyleMaskFullScreen*             = 1 shl 14
NSWindowStyleMaskFullSizeContentView*    = 1 shl 15

Flags for the GUI Anchor System

These flags inform the GUI object how they should react when the window is resized.

There is no need for a box/container paradigm because of this. You can determine both how a widget resizes, and how it 'flows' on resize events. Below is a breakdown of what each flag does.

# akNone                 No Anchor

# akRight                 Anchor to Right of Window

# akWidth                Anchor to Left and Right (width)

# akLeft                    Anchor to Left

# akBottom             Anchor to Bottom

# akHeight              Anchor to Top and Bottom

# akFull                    Anchor to Left/Right/Top/Bottom

# akTop                    Anchor to Top

akNone*      = 0
akRight*     = 1
akWidth*     = 2
akLeft*      = 4
akBottom*    = 8
akHeight*    = 16
akFull*      = 18
akTop*       = 32


Procs

Cocoa_Init*

proc Cocoa_Init*() {.cdecl, importc: "Cocoa_Init".}

REQUIRED

Initializes the Cocoa Runtime. Place before any GUI instantiation.


Cocoa_Run*

proc Cocoa_Run*(a2: ID) {.cdecl, importc: "Cocoa_Run".}

REQUIRED

Launches the Cocoa Runtime. Place after GUI instantiation is complete, passing the mainwindow as a parameter.


Cocoa_Quit*

proc Cocoa_Quit*(a2: ID) {.cdecl, importc: "Cocoa_Quit".}

Exits the Cocoa Runtime when early exit is desired.


Cocoa_About*

proc Cocoa_About*() {.cdecl, importc: "Cocoa_About".}

Shows an About dialog


anchor=*

proc `anchor=`*(widget: ID; value: cint) {.cdecl, importc: "Pin".}

Used to set the anchor flags for an object


text=*

proc `text=`*(widget: ID; txt: cstring) {.cdecl, importc: "SetText".}

Sets the text/label of an object


text*

proc text*(widget: ID): cstring {.cdecl, importc: "GetText".}

Retrieves the text/label value of an object


value*

proc value*(widget: ID): cint {.cdecl, importc: "GetValue".}

Retrieves the numerical value of an object


value=*

proc `value=`*(widget: ID; value: cint) {.cdecl, importc: "SetValue".}

Sets the numerical value of an object


add*

proc add*(widget: ID; txt: cstring) {.cdecl, importc: "AddItem".}

Adds a string value to a Combobox/Listbox


action=*

proc `action=`*(widget: ID; `func`: ACTION) {.cdecl, importc: "SetAction".}

Sets the callback proc for an object that supports callbacks


state=*

proc `state=`*(widget: ID; state: bool) {.cdecl, importc: "SetState".}

Sets the state of RadioButton/Checkbox objects


state*

proc state*(widget: ID): cint {.cdecl, importc: "State".}

Retrieves the state of RadioButton/Checkbox objects


clear*

proc clear*(widget: ID) {.cdecl, importc: "LB_Clear".}

Clears a ListBox object


item=

proc `item=`(widget: ID; pos: cint) {.cdecl, importc: "SetItem".}

Not Used


remove*

proc remove*(widget: ID; pos: cint) {.cdecl, importc: "RemoveItem".}

Not Used

---____

getColor*

proc getColor*(panel: ID): cstring {.cdecl, importc: "getColor".}

Not Used

---____

hexColor*

proc hexColor*(cPanel: ID): cstring {.cdecl, importc: "hexColor".}

Not Used

---____

Notify*

proc Notify*(title: cstring; subtitle: cstring; text: cstring) {.cdecl, importc: "Notify".}

Sends Notification to the macOS Notification Center


newSeparator*

proc newSeparator*(parent: ID; x: cint; y: cint; width: cint): ID {.cdecl, importc: "createLine".}

Creates a line to separate objects on a window form