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: WHLine widget (horizontal line)
37 #include "lib/global.h"
38 #include "lib/tty/tty.h"
39 #include "lib/tty/color.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 ************************************************************************/
54 hline_callback (Widget
* w
, widget_msg_t msg
, int parm
)
56 WHLine
*l
= (WHLine
*) w
;
57 Dlg_head
*h
= l
->widget
.owner
;
63 if (l
->auto_adjust_cols
)
65 if (((w
->owner
->flags
& DLG_COMPACT
) != 0))
68 w
->cols
= w
->owner
->cols
;
72 w
->x
= w
->owner
->x
+ 1;
73 w
->cols
= w
->owner
->cols
- 2;
78 /* We don't want to get the focus */
79 return MSG_NOT_HANDLED
;
83 tty_setcolor (DEFAULT_COLOR
);
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
);
99 return default_proc (msg
, parm
);
103 /* --------------------------------------------------------------------------------------------- */
104 /*** public functions ****************************************************************************/
105 /* --------------------------------------------------------------------------------------------- */
108 hline_new (int y
, int x
, int width
)
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
);
123 /* --------------------------------------------------------------------------------------------- */