File: table.c

package info (click to toggle)
libctk 3.0.24.6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,316 kB
  • ctags: 1,201
  • sloc: ansic: 10,623; sh: 10,438; makefile: 102
file content (118 lines) | stat: -rw-r--r-- 3,510 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <ctk/ctk.h>
#include <stdio.h>

void toggled(CtkWidget* button, gpointer data)
{
	ctk_noise("Shutdown");
}
void clicked(CtkWidget* button, gpointer data)
{
	ctk_noise("Doink");
}
void enter(CtkWidget* button, gpointer data)
{
	ctk_noise("drip");
}
void leave(CtkWidget* button, gpointer data)
{
	ctk_noise("FingerSnap");
}
void pressed(CtkWidget* button, gpointer data)
{
	ctk_noise("Wooeep");
}
void released(CtkWidget* button, gpointer data)
{
	ctk_noise("Eeeooop");
}

int main(int argc, char** argv)
{
	CtkWidget* window;
	CtkWidget* table;
	CtkWidget* buttons[7];
	CtkWidget* hbox;
	CtkWidget* label;
	
	ctk_init(CTK_USEMOUSE);
	
	/* Window */
	window = ctk_window_new(CTK_WINDOW_TOPLEVEL);
	ctk_widget_set_usize(window,1,1);
	ctk_widget_set_uposition(window,40,12);
   	ctk_window_set_title(CTK_WINDOW(window),"Crazy widget layot");
	ctk_widget_show(window);
	ctk_window_set_autocenter(CTK_WINDOW(window), TRUE);

	/* Table */
	table = ctk_table_new(4,4,FALSE);
	ctk_widget_show(table);
	
	ctk_table_set_col_spacings(CTK_TABLE(table),2);
	ctk_table_set_row_spacings(CTK_TABLE(table),1);
	ctk_container_set_border_width(CTK_CONTAINER(table), 1);
	
	ctk_container_add(CTK_CONTAINER(window),table);
	CTK_WIDGET(table)->xfill = 0;
	CTK_WIDGET(table)->yfill = 0;
	
	buttons[0] = ctk_button_new_with_label("I am 1x2 fY eX fX");
 	ctk_widget_show(buttons[0]);
 	ctk_table_attach(CTK_TABLE(table), buttons[0], 0, 1, 0, 2,
 			CTK_EXPAND|CTK_FILL, CTK_FILL, 0, 0);

	buttons[1] = ctk_button_new();
	label = ctk_button_new_with_label("I am 2x1 fY");
	ctk_widget_show(label);
	hbox = ctk_hbox_new(0, FALSE);
	ctk_widget_show(hbox);
	ctk_box_pack_start(CTK_BOX(hbox), label, FALSE, FALSE, 0);
	ctk_container_add(CTK_CONTAINER(buttons[1]), hbox);
	
 	ctk_widget_show(buttons[1]);
 	ctk_table_attach(CTK_TABLE(table), buttons[1], 0, 2, 2, 3,
 			0, CTK_FILL, 0, 0);

	buttons[2] = ctk_button_new_with_label("I am 4x1 fX eY");
	ctk_container_set_border_width(CTK_CONTAINER(buttons[2]), 1);
 	ctk_widget_show(buttons[2]);
 	ctk_table_attach(CTK_TABLE(table), buttons[2], 0, 4, 3, 4,
 			CTK_FILL, CTK_EXPAND, 0, 0);

	buttons[3] = ctk_button_new_with_label("I am 1x1 fX fY");
 	ctk_widget_show(buttons[3]);
 	ctk_table_attach(CTK_TABLE(table), buttons[3], 1, 2, 0, 1,
 			CTK_FILL, CTK_FILL, 0, 0);

	buttons[4] = ctk_button_new_with_label("I am 2x1 eY ********************");
 	ctk_widget_show(buttons[4]);
 	ctk_table_attach(CTK_TABLE(table), buttons[4], 1, 3, 1, 2,
 			0, CTK_EXPAND, 0, 0);

	buttons[5] = ctk_button_new_with_label("I am 1x1 eX");
 	ctk_widget_show(buttons[5]);
 	ctk_table_attach(CTK_TABLE(table), buttons[5], 2, 3, 2, 3,
 			CTK_EXPAND, 0, 0, 0);

	buttons[6] = ctk_radio_button_new_with_label(NULL, ""); //I am 1x3");
 	ctk_widget_show(buttons[6]);
 	ctk_table_attach(CTK_TABLE(table), buttons[6], 3, 4, 0, 3,
 			0, 0, 0, 0);
 	
 	ctk_table_colour_row(CTK_TABLE(table), 1, table->selected_col);

	ctk_signal_connect(CTK_OBJECT(buttons[6]), "clicked",
						CTK_SIGNAL_FUNC(&clicked), NULL);
	ctk_signal_connect(CTK_OBJECT(buttons[6]), "enter",
						CTK_SIGNAL_FUNC(&enter), NULL);
	ctk_signal_connect(CTK_OBJECT(buttons[6]), "leave",
						CTK_SIGNAL_FUNC(&leave), NULL);
	ctk_signal_connect(CTK_OBJECT(buttons[6]), "pressed",
						CTK_SIGNAL_FUNC(&pressed), NULL);
	ctk_signal_connect(CTK_OBJECT(buttons[6]), "released",
						CTK_SIGNAL_FUNC(&released), NULL);
	ctk_signal_connect(CTK_OBJECT(buttons[6]), "toggled",
						CTK_SIGNAL_FUNC(&toggled), NULL);
	ctk_main();
	return 0;
}