mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
(group_init): change argument for coordinates.
Use WRect instead of four values. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
ccdc909105
commit
390d614b5e
@ -398,6 +398,7 @@ dlg_create (gboolean modal, int y1, int x1, int lines, int cols, widget_pos_flag
|
||||
gboolean compact, const int *colors, widget_cb_fn callback,
|
||||
widget_mouse_cb_fn mouse_callback, const char *help_ctx, const char *title)
|
||||
{
|
||||
WRect r = { y1, x1, lines, cols };
|
||||
WDialog *new_d;
|
||||
Widget *w;
|
||||
WGroup *g;
|
||||
@ -405,8 +406,8 @@ 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);
|
||||
g = GROUP (new_d);
|
||||
widget_adjust_position (pos_flags, &y1, &x1, &lines, &cols);
|
||||
group_init (g, y1, x1, lines, cols, callback != NULL ? callback : dlg_default_callback,
|
||||
widget_adjust_position (pos_flags, &r.y, &r.x, &r.lines, &r.cols);
|
||||
group_init (g, &r, callback != NULL ? callback : dlg_default_callback,
|
||||
mouse_callback != NULL ? mouse_callback : dlg_default_mouse_callback);
|
||||
|
||||
w->pos_flags = pos_flags;
|
||||
|
@ -594,13 +594,11 @@ group_handle_hotkey (WGroup * g, int key)
|
||||
*/
|
||||
|
||||
void
|
||||
group_init (WGroup * g, int y1, int x1, int lines, int cols, widget_cb_fn callback,
|
||||
widget_mouse_cb_fn mouse_callback)
|
||||
group_init (WGroup * g, const WRect * r, widget_cb_fn callback, widget_mouse_cb_fn mouse_callback)
|
||||
{
|
||||
WRect r = { y1, x1, lines, cols };
|
||||
Widget *w = WIDGET (g);
|
||||
|
||||
widget_init (w, &r, callback != NULL ? callback : group_default_callback, mouse_callback);
|
||||
widget_init (w, r, callback != NULL ? callback : group_default_callback, mouse_callback);
|
||||
|
||||
w->mouse_handler = group_handle_mouse_event;
|
||||
|
||||
|
@ -38,7 +38,7 @@ struct WGroup
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void group_init (WGroup * g, int y1, int x1, int lines, int cols, widget_cb_fn callback,
|
||||
void group_init (WGroup * g, const WRect * r, widget_cb_fn callback,
|
||||
widget_mouse_cb_fn mouse_callback);
|
||||
/* Default callback for groups */
|
||||
cb_ret_t group_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
|
@ -877,26 +877,23 @@ chattrboxes_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static WChattrBoxes *
|
||||
chattrboxes_new (int y, int x, int height, int width)
|
||||
chattrboxes_new (const WRect * r)
|
||||
{
|
||||
WChattrBoxes *cb;
|
||||
Widget *w;
|
||||
WGroup *cbg;
|
||||
int i;
|
||||
|
||||
if (height <= 0)
|
||||
height = 1;
|
||||
|
||||
cb = g_new0 (WChattrBoxes, 1);
|
||||
w = WIDGET (cb);
|
||||
cbg = GROUP (cb);
|
||||
group_init (cbg, y, x, height, width, chattrboxes_callback, chattrboxes_mouse_callback);
|
||||
group_init (cbg, r, chattrboxes_callback, chattrboxes_mouse_callback);
|
||||
w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR;
|
||||
w->mouse_handler = chattrboxes_handle_mouse_event;
|
||||
w->keymap = chattr_map;
|
||||
|
||||
/* create checkboxes */
|
||||
for (i = 0; i < height; i++)
|
||||
for (i = 0; i < r->lines; i++)
|
||||
{
|
||||
int m;
|
||||
WCheck *check;
|
||||
@ -976,6 +973,7 @@ chattr_dlg_create (WPanel * panel, const char *fname, unsigned long attr)
|
||||
WGroup *dg;
|
||||
WChattrBoxes *cb;
|
||||
const int cb_scrollbar_width = 1;
|
||||
WRect r;
|
||||
|
||||
/* prepate to set up checkbox states */
|
||||
for (i = 0; i < check_attr_num; i++)
|
||||
@ -1012,8 +1010,7 @@ chattr_dlg_create (WPanel * panel, const char *fname, unsigned long attr)
|
||||
|
||||
if (cols < WIDGET (file_attr)->rect.cols)
|
||||
{
|
||||
WRect r = dw->rect;
|
||||
|
||||
r = dw->rect;
|
||||
cols = WIDGET (file_attr)->rect.cols;
|
||||
cols = MIN (cols, mw->rect.cols - wx * 2);
|
||||
r.cols = cols + wx * 2;
|
||||
@ -1022,7 +1019,8 @@ chattr_dlg_create (WPanel * panel, const char *fname, unsigned long attr)
|
||||
}
|
||||
|
||||
checkboxes_lines = MIN (check_attr_mod_num, checkboxes_lines);
|
||||
cb = chattrboxes_new (y++, wx, checkboxes_lines, cols);
|
||||
rect_init (&r, y++, wx, checkboxes_lines > 0 ? checkboxes_lines : 1, cols);
|
||||
cb = chattrboxes_new (&r);
|
||||
group_add_widget_autopos (dg, cb, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL);
|
||||
|
||||
y += checkboxes_lines - 1;
|
||||
@ -1053,8 +1051,7 @@ chattr_dlg_create (WPanel * panel, const char *fname, unsigned long attr)
|
||||
cols += 6;
|
||||
if (cols > dw->rect.cols)
|
||||
{
|
||||
WRect r = dw->rect;
|
||||
|
||||
r = dw->rect;
|
||||
r.lines = lines;
|
||||
r.cols = cols;
|
||||
widget_set_size_rect (dw, &r);
|
||||
|
@ -88,10 +88,12 @@ START_TEST (test_group_init_deinit)
|
||||
WRect r;
|
||||
|
||||
g = g_new0 (WGroup, 1);
|
||||
group_init (g, 0, 0, 20, 20, group_callback, NULL);
|
||||
rect_init (&r, 0, 0, 20, 20);
|
||||
group_init (g, &r, group_callback, NULL);
|
||||
|
||||
g0 = g_new0 (WGroup, 1);
|
||||
group_init (g0, 0, 0, 10, 10, group_callback, NULL);
|
||||
rect_init (&r, 0, 0, 10, 10);
|
||||
group_init (g0, &r, group_callback, NULL);
|
||||
group_add_widget (g, g0);
|
||||
|
||||
w0 = g_new0 (Widget, 1);
|
||||
@ -105,7 +107,8 @@ START_TEST (test_group_init_deinit)
|
||||
group_add_widget (g0, w0);
|
||||
|
||||
g0 = g_new0 (WGroup, 1);
|
||||
group_init (g0, 10, 10, 10, 10, group_callback, NULL);
|
||||
rect_init (&r, 10, 10, 10, 10);
|
||||
group_init (g0, &r, group_callback, NULL);
|
||||
group_add_widget (g, g0);
|
||||
|
||||
w0 = g_new0 (Widget, 1);
|
||||
|
@ -44,10 +44,12 @@ START_TEST (test_widget_find_by_id)
|
||||
WRect r;
|
||||
|
||||
g = g_new0 (WGroup, 1);
|
||||
group_init (g, 0, 0, 20, 20, NULL, NULL); /* ID = 0 */
|
||||
rect_init (&r, 0, 0, 20, 20);
|
||||
group_init (g, &r, NULL, NULL); /* ID = 0 */
|
||||
|
||||
g0 = g_new0 (WGroup, 1);
|
||||
group_init (g0, 0, 0, 10, 10, NULL, NULL); /* ID = 1 */
|
||||
rect_init (&r, 0, 0, 10, 10);
|
||||
group_init (g0, &r, NULL, NULL); /* ID = 1 */
|
||||
group_add_widget (g, g0);
|
||||
|
||||
w0 = g_new0 (Widget, 1);
|
||||
@ -61,7 +63,8 @@ START_TEST (test_widget_find_by_id)
|
||||
group_add_widget (g0, w0);
|
||||
|
||||
g0 = g_new0 (WGroup, 1);
|
||||
group_init (g0, 10, 10, 10, 10, NULL, NULL); /* ID = 4 */
|
||||
rect_init (&r, 10, 10, 10, 10);
|
||||
group_init (g0, &r, NULL, NULL); /* ID = 4 */
|
||||
group_add_widget (g, g0);
|
||||
|
||||
w0 = g_new0 (Widget, 1);
|
||||
|
@ -45,7 +45,8 @@ START_TEST (test_widget_make_global_local)
|
||||
|
||||
/* top level group */
|
||||
g0 = g_new0 (WGroup, 1);
|
||||
group_init (g0, 20, 20, 40, 40, NULL, NULL);
|
||||
rect_init (&r, 20, 20, 40, 40);
|
||||
group_init (g0, &r, NULL, NULL);
|
||||
|
||||
/* g0 child */
|
||||
w0 = g_new0 (Widget, 1);
|
||||
@ -55,7 +56,8 @@ START_TEST (test_widget_make_global_local)
|
||||
|
||||
/* g0 child */
|
||||
g1 = g_new0 (WGroup, 1);
|
||||
group_init (g1, 5, 5, 30, 30, NULL, NULL);
|
||||
rect_init (&r, 5, 5, 30, 30);
|
||||
group_init (g1, &r, NULL, NULL);
|
||||
|
||||
/* g1 child */
|
||||
w1 = g_new0 (Widget, 1);
|
||||
@ -65,7 +67,8 @@ START_TEST (test_widget_make_global_local)
|
||||
|
||||
/* g1 child */
|
||||
g2 = g_new0 (WGroup, 1);
|
||||
group_init (g2, 15, 15, 20, 20, NULL, NULL);
|
||||
rect_init (&r, 15, 15, 20, 20);
|
||||
group_init (g2, &r, NULL, NULL);
|
||||
group_add_widget (g1, g2);
|
||||
|
||||
/* g2 child */
|
||||
|
Loading…
Reference in New Issue
Block a user