Redid the interface a bit.

This commit is contained in:
Pietro Gagliardi 2015-04-22 13:08:21 -04:00
parent 9519c59011
commit 662146f46e
1 changed files with 20 additions and 35 deletions

55
ui.idl
View File

@ -20,18 +20,10 @@ struct InitOptions {
// If nonzero, allocations will be logged to stderr. // If nonzero, allocations will be logged to stderr.
// See leaks.awk. // See leaks.awk.
field debugLogAllocations int; field debugLogAllocations int;
// This is the menu that the application will use.
// To give this menu to a uiWindow, specify nonzero for the hasMenubar parameter to uiNewWindow().
// 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;
}; };
// TODO const char func Init(options *InitOptions) *const char;
raw "const char *uiInit(uiInitOptions *);"; func FreeInitError(err *const char);
raw "void uiFreeInitError(const char *);";
func Main(void); func Main(void);
func Quit(void); func Quit(void);
@ -50,7 +42,8 @@ interface Control {
field Internal *void; // for use by ui only field Internal *void; // for use by ui only
func Destroy(void); func Destroy(void);
func Handle(void) uintptr_t; func Handle(void) uintptr_t;
func SetParent(p *Parent); func SetHasParent(hasParent int);
func SetOSContainer(c *OSContainer);
func PreferredSize(d *Sizing, width *intmax_t, height *intmax_t); 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 Resize(x intmax_t, y intmax_t, width intmax_t, height intmax_t, d *Sizing);
func Visible(void) int; func Visible(void) int;
@ -64,17 +57,15 @@ interface Control {
func ContainerDisable(void); func ContainerDisable(void);
}; };
interface Parent { interface OSContainer {
field Internal *void; field Internal *void;
func Destroy(void); func Destroy(void);
// TODO object destruction debug handler
func Handle(void) uintptr_t; func Handle(void) uintptr_t;
func SetMainControl(c *Control); func SetMainControl(c *Control);
func SetMargins(left intmax_t, top intmax_t, right intmax_t, bottom intmax_t); func SetMargins(left intmax_t, top intmax_t, right intmax_t, bottom intmax_t);
// TODO Resize?
func Update(void); func Update(void);
}; };
func NewParent(osParent uintptr_t) *Parent; func NewOSContainer(osParent uintptr_t) *OSContainer;
interface Window { interface Window {
field Internal *void; field Internal *void;
@ -135,28 +126,22 @@ interface Tab from Control {
}; };
func NewTab(void) *Tab; func NewTab(void) *Tab;
struct Menu { interface Menu {
field Name *const char; func AddItem(name string) *MenuItem;
// TODO make a proper const *const func AddCheckItem(name string) *MenuItem;
// TODO idl2h doesn't support making this even const * yet... func AddQuitItem(void) *MenuItem;
field Items *MenuItem; func AddPreferencesItem(void) *MenuItem;
func AddAboutItem(void) *MenuItem;
func AddSeparator(void);
}; };
func NewMenu(name string) *Menu;
struct MenuItem { interface MenuItem {
field Type MenuItemType; func Enable(void);
field Name *const char; func Disable(void);
field OnClicked *func(sender *void, data *void); func OnClicked(f *func(sender *void, data *void), data *void);
field OnClickedData *void; func Checked(void) int;
}; func SetChecked(checked int);
enum MenuItemType {
End, // Name must be NULL; specicfy this as 0
Command,
Checkbox,
Quit, // Name must be NULL
Preferences, // Name must be NULL
About, // Name must be NULL
Separator, // Name must be NULL
}; };
raw "#endif"; raw "#endif";