-
Notifications
You must be signed in to change notification settings - Fork 5
/
viup.v
98 lines (69 loc) · 2.04 KB
/
viup.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
module viup
import os
#flag -I @VROOT/headers
#flag -L .
#flag -liup
//#flag @VOUTPUT/manifest.syso // `@VOUTPUT` doesn't exist, compilers will compain about this file next existing
#include "iup.h"
fn C.IupClose()
fn C.IupFlush()
fn C.IupGetGlobal() voidptr
fn C.IupGetHandle(charptr) voidptr
fn C.IupHelp(charptr) int
fn C.IupLog(charptr, charptr, voidptr)
fn C.IupLoopStep() int
fn C.IupMainLoop() int
fn C.IupMessage(charptr, charptr)
fn C.IupOpen(int, voidptr)
fn C.IupSetGlobal(charptr, charptr)
fn C.IupSetHandle(charptr, voidptr)
fn C.IupSetStrGlobal(charptr, charptr)
fn init() {
C.IupOpen(&os.args.len, &os.args.data)
}
pub fn close() {
C.IupClose()
}
pub fn flush() {
C.IupFlush()
}
pub fn get_global_reference(name string) voidptr {
return C.IupGetGlobal(name.to_upper().trim_space().str)
}
pub fn get_global_value(name string) string {
return unsafe { tos3(C.IupGetGlobal(name.to_upper().trim_space().str)) }
}
// get_handle returns a component with the provided handle name
// Note: This method can cause issues with autofree
pub fn get_handle(handle string) &Control {
return C.IupGetHandle(handle.str)
}
// help opens a browser to the provided `url`
pub fn help(url string) int {
return C.IupHelp(url.str)
}
pub fn log(log_type string, data string) {
C.IupLog(log_type.to_upper().str, data.str)
}
pub fn loop_step() int {
return C.IupLoopStep()
}
pub fn main_loop() int {
return C.IupMainLoop()
}
pub fn message(title string, message string) {
C.IupMessage(title.str, message.str)
}
pub fn set_global_reference(name string, data voidptr) {
C.IupSetGlobal(name.to_upper().trim_space().str, charptr(data))
}
pub fn set_global_value(name string, data string) {
C.IupSetStrGlobal(name.to_upper().trim_space().str, data.str)
}
// set_handle adds a component to the global scope based on
// the provided handle name. Note, currently accessing a component
// on the global scope with autofree enabled can cause crashes
pub fn set_handle(handle string, control &Control) &Control {
C.IupSetHandle(handle.str, control)
return control
}