(dlg_adjust_position): rename to widget_adjust_position and make public.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-10-10 10:20:27 +03:00
parent f6c4ae2f31
commit 297391fd60
3 changed files with 33 additions and 32 deletions

View File

@ -604,36 +604,6 @@ dlg_widget_set_position (gpointer data, gpointer user_data)
widget_set_size (c, y, x, lines, cols);
}
/* --------------------------------------------------------------------------------------------- */
static void
dlg_adjust_position (widget_pos_flags_t pos_flags, int *y, int *x, int *lines, int *cols)
{
if ((pos_flags & WPOS_FULLSCREEN) != 0)
{
*y = 0;
*x = 0;
*lines = LINES;
*cols = COLS;
}
else
{
if ((pos_flags & WPOS_CENTER_HORZ) != 0)
*x = (COLS - *cols) / 2;
if ((pos_flags & WPOS_CENTER_VERT) != 0)
*y = (LINES - *lines) / 2;
if ((pos_flags & WPOS_TRYUP) != 0)
{
if (*y > 3)
*y -= 2;
else if (*y == 3)
*y = 2;
}
}
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -712,7 +682,7 @@ dlg_set_size (WDialog * h, int lines, int cols)
{
int x = 0, y = 0;
dlg_adjust_position (WIDGET (h)->pos_flags, &y, &x, &lines, &cols);
widget_adjust_position (WIDGET (h)->pos_flags, &y, &x, &lines, &cols);
dlg_set_position (h, y, x, lines, cols);
}
@ -771,7 +741,7 @@ dlg_create (gboolean modal, int y1, int x1, int lines, int cols, widget_pos_flag
new_d = g_new0 (WDialog, 1);
w = WIDGET (new_d);
dlg_adjust_position (pos_flags, &y1, &x1, &lines, &cols);
widget_adjust_position (pos_flags, &y1, &x1, &lines, &cols);
widget_init (w, y1, x1, lines, cols, (callback != NULL) ? callback : dlg_default_callback,
mouse_callback);
w->pos_flags = pos_flags;

View File

@ -329,6 +329,36 @@ widget_set_state (Widget * w, widget_state_t state, gboolean enable)
/* --------------------------------------------------------------------------------------------- */
void
widget_adjust_position (widget_pos_flags_t pos_flags, int *y, int *x, int *lines, int *cols)
{
if ((pos_flags & WPOS_FULLSCREEN) != 0)
{
*y = 0;
*x = 0;
*lines = LINES;
*cols = COLS;
}
else
{
if ((pos_flags & WPOS_CENTER_HORZ) != 0)
*x = (COLS - *cols) / 2;
if ((pos_flags & WPOS_CENTER_VERT) != 0)
*y = (LINES - *lines) / 2;
if ((pos_flags & WPOS_TRYUP) != 0)
{
if (*y > 3)
*y -= 2;
else if (*y == 3)
*y = 2;
}
}
}
/* --------------------------------------------------------------------------------------------- */
void
widget_set_size (Widget * widget, int y, int x, int lines, int cols)
{

View File

@ -180,6 +180,7 @@ cb_ret_t widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg,
void *data);
void widget_set_options (Widget * w, widget_options_t options, gboolean enable);
cb_ret_t widget_set_state (Widget * w, widget_state_t state, gboolean enable);
void widget_adjust_position (widget_pos_flags_t pos_flags, int *y, int *x, int *lines, int *cols);
void widget_set_size (Widget * widget, int y, int x, int lines, int cols);
/* select color for widget in dependance of state */
void widget_selectcolor (Widget * w, gboolean focused, gboolean hotkey);