wxSize wxButton::DoGetBestSize() const { // the default button in wxGTK is bigger than the other ones because of an // extra border around it, but we don't want to take it into account in // our size calculations (otherwise the result is visually ugly), so // always return the size of non default button from here const bool isDefault = gtk_widget_has_default(m_widget) != 0; if ( isDefault ) { // temporarily unset default flag gtk_widget_set_can_default(m_widget, FALSE); } wxSize ret( wxAnyButton::DoGetBestSize() ); if ( isDefault ) { // set it back again gtk_widget_set_can_default(m_widget, TRUE); } if (!HasFlag(wxBU_EXACTFIT)) { wxSize defaultSize = GetDefaultSize(); if (ret.x < defaultSize.x) ret.x = defaultSize.x; if (ret.y < defaultSize.y) ret.y = defaultSize.y; } CacheBestSize(ret); return ret; }
void create_about_dialog(void) { char work[256]; GtkWidget *about_dialog; GtkWidget *main_widget; GtkWidget *ver_label; GtkWidget *ok_button; GtkWidget *neko_image; GdkPixbuf *neko_pixbuf; uninstall_idle_process(); about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(about_dialog), "About Neko Project II"); gtk_window_set_position(GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(about_dialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(about_dialog), FALSE); gtk_container_set_border_width(GTK_CONTAINER(about_dialog), 10); g_signal_connect(GTK_OBJECT(about_dialog), "destroy", G_CALLBACK(about_destroy), NULL); main_widget = gtk_hbox_new(FALSE, 3); gtk_widget_show(main_widget); gtk_container_add(GTK_CONTAINER(about_dialog), main_widget); neko_pixbuf = gdk_pixbuf_new_from_xpm_data(np2_icon); neko_image = gtk_image_new_from_pixbuf(neko_pixbuf); g_object_unref(neko_pixbuf); gtk_widget_show(neko_image); gtk_box_pack_start(GTK_BOX(main_widget), neko_image, FALSE, FALSE, 10); milstr_ncpy(work, "Neko Project II\n", sizeof(work)); milstr_ncat(work, NP2VER_CORE, sizeof(work)); #if defined(NP2VER_X11) milstr_ncat(work, NP2VER_X11, sizeof(work)); #endif ver_label = gtk_label_new(work); gtk_widget_show(ver_label); gtk_box_pack_start(GTK_BOX(main_widget), ver_label, FALSE, FALSE, 10); ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); gtk_widget_show(ok_button); gtk_box_pack_end(GTK_BOX(main_widget), ok_button, FALSE, TRUE, 0); g_signal_connect_swapped(GTK_OBJECT(ok_button), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(about_dialog)); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_default(ok_button, TRUE); gtk_widget_has_default(ok_button); #else GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(ok_button, GTK_HAS_DEFAULT); #endif gtk_widget_grab_default(ok_button); gtk_widget_show_all(about_dialog); }
void create_configure_dialog(void) { GtkWidget *config_dialog; GtkWidget *main_widget; GtkWidget *cpu_hbox; GtkWidget *cpu_frame; GtkWidget *cpuframe_vbox; GtkWidget *cpuclock_hbox; GtkWidget *baseclock_combo; GtkWidget *rate_combo; GtkWidget *times_label; GtkWidget *realclock_label; GtkWidget *confirm_widget; GtkWidget *ok_button; GtkWidget *cancel_button; GtkWidget *arch_frame; GtkWidget *arch_hbox; GtkWidget *arch_radiobutton[NELEMENTS(architecture)]; GtkWidget *sound_frame; GtkWidget *soundframe_vbox; GtkWidget *soundrate_hbox; GtkWidget *rate_label; GtkWidget *rate_radiobutton[NELEMENTS(samplingrate)]; GtkWidget *soundbuffer_hbox; GtkWidget *buffer_label; GtkWidget *ms_label; gchar buf[8]; int i; uninstall_idle_process(); config_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(config_dialog), "Configure"); gtk_window_set_position(GTK_WINDOW(config_dialog), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(config_dialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(config_dialog), FALSE); gtk_container_set_border_width(GTK_CONTAINER(config_dialog), 5); g_signal_connect(GTK_OBJECT(config_dialog), "destroy", G_CALLBACK(dialog_destroy), NULL); main_widget = gtk_vbox_new(FALSE, 0); gtk_widget_show(main_widget); gtk_container_add(GTK_CONTAINER(config_dialog), main_widget); /* CPU column */ cpu_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(cpu_hbox); gtk_box_pack_start(GTK_BOX(main_widget), cpu_hbox, TRUE, TRUE, 0); /* * CPU frame */ cpu_frame = gtk_frame_new("CPU"); gtk_widget_show(cpu_frame); gtk_box_pack_start(GTK_BOX(cpu_hbox), cpu_frame, TRUE, TRUE, 0); cpuframe_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(cpuframe_vbox), 5); gtk_widget_show(cpuframe_vbox); gtk_container_add(GTK_CONTAINER(cpu_frame), cpuframe_vbox); /* cpu clock */ cpuclock_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(cpuclock_hbox); gtk_box_pack_start(GTK_BOX(cpuframe_vbox),cpuclock_hbox, TRUE, TRUE, 2); baseclock_combo = gtk_combo_box_entry_new_text(); gtk_widget_show(baseclock_combo); gtk_box_pack_start(GTK_BOX(cpuclock_hbox), baseclock_combo, TRUE, FALSE, 0); gtk_widget_set_size_request(baseclock_combo, 96, -1); for (i = 0; i < NELEMENTS(baseclock_str); i++) { gtk_combo_box_append_text(GTK_COMBO_BOX(baseclock_combo), baseclock_str[i]); } baseclock_entry = GTK_BIN(baseclock_combo)->child; gtk_widget_show(baseclock_entry); gtk_editable_set_editable(GTK_EDITABLE(baseclock_entry), FALSE); switch (np2cfg.baseclock) { default: np2cfg.baseclock = PCBASECLOCK25; sysmng_update(SYS_UPDATECFG|SYS_UPDATECLOCK); /*FALLTHROUGH*/ case PCBASECLOCK25: gtk_entry_set_text(GTK_ENTRY(baseclock_entry),baseclock_str[1]); break; case PCBASECLOCK20: gtk_entry_set_text(GTK_ENTRY(baseclock_entry),baseclock_str[0]); break; } times_label = gtk_label_new("x"); gtk_widget_show(times_label); gtk_box_pack_start(GTK_BOX(cpuclock_hbox), times_label, TRUE, FALSE, 0); gtk_misc_set_padding(GTK_MISC(times_label), 5, 0); rate_combo = gtk_combo_box_entry_new_text(); gtk_widget_show(rate_combo); gtk_box_pack_start(GTK_BOX(cpuclock_hbox), rate_combo, TRUE, FALSE, 0); gtk_widget_set_size_request(rate_combo, 48, -1); for (i = 0; i < NELEMENTS(clockmult_str); i++) { gtk_combo_box_append_text(GTK_COMBO_BOX(rate_combo), clockmult_str[i]); } clockmult_entry = GTK_BIN(rate_combo)->child; gtk_widget_show(clockmult_entry); gtk_editable_set_editable(GTK_EDITABLE(clockmult_entry), FALSE); switch (np2cfg.multiple) { case 1: case 2: case 4: case 5: case 6: case 8: case 10: case 12: case 16: case 20: g_snprintf(buf, sizeof(buf), "%d", np2cfg.multiple); gtk_entry_set_text(GTK_ENTRY(clockmult_entry), buf); break; default: gtk_entry_set_text(GTK_ENTRY(clockmult_entry), "4"); break; } /* calculated cpu clock */ realclock_label = gtk_label_new("MHz"); gtk_widget_show(realclock_label); gtk_box_pack_start(GTK_BOX(cpuframe_vbox), realclock_label, FALSE, FALSE, 2); gtk_misc_set_alignment(GTK_MISC(realclock_label), 1.0, 0.5); g_signal_connect(GTK_OBJECT(baseclock_entry), "changed", G_CALLBACK(clock_changed), (gpointer)realclock_label); g_signal_connect(GTK_OBJECT(clockmult_entry), "changed", G_CALLBACK(clock_changed), (gpointer)realclock_label); clock_changed(NULL, realclock_label); /* OK, Cancel button base widget */ confirm_widget = gtk_vbutton_box_new(); gtk_widget_show(confirm_widget); gtk_box_pack_start(GTK_BOX(cpu_hbox), confirm_widget, TRUE, TRUE, 0); gtk_button_box_set_layout(GTK_BUTTON_BOX(confirm_widget), GTK_BUTTONBOX_END); //gtk_button_box_set_spacing(GTK_BUTTON_BOX(confirm_widget), 0); /* * Architecture frame */ arch_frame = gtk_frame_new("Architecture"); gtk_widget_show(arch_frame); gtk_box_pack_start(GTK_BOX(main_widget), arch_frame, TRUE, TRUE, 0); /* architecture */ arch_hbox = gtk_hbox_new(TRUE, 0); gtk_widget_show(arch_hbox); gtk_container_add(GTK_CONTAINER(arch_frame), arch_hbox); for (i = 0; i < NELEMENTS(architecture); i++) { arch_radiobutton[i] = gtk_radio_button_new_with_label_from_widget(i > 0 ? GTK_RADIO_BUTTON(arch_radiobutton[i-1]) : NULL, architecture[i].label); gtk_widget_show(arch_radiobutton[i]); gtk_box_pack_start(GTK_BOX(arch_hbox), arch_radiobutton[i], FALSE, FALSE, 0); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_focus(arch_radiobutton[i], FALSE); #else GTK_WIDGET_UNSET_FLAGS(rate_radiobutton[i], GTK_CAN_FOCUS); #endif g_signal_connect(GTK_OBJECT(arch_radiobutton[i]), "clicked", G_CALLBACK(arch_radiobutton_clicked), (gpointer)architecture[i].arch); } for (i = 0; i < NELEMENTS(architecture); i++) { if (strcmp(np2cfg.model, architecture[i].arch) == 0) { break; } } if (i == NELEMENTS(architecture)) { i = 1; milstr_ncpy(np2cfg.model, "VX", sizeof(np2cfg.model)); sysmng_update(SYS_UPDATECFG); } g_signal_emit_by_name(GTK_OBJECT(arch_radiobutton[i]), "clicked"); /* * Sound frame */ sound_frame = gtk_frame_new("Sound"); gtk_widget_show(sound_frame); gtk_box_pack_start(GTK_BOX(main_widget), sound_frame, TRUE, TRUE, 0); soundframe_vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(soundframe_vbox), 5); gtk_widget_show(soundframe_vbox); gtk_container_add(GTK_CONTAINER(sound_frame), soundframe_vbox); /* sampling rate */ soundrate_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(soundrate_hbox); gtk_box_pack_start(GTK_BOX(soundframe_vbox), soundrate_hbox, TRUE, TRUE, 2); rate_label = gtk_label_new("Sampling Rate"); gtk_widget_show(rate_label); gtk_box_pack_start(GTK_BOX(soundrate_hbox), rate_label, FALSE, TRUE, 3); gtk_widget_set_size_request(rate_label, 96, -1); for (i = 0; i < NELEMENTS(samplingrate); i++) { rate_radiobutton[i] = gtk_radio_button_new_with_label_from_widget((i > 0) ? GTK_RADIO_BUTTON(rate_radiobutton[i-1]) : NULL, samplingrate[i].label); gtk_widget_show(rate_radiobutton[i]); gtk_box_pack_start(GTK_BOX(soundrate_hbox), rate_radiobutton[i], FALSE, FALSE, 0); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_focus(rate_radiobutton[i], FALSE); #else GTK_WIDGET_UNSET_FLAGS(rate_radiobutton[i], GTK_CAN_FOCUS); #endif g_signal_connect(GTK_OBJECT(rate_radiobutton[i]), "clicked", G_CALLBACK(rate_radiobutton_clicked), GINT_TO_POINTER(samplingrate[i].rate)); } if (np2cfg.samplingrate == 11025) { i = 0; } else if (np2cfg.samplingrate == 22050) { i = 1; } else if (np2cfg.samplingrate == 44100) { i = 2; } else { i = 1; np2cfg.samplingrate = 22050; sysmng_update(SYS_UPDATECFG|SYS_UPDATERATE); } g_signal_emit_by_name(GTK_OBJECT(rate_radiobutton[i]), "clicked"); soundbuffer_hbox = gtk_hbox_new(FALSE, 0); gtk_widget_show(soundbuffer_hbox); gtk_box_pack_start(GTK_BOX(soundframe_vbox), soundbuffer_hbox, TRUE, TRUE, 2); /* buffer size */ buffer_label = gtk_label_new("Buffer"); gtk_widget_show(buffer_label); gtk_box_pack_start(GTK_BOX(soundbuffer_hbox), buffer_label, FALSE, FALSE, 0); gtk_widget_set_size_request(buffer_label, 96, -1); buffer_entry = gtk_entry_new(); gtk_widget_show(buffer_entry); gtk_box_pack_start(GTK_BOX(soundbuffer_hbox), buffer_entry, FALSE, FALSE, 0); gtk_widget_set_size_request(buffer_entry, 48, -1); if (np2cfg.delayms >= 20 && np2cfg.delayms <= 1000) { g_snprintf(buf, sizeof(buf), "%d", np2cfg.delayms); gtk_entry_set_text(GTK_ENTRY(buffer_entry), buf); } else { gtk_entry_set_text(GTK_ENTRY(buffer_entry), "500"); np2cfg.delayms = 500; sysmng_update(SYS_UPDATECFG|SYS_UPDATESBUF); soundrenewal = 1; } ms_label = gtk_label_new(" ms"); gtk_widget_show(ms_label); gtk_box_pack_start(GTK_BOX(soundbuffer_hbox),ms_label, FALSE, FALSE, 0); #if defined(SUPPORT_RESUME) /* resume */ resume_checkbutton = gtk_check_button_new_with_label("Resume"); gtk_widget_show(resume_checkbutton); gtk_box_pack_start(GTK_BOX(main_widget), resume_checkbutton, FALSE, FALSE, 1); if (np2oscfg.resume) { g_signal_emit_by_name(GTK_OBJECT(resume_checkbutton), "clicked"); } #endif #if defined(GCC_CPU_ARCH_IA32) /* Disable MMX */ disablemmx_checkbutton = gtk_check_button_new_with_label("Disable MMX"); gtk_widget_show(disablemmx_checkbutton); gtk_box_pack_start(GTK_BOX(main_widget), disablemmx_checkbutton, FALSE, FALSE, 1); if (mmxflag & MMXFLAG_NOTSUPPORT) { gtk_widget_set_sensitive(disablemmx_checkbutton, FALSE); } else if (mmxflag & MMXFLAG_DISABLE) { g_signal_emit_by_name(GTK_OBJECT(disablemmx_checkbutton), "clicked"); } #endif /* * OK, Cancel button */ ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); gtk_widget_show(ok_button); gtk_container_add(GTK_CONTAINER(confirm_widget), ok_button); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_default(ok_button, TRUE); gtk_widget_has_default(ok_button); #else GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS(ok_button, GTK_HAS_DEFAULT); #endif g_signal_connect(GTK_OBJECT(ok_button), "clicked", G_CALLBACK(ok_button_clicked), (gpointer)config_dialog); gtk_widget_grab_default(ok_button); cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); gtk_widget_show(cancel_button); gtk_container_add(GTK_CONTAINER(confirm_widget), cancel_button); #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 18) gtk_widget_set_can_default(cancel_button, TRUE); #else GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT); #endif g_signal_connect_swapped(GTK_OBJECT(cancel_button), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(config_dialog)); gtk_widget_show_all(config_dialog); }
static AtkStateSet * gtk_widget_accessible_ref_state_set (AtkObject *accessible) { GtkWidget *widget; AtkStateSet *state_set; state_set = ATK_OBJECT_CLASS (_gtk_widget_accessible_parent_class)->ref_state_set (accessible); widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible)); if (widget == NULL) atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT); else { if (gtk_widget_is_sensitive (widget)) { atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE); atk_state_set_add_state (state_set, ATK_STATE_ENABLED); } if (gtk_widget_get_can_focus (widget)) { atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE); } /* * We do not currently generate notifications when an ATK object * corresponding to a GtkWidget changes visibility by being scrolled * on or off the screen. The testcase for this is the main window * of the testgtk application in which a set of buttons in a GtkVBox * is in a scrolled window with a viewport. * * To generate the notifications we would need to do the following: * 1) Find the GtkViewport among the ancestors of the objects * 2) Create an accessible for the viewport * 3) Connect to the value-changed signal on the viewport * 4) When the signal is received we need to traverse the children * of the viewport and check whether the children are visible or not * visible; we may want to restrict this to the widgets for which * accessible objects have been created. * 5) We probably need to store a variable on_screen in the * GtkWidgetAccessible data structure so we can determine whether * the value has changed. */ if (gtk_widget_get_visible (widget)) { atk_state_set_add_state (state_set, ATK_STATE_VISIBLE); if (gtk_widget_accessible_on_screen (widget) && gtk_widget_get_mapped (widget) && gtk_widget_accessible_all_parents_visible (widget)) atk_state_set_add_state (state_set, ATK_STATE_SHOWING); } if (gtk_widget_has_focus (widget) && (widget == _focus_widget)) { AtkObject *focus_obj; focus_obj = g_object_get_data (G_OBJECT (accessible), "gail-focus-object"); if (focus_obj == NULL) atk_state_set_add_state (state_set, ATK_STATE_FOCUSED); } if (gtk_widget_has_default (widget)) atk_state_set_add_state (state_set, ATK_STATE_DEFAULT); if (GTK_IS_ORIENTABLE (widget)) { if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_HORIZONTAL) atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL); else atk_state_set_add_state (state_set, ATK_STATE_VERTICAL); } } return state_set; }
void create_screen_dialog(void) { GtkWidget* screen_dialog; GtkWidget *main_widget; GtkWidget* screen_notebook; GtkWidget* video_note; GtkWidget* chip_note; GtkWidget* timing_note; GtkWidget *confirm_widget; GtkWidget *ok_button; GtkWidget *cancel_button; uninstall_idle_process(); screen_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(screen_dialog), "Screen option"); gtk_window_set_position(GTK_WINDOW(screen_dialog), GTK_WIN_POS_CENTER); gtk_window_set_modal(GTK_WINDOW(screen_dialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(screen_dialog), FALSE); gtk_container_set_border_width(GTK_CONTAINER(screen_dialog), 5); g_signal_connect(GTK_OBJECT(screen_dialog), "destroy", G_CALLBACK(dialog_destroy), NULL); main_widget = gtk_vbox_new(FALSE, 0); gtk_widget_show(main_widget); gtk_container_add(GTK_CONTAINER(screen_dialog), main_widget); screen_notebook = gtk_notebook_new(); gtk_widget_show(screen_notebook); gtk_box_pack_start(GTK_BOX(main_widget),screen_notebook, TRUE, TRUE, 0); /* "Video" note */ video_note = create_video_note(); gtk_notebook_append_page(GTK_NOTEBOOK(screen_notebook), video_note, gtk_label_new("Video")); /* "Chip" note */ chip_note = create_chip_note(); gtk_notebook_append_page(GTK_NOTEBOOK(screen_notebook), chip_note, gtk_label_new("Chip")); /* "Timing" note */ timing_note = create_timing_note(); gtk_notebook_append_page(GTK_NOTEBOOK(screen_notebook), timing_note, gtk_label_new("Timing")); /* * OK, Cancel button */ confirm_widget = gtk_hbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(confirm_widget), 2); gtk_widget_show(confirm_widget); gtk_box_pack_start(GTK_BOX(main_widget), confirm_widget, TRUE, TRUE, 0); cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); gtk_widget_show(cancel_button); gtk_box_pack_end(GTK_BOX(confirm_widget),cancel_button,FALSE, FALSE, 0); gtk_widget_set_can_default(cancel_button, FALSE); g_signal_connect_swapped(GTK_OBJECT(cancel_button), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(screen_dialog)); ok_button = gtk_button_new_from_stock(GTK_STOCK_OK); gtk_widget_show(ok_button); gtk_box_pack_end(GTK_BOX(confirm_widget), ok_button, FALSE, FALSE, 0); g_signal_connect(GTK_OBJECT(ok_button), "clicked", G_CALLBACK(ok_button_clicked), (gpointer)screen_dialog); gtk_widget_set_can_default(ok_button, TRUE); gtk_widget_has_default(ok_button); gtk_widget_grab_default(ok_button); gtk_widget_show_all(screen_dialog); }