2 Widgets for the Midnight Commander
4 Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
5 2004, 2005, 2006, 2007, 2009, 2010, 2011
6 The Free Software Foundation, Inc.
9 Radek Doulik, 1994, 1995
10 Miguel de Icaza, 1994, 1995
12 Andrej Borsenkow, 1996
14 Andrew Borodin <aborodin@vmail.ru>, 2009, 2010
16 This file is part of the Midnight Commander.
18 The Midnight Commander is free software: you can redistribute it
19 and/or modify it under the terms of the GNU General Public License as
20 published by the Free Software Foundation, either version 3 of the License,
21 or (at your option) any later version.
23 The Midnight Commander is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
28 You should have received a copy of the GNU General Public License
29 along with this program. If not, see <http://www.gnu.org/licenses/>.
33 * \brief Source: WGroupbox widget
38 #include "lib/global.h"
40 #include "lib/tty/tty.h"
41 #include "lib/tty/color.h"
43 #include "lib/widget.h"
45 /*** global variables ****************************************************************************/
47 /*** file scope macro definitions ****************************************************************/
49 /*** file scope type declarations ****************************************************************/
51 /*** file scope variables ************************************************************************/
53 /*** file scope functions ************************************************************************/
56 groupbox_callback (Widget
* w
, widget_msg_t msg
, int parm
)
58 WGroupbox
*g
= (WGroupbox
*) w
;
66 return MSG_NOT_HANDLED
;
70 gboolean disabled
= (w
->options
& W_DISABLED
) != 0;
71 tty_setcolor (disabled
? DISABLED_COLOR
: COLOR_NORMAL
);
72 draw_box (g
->widget
.owner
, g
->widget
.y
- g
->widget
.owner
->y
,
73 g
->widget
.x
- g
->widget
.owner
->x
, g
->widget
.lines
, g
->widget
.cols
, TRUE
);
77 tty_setcolor (disabled
? DISABLED_COLOR
: COLOR_TITLE
);
78 dlg_move (g
->widget
.owner
, g
->widget
.y
- g
->widget
.owner
->y
,
79 g
->widget
.x
- g
->widget
.owner
->x
+ 1);
80 tty_print_string (g
->title
);
90 return default_proc (msg
, parm
);
94 /* --------------------------------------------------------------------------------------------- */
95 /*** public functions ****************************************************************************/
96 /* --------------------------------------------------------------------------------------------- */
99 groupbox_new (int y
, int x
, int height
, int width
, const char *title
)
103 g
= g_new (WGroupbox
, 1);
104 init_widget (&g
->widget
, y
, x
, height
, width
, groupbox_callback
, NULL
);
106 widget_want_cursor (g
->widget
, FALSE
);
107 widget_want_hotkey (g
->widget
, FALSE
);
109 /* Strip existing spaces, add one space before and after the title */
114 t
= g_strstrip (g_strdup (title
));
115 g
->title
= g_strconcat (" ", t
, " ", (char *) NULL
);
122 /* --------------------------------------------------------------------------------------------- */