MIZU_API reference

The table Mizu hands an application, generated from desktop/mizu.h (also in the SDK). The number in brackets is the MIZU_API_VERSION a field arrived in: check api->version before using a newer one.

unsigned int version;

MIZU_API_VERSION Mizu was built with. Refuse if too old.

WINDOW* (*window_new)(const char* title, int x, int y, int width, int height);

Windows. Fill in paint, key, click on what comes back.

void (*window_delete)(WINDOW* window);
void (*window_raise)(WINDOW* window);
void (*window_client)(const WINDOW* window, int* x, int* y, int* width, int* height);
void (*repaint)(void);
void (*label)(int x, int y, const char* text, koi_uint32 color);

Drawing that matches the desktop's frames and theme.

void (*label_styled)(int x, int y, const char* text, koi_uint32 color, int style);
void (*raised)(int x, int y, int width, int height);
void (*sunken)(int x, int y, int width, int height);
koi_uint32 (*color)(int which);
int (*confirm)(const char* title, const char* message, const char* accept, const char* cancel, int accept_by_default);

Asking something, in the desktop's own manner and language.

int (*message)(const char* title, const char* message, const char* accept);
int (*prompt)(const char* title, const char* message, const char* accept, const char* cancel, char* buffer, int size);
const char* (*say)(int phrase);

Phrase table in the machine's language.

void (*yield)(void);

Give the desktop a turn during long work (cooperative: an application that never yields freezes the desktop). Does nothing inside a handler.

int (*run)(const char* command);

Run a command line and wait. The desktop gives up the screen meanwhile. Returns the exit code or KOI_EXIT_NOT_FOUND.

int (*open_file)(const char* path);

Open a file in whatever application handles its type. 1 if taken.

int (*language)(void);

Current language, and changing it (relabels everything on screen).

int (*language_count)(void);
const char* (*language_name)(int which);
void (*language_set)(int which);
int (*context_menu)(const WINDOW_ITEM* items, int count, int x, int y);

Context menu at the pointer (the Start menu's popup, opening downwards).

void (*scrollbar)(int x, int y, int height, int top, int visible, int total);

Scrollbar in the caller's units (items, visible, first). `scrollbar_press`: arrows step, trough pages, thumb starts a drag. `scrollbar_drag`: drag with the button down. Both return the new first item.

int (*scrollbar_press)(int y, int height, int top, int visible, int total, int point_y);
int (*scrollbar_drag)(int y, int height, int visible, int total, int point_y);
int (*scheme_count)(void);

Colour schemes (9). The desktop applies and saves them; `scheme_name` is in the machine's language.

const char* (*scheme_name)(int which);
int (*scheme)(void);
void (*scheme_set)(int which);
void (*wallpaper_get)(char* path, int size, int* mode);

Wallpaper and scheme colours for previews (10). See WINDOW_WALL_* and WINDOW_ROLE_* in window.h.

int (*wallpaper_set)(const char* path, int mode);
int (*wallpaper_preview)(const char* path, int mode, koi_uint32* out, int width, int height);
koi_uint32 (*scheme_color)(int which, int role);
void (*clip_set)(const char* paths, int cut);

File clipboard (11): paths, one per line, and whether they were cut. `clip_get` returns the count.

int (*clip_get)(char* paths, int size, int* cut);
void (*files_changed)(void);

Something on disk changed: the desktop rereads its folder.

int (*pick_file)(const char* title, const char* extensions, const char* accept, const char* cancel, char* path, int size);

Browsing for a file (12): see window_pick_file in window.h.

int (*screen_set)(int width, int height);

The screen's size, changed now (13): see window_screen_set.

int (*internet)(void);

Internet reachable (14), from the tray: 1 yes, 0 no, -1 unknown.

WINDOW* (*active)(void);

The window keys go to now (15), or null.

int (*remote_set)(int on, const char* password);

Remote desktop (16): on or off, the password (0 keeps it); and its state in one line, 1 if on.

int (*remote_status)(char* status, int size);
int (*background)(void (*work)(void*), void (*done)(void*), void* data);

17: slow work (reading a big file, decoding) off the desktop's thread. `work(data)` runs in a background thread and must not touch windows; then `done(data)` runs on the desktop's thread, where it may. `done` is always called, so `data` must stay allocated until then. 1 if queued; 0 if not (both then ran before it returned).

CONTROL* (*control_new)(WINDOW* window, int kind, int x, int y, int width, int height, const char* text);

18: standard controls (CONTROL in window.h): buttons, fields, check boxes, radio buttons, lists, drop-downs, sliders, progress bars, group frames and tabs, drawn and driven by the desktop.

void (*control_delete)(CONTROL* control);
void (*control_set_text)(CONTROL* control, const char* text);
const char* (*control_text)(const CONTROL* control);
void (*control_set_value)(CONTROL* control, int value);
void (*control_add)(CONTROL* control, const char* item, int icon);
void (*control_clear)(CONTROL* control);
const char* (*control_item)(const CONTROL* control, int index);
void (*control_enable)(CONTROL* control, int enabled);
void (*control_show)(CONTROL* control, int shown);
void (*control_focus)(CONTROL* control);
void (*control_page)(CONTROL* control, CONTROL* tabs, int page);
int (*icon)(const char* name);

An icon of the desktop's ("FOLDER32.BMP", ...) for control_add, or 0.

int (*modal)(WINDOW* dialog);

An application's own dialog made of controls: modal runs it until modal_end gives its result (or its close box, 0).

void (*modal_end)(WINDOW* dialog, int result);
int (*choose_color)(const char* title, const char* accept, const char* cancel, koi_uint32* rgb);

The common dialogs: a colour (0xRRGGBB), saving a file (open is pick_file). 1 when accepted.

int (*save_file)(const char* title, const char* extensions, const char* accept, const char* cancel, char* path, int size);
int (*control_tree_add)(CONTROL* tree, int parent, const char* item, int icon, int can_open);

19: trees (CONTROL_TREE) and tips.

void (*control_tree_open)(CONTROL* tree, int index, int open);
int (*control_tree_parent)(const CONTROL* tree, int index);
void (*control_set_tip)(CONTROL* control, const char* tip);
void (*power)(int what);

20: restart or turn off the way the Start menu does (KOI_POWER_*): "Restarting..." on the boot picture, disks written out. Returns only if the machine stayed on.

int (*drag_files)(const char* paths, int count, int icon);

21: carry files under the pointer while the left button is held, to a window that takes them (its `drop`) or the desktop. 1 when taken.

void (*icon_draw)(int icon, int x, int y);

Draw an icon (from `icon`) at a point of the screen.

void (*notify)(const char* title, const char* text, const char* icon, const char* target);

22: tell the user something: a balloon over the tray, then a line in the notification list. `icon` is a desktop icon ("IMAGE32.BMP") or empty; `target` what a click opens (a file, folder or "NAME.APP").

void (*clip_image_set)(const koi_uint32* pixels, int width, int height);

A picture on the clipboard (0xRRGGBB; replaces files there), and the one there now (valid until the next change) or null.

const koi_uint32* (*clip_image_get)(int* width, int* height);
void (*screen_saver)(int kind, int minutes, int preview);

23: the screen saver (0 none, 1 ripples, 2 stars, 3 mystify, 4 blank) after `minutes`, kept in the settings; or, with `preview`, run now.

int (*known_folder)(int which, char* out, int size);

24: the user's folders (made if missing; 1 if there): 0 the profile (Z:\\Users\\<name>), 1 Desktop, 2 Documents, 3 Downloads, 4 Music, 5 Pictures, 6 Videos, 7 AppData (programs' own files).

const char* (*folder_label)(const char* path);

How to show a path that is one of them, in the language; else null.

int (*open_with_app)(const char* file, const char* argument);

25: one of the desktop's applications ("PLAYER.APP"), given something to open (its open_with). 1 if it opened a window.

int (*shadows)(void);

26: shadows under windows and menus (see window_shadows); set applies and saves.

void (*shadows_set)(int kind);
int (*clear)(void);

27: see-through windows while dragged and menus (see window_clear).

void (*clear_set)(int kind);
void (*time_zone_set)(int minutes, int rule);

28: the clock. `time_zone_set` moves it to another zone (minutes east of UTC) and summer time rule (timezone.h), keeping the moment, and saves both. `time_sync` with `start` asks the network for the time; returns 0 never asked, 1 asking, 2 set (`when` gets the local time it was set, "DD.MM.YYYY HH:MM"), 3 no answer.

int (*time_sync)(int start, char* when, int size);
int (*frames)(void);

29: frames (see window_frames).

void (*frames_set)(int style);
int (*sound_play)(const char* event);

30: sounds for events. `sound_play` plays one ("error", "warning", "question", "notify", ...) and returns how long it lasts in ms. For the Sound tab: the events, their names (SAY_*), the file each plays ("" none), setting it ("" none, null the desktop's own), and hearing a file.

int (*sound_count)(void);
int (*sound_say)(int which);
void (*sound_get)(int which, char* path, int size);
void (*sound_set)(int which, const char* path);
int (*sound_play_file)(const char* path);
int (*alert)(int kind, const char* title, const char* message, const char* accept, const char* cancel);

31: a message box of a kind (WINDOW_ALERT_*: error, warning, question, information) with its icon and sound; `cancel` null for one button. 1 accept, 0 cancel.

int (*choose)(int kind, const char* title, const char* message, const char* const* buttons, int count, int chosen_by_default);

32: a box of a kind with up to three buttons ("Save", "Don't save", "Cancel"): the index chosen, or -1 for Escape.

const MIZU_SYSTEM_API* system;

33: the system's settings (MIZU_SYSTEM_API), null unless this is an application of the system. Since 33 the setters above that it holds (language_set, scheme_set, wallpaper_set, screen_set, remote_set, power, screen_saver, shadows_set, clear_set, time_zone_set, frames_set, sound_set) do nothing for any other application.

void (*window_full_screen)(WINDOW* window, int on);

34: the whole screen for a window, without its frame and the bars (window_full_screen); 0 puts it back. Null in a process of its own.