mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
(dlg_set_position): minor refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
163d9cd94a
commit
0933b08964
@ -667,7 +667,7 @@ dlg_default_repaint (WDialog * h)
|
|||||||
/** this function allows to set dialog position */
|
/** this function allows to set dialog position */
|
||||||
|
|
||||||
void
|
void
|
||||||
dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2)
|
dlg_set_position (WDialog * h, int y, int x, int lines, int cols)
|
||||||
{
|
{
|
||||||
Widget *wh = WIDGET (h);
|
Widget *wh = WIDGET (h);
|
||||||
|
|
||||||
@ -681,10 +681,10 @@ dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2)
|
|||||||
oc = wh->cols;
|
oc = wh->cols;
|
||||||
ol = wh->lines;
|
ol = wh->lines;
|
||||||
|
|
||||||
wh->x = x1;
|
wh->x = x;
|
||||||
wh->y = y1;
|
wh->y = y;
|
||||||
wh->lines = y2 - y1;
|
wh->lines = lines;
|
||||||
wh->cols = x2 - x1;
|
wh->cols = cols;
|
||||||
|
|
||||||
/* dialog is empty */
|
/* dialog is empty */
|
||||||
if (h->widgets == NULL)
|
if (h->widgets == NULL)
|
||||||
@ -715,36 +715,36 @@ dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2)
|
|||||||
one direction - it should be sized */
|
one direction - it should be sized */
|
||||||
|
|
||||||
Widget *c = WIDGET (w->data);
|
Widget *c = WIDGET (w->data);
|
||||||
int x = c->x;
|
int cx = c->x;
|
||||||
int y = c->y;
|
int cy = c->y;
|
||||||
int cols = c->cols;
|
int ccols = c->cols;
|
||||||
int lines = c->lines;
|
int clines = c->lines;
|
||||||
|
|
||||||
if ((c->pos_flags & WPOS_CENTER_HORZ) != 0)
|
if ((c->pos_flags & WPOS_CENTER_HORZ) != 0)
|
||||||
x = wh->x + (wh->cols - c->cols) / 2;
|
cx = wh->x + (wh->cols - c->cols) / 2;
|
||||||
else if ((c->pos_flags & WPOS_KEEP_LEFT) != 0 && (c->pos_flags & WPOS_KEEP_RIGHT) != 0)
|
else if ((c->pos_flags & WPOS_KEEP_LEFT) != 0 && (c->pos_flags & WPOS_KEEP_RIGHT) != 0)
|
||||||
{
|
{
|
||||||
x += shift_x;
|
cx += shift_x;
|
||||||
cols += scale_x;
|
ccols += scale_x;
|
||||||
}
|
}
|
||||||
else if ((c->pos_flags & WPOS_KEEP_LEFT) != 0)
|
else if ((c->pos_flags & WPOS_KEEP_LEFT) != 0)
|
||||||
x += shift_x;
|
cx += shift_x;
|
||||||
else if ((c->pos_flags & WPOS_KEEP_RIGHT) != 0)
|
else if ((c->pos_flags & WPOS_KEEP_RIGHT) != 0)
|
||||||
x += shift_x + scale_x;
|
cx += shift_x + scale_x;
|
||||||
|
|
||||||
if ((c->pos_flags & WPOS_CENTER_VERT) != 0)
|
if ((c->pos_flags & WPOS_CENTER_VERT) != 0)
|
||||||
y = wh->y + (wh->lines - c->lines) / 2;
|
cy = wh->y + (wh->lines - c->lines) / 2;
|
||||||
else if ((c->pos_flags & WPOS_KEEP_TOP) != 0 && (c->pos_flags & WPOS_KEEP_BOTTOM) != 0)
|
else if ((c->pos_flags & WPOS_KEEP_TOP) != 0 && (c->pos_flags & WPOS_KEEP_BOTTOM) != 0)
|
||||||
{
|
{
|
||||||
y += shift_y;
|
cy += shift_y;
|
||||||
lines += scale_y;
|
clines += scale_y;
|
||||||
}
|
}
|
||||||
else if ((c->pos_flags & WPOS_KEEP_TOP) != 0)
|
else if ((c->pos_flags & WPOS_KEEP_TOP) != 0)
|
||||||
y += shift_y;
|
cy += shift_y;
|
||||||
else if ((c->pos_flags & WPOS_KEEP_BOTTOM) != 0)
|
else if ((c->pos_flags & WPOS_KEEP_BOTTOM) != 0)
|
||||||
y += shift_y + scale_y;
|
cy += shift_y + scale_y;
|
||||||
|
|
||||||
widget_set_size (c, y, x, lines, cols);
|
widget_set_size (c, cy, cx, clines, ccols);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -772,7 +772,7 @@ dlg_set_size (WDialog * h, int lines, int cols)
|
|||||||
y = 2;
|
y = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
dlg_set_position (h, y, x, y + lines, x + cols);
|
dlg_set_position (h, y, x, lines, cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
@ -130,7 +130,7 @@ void del_widget (void *w);
|
|||||||
according to dialog flags */
|
according to dialog flags */
|
||||||
void dlg_set_size (WDialog * h, int lines, int cols);
|
void dlg_set_size (WDialog * h, int lines, int cols);
|
||||||
/* this function allows to set dialog position */
|
/* this function allows to set dialog position */
|
||||||
void dlg_set_position (WDialog * h, int y1, int x1, int y2, int x2);
|
void dlg_set_position (WDialog * h, int y, int x, int lines, int cols);
|
||||||
|
|
||||||
void dlg_init (WDialog * h);
|
void dlg_init (WDialog * h);
|
||||||
int dlg_run (WDialog * d);
|
int dlg_run (WDialog * d);
|
||||||
|
@ -107,7 +107,7 @@ history_dlg_reposition (WDialog * dlg_head)
|
|||||||
x = COLS - wi;
|
x = COLS - wi;
|
||||||
}
|
}
|
||||||
|
|
||||||
dlg_set_position (dlg_head, y, x, y + he, x + wi);
|
dlg_set_position (dlg_head, y, x, he, wi);
|
||||||
|
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ query_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
|||||||
xpos = COLS / 2 - w->cols / 2;
|
xpos = COLS / 2 - w->cols / 2;
|
||||||
|
|
||||||
/* set position */
|
/* set position */
|
||||||
dlg_set_position (h, ypos, xpos, ypos + w->lines, xpos + w->cols);
|
dlg_set_position (h, ypos, xpos, w->lines, w->cols);
|
||||||
|
|
||||||
return MSG_HANDLED;
|
return MSG_HANDLED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user