2015 ソフトウェア設計及び演習用の班Wiki
15::gr11::mondai.c
#include "gtk_lib.h" #include "widget.h" guint timer_id; // 2択問題 GtkWidget * mondai2(GtkWidget *window, QUESTION ques){ Max_widget = 5; Max_hbox = 1; GtkWidget *widget[Max_widget]; widget[0] = my_image_new (ques.mondaibun); widget[1] = gtk_button_new_with_label(ques.choices2[0]); g_signal_connect(G_OBJECT(widget[1]), "clicked", G_CALLBACK(answer_button_clicked), "1"); widget[2] = gtk_button_new_with_label(ques.choices2[1]); g_signal_connect(G_OBJECT(widget[2]), "clicked", G_CALLBACK(answer_button_clicked), "2"); widget[3] = gtk_button_new_with_label("採点"); g_signal_connect(G_OBJECT(widget[3]), "clicked", G_CALLBACK(saiten_button_clicked), NULL); if(return_item_number() == 1) // 制限時間2倍時 { widget[4] = gtk_label_new ("Count 20"); }else{ widget[4] = gtk_label_new ("Count 10"); } timer_id = g_timeout_add (1000, (GSourceFunc) count_down, widget[4]); vbox = gtk_vbox_new(FALSE, 15); gtk_container_add(GTK_CONTAINER(window), vbox); { int i, j; for(i=0; i<Max_widget; i+=Max_hbox) { hbox = gtk_hbox_new(TRUE, 15); gtk_container_add(GTK_CONTAINER(vbox), hbox); for(j=i; j<i+Max_hbox && j<Max_widget; j++) { gtk_box_pack_start(GTK_BOX(hbox), widget[j], TRUE, TRUE, 0); } } } return window; } // 4択問題 GtkWidget * mondai4(GtkWidget *window, QUESTION ques){ Max_widget = 7; Max_hbox = 1; GtkWidget *widget[Max_widget]; widget[0] = my_image_new (ques.mondaibun); widget[1] = gtk_button_new_with_label(ques.choices4[0]); g_signal_connect(G_OBJECT(widget[1]), "clicked", G_CALLBACK(answer_button_clicked), "1"); widget[2] = gtk_button_new_with_label(ques.choices4[1]); g_signal_connect(G_OBJECT(widget[2]), "clicked", G_CALLBACK(answer_button_clicked), "2"); widget[3] = gtk_button_new_with_label(ques.choices4[2]); g_signal_connect(G_OBJECT(widget[3]), "clicked", G_CALLBACK(answer_button_clicked), "3"); widget[4] = gtk_button_new_with_label(ques.choices4[3]); g_signal_connect(G_OBJECT(widget[4]), "clicked", G_CALLBACK(answer_button_clicked), "4"); widget[5] = gtk_button_new_with_label("採点"); g_signal_connect(G_OBJECT(widget[5]), "clicked", G_CALLBACK(saiten_button_clicked), NULL); if(return_item_number() == 1) // 制限時間2倍時 { widget[6] = gtk_label_new ("Count 20"); }else{ widget[6] = gtk_label_new ("Count 10"); } timer_id = g_timeout_add (1000, (GSourceFunc) count_down, widget[6]); vbox = gtk_vbox_new(FALSE, 10); gtk_container_add(GTK_CONTAINER(window), vbox); { int i, j; for(i=0; i<Max_widget; i+=Max_hbox) { hbox = gtk_hbox_new(TRUE, 10); gtk_container_add(GTK_CONTAINER(vbox), hbox); for(j=i; j<i+Max_hbox && j<Max_widget; j++) { gtk_box_pack_start(GTK_BOX(hbox), widget[j], TRUE, TRUE, 0); } } } return window; }
最終更新日:2015/07/17 12:37:14