![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Macros | |
| #define | N_GUI_POPUP_ROOT 0 |
| the top level, as a parent for n_gui_popup_add_item() and the others | |
Typedefs | |
| typedef void(* | N_GUI_POPUP_FN) (N_GUI_POPUP *popup, int tag, void *user_data) |
| called when an item is picked, after the popup has closed. | |
Functions | |
| int | n_gui_popup_add_item (N_GUI_POPUP *popup, int parent, const char *text, int tag, const char *tip) |
| Add an item at the end of a level. | |
| int | n_gui_popup_add_separator (N_GUI_POPUP *popup, int parent) |
| Add a separator at the end of a level. | |
| int | n_gui_popup_add_submenu (N_GUI_POPUP *popup, int parent, const char *text, const char *tip) |
| Add a submenu at the end of a level. | |
| void | n_gui_popup_close (N_GUI_POPUP *popup) |
| Close every level without picking anything. | |
| void | n_gui_popup_free (N_GUI_POPUP **popup) |
| Close the popup and release the handle. | |
| int | n_gui_popup_hit (const N_GUI_POPUP *popup, float x, float y) |
| Is a point on any of its open levels. | |
| int | n_gui_popup_is_open (const N_GUI_POPUP *popup) |
| Is its top level on screen. | |
| N_GUI_POPUP * | n_gui_popup_new (N_GUI_CTX *ctx, float scale, N_GUI_POPUP_FN on_pick, void *user_data) |
Make an empty popup menu in ctx, closed. | |
| int | n_gui_popup_open (N_GUI_POPUP *popup, float x, float y) |
| Open the top level with its corner at a point. | |
| int | n_gui_popup_press (N_GUI_POPUP *popup, int entry) |
| Press the row of an entry, as a click on it would. | |
| void | n_gui_popup_set_enabled (N_GUI_POPUP *popup, int entry, int enabled) |
| Enable or grey out an entry. | |
| void | n_gui_popup_set_shown (N_GUI_POPUP *popup, int entry, int shown) |
| Show or hide an entry. | |
| void | n_gui_popup_set_title (N_GUI_POPUP *popup, const char *text) |
| Set the heading line over the top level. | |
| int | n_gui_popup_window (const N_GUI_POPUP *popup, int level) |
| The window of a level, for an application that wants to test it. | |
| #define N_GUI_POPUP_ROOT 0 |
the top level, as a parent for n_gui_popup_add_item() and the others
Definition at line 68 of file n_gui_popup.h.
Referenced by _popup_draw(), _popup_layout(), main(), n_gui_popup_close(), n_gui_popup_hit(), n_gui_popup_is_open(), n_gui_popup_new(), n_gui_popup_open(), n_gui_popup_press(), n_gui_popup_set_enabled(), n_gui_popup_set_shown(), and n_gui_popup_set_title().
| typedef void(* N_GUI_POPUP_FN) (N_GUI_POPUP *popup, int tag, void *user_data) |
called when an item is picked, after the popup has closed.
| popup | the popup |
| tag | the tag the item was added with |
| user_data | what was handed to n_gui_popup_new() |
Definition at line 78 of file n_gui_popup.h.
| int n_gui_popup_add_item | ( | N_GUI_POPUP * | popup, |
| int | parent, | ||
| const char * | text, | ||
| int | tag, | ||
| const char * | tip ) |
Add an item at the end of a level.
| popup | the popup |
| parent | N_GUI_POPUP_ROOT, or an id from n_gui_popup_add_submenu() |
| text | what the row says. Copied. |
| tag | handed to on_pick when it is picked |
| tip | tooltip for the row, or NULL. Copied. |
Definition at line 522 of file n_gui_popup.c.
References _popup_append(), _popup_is_level(), and _POPUP_KIND_ITEM.
Referenced by main().
| int n_gui_popup_add_separator | ( | N_GUI_POPUP * | popup, |
| int | parent ) |
Add a separator at the end of a level.
| popup | the popup |
| parent | N_GUI_POPUP_ROOT or a submenu's id |
Definition at line 532 of file n_gui_popup.c.
References _popup_append(), _popup_is_level(), and _POPUP_KIND_SEP.
Referenced by main().
| int n_gui_popup_add_submenu | ( | N_GUI_POPUP * | popup, |
| int | parent, | ||
| const char * | text, | ||
| const char * | tip ) |
Add a submenu at the end of a level.
| popup | the popup |
| parent | N_GUI_POPUP_ROOT, or another submenu's id |
| text | what its row says; the arrow is drawn, not written. Copied. |
| tip | tooltip for the row, or NULL. Copied. |
Definition at line 527 of file n_gui_popup.c.
References _popup_append(), _popup_is_level(), and _POPUP_KIND_SUB.
Referenced by main().
| void n_gui_popup_close | ( | N_GUI_POPUP * | popup | ) |
Close every level without picking anything.
| popup | the popup. NULL is a no-op. |
Definition at line 563 of file n_gui_popup.c.
References _popup_close_level(), N_GUI_POPUP::ctx, N_GUI_POPUP::entries, n_gui_mark_dirty(), and N_GUI_POPUP_ROOT.
Referenced by _popup_activate(), main(), n_gui_popup_free(), and n_gui_popup_open().
| void n_gui_popup_free | ( | N_GUI_POPUP ** | popup | ) |
Close the popup and release the handle.
Its windows stay in the context, closed, and their widgets no longer call into the freed handle.
| popup | the popup; set to NULL. NULL or *NULL is a no-op. |
Definition at line 607 of file n_gui_popup.c.
References FreeNoLog, _N_GUI_POPUP_ENTRY::hook, n_gui_custom_set_mouse(), n_gui_popup_close(), n_gui_set_widget_visible(), _N_GUI_POPUP_ENTRY::row_y, _N_GUI_POPUP_ENTRY::rows, _N_GUI_POPUP_ENTRY::text, _N_GUI_POPUP_ENTRY::tip, and _N_GUI_POPUP_ENTRY::widget.
Referenced by main().
| int n_gui_popup_hit | ( | const N_GUI_POPUP * | popup, |
| float | x, | ||
| float | y ) |
Is a point on any of its open levels.
| popup | the popup |
| x | screen x |
| y | screen y |
Definition at line 574 of file n_gui_popup.c.
References _N_GUI_POPUP_ENTRY::child, N_GUI_POPUP::entries, _N_GUI_POPUP_ENTRY::h, n_gui_popup_is_open(), N_GUI_POPUP_ROOT, _N_GUI_POPUP_ENTRY::w, _N_GUI_POPUP_ENTRY::x, and _N_GUI_POPUP_ENTRY::y.
Referenced by main().
| int n_gui_popup_is_open | ( | const N_GUI_POPUP * | popup | ) |
Is its top level on screen.
| popup | the popup |
Definition at line 569 of file n_gui_popup.c.
References N_GUI_POPUP::ctx, N_GUI_POPUP::entries, N_GUI_POPUP_ROOT, n_gui_window_is_open(), and _N_GUI_POPUP_ENTRY::window.
Referenced by main(), n_gui_popup_hit(), and on_pick().
| N_GUI_POPUP * n_gui_popup_new | ( | N_GUI_CTX * | ctx, |
| float | scale, | ||
| N_GUI_POPUP_FN | on_pick, | ||
| void * | user_data ) |
Make an empty popup menu in ctx, closed.
No window is made until a level is first opened. The windows belong to ctx like any others and outlive the handle, closed and inert.
| ctx | the GUI context |
| scale | interface scale, for padding and the arrow; 1.0 at 96 dpi |
| on_pick | called with an item's tag when it is picked. Required. |
| user_data | handed back to on_pick |
Definition at line 503 of file n_gui_popup.c.
References __n_assert, _popup_append(), _POPUP_KIND_ROOT, N_GUI_POPUP::ctx, N_GUI_POPUP::entries, N_GUI_POPUP_ROOT, N_GUI_POPUP::on_pick, on_pick(), N_GUI_POPUP::scale, and N_GUI_POPUP::user_data.
Referenced by main().
| int n_gui_popup_open | ( | N_GUI_POPUP * | popup, |
| float | x, | ||
| float | y ) |
Open the top level with its corner at a point.
Below and to the right of the point, pulled back inside the display rather than flipped. Any level already open is closed first.
| popup | the popup |
| x | screen x, usually where the click was |
| y | screen y |
Definition at line 557 of file n_gui_popup.c.
References _popup_show_level(), n_gui_popup_close(), and N_GUI_POPUP_ROOT.
Referenced by main().
| int n_gui_popup_press | ( | N_GUI_POPUP * | popup, |
| int | entry ) |
Press the row of an entry, as a click on it would.
For tests and for keyboard front ends: an item is picked (the popup closes, then on_pick is called), a submenu opens beside its row. The entry's level must be open and the entry shown and enabled.
| popup | the popup |
| entry | the entry's id |
Definition at line 593 of file n_gui_popup.c.
References _popup_activate(), _popup_valid(), N_GUI_POPUP::ctx, N_GUI_POPUP::entries, N_GUI_POPUP_ROOT, n_gui_window_is_open(), _N_GUI_POPUP_ENTRY::nb_rows, _N_GUI_POPUP_ENTRY::parent, _N_GUI_POPUP_ENTRY::rows, and _N_GUI_POPUP_ENTRY::window.
Referenced by main().
| void n_gui_popup_set_enabled | ( | N_GUI_POPUP * | popup, |
| int | entry, | ||
| int | enabled ) |
Enable or grey out an entry.
A disabled row is drawn greyed, is not highlighted and does nothing when pressed; a disabled submenu does not open.
| popup | the popup |
| entry | an id returned by one of the add functions |
| enabled | non-zero to enable it |
Definition at line 552 of file n_gui_popup.c.
References _popup_valid(), _N_GUI_POPUP_ENTRY::enabled, N_GUI_POPUP::entries, and N_GUI_POPUP_ROOT.
Referenced by main().
| void n_gui_popup_set_shown | ( | N_GUI_POPUP * | popup, |
| int | entry, | ||
| int | shown ) |
Show or hide an entry.
| popup | the popup |
| entry | an id returned by one of the add functions |
| shown | non-zero to show it |
Definition at line 547 of file n_gui_popup.c.
References _popup_valid(), N_GUI_POPUP::entries, N_GUI_POPUP_ROOT, and _N_GUI_POPUP_ENTRY::shown.
Referenced by main().
| void n_gui_popup_set_title | ( | N_GUI_POPUP * | popup, |
| const char * | text ) |
Set the heading line over the top level.
Not a row that can be picked: it says what the popup is about, a file name or a count. Takes effect at the next n_gui_popup_open().
| popup | the popup |
| text | the heading, or NULL or "" for none. Copied. |
Definition at line 537 of file n_gui_popup.c.
References N_GUI_POPUP::entries, FreeNoLog, N_GUI_POPUP_ROOT, and _N_GUI_POPUP_ENTRY::text.
Referenced by main().
| int n_gui_popup_window | ( | const N_GUI_POPUP * | popup, |
| int | level ) |
The window of a level, for an application that wants to test it.
| popup | the popup |
| level | N_GUI_POPUP_ROOT or a submenu's id |
Definition at line 588 of file n_gui_popup.c.
References _popup_is_level(), N_GUI_POPUP::entries, and _N_GUI_POPUP_ENTRY::window.
Referenced by level_window(), and main().