2 * GNT - The GLib Ncurses Toolkit
4 * GNT is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * This library is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
36 static GntWidgetClass
*parent_class
= NULL
;
39 gnt_line_draw(GntWidget
*widget
)
41 GntLine
*line
= GNT_LINE(widget
);
43 mvwvline(widget
->window
, 1, 0, ACS_VLINE
| gnt_color_pair(GNT_COLOR_NORMAL
),
44 widget
->priv
.height
- 2);
46 mvwhline(widget
->window
, 0, 1, ACS_HLINE
| gnt_color_pair(GNT_COLOR_NORMAL
),
47 widget
->priv
.width
- 2);
51 gnt_line_size_request(GntWidget
*widget
)
53 if (GNT_LINE(widget
)->vertical
)
55 widget
->priv
.width
= 1;
56 widget
->priv
.height
= 5;
60 widget
->priv
.width
= 5;
61 widget
->priv
.height
= 1;
66 gnt_line_map(GntWidget
*widget
)
68 if (widget
->priv
.width
== 0 || widget
->priv
.height
== 0)
69 gnt_widget_size_request(widget
);
74 gnt_line_set_property(GObject
*obj
, guint prop_id
, const GValue
*value
,
77 GntLine
*line
= GNT_LINE(obj
);
80 line
->vertical
= g_value_get_boolean(value
);
82 GNT_WIDGET_SET_FLAGS(line
, GNT_WIDGET_GROW_Y
);
84 GNT_WIDGET_SET_FLAGS(line
, GNT_WIDGET_GROW_X
);
93 gnt_line_get_property(GObject
*obj
, guint prop_id
, GValue
*value
,
96 GntLine
*line
= GNT_LINE(obj
);
99 g_value_set_boolean(value
, line
->vertical
);
107 gnt_line_class_init(GntLineClass
*klass
)
109 GObjectClass
*gclass
= G_OBJECT_CLASS(klass
);
110 parent_class
= GNT_WIDGET_CLASS(klass
);
111 parent_class
->draw
= gnt_line_draw
;
112 parent_class
->map
= gnt_line_map
;
113 parent_class
->size_request
= gnt_line_size_request
;
115 gclass
->set_property
= gnt_line_set_property
;
116 gclass
->get_property
= gnt_line_get_property
;
117 g_object_class_install_property(gclass
,
119 g_param_spec_boolean("vertical", "Vertical",
120 "Whether it's a vertical line or a horizontal one.",
122 G_PARAM_READWRITE
|G_PARAM_STATIC_NAME
|G_PARAM_STATIC_NICK
|G_PARAM_STATIC_BLURB
128 gnt_line_init(GTypeInstance
*instance
, gpointer
class)
130 GntWidget
*widget
= GNT_WIDGET(instance
);
131 GNT_WIDGET_SET_FLAGS(widget
, GNT_WIDGET_NO_SHADOW
| GNT_WIDGET_NO_BORDER
);
132 widget
->priv
.minw
= 1;
133 widget
->priv
.minh
= 1;
137 /******************************************************************************
139 *****************************************************************************/
141 gnt_line_get_gtype(void)
143 static GType type
= 0;
147 static const GTypeInfo info
= {
148 sizeof(GntLineClass
),
149 NULL
, /* base_init */
150 NULL
, /* base_finalize */
151 (GClassInitFunc
)gnt_line_class_init
,
152 NULL
, /* class_finalize */
153 NULL
, /* class_data */
156 gnt_line_init
, /* instance_init */
157 NULL
/* value_table */
160 type
= g_type_register_static(GNT_TYPE_WIDGET
,
168 GntWidget
*gnt_line_new(gboolean vertical
)
170 GntWidget
*widget
= g_object_new(GNT_TYPE_LINE
, "vertical", vertical
, NULL
);