mirror of https://github.com/Airr/nim-cocoa.git
parent
5003cc5b2a
commit
ee1fa4994f
@ -1,56 +0,0 @@ |
|||||||
{.compile: "widgets/functions.m".} |
|
||||||
|
|
||||||
type |
|
||||||
ID* = pointer |
|
||||||
ACTION* = proc (a2: ID) |
|
||||||
|
|
||||||
# GUI ANCHOR SYSTEM |
|
||||||
const |
|
||||||
akNone* = 0 |
|
||||||
akRight* = 1 |
|
||||||
akWidth* = 2 |
|
||||||
akLeft* = 4 |
|
||||||
akBottom* = 8 |
|
||||||
akHeight* = 16 |
|
||||||
akFull* = 18 |
|
||||||
akTop* = 32 |
|
||||||
|
|
||||||
# Flags for GUI Anchor System |
|
||||||
|
|
||||||
# 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 |
|
||||||
|
|
||||||
proc `anchor=`*(widget: ID; value: cint) {.cdecl, importc: "Pin".} |
|
||||||
proc Cocoa_Init*() {.cdecl, importc: "Cocoa_Init".} |
|
||||||
proc Cocoa_Run*() {.cdecl, importc: "Cocoa_Run".} |
|
||||||
proc `text=`*(widget: ID; txt: cstring) {.cdecl, importc: "SetText".} |
|
||||||
proc `text`*(widget: ID): cstring {.cdecl, importc: "GetText".} |
|
||||||
proc `item=`*(widget: ID; txt: cstring) {.cdecl, importc: "AddItem".} |
|
||||||
proc `item`*(widget: ID) {.cdecl, importc: "GetItem".} |
|
||||||
proc `value=`*(widget: ID, value: cint) {.cdecl, importc: "SetValue".} |
|
||||||
proc `value`*(widget: ID): cint {.cdecl, importc: "GetValue".} |
|
||||||
|
|
||||||
|
|
||||||
# proc `text=`*(widget: ID; txt: cstring) = |
|
||||||
# widget.SetText(txt) |
|
||||||
|
|
||||||
# proc `text`*(widget: ID): cstring = |
|
||||||
# GetText(widget) |
|
||||||
|
|
||||||
# proc `item`*(widget: ID): cstring = |
|
||||||
# GetItem(widget) |
|
||||||
|
|
||||||
# proc `anchor=`*(widget: ID; value: cint) = |
|
||||||
# widget.AutoSizeMask(value) |
|
||||||
|
|
||||||
# proc `value=`*(widget: ID, value: cint) = |
|
||||||
# widget.SetValue(value) |
|
||||||
|
|
||||||
# proc `value`*(widget: ID): cint = |
|
||||||
# result = widget.GetValue() |
|
@ -0,0 +1,12 @@ |
|||||||
|
# Package |
||||||
|
|
||||||
|
version = "0.1.0" |
||||||
|
author = "Armando Rivera" |
||||||
|
description = "macOS Cocoa GUI package" |
||||||
|
license = "MIT" |
||||||
|
srcDir = "src" |
||||||
|
|
||||||
|
|
||||||
|
# Dependencies |
||||||
|
|
||||||
|
requires "nim >= 1.4.8" |
@ -0,0 +1,7 @@ |
|||||||
|
import Cocoa / [NSButton, NSCombobox, NSLabel, NSMenu, NSSavedialog, NSTextfield] |
||||||
|
import Cocoa / [NSCheckbox, NSDialog, NSLine, NSMessagebox, NSSlider, NSWindow] |
||||||
|
import Cocoa / [NSColordialog, NSFunctions, NSListbox, NSOpendialog, NSTextedit] |
||||||
|
|
||||||
|
export NSButton, NSCombobox, NSLabel, NSMenu, NSSavedialog, NSTextfield |
||||||
|
export NSCheckbox, NSDialog, NSLine, NSMessagebox, NSSlider, NSWindow |
||||||
|
export NSColordialog, NSFunctions, NSListbox, NSOpendialog, NSTextedit |
@ -1,5 +1,5 @@ |
|||||||
{.compile: "widgets/dialog.m".} |
{.compile: "widgets/dialog.m".} |
||||||
|
|
||||||
import NSFunctions |
# import NSFunctions |
||||||
|
|
||||||
proc newDialog*(title, message: cstring, height: cint): cint {.cdecl, importc: "createDialog".} |
proc newDialog*(title, message: cstring, height: cint): cint {.cdecl, importc: "createDialog".} |
@ -0,0 +1,61 @@ |
|||||||
|
{.compile: "widgets/functions.m".} |
||||||
|
|
||||||
|
type |
||||||
|
ID* = pointer |
||||||
|
ACTION* = proc (a2: ID) {.cdecl.} |
||||||
|
|
||||||
|
# GUI ANCHOR SYSTEM |
||||||
|
const |
||||||
|
akNone* = 0 |
||||||
|
akRight* = 1 |
||||||
|
akWidth* = 2 |
||||||
|
akLeft* = 4 |
||||||
|
akBottom* = 8 |
||||||
|
akHeight* = 16 |
||||||
|
akFull* = 18 |
||||||
|
akTop* = 32 |
||||||
|
|
||||||
|
# Flags for GUI Anchor System |
||||||
|
|
||||||
|
# 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 |
||||||
|
|
||||||
|
proc Cocoa_Init*() {.cdecl, importc: "Cocoa_Init".} |
||||||
|
|
||||||
|
proc Cocoa_Run*(a2: ID) {.cdecl, importc: "Cocoa_Run".} |
||||||
|
|
||||||
|
proc Cocoa_Quit*(a2: ID) {.cdecl, importc: "Cocoa_Quit".} |
||||||
|
|
||||||
|
proc Cocoa_About*() {.cdecl, importc: "Cocoa_About".} |
||||||
|
proc `anchor=`*(widget: ID; value: cint) {.cdecl, importc: "Pin".} |
||||||
|
proc `text=`*(widget: ID; txt: cstring) {.cdecl, importc: "SetText".} |
||||||
|
|
||||||
|
proc text*(widget: ID): cstring {.cdecl, importc: "GetText".} |
||||||
|
|
||||||
|
proc value*(widget: ID): cint {.cdecl, importc: "GetValue".} |
||||||
|
|
||||||
|
proc `value=`*(widget: ID; value: cint) {.cdecl, importc: "SetValue".} |
||||||
|
|
||||||
|
proc add*(widget: ID; txt: cstring) {.cdecl, importc: "AddItem".} |
||||||
|
|
||||||
|
proc `action=`*(widget: ID; `func`: ACTION) {.cdecl, importc: "SetAction".} |
||||||
|
|
||||||
|
proc `state=`*(widget: ID; state: bool) {.cdecl, importc: "SetState".} |
||||||
|
|
||||||
|
proc state*(widget: ID): cint {.cdecl, importc: "State".} |
||||||
|
|
||||||
|
proc clear*(widget: ID) {.cdecl, importc: "LB_Clear".} |
||||||
|
proc `item=`(widget: ID; pos: cint) {.cdecl, importc: "SetItem".} |
||||||
|
proc remove*(widget: ID; pos: cint) {.cdecl, importc: "RemoveItem".} |
||||||
|
proc getColor*(panel: ID): cstring {.cdecl, importc: "getColor".} |
||||||
|
proc hexColor*(cPanel: ID): cstring {.cdecl, importc: "hexColor".} |
||||||
|
|
||||||
|
proc Notify*(title: cstring; subtitle: cstring; text: cstring) {.cdecl, importc: "Notify".} |
||||||
|
|
||||||
|
proc newSeparator*(parent: ID; x: cint; y: cint; width: cint): ID {.cdecl, importc: "createLine".} |
@ -1,5 +1,5 @@ |
|||||||
{.compile: "widgets/messagebox.m".} |
{.compile: "widgets/messagebox.m".} |
||||||
|
|
||||||
import NSFunctions |
# import NSFunctions |
||||||
|
|
||||||
proc newMessageBox*(title, message: cstring, height: cint): cint {.cdecl, importc: "createMessageBox".} |
proc newMessageBox*(title, message: cstring, height: cint): cint {.cdecl, importc: "createMessageBox".} |
@ -0,0 +1,119 @@ |
|||||||
|
{.pragma: libcol_s, cdecl.} |
||||||
|
{.passL: "-fobjc-arc -framework Cocoa -lcol_s"} |
||||||
|
|
||||||
|
|
||||||
|
type |
||||||
|
id* = pointer |
||||||
|
ACTION* = proc (a1: id) {.cdecl.} |
||||||
|
|
||||||
|
|
||||||
|
const |
||||||
|
akNone* = 0 |
||||||
|
akRight* = 1 |
||||||
|
akWidth* = 2 |
||||||
|
akLeft* = 4 |
||||||
|
akBottom* = 8 |
||||||
|
akHeight* = 16 |
||||||
|
akFull* = 18 |
||||||
|
akTop* = 32 |
||||||
|
|
||||||
|
|
||||||
|
proc newWindow*(title: cstring; width: cint; height: cint): id {.cdecl, importc: "createWindow".} |
||||||
|
|
||||||
|
proc Pin(widget: id; value: cint) {.cdecl, importc: "Pin".} |
||||||
|
|
||||||
|
proc Cocoa_Init*() {.cdecl, importc: "Cocoa_Init".} |
||||||
|
|
||||||
|
proc Cocoa_Run*(a2: id) {.cdecl, importc: "Cocoa_Run".} |
||||||
|
|
||||||
|
proc Cocoa_Quit*(a2: id) {.cdecl, importc: "Cocoa_Quit".} |
||||||
|
|
||||||
|
proc Cocoa_About*() {.cdecl, importc: "Cocoa_About".} |
||||||
|
|
||||||
|
proc SetText(widget: id; txt: cstring) {.cdecl, importc: "SetText".} |
||||||
|
|
||||||
|
proc GetText(widget: id): cstring {.cdecl, importc: "GetText".} |
||||||
|
|
||||||
|
proc GetValue(widget: id): cint {.cdecl, importc: "GetValue".} |
||||||
|
|
||||||
|
proc SetValue(widget: id; value: cint) {.cdecl, importc: "SetValue".} |
||||||
|
|
||||||
|
proc AddItem(widget: id; txt: cstring) {.cdecl, importc: "AddItem".} |
||||||
|
|
||||||
|
proc newTextField*(parent: id; txt: cstring; l: cint; t: cint; w: cint; h: cint): id {.cdecl, importc: "createTextField".} |
||||||
|
|
||||||
|
proc newComboBox*(parent: id; l: cint; t: cint; w: cint; h: cint; callback: ACTION): id {.cdecl, importc: "createComboBox".} |
||||||
|
|
||||||
|
proc newButton*(parent: id; caption: cstring; l: cint; t: cint; w: cint; h: cint; `func`: ACTION): id {.cdecl, importc: "createButton".} |
||||||
|
|
||||||
|
proc SetAction(widget: id; `func`: ACTION) {.cdecl, importc: "SetAction".} |
||||||
|
proc newCheckBox*(parent: id; caption: cstring; l: cint; t: cint; w: cint; h: cint): id {.cdecl, importc: "createCheckBox".} |
||||||
|
|
||||||
|
proc SetState(widget: id; state: bool) {.cdecl, importc: "SetState".} |
||||||
|
|
||||||
|
proc State(widget: id): cint {.cdecl, importc: "State".} |
||||||
|
|
||||||
|
proc newListBox*(parent: id; l: cint; t: cint; w: cint; h: cint): id {.cdecl, importc: "createListBox".} |
||||||
|
|
||||||
|
proc Clearitems*(widget: id) {.cdecl, importc: "LB_Clear".} |
||||||
|
proc SetItem*(widget: id; pos: cint) {.cdecl, importc: "SetItem".} |
||||||
|
proc RemoveItem*(widget: id; pos: cint) {.cdecl, importc: "RemoveItem".} |
||||||
|
proc newOpenDialog*(parent: id; types: cstring): cstring {.cdecl, importc: "createOpenDialog".} |
||||||
|
|
||||||
|
proc newSaveDialog*(parent: id; title: cstring; types: cstring): cstring {.cdecl, importc: "createSaveDialog".} |
||||||
|
|
||||||
|
proc newDialog*(title: cstring; message: cstring; `type`: cint): cint {.cdecl, importc: "createDialog".} |
||||||
|
proc newMessageBox*(title: cstring; message: cstring; `type`: cint): cint {.cdecl, importc: "createMessageBox".} |
||||||
|
|
||||||
|
proc newColorDialog*(): id {.cdecl, importc: "createColorDialog".} |
||||||
|
proc getColor*(panel: id): cstring {.cdecl, importc: "getColor".} |
||||||
|
proc hexColor*(cPanel: id): cstring {.cdecl, importc: "hexColor".} |
||||||
|
proc newLabel*(parent: id; txt: cstring; l: cint; t: cint; w: cint; h: cint): id {.cdecl, importc: "createLabel".} |
||||||
|
|
||||||
|
proc newTextEdit*(parent: id; txt: cstring; l: cint; t: cint; w: cint; h: cint): id {.cdecl, importc: "createTextEdit".} |
||||||
|
|
||||||
|
proc Notify*(title: cstring; subtitle: cstring; text: cstring) {.cdecl, importc: "Notify".} |
||||||
|
|
||||||
|
proc newSeparator*(parent: id; x: cint; y: cint; width: cint): id {.cdecl, importc: "createLine".} |
||||||
|
proc newMenu*(Title: cstring): id {.cdecl, importc: "createMenu".} |
||||||
|
proc newMenuItem*(parent: id; caption: cstring; key: cstring; callback: ACTION) {.cdecl, importc: "createMenuItem".} |
||||||
|
proc newMenuSeparator*(parent: id) {.cdecl, importc: "createMenuSeparator".} |
||||||
|
proc newSlider*(parent: id; left: cint; top: cint; width: cint; height: cint; callback: ACTION): id {.cdecl, importc: "createSlider".} |
||||||
|
|
||||||
|
proc `text=`*(widget: id; txt: cstring) = |
||||||
|
widget.SetText(txt) |
||||||
|
|
||||||
|
proc `reset`*(widget: id) = |
||||||
|
widget.SetText("") |
||||||
|
|
||||||
|
proc `text`*(widget: id): string = |
||||||
|
$GetText(widget) |
||||||
|
|
||||||
|
# proc `item`*(widget: id): cstring = |
||||||
|
# GetItem(widget) |
||||||
|
|
||||||
|
proc `anchor=`*(widget: id; value: cint) = |
||||||
|
widget.Pin(value) |
||||||
|
|
||||||
|
proc `state`*(widget: id): cint = |
||||||
|
widget.State() |
||||||
|
|
||||||
|
proc `state=`*(widget: id; val: bool) = |
||||||
|
widget.SetState(val) |
||||||
|
|
||||||
|
proc `item=`*(widget: id, val: cstring) = |
||||||
|
widget.AddItem(val) |
||||||
|
|
||||||
|
proc `item`*(widget: id): string = |
||||||
|
$GetText(widget) |
||||||
|
|
||||||
|
proc action*(widget: id, action:ACTION) = |
||||||
|
SetAction(widget, action) |
||||||
|
|
||||||
|
proc value*(widget: id, value: cint) = |
||||||
|
SetValue(widget, value) |
||||||
|
|
||||||
|
proc value*(widget: id): cint = |
||||||
|
GetValue(widget) |
||||||
|
|
||||||
|
# #endif |
@ -0,0 +1 @@ |
|||||||
|
switch("path", "$projectDir/../src") |
@ -0,0 +1,12 @@ |
|||||||
|
# This is just an example to get you started. You may wish to put all of your |
||||||
|
# tests into a single file, or separate them into multiple `test1`, `test2` |
||||||
|
# etc. files (better names are recommended, just make sure the name starts with |
||||||
|
# the letter 't'). |
||||||
|
# |
||||||
|
# To run these tests, simply execute `nimble test`. |
||||||
|
|
||||||
|
import unittest |
||||||
|
|
||||||
|
import nimcocoa |
||||||
|
test "can add": |
||||||
|
check add(5, 5) == 10 |
Loading…
Reference in new issue