0
GtkScrolledWindow와 GtkLayout을 결합한 GTK + 2 프로그램이 있습니다. 그것은 잘 작동합니다. 그러나 GtkEvent 객체를 GtkLayout에두면 제대로 표시되지 않습니다. 왜 그런지 압니까? 감사.스크롤 된 창 레이아웃에 GtkEventBox를 추가하려면 어떻게해야합니까?
#include <gtk/gtk.h>
int main(int argc, char *argv[])
{
GtkWidget *window, *button, *layout, *eventbox, *scrollwindow;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request (window, 150, 150);
button = gtk_button_new_with_label ("button");
layout = gtk_layout_new(NULL, NULL);
gtk_layout_set_size(GTK_LAYOUT(layout), 300, 300);
scrollwindow = gtk_scrolled_window_new(GTK_LAYOUT(layout)->hadjustment, GTK_LAYOUT(layout)->vadjustment);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_layout_put(GTK_LAYOUT(layout), button, 50, 250);
/* uncomment to use eventbox
eventbox = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(eventbox), layout);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollwindow), eventbox);
*/
// comment this line when use eventbox
gtk_container_add(GTK_CONTAINER(scrollwindow), layout);
gtk_container_add((GtkContainer*)window, scrollwindow);
gtk_widget_show_all(window);
gtk_main();
return 0;
}