Add Window module

master
Alec Murphy 1 week ago
parent 05b9a610fd
commit ee0988d48c
  1. 90
      Lib/Window.HC
  2. 1
      Load.HC
  3. 2
      dc.jakt
  4. 7
      include/window.h
  5. 16
      libtemple/libtemple.cpp
  6. 38
      window.jakt

@ -0,0 +1,90 @@
U0 @window_draw_it(CTask *task, CDC *dc) {
if (task->user_data)
@dc_copy(dc, task->pix_left, task->pix_top, task->user_data);
}
CTask *@window_user() {
CTask *task = Spawn(&UserCmdLine, , , 0);
TaskWait(task);
XTalk(task,
"while (1) { StrCpy(Fs->task_title, Fs->task_name); Sleep(1); };\n");
return task;
}
CTask *@window_create() {
CTask *task = @window_user;
task->draw_it = &@window_draw_it;
return task;
}
U0 _Z13window_createv() {
// window_create()
PUSH_SYSV_REGS
GET_SYSV_ARGS
debug_print("called: window_create()\n");
@window_create();
POP_SYSV_REGS
}
U0 _Z14window_destroym() {
// window_destroy(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
debug_print("called: window_destroy(0x%08x)\n", p0);
Kill(p0);
POP_SYSV_REGS
}
Bool @window_is_focused(CTask *task) { return task == sys_focus_task; }
U0 _Z17window_is_focusedm() {
// window_is_focused(unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
debug_print("called: window_is_focused(0x%08x)\n", p0);
@window_is_focused(p0);
POP_SYSV_REGS
}
U0 @window_set_coordinates(CTask *task, I64 top, I64 left, I64 bottom,
I64 right) {
task->win_top = top;
task->win_left = left;
task->win_bottom = bottom;
task->win_right = right;
}
U0 _Z22window_set_coordinatesmllll() {
// window_set_coordinates(unsigned long, long, long, long, long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
debug_print("called: window_set_coordinates(0x%08x, %d, %d, %d, %d)\n", p0,
p1, p2, p3, p4);
@window_set_coordinates(p0, p1, p2, p3, p4);
POP_SYSV_REGS
}
U0 @window_set_context(CTask *task, CDC *dc) { task->user_data = dc; }
U0 _Z18window_set_contextmm() {
// window_set_context(unsigned long, unsigned long)
PUSH_SYSV_REGS
GET_SYSV_ARGS
debug_print("called: window_set_context(0x%08x, 0x%08x)\n", p0, p1);
@window_set_context(p0, p1);
POP_SYSV_REGS
}
U0 @window_set_title(CTask *task, U8 *title) {
StrCpy(task->task_name, title);
StrCpy(task->task_title, title);
}
U0 _Z16window_set_titlemPKc() {
// window_set_title(unsigned long, char const*)
PUSH_SYSV_REGS
GET_SYSV_ARGS
debug_print("called: window_set_title(0x%08x, \"%s\")\n", p0, p1);
@window_set_title(p0, p1);
POP_SYSV_REGS
}

@ -11,6 +11,7 @@
#include "Lib/DC";
#include "Lib/Input";
#include "Lib/Time";
#include "Lib/Window";
#include "Lib/ELF64";

@ -40,7 +40,7 @@ class DC {
public function thickness(this) -> i64 {
return dc_thickness(.context)
}
context: usize
public context: usize
public function alias(this) throws -> DC {
return DC(context: dc_alias(.context))
}

@ -0,0 +1,7 @@
unsigned long window_create();
unsigned long window_dc_alias(unsigned long task);
void window_destroy(unsigned long task);
bool window_is_focused(unsigned long task);
void window_set_context(unsigned long task, unsigned long dc);
void window_set_coordinates(unsigned long task, long top, long left, long bottom, long right);
void window_set_title(unsigned long task, const char * title);

@ -70,4 +70,18 @@ void os_write_entire_file(const char *filename, unsigned char *buffer, long size
long time_jiffies() { return 0; }
void time_sleep(long duration) { }
void time_sleep(long duration) { }
unsigned long window_create() { return 0; }
unsigned long window_dc_alias(unsigned long task) { return 0; }
void window_destroy(unsigned long task) { }
bool window_is_focused(unsigned long task) { return 0; }
void window_set_context(unsigned long task, unsigned long dc) { }
void window_set_coordinates(unsigned long task, long top, long left, long bottom, long right) { }
void window_set_title(unsigned long task, const char * title) { }

@ -0,0 +1,38 @@
import dc { DC }
import extern c "window.h" {
extern function window_create() -> usize
extern function window_dc_alias(anon task: usize) -> usize
extern function window_destroy(anon task: usize)
extern function window_is_focused(anon task: usize) -> bool
extern function window_set_context(anon task: usize, dc: usize)
extern function window_set_coordinates(anon task: usize, top: i64, left: i64, bottom: i64, right: i64)
extern function window_set_title(anon task: usize, title: raw c_char)
}
class Window {
public function create_new() throws -> Window {
mut window = Window(task: 0)
window.task = window_create()
return window
}
public function dc_alias(this) -> usize {
return window_dc_alias(.task)
}
public function destroy(this) {
window_destroy(.task)
}
public function is_focused(this) -> bool {
return window_is_focused(.task)
}
public function set_context(this, anon dc: DC) {
window_set_context(.task, dc: dc.context)
}
public function set_coordinates(this, top: i64, left: i64, bottom: i64, right: i64) {
window_set_coordinates(.task, top, left, bottom, right)
}
public function set_title(this, anon title: String) {
window_set_title(.task, title: title.c_string())
}
task: usize
}
Loading…
Cancel
Save