1 /* Widgets for the Midnight Commander
3 Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
4 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
6 Authors: 1994, 1995 Radek Doulik
7 1994, 1995 Miguel de Icaza
11 2009, 2010 Andrew Borodin
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 * \brief Source: WGroupbox widget
35 #include "lib/global.h"
37 #include "lib/tty/tty.h"
38 #include "lib/tty/color.h"
40 #include "lib/widget.h"
42 /*** global variables ****************************************************************************/
44 /*** file scope macro definitions ****************************************************************/
46 /*** file scope type declarations ****************************************************************/
48 /*** file scope variables ************************************************************************/
50 /*** file scope functions ************************************************************************/
53 groupbox_callback (Widget
* w
, widget_msg_t msg
, int parm
)
55 WGroupbox
*g
= (WGroupbox
*) w
;
63 return MSG_NOT_HANDLED
;
67 gboolean disabled
= (w
->options
& W_DISABLED
) != 0;
68 tty_setcolor (disabled
? DISABLED_COLOR
: COLOR_NORMAL
);
69 draw_box (g
->widget
.owner
, g
->widget
.y
- g
->widget
.owner
->y
,
70 g
->widget
.x
- g
->widget
.owner
->x
, g
->widget
.lines
, g
->widget
.cols
, TRUE
);
74 tty_setcolor (disabled
? DISABLED_COLOR
: COLOR_TITLE
);
75 dlg_move (g
->widget
.owner
, g
->widget
.y
- g
->widget
.owner
->y
,
76 g
->widget
.x
- g
->widget
.owner
->x
+ 1);
77 tty_print_string (g
->title
);
87 return default_proc (msg
, parm
);
91 /* --------------------------------------------------------------------------------------------- */
92 /*** public functions ****************************************************************************/
93 /* --------------------------------------------------------------------------------------------- */
96 groupbox_new (int y
, int x
, int height
, int width
, const char *title
)
100 g
= g_new (WGroupbox
, 1);
101 init_widget (&g
->widget
, y
, x
, height
, width
, groupbox_callback
, NULL
);
103 widget_want_cursor (g
->widget
, FALSE
);
104 widget_want_hotkey (g
->widget
, FALSE
);
106 /* Strip existing spaces, add one space before and after the title */
111 t
= g_strstrip (g_strdup (title
));
112 g
->title
= g_strconcat (" ", t
, " ", (char *) NULL
);
119 /* --------------------------------------------------------------------------------------------- */