1 #ifndef __UI_TEST_WIN__
2 #define __UI_TEST_WIN__
3
4 #include "BaseObject.hpp"
5 #include <gtk/gtk.h>
6
7 class TestDialog: public BaseObject
8 {
9 public:
10 virtual ~TestDialog() {};
11 virtual gulong setupObject();
12
13 protected:
14 GtkWidget *calendar1;
15
16 virtual SIGNAL_CALLBACK gulong OnOk();
17 };
18
19 #endif
2 #define __UI_TEST_WIN__
3
4 #include "BaseObject.hpp"
5 #include <gtk/gtk.h>
6
7 class TestDialog: public BaseObject
8 {
9 public:
10 virtual ~TestDialog() {};
11 virtual gulong setupObject();
12
13 protected:
14 GtkWidget *calendar1;
15
16 virtual SIGNAL_CALLBACK gulong OnOk();
17 };
18
19 #endif
1 #include "ui_testwin.hpp"
2
3 gulong TestDialog::setupObject()
4 {
5 GtkWidget* window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
6 gtk_window_set_title (GTK_WINDOW (window1), "window1");
7
8 ConnectSignal(G_OBJECT (window1), "destroy", reinterpret_cast<CommonCallback>(&TestDialog::OnOk));
9
10 calendar1 = gtk_calendar_new ();
11 gtk_widget_show (calendar1);
12 gtk_container_add (GTK_CONTAINER (window1), calendar1);
13 gtk_calendar_display_options (GTK_CALENDAR (calendar1),
14 GtkCalendarDisplayOptions( GTK_CALENDAR_SHOW_HEADING
15 | GTK_CALENDAR_SHOW_DAY_NAMES
16 | GTK_CALENDAR_SHOW_WEEK_NUMBERS));
17
18 /* Store pointers to all widgets, for use by lookup_widget(). */
19 //GLADE_HOOKUP_OBJECT_NO_REF (window1, window1, "window1");
20 //GLADE_HOOKUP_OBJECT (window1, calendar1, "calendar1");
21 gtk_widget_show(window1);
22
23 /* 存放对象的基类指针 */
24 x_pObject = (GObject*)window1;
25
26 return 0;
27 }
28
29 gulong TestDialog::OnOk()
30 {
31 gtk_main_quit();
32 return 0;
33 }
34
35 int main (int argc, char *argv[])
36 {
37 TestDialog* lpDialog = NULL;
38
39 gtk_init (&argc, &argv);
40
41 lpDialog = new TestDialog;
42 lpDialog->setupObject();
43
44 gtk_main ();
45
46 delete lpDialog;
47 }
2
3 gulong TestDialog::setupObject()
4 {
5 GtkWidget* window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
6 gtk_window_set_title (GTK_WINDOW (window1), "window1");
7
8 ConnectSignal(G_OBJECT (window1), "destroy", reinterpret_cast<CommonCallback>(&TestDialog::OnOk));
9
10 calendar1 = gtk_calendar_new ();
11 gtk_widget_show (calendar1);
12 gtk_container_add (GTK_CONTAINER (window1), calendar1);
13 gtk_calendar_display_options (GTK_CALENDAR (calendar1),
14 GtkCalendarDisplayOptions( GTK_CALENDAR_SHOW_HEADING
15 | GTK_CALENDAR_SHOW_DAY_NAMES
16 | GTK_CALENDAR_SHOW_WEEK_NUMBERS));
17
18 /* Store pointers to all widgets, for use by lookup_widget(). */
19 //GLADE_HOOKUP_OBJECT_NO_REF (window1, window1, "window1");
20 //GLADE_HOOKUP_OBJECT (window1, calendar1, "calendar1");
21 gtk_widget_show(window1);
22
23 /* 存放对象的基类指针 */
24 x_pObject = (GObject*)window1;
25
26 return 0;
27 }
28
29 gulong TestDialog::OnOk()
30 {
31 gtk_main_quit();
32 return 0;
33 }
34
35 int main (int argc, char *argv[])
36 {
37 TestDialog* lpDialog = NULL;
38
39 gtk_init (&argc, &argv);
40
41 lpDialog = new TestDialog;
42 lpDialog->setupObject();
43
44 gtk_main ();
45
46 delete lpDialog;
47 }
在windows上调试时发现在调用OnOk时,如果带参数会有段错误,经检查,是函数调用规则导致,因此所有的事件处理函数应增加__cdecl关键字