mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-24 20:22:11 +03:00
* widget.c: Implement new widget - groupbox.
* option.c: Use it.
This commit is contained in:
parent
86c2a91184
commit
af893babbd
@ -1,5 +1,8 @@
|
||||
2003-09-07 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* widget.c: Implement new widget - groupbox.
|
||||
* option.c: Use it.
|
||||
|
||||
* layout.c: Fix remaining callback calls.
|
||||
* widget.c: Likewise.
|
||||
|
||||
|
43
src/option.c
43
src/option.c
@ -43,8 +43,6 @@
|
||||
#include "option.h"
|
||||
static Dlg_head *conf_dlg;
|
||||
|
||||
static int r_but;
|
||||
|
||||
#define TOGGLE_VARIABLE 0
|
||||
|
||||
static int first_width, second_width;
|
||||
@ -107,36 +105,6 @@ static char *pause_options [3] = {
|
||||
#define RX X_MARGIN
|
||||
#define OX (first_width + X_MARGIN + X_PANE_GAP)
|
||||
|
||||
static cb_ret_t
|
||||
configure_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
||||
{
|
||||
switch (msg) {
|
||||
case DLG_DRAW:
|
||||
common_dialog_repaint (h);
|
||||
|
||||
attrset (COLOR_NORMAL);
|
||||
draw_box (h, PY, PX, PANEL_OPTIONS + 2, first_width);
|
||||
draw_box (h, RY, RX, PAUSE_OPTIONS + 2, first_width);
|
||||
draw_box (h, OY, OX, OTHER_OPTIONS + 2, second_width);
|
||||
|
||||
attrset (COLOR_HOT_NORMAL);
|
||||
dlg_move (h, OY, OX+1);
|
||||
addstr (title3);
|
||||
dlg_move (h, RY, RX+1);
|
||||
addstr (title2);
|
||||
dlg_move (h, PY, PX+1);
|
||||
addstr (title1);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case DLG_END:
|
||||
r_but = parm;
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return default_dlg_callback (h, msg, parm);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the "Configure options" dialog */
|
||||
static void
|
||||
init_configure (void)
|
||||
@ -199,9 +167,18 @@ init_configure (void)
|
||||
conf_dlg =
|
||||
create_dlg (0, 0, DLG_Y,
|
||||
first_width + second_width + 2 * X_MARGIN + X_PANE_GAP,
|
||||
dialog_colors, configure_callback, "[Configuration]",
|
||||
dialog_colors, NULL, "[Configuration]",
|
||||
_("Configure options"), DLG_CENTER);
|
||||
|
||||
add_widget (conf_dlg,
|
||||
groupbox_new (PX, PY, first_width, PANEL_OPTIONS + 2, title1));
|
||||
|
||||
add_widget (conf_dlg,
|
||||
groupbox_new (RX, RY, first_width, PAUSE_OPTIONS + 2, title2));
|
||||
|
||||
add_widget (conf_dlg,
|
||||
groupbox_new (OX, OY, second_width, OTHER_OPTIONS + 2, title3));
|
||||
|
||||
add_widget (conf_dlg,
|
||||
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON,
|
||||
cancel_button, 0));
|
||||
|
55
src/widget.c
55
src/widget.c
@ -2354,3 +2354,58 @@ redraw_labels (Dlg_head *h)
|
||||
send_message ((Widget *) bb, WIDGET_DRAW, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
groupbox_callback (WGroupbox *g, int msg, int parm)
|
||||
{
|
||||
switch (msg) {
|
||||
case WIDGET_INIT:
|
||||
return MSG_HANDLED;
|
||||
|
||||
case WIDGET_FOCUS:
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
case WIDGET_DRAW:
|
||||
attrset (COLOR_NORMAL);
|
||||
draw_box (g->widget.parent, g->widget.y - g->widget.parent->y,
|
||||
g->widget.x - g->widget.parent->x, g->widget.lines,
|
||||
g->widget.cols);
|
||||
|
||||
attrset (COLOR_HOT_NORMAL);
|
||||
dlg_move (g->widget.parent, g->widget.y - g->widget.parent->y,
|
||||
g->widget.x - g->widget.parent->x + 1);
|
||||
addstr (g->title);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return default_proc (msg, parm);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
groupbox_destroy (WGroupbox *g)
|
||||
{
|
||||
g_free (g->title);
|
||||
}
|
||||
|
||||
WGroupbox *
|
||||
groupbox_new (int x, int y, int width, int height, char *title)
|
||||
{
|
||||
WGroupbox *g = g_new (WGroupbox, 1);
|
||||
|
||||
init_widget (&g->widget, y, x, height, width,
|
||||
(callback_fn) groupbox_callback,
|
||||
(destroy_fn) groupbox_destroy, NULL);
|
||||
|
||||
g->widget.options &= ~W_WANT_CURSOR;
|
||||
widget_want_hotkey (g->widget, 0);
|
||||
|
||||
/* Strip existing spaces, add one space before and after the title */
|
||||
if (title) {
|
||||
char *t;
|
||||
t = g_strstrip (g_strdup (title));
|
||||
g->title = g_strconcat (" ", t, " ", NULL);
|
||||
g_free (t);
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
@ -119,6 +119,11 @@ struct WListbox {
|
||||
int cursor_x, cursor_y; /* Cache the values */
|
||||
};
|
||||
|
||||
typedef struct WGroupbox {
|
||||
Widget widget;
|
||||
char *title;
|
||||
} WGroupbox;
|
||||
|
||||
typedef void (*buttonbarfn)(void *);
|
||||
|
||||
typedef struct {
|
||||
@ -140,6 +145,7 @@ WInput *input_new (int y, int x, int color, int len, const char *text, char
|
||||
WLabel *label_new (int y, int x, const char *text);
|
||||
WGauge *gauge_new (int y, int x, int shown, int max, int current);
|
||||
WListbox *listbox_new (int x, int y, int width, int height, lcback callback);
|
||||
WGroupbox *groupbox_new (int x, int y, int width, int height, char *title);
|
||||
|
||||
/* Input lines */
|
||||
void winput_set_origin (WInput *i, int x, int field_len);
|
||||
|
Loading…
Reference in New Issue
Block a user