| maug
    Quick and dirty C mini-augmentation library. | 
Tools for drawing interactive GUI elements in a RetroFlat program. More...

| Modules | |
| RetroGUI Overrideable Config | |
| Options to configure RetroGUI behavior defined at compile time. | |
| RetroGUI Controls | |
| Files | |
| file | retrogui.h | 
| Data Structures | |
| struct | RETROGUI | 
| Macros | |
| #define | RETROGUI_TRACE_LVL 0 | 
| #define | RETROGUI_COLOR_BORDER RETROFLAT_COLOR_DARKBLUE | 
| RetroGUI will try to use this color on non-monochrome systems instead of black to draw things like borders, in order to coexist with window transparency (which uses black). | |
| #define | RETROGUI_FILLBAR_FLAG_SHOWNUM 0x02 | 
| #define | _retrogui_copy_str(field, src_str, dest_ctl, str_tmp, str_sz) | 
| #define | RETROGUI_IDC_FMT "%d" | 
| #define | RETROGUI_IDC_NONE -1 | 
| #define | RETROGUI_COLOR_BG 1 | 
| Value for retrogui_set_ctl_color() color_key indicating background. | |
| #define | RETROGUI_COLOR_FG 2 | 
| Value for retrogui_set_ctl_color() color_key indicating foreground. | |
| #define | RETROGUI_COLOR_SEL_BG 3 | 
| Value for retrogui_set_ctl_color() color_key indicating selection background. | |
| #define | RETROGUI_COLOR_SEL_FG 4 | 
| Value for retrogui_set_ctl_color() color_key indicating selection foreground. | |
| #define | retrogui_focus_next(gui) retrogui_focus_iter( gui, 0, 1 ) | 
| #define | retrogui_focus_prev(gui) retrogui_focus_iter( gui, mdata_vector_ct( &((gui)->ctls) ) - 1, -1 ) | 
| #define | RETROGUI_CTL_TABLE_CONSTS(idx, c_name, c_fields) extern MAUG_CONST uint8_t SEG_MCONST RETROGUI_CTL_TYPE_ ## c_name; | 
| Typedefs | |
| typedef int16_t | retrogui_idc_t | 
| Unique identifying constant number for controls. | |
| typedef void(* | retrogui_xy_cb) (retroflat_pxxy_t *x, retroflat_pxxy_t *y, void *data) | 
| typedef char | retrogui_list_t[RETROGUI_CTL_LISTBOX_STR_SZ_MAX+1] | 
| Functions | |
| MERROR_RETVAL | retrogui_push_listbox_item (struct RETROGUI *gui, retrogui_idc_t idc, const char *item, size_t item_sz) | 
| retrogui_idc_t | retrogui_poll_ctls (struct RETROGUI *gui, RETROFLAT_IN_KEY *p_input, struct RETROFLAT_INPUT *input_evt) | 
| Poll for the last clicked control and maintain listboxes and menus.  More... | |
| MERROR_RETVAL | retrogui_redraw_ctls (struct RETROGUI *gui) | 
| MERROR_RETVAL | retrogui_sz_ctl (struct RETROGUI *gui, retrogui_idc_t idc, retroflat_pxxy_t *p_w, retroflat_pxxy_t *p_h, retroflat_pxxy_t max_w, retroflat_pxxy_t max_h) | 
| MERROR_RETVAL | retrogui_pos_ctl (struct RETROGUI *gui, retrogui_idc_t idc, retroflat_pxxy_t x, retroflat_pxxy_t y, retroflat_pxxy_t w, retroflat_pxxy_t h) | 
| MERROR_RETVAL | retrogui_push_ctl (struct RETROGUI *gui, union RETROGUI_CTL *ctl) | 
| MERROR_RETVAL | retrogui_set_font (struct RETROGUI *gui, const char *font_path) | 
| Load the RetroFont API for the given RETROGUI to draw its controls with. Use RetroGXCache API if available.  More... | |
| MERROR_RETVAL | retrogui_get_ctl_text (struct RETROGUI *gui, retrogui_idc_t idc, char *buffer, size_t buffer_sz) | 
| ssize_t | retrogui_get_ctl_sel_idx (struct RETROGUI *gui, retrogui_idc_t idc) | 
| MERROR_RETVAL | retrogui_set_ctl_color (struct RETROGUI *gui, retrogui_idc_t idc, uint8_t color_key, RETROFLAT_COLOR color_val) | 
| MERROR_RETVAL | retrogui_set_ctl_text (struct RETROGUI *gui, retrogui_idc_t idc, size_t buffer_sz, const char *fmt,...) | 
| MERROR_RETVAL | retrogui_set_ctl_image (struct RETROGUI *gui, retrogui_idc_t idc, const char *path, uint8_t flags) | 
| Set the image displayed by an IMAGE-type RETROGUI_CTL.  More... | |
| MERROR_RETVAL | retrogui_set_ctl_level (struct RETROGUI *gui, retrogui_idc_t idc, uint16_t level, uint16_t max, uint8_t flags) | 
| Set the current progress level displayed by a FILLBAR-type RETROGUI_CTL.  More... | |
| MERROR_RETVAL | retrogui_init_ctl (union RETROGUI_CTL *ctl, uint8_t type, size_t idc) | 
| retrogui_idc_t | retrogui_focus_iter (struct RETROGUI *gui, size_t start, ssize_t incr) | 
| Increment RETROGUI::focus, skipping elements that cannot hold focus.  More... | |
| MERROR_RETVAL | retrogui_init (struct RETROGUI *gui) | 
| Prepare a RETROGUI controller for use.  More... | |
| MERROR_RETVAL | retrogui_remove_ctl (struct RETROGUI *gui, retrogui_idc_t idc) | 
| Remove a control with the given unique identifier index from the given RETROGUI controller.  More... | |
| MERROR_RETVAL | retrogui_destroy (struct RETROGUI *gui) | 
| Free memory held by a RETROGUI controller internally and clean up any subordinate controls.  More... | |
Tools for drawing interactive GUI elements in a RetroFlat program.
This library works well with the RetroFlat Window API.
  / * These are arbitrary; they only must be unique! * /
  # define EXAMPLE_IDC_LABEL    10
  # define EXAMPLE_IDC_BUTTON   20
  # define EXAMPLE_IDC_FILLBAR  30
  / * Insert the label control. * /
  retrogui_init_ctl( &ctl, RETROGUI_CTL_TYPE_LABEL, EXAMPLE_IDC_LABEL );
  ctl.base.x = 10;
  ctl.base.y = 10;
  ctl.base.w = 100;
  ctl.base.h = 20;
  ctl.base.fg_color = RETROFLAT_COLOR_WHITE;
  ctl.BUTTON.label = "Example\nLabel";
  ctl.BUTTON.label_sz = maug_strlen( ctl.BUTTON.label );
  retval = retrogui_push_ctl( gui_p, &ctl );
  maug_cleanup_if_not_ok();
  / * Insert the button control. * /
  retrogui_init_ctl(
     &ctl, RETROGUI_CTL_TYPE_BUTTON, EXAMPLE_IDC_BUTTON );
  ctl.base.x = 10;
  ctl.base.y = 40;
  ctl.base.w = 60;
  ctl.base.h = 20;
  ctl.BUTTON.label = "Test";
  ctl.BUTTON.label_sz = maug_strlen( ctl.BUTTON.label );
  retval = retrogui_push_ctl( gui_p, &ctl );
  maug_cleanup_if_not_ok();
  / * Insert the fillbar control. * /
  retrogui_init_ctl(
     &ctl, RETROGUI_CTL_TYPE_FILLBAR, EXAMPLE_IDC_FILLBAR );
  ctl.base.x = 10;
  ctl.base.y = 70;
  ctl.base.w = 100;
  ctl.base.h = 10;
  ctl.base.bg_color = RETROGUI_COLOR_BORDER;
  ctl.base.fg_color = RETROFLAT_COLOR_RED;
  retval = retrogui_push_ctl( gui_p, &ctl );
  maug_cleanup_if_not_ok();
  / * Set the level of the inserted fillbar to 50%. * /
  retval = retrogui_set_ctl_level(
     gui_p, EXAMPLE_IDC_FILLBAR, 50, 100, 0 );
 | #define _retrogui_copy_str | ( | field, | |
| src_str, | |||
| dest_ctl, | |||
| str_tmp, | |||
| str_sz | |||
| ) | 
| 
 | related | 
Free memory held by a RETROGUI controller internally and clean up any subordinate controls.
| 
 | related | 
Increment RETROGUI::focus, skipping elements that cannot hold focus.
| start | Value to start from, either 0 for the first element or ctl_count - 1 for the last. | 
| incr | 1 or -1, depending on whether to increment forwards or backwards. | 
| 
 | related | 
Prepare a RETROGUI controller for use.
| gui | Pointer to a RETROGUI struct to initialize. | 
| retrogui_idc_t retrogui_poll_ctls | ( | struct RETROGUI * | gui, | 
| RETROFLAT_IN_KEY * | p_input, | ||
| struct RETROFLAT_INPUT * | input_evt | ||
| ) | 
Poll for the last clicked control and maintain listboxes and menus.
| input | Input integer returned from retroflat_poll_input(). | 
| input_evt | RETROFLAT_INPUT initialized by retroflat_poll_input(). | 
| 
 | related | 
Remove a control with the given unique identifier index from the given RETROGUI controller.
| gui | Pointer to a RETROGUI struct to remove a control from. | 
| idc | Unique identifier index of the control to remove. | 
| MERROR_RETVAL retrogui_set_ctl_image | ( | struct RETROGUI * | gui, | 
| retrogui_idc_t | idc, | ||
| const char * | path, | ||
| uint8_t | flags | ||
| ) | 
Set the image displayed by an IMAGE-type RETROGUI_CTL.
| idc | Unique identifier index of the control to adjust. | 
| path | Filesystem path to pass to retroflat_load_bitmap(). | 
| flags | Flags from the RetroFlat Drawing API to pass to retroflat_load_bitmap(). | 
| MERROR_RETVAL retrogui_set_ctl_level | ( | struct RETROGUI * | gui, | 
| retrogui_idc_t | idc, | ||
| uint16_t | level, | ||
| uint16_t | max, | ||
| uint8_t | flags | ||
| ) | 
Set the current progress level displayed by a FILLBAR-type RETROGUI_CTL.
| idc | Unique identifier index of the control to adjust. | 
| level | Numeric value out of the max param (e.g. 50 for half if max is 100). | 
| max | The maximum possible value. | 
| MERROR_RETVAL retrogui_set_font | ( | struct RETROGUI * | gui, | 
| const char * | font_path | ||
| ) | 
Load the RetroFont API for the given RETROGUI to draw its controls with. Use RetroGXCache API if available.
Fonts loaded with this function will be automatically freed by calling retrogui_destroy() on this RETROGUI.