(check_set_text): new WCheck API.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-12-14 16:53:11 +03:00
parent 432af88b06
commit b031b44823
2 changed files with 27 additions and 0 deletions

View File

@ -148,3 +148,29 @@ check_new (int y, int x, gboolean state, const char *text)
}
/* --------------------------------------------------------------------------------------------- */
void
check_set_text (WCheck * check, const char *text)
{
Widget *w = WIDGET (check);
hotkey_t hk;
hk = hotkey_new (text);
if (hotkey_equal (check->text, hk))
{
hotkey_free (hk);
return;
}
hotkey_free (check->text);
check->text = hk;
if (check->text.start[0] == '\0' && check->text.hotkey == NULL && check->text.end == NULL)
w->cols = 3; /* "[ ]" */
else
w->cols = 4 + hotkey_width (check->text); /* "[ ] text" */
widget_draw (w);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -26,6 +26,7 @@ typedef struct WCheck
/*** declarations of public functions ************************************************************/
WCheck *check_new (int y, int x, gboolean state, const char *text);
void check_set_text (WCheck * check, const char *text);
/*** inline functions ****************************************************************************/