libui/ui.idl

163 lines
4.0 KiB
Plaintext
Raw Normal View History

2015-04-15 17:41:04 -05:00
// 6 april 2015
// This is not an IDL file for the conventional RPC or Microsoft IDLs.
// Instead, this is for a custom IDL of my own creation.
// You can find it at github.com/andlabs/pgidl
package ui {
// TODO autogenerate this somehow
// TODO alternatively, move AFTER typedefs
raw "#ifndef __UI_UI_H__";
raw "#define __UI_UI_H__";
raw "#include <stdint.h>";
// TODO note that should be initialized to zero
struct InitOptions {
// TODO cbSize
// If nonzero, allocations will be logged to stderr.
// See leaks.awk.
field debugLogAllocations int;
2015-04-20 17:06:27 -05:00
// This is the menu that the application will use.
// To give this menu to a uiWindow, specify nonzero for the hasMenubar parameter to uiNewWindow().
2015-04-20 17:06:27 -05:00
// This value, nor any element of the array it points to, should never change during execution of the program.
// TODO make it a proper const *const
// TODO idl2h doesn't support making this even const * yet...
field Menu *Menu;
2015-04-15 17:41:04 -05:00
};
// TODO const char
raw "const char *uiInit(uiInitOptions *);";
raw "void uiFreeInitError(const char *);";
func Main(void);
func Quit(void);
func FreeText(text *char);
raw "typedef struct uiSizingSys uiSizingSys;";
struct Sizing {
field xPadding intmax_t;
field yPadding intmax_t;
field sys *uiSizingSys;
};
interface Control {
field Internal *void; // for use by ui only
func Destroy(void);
func Handle(void) uintptr_t;
func SetParent(p *Parent);
func PreferredSize(d *Sizing, width *intmax_t, height *intmax_t);
func Resize(x intmax_t, y intmax_t, width intmax_t, height intmax_t, d *Sizing);
func Visible(void) int;
func Show(void);
func Hide(void);
func ContainerShow(void);
func ContainerHide(void);
func Enable(void);
func Disable(void);
func ContainerEnable(void);
func ContainerDisable(void);
};
interface Parent {
field Internal *void;
func Destroy(void);
2015-04-15 17:41:04 -05:00
// TODO object destruction debug handler
func Handle(void) uintptr_t;
func SetMainControl(c *Control);
2015-04-15 17:41:04 -05:00
func SetMargins(left intmax_t, top intmax_t, right intmax_t, bottom intmax_t);
// TODO Resize?
func Update(void);
};
func NewParent(osParent uintptr_t) *Parent;
2015-04-15 17:41:04 -05:00
2015-04-15 17:47:27 -05:00
interface Window {
2015-04-15 17:41:04 -05:00
field Internal *void;
func Destroy(void);
func Handle(void) uintptr_t;
func Title(void) *char;
func SetTitle(title *const char);
func Show(void);
func Hide(void);
func OnClosing(f *func(w *Window, data *void) int, data *void);
2015-04-15 17:41:04 -05:00
func SetChild(c *Control);
func Margined(void) int;
func SetMargined(margined int);
};
func NewWindow(title *const char, width int, height int, hasMenubar int) *Window;
2015-04-15 17:41:04 -05:00
interface Button from Control {
func Text(void) *char;
2015-04-15 17:45:52 -05:00
func SetText(text *const char);
2015-04-15 17:41:04 -05:00
func OnClicked(f *func(b *Button, data *void), data *void);
};
func NewButton(text *const char) *Button;
2015-04-20 09:19:25 -05:00
interface Box from Control {
2015-04-15 17:41:04 -05:00
func Append(c *Control, stretchy int);
func Delete(index uintmax_t);
func Padded(void) int;
func SetPadded(padded int);
};
2015-04-20 09:19:25 -05:00
func NewHorizontalBox(void) *Box;
func NewVerticalBox(void) *Box;
2015-04-15 17:41:04 -05:00
interface Entry from Control {
func Text(void) *char;
func SetText(text *const char);
};
2015-04-15 17:45:52 -05:00
func NewEntry(void) *Entry;
2015-04-15 17:41:04 -05:00
interface Checkbox from Control {
func Text(void) *char;
func SetText(text *const char);
func OnToggled(f *func(c *Checkbox, data *void), data *void);
func Checked(void) int;
func SetChecked(checked int);
};
func NewCheckbox(text *const char) *Checkbox;
interface Label from Control {
func Text(void) *char;
func SetText(text *const char);
};
func NewLabel(text *const char) *Label;
2015-04-15 17:41:04 -05:00
interface Tab from Control {
2015-04-17 21:17:00 -05:00
// TODO rename to AppendPage()
2015-04-15 17:45:52 -05:00
func AddPage(name *const char, c *Control);
func DeletePage(index uintmax_t);
2015-04-15 17:45:52 -05:00
};
func NewTab(void) *Tab;
2015-04-15 17:41:04 -05:00
2015-04-20 17:06:27 -05:00
struct Menu {
field Name *const char;
// TODO make a proper const *const
// TODO idl2h doesn't support making this even const * yet...
field Items *MenuItem;
};
struct MenuItem {
field Type MenuItemType;
field Name *const char;
2015-04-20 17:06:27 -05:00
};
enum MenuItemType {
End, // Name must be NULL; specicfy this as 0
2015-04-20 17:06:27 -05:00
Command,
Checkbox,
Quit, // Name must be NULL
Preferences, // Name must be NULL
About, // Name must be NULL
Separator, // Name must be NULL
2015-04-20 17:06:27 -05:00
};
2015-04-15 17:41:04 -05:00
raw "#endif";
};