MiniWinWM Window Management API
This is in need of updating and will be done as soon as I get time. In the mean time the PDF document on the main page is up-to-date.
/**
* This function is declared by MiniWin but is up to the user to implement.
* All user user interface initializations like creating windows and controls
* can be collected together here . A stubbed version is found in miniwin_user.c
* in MiniWin/user. Remove this file from the build, copy it to your
* application folder, and implement this function. The user never calls this
* function; it is called by the window manager.
*/
void mw_user_init(void);
/**
* This function is declared by MiniWin but is up to the user to implement. In
* this function the user implements the painting of the root window. A stubbed
* version is found in miniwin_user.c in MiniWin/user. Remove this file from the
* build, copy it to your application folder, and implement this function. The
* user never calls this function; it is called by the window manager.
*/
void mw_user_root_paint_function(const mw_gl_draw_info_t *draw_info);
/**
* This function is declared by MiniWin but is up to the user to implement. The
* user can respond to messages sent to the root window here, for example a tap
* on the root window. A stubbed version is found in miniwin_user.c in
* MiniWin/user. Remove this file from the build, copy it to your application
* folder, and implement this function. The user never calls this function; it
* is called by the window manager.
*/
void mw_user_root_message_function(const mw_message_t *message);
/**
* Initialize the window manager. This initialize all the drivers, create the
* root window and calls wm_user_init. This function needs to be called before
* any messages are posted or processed. This function is usually called from
* your application's main function, or MiniWin thread first call if running in
* a thread.
*/
void mw_init();
/**
* Memory for holding window data is allocated statically at compile time.
* Before adding a new window it may be useful to see if there are any slots
* in the array of window data structures free.
*/
bool mw_find_if_any_window_slots_free(void);
/**
* Add a new window. This can be called in mw_user_init for windows that exist
* for the lifetime of the application or later for windows which come and go.
* There must be space statically allocated to create the new window. Returns
* new window reference number or MW_INVALID_HANDLE if there is an error.
*/
mw_handle_t mw_add_window(mw_util_rect_t *rect,
char *title,
mw_paint_func_p paint_func,
mw_message_func_p message_func,
char **menu_bar_items,
uint8_t menu_bar_items_count,
uint32_t window_flags,
void *instance_data);
/**
* Test if a window handle is valid and represents a valid window
*/
bool mw_is_window_handle_valid(mw_handle_t window_handle);
/**
* Bring a window to the front giving it the highest Z order of all windows.
*/
void mw_bring_window_to_front(mw_handle_t window_handle);
/**
* Send a window to the back giving it the lowest Z order of all windows.
*/
void mw_send_window_to_back(mw_handle_t window_handle);
/**
* Set a window's visibility if it is used. If set visible it is given focus and brought
* to the front of other showing windows.
*/
void mw_set_window_visible(mw_handle_t window_handle, bool visible);
/**
* Set a window minimised if it is used.
*/
void mw_set_window_minimised(mw_handle_t window_handle, bool minimised);
/**
* Reposition a window. All contained controls' client areas updated automatically.
*/
void mw_reposition_window(mw_handle_t window_handle, int16_t new_x, int16_t new_y);
/**
* Resize a window. All contained controls' client areas updated automatically.
*/
bool mw_resize_window(mw_handle_t window_handle, uint16_t new_width, uint16_t new_height);
/**
* Find the window with focus. This is the visible window with the highest Z order.
*/
mw_handle_t mw_find_window_with_focus(void);
/**
* Return if any user window is currently modal.
*/
bool mw_is_any_window_modal(void);
/**
* Set the specified window system modal. This means that the window cannot be switched away from and no
* other window accepts input. The title bar icons are removed while in modal state so that the window cannot
* be closed or minimised. If any window is currently modal this call is ignored. Call ignored for unused,
* minimised or invisible windows. A model window has a different title bar colour set in miniwin_config.h.
*/
void mw_set_window_modal(mw_handle_t window_handle, bool modal);
/**
* Set a menu bar enabled or disabled for a window
*/
void mw_set_menu_bar_enabled_state(mw_handle_t window_handle, bool enabled);
/**
* Set menu bar's individual items enabled or disabled
*/
void mw_set_menu_bar_items_enabled_state(mw_handle_t window_handle, uint16_t item_enables);
/**
* Set a window horizontal scroll bar enabled or disabled
*/
void mw_set_window_horiz_scroll_bar_enabled_state(mw_handle_t window_handle, bool enabled);
/**
* Set a window vertical scroll bar enabled or disabled
*/
void mw_set_window_vert_scroll_bar_enabled_state(mw_handle_t window_handle, bool enabled);
/**
* Add a message to the message queue to get a window frame painted. This
* paints the borders, title bar, menu bar and scroll bars.
*/
void mw_paint_window_frame(mw_handle_t window_handle, uint8_t components);
/**
* Add a message to the message queue to get a window's client area and contained controls painted.
* This is useful when you know that the window is at the front and has focus and the borders and title
* bar do not need repainting.
*/
void mw_paint_window_client(mw_handle_t window_handle);
/**
* Add a message to the message queue to get a specified part of a window's client area and contained controls painted.
* This is useful when you know that the window is at the front and has focus and the borders and title
* bar do not need repainting.
*/
void mw_paint_window_client_rect(mw_handle_t window_handle, const mw_util_rect_t *rect);
/**
* Remove a window and all its controls if it has any.
*/
void mw_remove_window(mw_handle_t window_handle);
/**
* Get a window's client area rect
*/
mw_util_rect_t mw_get_window_client_rect(mw_handle_t window_handle);
/**
* Get a window's instance_data data pointer
*/
void *mw_get_window_instance_data(mw_handle_t window_handle);
/**
* Get a window's flags bitfield
*/
uint16_t mw_get_window_flags(mw_handle_t window_handle);
/**
* Set the window's title bar text
*/
void wm_set_window_title(mw_handle_t window_handle, char *title_text);
/**
* Find if there are any free control slots in array of controls
*/
bool mw_find_if_any_control_slots_free(void);
/**
* Add a new control to a window. Returns new control reference number or MAX_WINDOW_COUNT if there is an error.
*/
mw_handle_t mw_add_control(mw_util_rect_t *rect,
mw_handle_t parent_handle,
mw_paint_func_p paint_func,
mw_message_func_p message_func,
uint16_t control_flags,
void *instance_data);
/**
* Test if a control handle is valid and represents a valid control
*/
bool mw_is_control_handle_valid(mw_handle_t control_handle);
/**
* Set a control visible if it is used
*/
void mw_set_control_visible(mw_handle_t control_handle, bool visible);
/**
* Set a control enabled if it is used
*/
void mw_set_control_enabled(mw_handle_t control_handle, bool enabled);
/**
* Add a message to the message queue to get a control painted.
*/
void mw_paint_control(mw_handle_t control_handle);
/**
* Add a message to the message queue to get a specified part of a control's client area painted.
*/
void mw_paint_control_rect(mw_handle_t control_handle, const mw_util_rect_t *rect);
/**
* Remove a control.
*
* @param control_handle Handle of this control.
*/
void mw_remove_control(mw_handle_t control_handle);
/**
* Get a control's rect
*/
mw_util_rect_t mw_get_control_rect(mw_handle_t control_handle);
/**
* Get a control's parent window handle
*/
mw_handle_t mw_get_control_parent_window_handle(mw_handle_t control_handle);
/**
* Get a control's instance_data data pointer
*/
void *mw_get_control_instance_data(mw_handle_t control_handle);
/**
* Get a control's flags bitfield
*/
uint16_t mw_get_control_flags(mw_handle_t control_handle);
/**
* Find if there are any free control slots in array of controls
*/
bool mw_find_if_any_control_slots_free(void);
/**
* Set a timer if there is space for it in the array of timers.
*/
mw_handle_t mw_set_timer(uint32_t fire_time, mw_handle_t recipient_handle, mw_message_recipient_type_t recipient_type);
/**
* Cancel a previously set timer.
*/
void mw_cancel_timer(mw_handle_t timer_handle);
/**
* Package up the filling in and sending of a windows message.
*
* The message is added to the window manager message queue and will be processed by the recipient
* asynchronously.
*/
void mw_post_message(uint8_t message_id,
mw_handle_t sender_handle,
mw_handle_t recipient_handle,
uint32_t message_data,
void *message_pointer,
mw_message_recipient_type_t recipient_type);
/**
* Process the next message in the message queue. This function must be called frequently to enable user interface responsiveness.
*/
bool mw_process_message(void);
/**
* Paint everything.
*/
void mw_paint_all();
/**
* Show a busy string as defined in minwin_user.h when a long process is locking the user interface
*
* @param show true to show message, false to stop showing it
*/
void mw_show_busy(bool show);