Windows, menus, popups, toolbars and dialogs

EsWindowCreate

EsWindow *EsWindowCreate(ES_INSTANCE_TYPE *instance, EsWindowStyle style);

Creates a window with the given style. instance may be ES_NULL for internal windows.
Returns the new window, or ES_NULL on failure. Must run on the message thread.

EsWindowGetBounds

EsRectangle EsWindowGetBounds(EsWindow *window);

Returns the screen bounds of the window.

EsWindowGetToolbar

EsElement *EsWindowGetToolbar(EsWindow *window, bool createNew = false);

Returns the window's toolbar. With createNew true, always creates a new one.
Returns ES_NULL if creation fails. The toolbar belongs to the window.

EsWindowSwitchToolbar

void EsWindowSwitchToolbar(EsWindow *window, EsElement *toolbar, EsTransitionType transitionType);

Replaces the displayed toolbar with the given toolbar, using the given transition.

EsWindowSetIcon

void EsWindowSetIcon(EsWindow *window, uint32_t iconID);

Sets the window's icon from the icon database. Must run on the message thread.

EsWindowSetTitle

void EsWindowSetTitle(EsWindow *window, STRING title = BLANK_STRING);

Sets the window title. With an empty title, uses the instance's application name.
If both are empty, nothing changes. Must run on the message thread.

EsWindowAddSizeAlternative

void EsWindowAddSizeAlternative(EsWindow *window, EsElement *small, EsElement *big, int widthThreshold, int heightThreshold);

Switch between elements when the window size goes below a threshold.

EsMenuCreate

EsMenu *EsMenuCreate(EsElement *source, EsMenuFlags flags = ES_FLAGS_DEFAULT);

Creates a menu bound to the source element. Returns ES_NULL on failure.

EsMenuGetSource

EsElement *EsMenuGetSource(EsMenu *menu);

Returns the source element the menu was created from. The caller does not own it.

EsMenuAddItem

void EsMenuAddItem(EsMenu *menu, EsMenuItemFlags flags, STRING label = BLANK_STRING, EsMenuCallback callback = ES_NULL, EsGeneric context = ES_NULL);

Adds a menu item with the given label. The callback runs with the context when the item is activated.

EsMenuAddCommand

void EsMenuAddCommand(EsMenu *menu, EsMenuItemFlags flags, STRING label, EsCommand *command);

Adds a menu item that activates the given command.
The item mirrors the command's enabled state, check state and callback.

EsMenuAddSeparator

void EsMenuAddSeparator(EsMenu *menu);

Adds a horizontal separator line to the menu.

EsMenuNextColumn

void EsMenuNextColumn(EsMenu *menu, EsElementFlags flags = ES_FLAGS_DEFAULT);

Starts a new column in the menu. Later items are added to that column.

EsMenuShow

void EsMenuShow(EsMenu *menu, int fixedWidth = 0, int fixedHeight = 0);

Shows the menu near its source element, or at the cursor with ES_MENU_AT_CURSOR.
fixedWidth and fixedHeight force the menu size; with ES_MENU_MAXIMUM_HEIGHT, fixedHeight is a maximum.

EsMenuClose

void EsMenuClose(EsMenu *menu);

Closes the menu with an exit transition.

EsMenuCloseAll

void EsMenuCloseAll();

Closes every open menu.

EsMenuAddCommandsFromToolbar

void EsMenuAddCommandsFromToolbar(EsMenu *menu, EsElement *element);

Adds a menu item for each toolbar button that has a command.
Recurses into child elements and skips non-client elements.

EsDialogShow

EsDialog *EsDialogShow(EsWindow *window, STRING title, STRING content, uint32_t iconID, EsDialogShowFlags flags = ES_FLAGS_DEFAULT);

Shows a modal dialog on the given window. Blocks interaction with the window content until it closes.
Returns the dialog, or ES_NULL on allocation failure. Only valid on normal windows.

EsDialogAddButton

EsButton *EsDialogAddButton(EsDialog *dialog, EsButtonFlags flags = ES_FLAGS_DEFAULT, EsStyleID style = 0, STRING label = BLANK_STRING, EsCommandCallback callback = ES_NULL);

Adds a button to the dialog. Returns the button, or ES_NULL on failure.
The callback runs when the button is activated. ES_BUTTON_CANCEL makes it the cancel button.

EsDialogClose

void EsDialogClose(EsDialog *dialog);

Closes the dialog with an exit transition and re-enables the content behind it.

EsDialogGetContentArea

EsElement *EsDialogGetContentArea(EsDialog *dialog);

Returns the dialog's content area element. Add custom content there. It belongs to the dialog.

EsFileMenuAddToToolbar

void EsFileMenuAddToToolbar(EsElement *toolbar, const EsFileMenuSettings *settings = ES_NULL);

Adds a File button to the toolbar. The button opens the file menu for the instance.
settings is optional.

EsFileMenuCreate

void EsFileMenuCreate(ES_INSTANCE_TYPE *instance, EsElement *parent, EsMenuFlags flags = ES_FLAGS_DEFAULT);

Creates and shows the file menu on the given parent element. Only for editor instances.