94 lines
3.1 KiB
Plaintext
94 lines
3.1 KiB
Plaintext
import t, c
|
|
from . import syscall as syscall
|
|
from stdint import *
|
|
|
|
STYLE_CLASSIC: t.CDefine = 0
|
|
STYLE_WIN10: t.CDefine = 1
|
|
STYLE_WIN11: t.CDefine = 2
|
|
STYLE_WIN7: t.CDefine = 3
|
|
STYLE_WINXP: t.CDefine = 4
|
|
|
|
EVENT_TYPE_NONE: t.CDefine = 0
|
|
EVENT_TYPE_CLICK: t.CDefine = 1
|
|
EVENT_TYPE_HOVER: t.CDefine = 2
|
|
EVENT_TYPE_RELEASE: t.CDefine = 3
|
|
EVENT_TYPE_HOVER_LEAVE: t.CDefine = 4
|
|
EVENT_TYPE_KEY: t.CDefine = 5
|
|
EVENT_TYPE_KEY_RELEASE: t.CDefine = 6
|
|
EVENT_TYPE_PING: t.CDefine = 7
|
|
EVENT_TYPE_RESIZE: t.CDefine = 8
|
|
|
|
KEY_STATE_PRESS: t.CDefine = 1
|
|
KEY_STATE_RELEASE: t.CDefine = 2
|
|
KEY_STATE_REPEAT: t.CDefine = 3
|
|
|
|
CURSOR_DEFAULT: t.CDefine = 0
|
|
CURSOR_IBEAM: t.CDefine = 1
|
|
CURSOR_RESIZE_EW: t.CDefine = 2
|
|
CURSOR_RESIZE_NS: t.CDefine = 3
|
|
CURSOR_RESIZE_NWSE: t.CDefine = 4
|
|
|
|
VK_LEFT: t.CDefine = -1
|
|
VK_RIGHT: t.CDefine = -2
|
|
VK_UP: t.CDefine = -3
|
|
VK_DOWN: t.CDefine = -4
|
|
VK_HOME: t.CDefine = -5
|
|
VK_END: t.CDefine = -6
|
|
VK_DELETE: t.CDefine = -7
|
|
VK_PRIOR: t.CDefine = -8
|
|
VK_NEXT: t.CDefine = -9
|
|
|
|
@c.Attribute(t.attr.packed)
|
|
@t.Object
|
|
class InputEvent:
|
|
type: uint32
|
|
win_id: int
|
|
x: int
|
|
y: int
|
|
button: uint8
|
|
_pad0: uint8
|
|
_pad1: uint8
|
|
_pad2: uint8
|
|
|
|
def create_window(x: int, y: int, w: int, h: int, title: t.CConst | t.CChar | t.CPtr, style: int) -> int:
|
|
return int(syscall._syscall6(uint64(syscall.CREATE_WINDOW), uint64(x), uint64(y), uint64(w), uint64(h), uint64(title), uint64(style)))
|
|
|
|
def draw_text(win_id: int, x: int, y: int, text: t.CConst | t.CChar | t.CPtr, color: uint32) -> int:
|
|
return int(syscall._syscall5(uint64(syscall.DRAW_TEXT), uint64(win_id), uint64(x), uint64(y), uint64(text), uint64(color)))
|
|
|
|
def get_winbuf(win_id: int) -> UINT32PTR:
|
|
return t.CPtr(syscall._syscall2(uint64(syscall.GET_WINBUF), uint64(win_id), 0))
|
|
|
|
def get_win_size(win_id: int) -> int:
|
|
return int(syscall._syscall2(uint64(syscall.GET_WIN_SIZE), uint64(win_id), 0))
|
|
|
|
def flush(win_id: int):
|
|
syscall._syscall2(uint64(syscall.WIN_FLUSH), uint64(win_id), 0)
|
|
|
|
def mainloop(win_id: int):
|
|
syscall._syscall1(uint64(syscall.WAIT_WINDOW), uint64(win_id))
|
|
|
|
def poll_event(evt: InputEvent | t.CPtr) -> int:
|
|
return int(syscall._syscall1(uint64(syscall.POLL_EVENT), uint64(evt)))
|
|
|
|
def is_active(win_id: int) -> int:
|
|
return int(syscall._syscall2(uint64(syscall.WAIT_WINDOW), uint64(win_id), 1))
|
|
|
|
def set_cursor_type(win_id: int, cursor_t: int):
|
|
syscall._syscall2(uint64(syscall.SET_CURSOR), uint64(win_id), uint64(cursor_t))
|
|
|
|
def set_title(win_id: int, title: t.CConst | str) -> int:
|
|
return int(syscall._syscall2(uint64(syscall.SET_TITLE), uint64(win_id), uint64(title)))
|
|
|
|
def set_geometry(win_id: int, x: int, y: int, w: int, h: int) -> int:
|
|
return int(syscall._syscall5(uint64(syscall.SET_GEOMETRY), uint64(win_id), uint64(x), uint64(y), uint64(w), uint64(h)))
|
|
|
|
def set_resizable(win_id: int, rw: int, rh: int) -> int:
|
|
return int(syscall._syscall3(uint64(syscall.SET_RESIZABLE), uint64(win_id), uint64(rw), uint64(rh)))
|
|
|
|
#class Window:
|
|
# HWND: int
|
|
# def __init__(self):
|
|
# self.HWND = create_window(100, 100, 100, 100)
|
|
|