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. In a process of its own since MIZU_API 46 too (the desktop places it).
int (*install_where)(const char* name, int me_only, int everyone_only, char* folder, int size);
35: who an installer puts a program `name` in for, asked as the App Store asks it: MIZU_INSTALL_EVERYONE (into Z:\\NAME: the system's, so the installer must run as an administrator - mizupkg's `setup` does), MIZU_INSTALL_ME (into %USERPROFILE%\\Programs\\NAME, the account's own; no administrator), or 0 for cancelled. `folder` takes where to put it. `me_only` / `everyone_only` grey the other choice.
void (*media_keys)(WINDOW* window, int on);
36: the window takes the media keys (play/pause, next, previous, stop) wherever it is, as its key(); for a player.
int (*look)(void);
37: looks (window_look_*): the one in use, how many there are, and each one's name (a SAY_* to say). Setting one is the system's (MIZU_SYSTEM_API.look_set).
int (*look_count)(void);
int (*look_say)(int which);
void (*look_label)(int x, int y, const char* text, koi_uint32 color);
38: text in the look's own font (Molten Glass writes in Inter, proportional), and how wide it comes out. label and label_styled stay in the system's font, eight pixels a character, as apps built before looks expect: an app that lays text out by WINDOW_CHAR_W keeps using them. Measure with look_text_width before using these.
void (*look_label_styled)(int x, int y, const char* text, koi_uint32 color, int style);
int (*look_text_width)(const char* text, int style);
void (*button)(int x, int y, int w, int h, const char* text, int is_default);
39: a push button drawn as the look draws its own, from the window's paint. A press on it reaches `click` only when the left button comes up over it (moved off, nothing happens), and it shows pushed in while held: draw each button with this in every paint and hit-test it in `click` as before. `is_default`: the one Enter would choose.
void (*check)(int x, int y, const char* text, int on, int enabled);
40: the look's other controls, drawn from paint as `button` is (hit-testing stays the app's). `check` and `radio`: the box at (x, y) in a row WINDOW_CHAR_H high, its text 19 pixels after. `tabs`: the tabs along the top of a page (x, y, w, h the whole of it, the strip 20 high), each as wide as its name (look_text_width) plus 16, the first at x + 2; `tab_at` says which is at `x` from the left of them, -1 none. `slider`: a track along w, its thumb's middle going from x + 5 to x + w - 5. `chosen_row`: a list's chosen row, its ground drawn; returns the colour its text takes.
void (*radio)(int x, int y, const char* text, int on, int enabled);
void (*tabs)(int x, int y, int w, int h, const char* const* names, int count, int chosen);
int (*tab_at)(int x, const char* const* names, int count);
void (*slider)(int x, int y, int w, int h, int value, int minimum, int maximum);
koi_uint32 (*chosen_row)(int x, int y, int w, int h, int focused);
void (*button_flags)(int x, int y, int w, int h, const char* text, int flags);
41: `button` with flags (WINDOW_PUSH_* in window.h): DEFAULT the one Enter would choose, OFF greyed and taking no press, ON held in (a chosen tool, a filter that is on). Text "" for a button the app draws a picture on afterwards.
int (*account_picture)(const char* id, int cx, int cy, int r);
42: an account's picture (USER_INFO id), in a round of radius r at (cx, cy), smooth in a rounded look; someone drawn there when it has none (returns 0, 1 for a picture). `account_picture_set` makes a picture file (PNG, JPEG, BMP) the account's, its middle square; "" takes it away. One's own account, or any for an administrator. 1 done.
int (*account_picture_set)(const char* id, const char* image);
void (*toggle)(int x, int y, int on, int enabled);
43: more of the look's own, from paint: a switch, 38 by 22 (a check box in Retro); a card to group rows on (a rounded panel; a grooved frame in Retro); a drop-down's box showing what is chosen, its choices the app's to offer (context_menu) when it is pressed.
void (*card)(int x, int y, int w, int h);
void (*choice)(int x, int y, int w, int h, const char* text, int enabled);
void (*swatch)(int cx, int cy, int r, koi_uint32 first, koi_uint32 second, int chosen);
44: a colour scheme's swatch: a round of radius r at (cx, cy) split on its diagonal, `first` above it and `second` below, with a ring of the accent when `chosen`; smooth in a rounded look.
void (*water_drop)(int cx, int top, int height, int level, int phase, int done);
45: Mizu's drop (the splash's), `height` tall, its point at (cx, top), water in it up to `level` of 1000, the water's face a gentle wave moved by `phase` (milliseconds: give koi_uptime() and paint again to see it move); `done`: a green tick on it. For progress.
void (*heading)(int x, int y, const char* text, koi_uint32 color);
46: large text, Inter semi-bold 24 on a 32-pixel line (the system's font, bold, without Inter), and how wide it comes out.
int (*heading_width)(const char* text);
void (*repaint_part)(WINDOW* window, int x, int y, int width, int height);
47: only this part of the window's client area (client coordinates) changed: the window is drawn again inside it alone (a terminal's line, a clock's digits), where it can be; repaint asks for all of it. While paint runs for a part, painting_part gives it (screen coordinates, as paint's) so what lies outside need not be drawn; 0 when the whole is being drawn.
int (*painting_part)(int* x, int* y, int* width, int* height);
void (*program_ended)(const char* title);
48: a program the application started has faulted (a Command Prompt's line from Run): the desktop shows the system's last fault in its box, with "Send report". `title` names it. Null where there is no desktop to show it.
int (*file_job)(int kind, const char* paths, const char* folder, void (*done)(void* data, int failed), void* data);
49: nothing new here: CONTROL.button_icon (window.h), a button's icon before its text, is drawn from this version on. 50: copy, move or delete files (`paths` one a line) on the desktop's file thread, one job after another. Once one has taken half a second a window shows it: the file now, a bar, speed, time left and Cancel. `kind` is a MIZU_FILE_; `folder` is where to (MIZU_FILE_EMPTY_BIN: its drive, "Z:"). Then `done(data, failed)` runs on the desktop's thread (how many failed, -1 when cancelled; MIZU_FILE_FAILED_OPEN added when one failed because a program had it open); `data` must last until then. 1 if started; 0 if not (nothing was done, `done` is not called).
void (*label_emoji)(int x, int y, const char* text, koi_uint32 color);
51: `label` with emoji in it: each its picture, two columns wide (a terminal's wide characters), laid over what is drawn there.
koi_uint32 (*role)(int role);
52: a colour role of the theme in use (MIZU_ROLE_*), as drawn now: an application draws in these and writes no colour of its own.
koi_uint32 (*role_text)(int role, koi_uint32 ground);
The role to write text in on `ground` (MIZU_GROUND_PAPER: the window's paper; any other value a colour, black too): its lightness moved until it reads at 4.5:1, the hue kept. A status role drawn as text (success, danger, link...) goes through this; a fill does not.
int (*material)(int x, int y, int width, int height, koi_uint32* ground);
53: Kasumi's material (window_material) in a rectangle of the window: 1 drawn, and its average colour in *ground (null: not wanted) to write on - role_text(role, *ground) for text that reads on it; 0 none, fill it yourself then. It holds only the wallpaper blurred, never another window's pixels.
int (*context_tree)(const WINDOW_ITEM* items, int count, int x, int y, const WINDOW_SUBMENU_LIST* tree, int tree_count);
54: "Open with". context_tree: context_menu with submenus (an item's id WINDOW_SUBMENU(n) opens tree[n]); null in a process of its own. open_with_choices: the applications that open `path`, the one it opens with now first, as lines "<id>\t<name>\n" into `out`; how many (0: a program, a folder, or none). open_file_with: `path` opened this once with one of those ids; 1 opened.
int (*open_with_choices)(const char* path, char* out, int size);
int (*open_file_with)(const char* id, const char* path);
int (*open_with_set)(const char* path, const char* id);
55: "Choose another app". open_with_set: the account's default for `path`'s kind, one of open_with_choices' ids ("" none); 1 set. open_file_with_program: `path` opened this once with an .EXE the user chose; never a default. 1 started.
int (*open_file_with_program)(const char* program, const char* path);
void (*show)(int what);
56: what the desktop itself opens, as from its bar or the Win key (the Quick tour's "Show me"): MIZU_SHOW_LAUNCHER, MIZU_SHOW_NOTES.
int (*file_choice)(const char* path);
57: what opening a file is to do, by its content and its name (MIZU_FILE_*); file_refuse tells the person why one of the MIZU_FILE_REFUSED_* is not run (and for Kawa offers its page).
void (*file_refuse)(const char* path, int choice);
int (*web_browser)(int set);
58: the account's web browser for links and pages: `set` -1 asks, 0 NetSurf, 1 Aoba. Answers 0 NetSurf, 1 Aoba, -2 Aoba not installed here (no choice to show).
int (*mono_cluster)(const char* text, int* bytes);
60: text on the system font's grid as a terminal or an editor lays it out: mono_cluster says how many cells the cluster at `text` takes (0 a code point drawn as nothing: a joiner, a variation selector, the BOM; 2 an emoji with all its sequence; 1 anything else) and its bytes; label_mono_cells draws a line by the same rule, in `style`. Null in an older desktop: one cell a code point, as before.
void (*label_mono_cells)(int x, int y, const char* text, koi_uint32 color, int style);
int (*open_url)(const char* url);
61: a link opened as the person asked: http:// and https:// in the account's web browser; file:///X:/... a folder in Files, a document in its viewer, anything else (a program, a script) only shown in Files. Never runs anything. At most 1023 bytes, printable, no quote or backslash. 1 when it was opened (or shown), 0 refused.