5fff66809936b7ca4dda6decdd67fd22ea42c2aa
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
* sender
, widget_msg_t msg
, int parm
, void *data
)
58 WGroupbox
*g
= (WGroupbox
*) w
;
66 return MSG_NOT_HANDLED
;
70 Widget
*wo
= WIDGET (w
->owner
);
72 gboolean disabled
= (w
->options
& W_DISABLED
) != 0;
73 tty_setcolor (disabled
? DISABLED_COLOR
: COLOR_NORMAL
);
74 draw_box (w
->owner
, w
->y
- wo
->y
, w
->x
- wo
->x
, w
->lines
, w
->cols
, TRUE
);
78 tty_setcolor (disabled
? DISABLED_COLOR
: COLOR_TITLE
);
79 widget_move (w
->owner
, w
->y
- wo
->y
, w
->x
- wo
->x
+ 1);
80 tty_print_string (g
->title
);
90 return widget_default_callback (w
, sender
, msg
, parm
, data
);
94 /* --------------------------------------------------------------------------------------------- */
95 /*** public functions ****************************************************************************/
96 /* --------------------------------------------------------------------------------------------- */
99 groupbox_new (int y
, int x
, int height
, int width
, const char *title
)
104 g
= g_new (WGroupbox
, 1);
106 init_widget (w
, y
, x
, height
, width
, groupbox_callback
, NULL
);
108 widget_want_cursor (w
, FALSE
);
109 widget_want_hotkey (w
, FALSE
);
112 groupbox_set_title (g
, title
);
117 /* --------------------------------------------------------------------------------------------- */
120 groupbox_set_title (WGroupbox
*g
, const char *title
)
122 Widget
*w
= WIDGET (g
);
127 /* Strip existing spaces, add one space before and after the title */
128 if (title
!= NULL
&& *title
!= '\0')
132 t
= g_strstrip (g_strdup (title
));
133 g
->title
= g_strconcat (" ", t
, " ", (char *) NULL
);
137 if (w
->owner
!= NULL
)
138 send_message (w
, NULL
, MSG_DRAW
, 0, NULL
);
141 /* --------------------------------------------------------------------------------------------- */