Updated Russian translation.
[midnight-commander.git] / lib / widget / hline.c
blob14021d6217cb15bca1bafeda1e7968c7edcdb5ea
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 hline.c
30 * \brief Source: WHLine widget (horizontal line)
33 #include <config.h>
35 #include <stdlib.h>
37 #include "lib/global.h"
38 #include "lib/tty/tty.h"
39 #include "lib/tty/color.h"
40 #include "lib/skin.h"
41 #include "lib/widget.h"
43 /*** global variables ****************************************************************************/
45 /*** file scope macro definitions ****************************************************************/
47 /*** file scope type declarations ****************************************************************/
49 /*** file scope variables ************************************************************************/
51 /*** file scope functions ************************************************************************/
53 static cb_ret_t
54 hline_callback (Widget * w, widget_msg_t msg, int parm)
56 WHLine *l = (WHLine *) w;
57 Dlg_head *h = l->widget.owner;
59 switch (msg)
61 case WIDGET_INIT:
62 case WIDGET_RESIZED:
63 if (l->auto_adjust_cols)
65 if (((w->owner->flags & DLG_COMPACT) != 0))
67 w->x = w->owner->x;
68 w->cols = w->owner->cols;
70 else
72 w->x = w->owner->x + 1;
73 w->cols = w->owner->cols - 2;
77 case WIDGET_FOCUS:
78 /* We don't want to get the focus */
79 return MSG_NOT_HANDLED;
81 case WIDGET_DRAW:
82 if (l->transparent)
83 tty_setcolor (DEFAULT_COLOR);
84 else
85 tty_setcolor (h->color[DLG_COLOR_NORMAL]);
87 tty_draw_hline (w->y, w->x + 1, ACS_HLINE, w->cols - 2);
89 if (l->auto_adjust_cols)
91 widget_move (w, 0, 0);
92 tty_print_alt_char (ACS_LTEE, FALSE);
93 widget_move (w, 0, w->cols - 1);
94 tty_print_alt_char (ACS_RTEE, FALSE);
96 return MSG_HANDLED;
98 default:
99 return default_proc (msg, parm);
103 /* --------------------------------------------------------------------------------------------- */
104 /*** public functions ****************************************************************************/
105 /* --------------------------------------------------------------------------------------------- */
107 WHLine *
108 hline_new (int y, int x, int width)
110 WHLine *l;
111 int lines = 1;
113 l = g_new (WHLine, 1);
114 init_widget (&l->widget, y, x, lines, width, hline_callback, NULL);
115 l->auto_adjust_cols = (width < 0);
116 l->transparent = FALSE;
117 widget_want_cursor (l->widget, FALSE);
118 widget_want_hotkey (l->widget, FALSE);
120 return l;
123 /* --------------------------------------------------------------------------------------------- */