15817
|
1 #include "gntline.h"
|
|
2
|
|
3 enum
|
|
4 {
|
|
5 SIGS = 1,
|
|
6 };
|
|
7
|
|
8 static GntWidgetClass *parent_class = NULL;
|
|
9
|
|
10 static void
|
|
11 gnt_line_draw(GntWidget *widget)
|
|
12 {
|
|
13 GntLine *line = GNT_LINE(widget);
|
|
14 if (line->vertical)
|
|
15 mvwvline(widget->window, 1, 0, ACS_VLINE | COLOR_PAIR(GNT_COLOR_NORMAL),
|
|
16 widget->priv.height - 2);
|
|
17 else
|
|
18 mvwhline(widget->window, 0, 1, ACS_HLINE | COLOR_PAIR(GNT_COLOR_NORMAL),
|
|
19 widget->priv.width - 2);
|
|
20 }
|
|
21
|
|
22 static void
|
|
23 gnt_line_size_request(GntWidget *widget)
|
|
24 {
|
|
25 if (GNT_LINE(widget)->vertical)
|
|
26 {
|
|
27 widget->priv.width = 1;
|
|
28 widget->priv.height = 5;
|
|
29 }
|
|
30 else
|
|
31 {
|
|
32 widget->priv.width = 5;
|
|
33 widget->priv.height = 1;
|
|
34 }
|
|
35 }
|
|
36
|
|
37 static void
|
|
38 gnt_line_map(GntWidget *widget)
|
|
39 {
|
|
40 if (widget->priv.width == 0 || widget->priv.height == 0)
|
|
41 gnt_widget_size_request(widget);
|
|
42 GNTDEBUG;
|
|
43 }
|
|
44
|
|
45 static void
|
|
46 gnt_line_class_init(GntLineClass *klass)
|
|
47 {
|
|
48 parent_class = GNT_WIDGET_CLASS(klass);
|
|
49 parent_class->draw = gnt_line_draw;
|
|
50 parent_class->map = gnt_line_map;
|
|
51 parent_class->size_request = gnt_line_size_request;
|
|
52
|
|
53 GNTDEBUG;
|
|
54 }
|
|
55
|
|
56 static void
|
|
57 gnt_line_init(GTypeInstance *instance, gpointer class)
|
|
58 {
|
|
59 GntWidget *widget = GNT_WIDGET(instance);
|
|
60 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER);
|
|
61 widget->priv.minw = 1;
|
|
62 widget->priv.minh = 1;
|
|
63 GNTDEBUG;
|
|
64 }
|
|
65
|
|
66 /******************************************************************************
|
|
67 * GntLine API
|
|
68 *****************************************************************************/
|
|
69 GType
|
|
70 gnt_line_get_gtype(void)
|
|
71 {
|
|
72 static GType type = 0;
|
|
73
|
|
74 if(type == 0)
|
|
75 {
|
|
76 static const GTypeInfo info = {
|
|
77 sizeof(GntLineClass),
|
|
78 NULL, /* base_init */
|
|
79 NULL, /* base_finalize */
|
|
80 (GClassInitFunc)gnt_line_class_init,
|
|
81 NULL, /* class_finalize */
|
|
82 NULL, /* class_data */
|
|
83 sizeof(GntLine),
|
|
84 0, /* n_preallocs */
|
|
85 gnt_line_init, /* instance_init */
|
|
86 NULL /* value_table */
|
|
87 };
|
|
88
|
|
89 type = g_type_register_static(GNT_TYPE_WIDGET,
|
|
90 "GntLine",
|
|
91 &info, 0);
|
|
92 }
|
|
93
|
|
94 return type;
|
|
95 }
|
|
96
|
|
97 GntWidget *gnt_line_new(gboolean vertical)
|
|
98 {
|
|
99 GntWidget *widget = g_object_new(GNT_TYPE_LINE, NULL);
|
|
100 GntLine *line = GNT_LINE(widget);
|
|
101
|
|
102 line->vertical = vertical;
|
|
103
|
|
104 if (vertical)
|
|
105 {
|
|
106 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_Y);
|
|
107 }
|
|
108 else
|
|
109 {
|
|
110 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X);
|
|
111 }
|
|
112
|
|
113 return widget;
|
|
114 }
|
|
115
|