Updated Russian translation.
[midnight-commander.git] / lib / widget / groupbox.c
blob0fd3d2e39d23bfd496dc7ad760f23f79c1b2c2ce
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
8 1995 Jakub Jelinek
9 1996 Andrej Borsenkow
10 1997 Norbert Warmuth
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.
29 /** \file groupbox.c
30 * \brief Source: WGroupbox widget
33 #include <config.h>
35 #include "lib/global.h"
37 #include "lib/tty/tty.h"
38 #include "lib/tty/color.h"
39 #include "lib/skin.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 ************************************************************************/
52 static cb_ret_t
53 groupbox_callback (Widget * w, widget_msg_t msg, int parm)
55 WGroupbox *g = (WGroupbox *) w;
57 switch (msg)
59 case WIDGET_INIT:
60 return MSG_HANDLED;
62 case WIDGET_FOCUS:
63 return MSG_NOT_HANDLED;
65 case WIDGET_DRAW:
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);
72 if (g->title != NULL)
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);
79 return MSG_HANDLED;
82 case WIDGET_DESTROY:
83 g_free (g->title);
84 return MSG_HANDLED;
86 default:
87 return default_proc (msg, parm);
91 /* --------------------------------------------------------------------------------------------- */
92 /*** public functions ****************************************************************************/
93 /* --------------------------------------------------------------------------------------------- */
95 WGroupbox *
96 groupbox_new (int y, int x, int height, int width, const char *title)
98 WGroupbox *g;
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 */
107 if (title != NULL)
109 char *t;
111 t = g_strstrip (g_strdup (title));
112 g->title = g_strconcat (" ", t, " ", (char *) NULL);
113 g_free (t);
116 return g;
119 /* --------------------------------------------------------------------------------------------- */