bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { m_needParent = true; m_acceptsFocus = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxButton creation failed") ); return false; } m_widget = gtk_button_new_with_mnemonic(""); float x_alignment = 0.5; if (HasFlag(wxBU_LEFT)) x_alignment = 0.0; else if (HasFlag(wxBU_RIGHT)) x_alignment = 1.0; float y_alignment = 0.5; if (HasFlag(wxBU_TOP)) y_alignment = 0.0; else if (HasFlag(wxBU_BOTTOM)) y_alignment = 1.0; #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) { gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, y_alignment); } else #endif { if (GTK_IS_MISC(GTK_BIN(m_widget)->child)) gtk_misc_set_alignment(GTK_MISC(GTK_BIN(m_widget)->child), x_alignment, y_alignment); } SetLabel(label); if (style & wxNO_BORDER) gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); g_signal_connect_after (m_widget, "clicked", G_CALLBACK (gtk_button_clicked_callback), this); g_signal_connect_after (m_widget, "style_set", G_CALLBACK (gtk_button_style_set_callback), this); m_parent->DoAddChild( this ); PostCreation(size); return true; }
bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name) { if (!PreCreation(parent, pos, size) || !CreateBase(parent, id, pos, size, style, validator, name )) { wxFAIL_MSG(wxT("wxToggleButton creation failed")); return false; } // Create the gtk widget. m_widget = gtk_toggle_button_new_with_mnemonic(""); g_object_ref(m_widget); SetLabel(label); g_signal_connect (m_widget, "clicked", G_CALLBACK (gtk_togglebutton_clicked_callback), this); m_parent->DoAddChild(this); PostCreation(size); return true; }
bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { m_needParent = TRUE; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxStaticBitmap creation failed") ); return false; } m_bitmap = bitmap; wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm)); m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL); if (bitmap.Ok()) SetBitmap(bitmap); PostCreation(size); m_parent->DoAddChild( this ); return true; }
bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name) { m_needParent = TRUE; m_acceptsFocus = TRUE; m_blockEvent = FALSE; if (!PreCreation(parent, pos, size) || !CreateBase(parent, id, pos, size, style, validator, name )) { wxFAIL_MSG(wxT("wxToggleButton creation failed")); return FALSE; } wxControl::SetLabel(label); // Create the gtk widget. m_widget = gtk_toggle_button_new_with_label( wxGTK_CONV( m_label ) ); gtk_signal_connect(GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback), (gpointer *)this); m_parent->DoAddChild(this); PostCreation(size); return TRUE; }
bool wxGauge::Create( wxWindow *parent, wxWindowID id, int range, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) { m_needParent = TRUE; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxGauge creation failed") ); return FALSE; } m_rangeMax = range; m_widget = gtk_progress_bar_new(); if ( style & wxGA_VERTICAL ) { gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget), GTK_PROGRESS_BOTTOM_TO_TOP ); } m_parent->DoAddChild( this ); PostCreation(size); SetBestSize(size); return TRUE; }
bool wxAnimationCtrl::Create( wxWindow *parent, wxWindowID id, const wxAnimation& anim, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if (!PreCreation( parent, pos, size ) || !base_type::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK, wxDefaultValidator, name)) { wxFAIL_MSG( wxT("wxAnimationCtrl creation failed") ); return false; } SetWindowStyle(style); m_widget = gtk_image_new(); g_object_ref(m_widget); m_parent->DoAddChild( this ); PostCreation(size); SetInitialSize(size); if (anim.IsOk()) SetAnimation(anim); // init the timer used for animation m_timer.SetOwner(this); return true; }
bool wxColourButton::Create( wxWindow *parent, wxWindowID id, const wxColour &col, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { if (!PreCreation( parent, pos, size ) || !wxControl::CreateBase(parent, id, pos, size, style, validator, name)) { wxFAIL_MSG( wxT("wxColourButton creation failed") ); return false; } m_colour = col; #ifdef __WXGTK3__ m_widget = gtk_color_button_new_with_rgba(m_colour); #else m_widget = gtk_color_button_new_with_color( m_colour.GetColor() ); #endif g_object_ref(m_widget); // GtkColourButton signals g_signal_connect(m_widget, "color-set", G_CALLBACK(gtk_clrbutton_setcolor_callback), this); m_parent->DoAddChild( this ); PostCreation(size); SetInitialSize(size); return true; }
bool wxChoice::Create( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString &name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxChoice creation failed") ); return false; } if ( IsSorted() ) { // if our m_strings != NULL, Append() will check for it and insert // items in the correct order m_strings = new wxSortedArrayString; } m_widget = gtk_combo_box_new_text(); g_object_ref(m_widget); Append(n, choices); m_parent->DoAddChild( this ); PostCreation(size); g_signal_connect_after (m_widget, "changed", G_CALLBACK (gtk_choice_changed_callback), this); return true; }
bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style ) { m_needParent = true; m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI; if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || !CreateBase( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("wxMDIClientWindow") )) { wxFAIL_MSG( wxT("wxMDIClientWindow creation failed") ); return false; } m_widget = gtk_notebook_new(); gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", GTK_SIGNAL_FUNC(gtk_mdi_page_change_callback), (gpointer)parent ); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); m_parent->DoAddChild( this ); PostCreation(); Show( true ); return true; }
// Scrollbar bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; PreCreation(); wxSize newSize = ( style & wxHORIZONTAL ) ? wxSize( 140, 16 ) : wxSize( 16, 140 ); if( size.x != -1 ) newSize.x = size.x; if( size.y != -1 ) newSize.y = size.y; Widget parentWidget = (Widget) parent->GetClientWidget(); m_mainWidget = DoCreateScrollBar( (WXWidget)parentWidget, (wxOrientation)(style & (wxHORIZONTAL|wxVERTICAL)), (void (*)())wxScrollBarCallback ); PostCreation(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, newSize.x, newSize.y); return true; }
bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name) { if (!PreCreation(parent, pos, size) || !CreateBase(parent, id, pos, size, style, validator, name )) { wxFAIL_MSG(wxT("wxBitmapToggleButton creation failed")); return false; } // Create the gtk widget. m_widget = gtk_toggle_button_new(); g_object_ref(m_widget); if (style & wxNO_BORDER) gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); m_bitmap = label; OnSetBitmap(); g_signal_connect (m_widget, "clicked", G_CALLBACK (gtk_togglebutton_clicked_callback), this); m_parent->DoAddChild(this); PostCreation(size); return true; }
bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) { if ( !PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || !CreateBase( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, "wxMDIClientWindow" )) { wxFAIL_MSG( "wxMDIClientWindow creation failed" ); return false; } m_widget = gtk_notebook_new(); g_object_ref(m_widget); g_signal_connect (m_widget, "switch_page", G_CALLBACK (gtk_mdi_page_change_callback), parent); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); m_parent->DoAddChild( this ); PostCreation(); Show( true ); return true; }
bool wxDirDialog::Create(wxWindow* parent, const wxString& title, const wxString& defaultPath, long style, const wxPoint& pos, const wxSize& WXUNUSED(sz), const wxString& WXUNUSED(name)) { m_message = title; parent = GetParentForModalDialog(parent, style); if (!PreCreation(parent, pos, wxDefaultSize) || !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, wxDefaultValidator, wxT("dirdialog"))) { wxFAIL_MSG( wxT("wxDirDialog creation failed") ); return false; } GtkWindow* gtk_parent = NULL; if (parent) gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); m_widget = gtk_file_chooser_dialog_new( wxGTK_CONV(m_message), gtk_parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); g_object_ref(m_widget); gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT); #if GTK_CHECK_VERSION(2,18,0) #ifndef __WXGTK3__ if (gtk_check_version(2,18,0) == NULL) #endif { gtk_file_chooser_set_create_folders( GTK_FILE_CHOOSER(m_widget), (style & wxDD_DIR_MUST_EXIST) == 0); } #endif // local-only property could be set to false to allow non-local files to be loaded. // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere // and the GtkFileChooserDialog should probably also be created with a backend, // e.g. "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend). // Currently local-only is kept as the default - true: // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true); g_signal_connect (m_widget, "response", G_CALLBACK (gtk_dirdialog_response_callback), this); if ( !defaultPath.empty() ) SetPath(defaultPath); return true; }
bool wxFontDialog::DoCreate(wxWindow *parent) { m_needParent = false; if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, wxDefaultValidator, wxT("fontdialog") )) { wxFAIL_MSG( wxT("wxFontDialog creation failed") ); return false; } wxString m_message( _("Choose font") ); m_widget = gtk_font_selection_dialog_new( wxGTK_CONV( m_message ) ); if (parent) gtk_window_set_transient_for(GTK_WINDOW(m_widget), GTK_WINDOW(parent->m_widget)); GtkFontSelectionDialog *sel = GTK_FONT_SELECTION_DIALOG(m_widget); gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this ); // strange way to internationalize gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") ); gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked", GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this ); // strange way to internationalize gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") ); gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this ); wxFont font = m_fontData.GetInitialFont(); if( font.IsOk() ) { const wxNativeFontInfo *info = font.GetNativeFontInfo(); if ( info ) { const wxString& fontname = info->GetXFontName(); if ( !fontname ) font.GetInternalFont(); gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname)); } else { // this is not supposed to happen! wxFAIL_MSG(wxT("font is ok but no native font info?")); } } return true; }
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { m_needParent = true; m_acceptsFocus = true; m_blockEvent = false; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxCheckBox creation failed") ); return false; } wxASSERT_MSG( (style & wxCHK_ALLOW_3RD_STATE_FOR_USER) == 0 || (style & wxCHK_3STATE) != 0, wxT("Using wxCHK_ALLOW_3RD_STATE_FOR_USER") wxT(" style flag for a 2-state checkbox is useless") ); if ( style & wxALIGN_RIGHT ) { // VZ: as I don't know a way to create a right aligned checkbox with // GTK we will create a checkbox without label and a label at the // left of it m_widgetCheckbox = gtk_check_button_new(); m_widgetLabel = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5); m_widget = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(m_widget), m_widgetLabel, FALSE, FALSE, 3); gtk_box_pack_start(GTK_BOX(m_widget), m_widgetCheckbox, FALSE, FALSE, 3); gtk_widget_show( m_widgetLabel ); gtk_widget_show( m_widgetCheckbox ); } else { m_widgetCheckbox = gtk_check_button_new_with_label(""); m_widgetLabel = GTK_BIN(m_widgetCheckbox)->child; m_widget = m_widgetCheckbox; } SetLabel( label ); g_signal_connect (m_widgetCheckbox, "toggled", G_CALLBACK (gtk_checkbox_toggled_callback), this); m_parent->DoAddChild( this ); PostCreation(size); return true; }
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; PreCreation(); m_bitmaps[State_Normal] = m_bitmapsOriginal[State_Normal] = bitmap; m_bitmaps[State_Pressed] = m_bitmapsOriginal[State_Pressed] = bitmap; Widget parentWidget = (Widget) parent->GetClientWidget(); /* * Patch Note (important) * There is no major reason to put a defaultButtonThickness here. * Not requesting it give the ability to put wxButton with a spacing * as small as requested. However, if some button become a DefaultButton, * other buttons are no more aligned -- This is why we set * defaultButtonThickness of ALL buttons belonging to the same wxPanel, * in the ::SetDefaultButton method. */ Widget buttonWidget = XtVaCreateManagedWidget ("button", // Gadget causes problems for default button operation. #if wxUSE_GADGETS xmPushButtonGadgetClass, parentWidget, #else xmPushButtonWidgetClass, parentWidget, #endif // See comment for wxButton::SetDefault // XmNdefaultButtonShadowThickness, 1, XmNrecomputeSize, False, NULL); m_mainWidget = (WXWidget) buttonWidget; XtAddCallback (buttonWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, (XtPointer) this); wxSize best = GetBitmapLabel().IsOk() ? GetBestSize() : wxSize(30, 30); if( size.x != -1 ) best.x = size.x; if( size.y != -1 ) best.y = size.y; PostCreation(); OnSetBitmap(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, best.x, best.y); return true; }
bool wxDirDialog::Create(wxWindow* parent, const wxString& title, const wxString& defaultPath, long style, const wxPoint& pos, const wxSize& WXUNUSED(sz), const wxString& WXUNUSED(name)) { m_message = title; parent = GetParentForModalDialog(parent, style); if (!PreCreation(parent, pos, wxDefaultSize) || !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, wxDefaultValidator, wxT("dirdialog"))) { wxFAIL_MSG( wxT("wxDirDialog creation failed") ); return false; } GtkWindow* gtk_parent = NULL; if (parent) gtk_parent = GTK_WINDOW( gtk_widget_get_toplevel(parent->m_widget) ); m_widget = gtk_file_chooser_dialog_new( wxGTK_CONV(m_message), gtk_parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); g_object_ref(m_widget); gtk_dialog_set_default_response(GTK_DIALOG(m_widget), GTK_RESPONSE_ACCEPT); // gtk_widget_hide_on_delete is used here to avoid that Gtk automatically destroys // the dialog when the user press ESC on the dialog: in that case a second call to // ShowModal() would result in a bunch of Gtk-CRITICAL errors... g_signal_connect (m_widget, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), (gpointer)this); // local-only property could be set to false to allow non-local files to be loaded. // In that case get/set_uri(s) should be used instead of get/set_filename(s) everywhere // and the GtkFileChooserDialog should probably also be created with a backend, // e.g. "gnome-vfs", "default", ... (gtk_file_chooser_dialog_new_with_backend). // Currently local-only is kept as the default - true: // gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(m_widget), true); g_signal_connect (m_widget, "response", G_CALLBACK (gtk_dirdialog_response_callback), this); if ( !defaultPath.empty() ) SetPath(defaultPath); return true; }
bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) { m_acceptsFocus = TRUE; m_needParent = TRUE; m_blockEvent = FALSE; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxRadioButton creation failed") ); return FALSE; } GSList* radioButtonGroup = NULL; if (!HasFlag(wxRB_GROUP)) { // search backward for last group start wxRadioButton *chief = NULL; wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast(); while (node) { wxWindow *child = node->GetData(); if (child->IsRadioButton()) { chief = (wxRadioButton*) child; if (child->HasFlag(wxRB_GROUP)) break; } node = node->GetPrevious(); } if (chief) { // we are part of the group started by chief radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) ); } } m_widget = gtk_radio_button_new_with_label( radioButtonGroup, wxGTK_CONV( label ) ); SetLabel(label); gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); m_parent->DoAddChild( this ); PostCreation(size); return TRUE; }
bool wxToolBar::Create( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { if ( !PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxToolBar creation failed") ); return false; } FixupStyle(); m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); #if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED) if (gtk_check_version(2, 12, 0)) { m_tooltips = gtk_tooltips_new(); g_object_ref(m_tooltips); gtk_object_sink(GTK_OBJECT(m_tooltips)); } #endif GtkSetStyle(); if (style & wxTB_DOCKABLE) { m_widget = gtk_handle_box_new(); g_signal_connect(m_widget, "child_detached", G_CALLBACK(child_detached), NULL); g_signal_connect(m_widget, "child_attached", G_CALLBACK(child_attached), NULL); if (style & wxTB_FLAT) gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE ); } else { m_widget = gtk_event_box_new(); ConnectWidget( m_widget ); } g_object_ref(m_widget); gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar)); gtk_widget_show(GTK_WIDGET(m_toolbar)); m_parent->DoAddChild( this ); PostCreation(size); g_signal_connect_after(m_toolbar, "size_request", G_CALLBACK(size_request), this); return true; }
bool wxPopupWindow::Create( wxWindow *parent, int style ) { if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("popup") )) { wxFAIL_MSG( wxT("wxPopupWindow creation failed") ); return false; } // Unlike windows, top level windows are created hidden by default. m_isShown = false; // All dialogs should really have this style m_windowStyle |= wxTAB_TRAVERSAL; m_widget = gtk_window_new( GTK_WINDOW_POPUP ); g_object_ref( m_widget ); gtk_widget_set_name( m_widget, "wxPopupWindow" ); // wxPopupWindow is used for different windows as well // gtk_window_set_type_hint( GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_COMBO ); GtkWidget *toplevel = gtk_widget_get_toplevel( parent->m_widget ); if (GTK_IS_WINDOW (toplevel)) { #if GTK_CHECK_VERSION(2,10,0) #ifndef __WXGTK3__ if (!gtk_check_version(2,10,0)) #endif { gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), GTK_WINDOW (m_widget)); } #endif gtk_window_set_transient_for (GTK_WINDOW (m_widget), GTK_WINDOW (toplevel)); } gtk_window_set_resizable (GTK_WINDOW (m_widget), FALSE); gtk_window_set_screen (GTK_WINDOW (m_widget), gtk_widget_get_screen (GTK_WIDGET (parent->m_widget))); g_signal_connect (m_widget, "delete_event", G_CALLBACK (gtk_dialog_delete_callback), this); m_wxwindow = wxPizza::New(); gtk_widget_show( m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); if (m_parent) m_parent->AddChild( this ); PostCreation(); m_time = gtk_get_current_event_time(); g_signal_connect (m_widget, "button_press_event", G_CALLBACK (gtk_popup_button_press), this); return true; }
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { m_needParent = true; m_acceptsFocus = true; m_blockEvent = false; WXValidateStyle(&style); if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxCheckBox creation failed") ); return false; } if ( style & wxALIGN_RIGHT ) { // VZ: as I don't know a way to create a right aligned checkbox with // GTK we will create a checkbox without label and a label at the // left of it m_widgetCheckbox = gtk_check_button_new(); m_widgetLabel = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5); m_widget = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(m_widget), m_widgetLabel, FALSE, FALSE, 3); gtk_box_pack_start(GTK_BOX(m_widget), m_widgetCheckbox, FALSE, FALSE, 3); gtk_widget_show( m_widgetLabel ); gtk_widget_show( m_widgetCheckbox ); } else { m_widgetCheckbox = gtk_check_button_new_with_label(""); m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox ); m_widget = m_widgetCheckbox; } SetLabel( label ); gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox), "toggled", GTK_SIGNAL_FUNC(gtk_checkbox_toggled_callback), (gpointer *)this ); m_parent->DoAddChild( this ); PostCreation(size); return true; }
bool wxToolBar::Create( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { m_needParent = true; m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar; if ( !PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxToolBar creation failed") ); return false; } FixupStyle(); GtkOrientation orient; GtkToolbarStyle gtkStyle; GetGtkStyle(style, &orient, >kStyle); m_toolbar = GTK_TOOLBAR( gtk_toolbar_new(orient, gtkStyle) ); SetToolSeparation(7); if (style & wxTB_DOCKABLE) { m_widget = gtk_handle_box_new(); gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) ); gtk_widget_show( GTK_WIDGET(m_toolbar) ); if (style & wxTB_FLAT) gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE ); } else { m_widget = gtk_event_box_new(); gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) ); ConnectWidget( m_widget ); gtk_widget_show(GTK_WIDGET(m_toolbar)); } gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); if (style & wxTB_FLAT) gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE ); m_parent->DoAddChild( this ); PostCreation(size); return true; }
bool wxGauge::Create(wxWindow *parent, wxWindowID id, int range, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; PreCreation(); Widget parentWidget = (Widget) parent->GetClientWidget(); Arg args[7]; int count = 4; if (style & wxGA_HORIZONTAL) { XtSetArg (args[0], XmNorientation, XmHORIZONTAL); XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_RIGHT); } else { XtSetArg (args[0], XmNorientation, XmVERTICAL); XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_TOP); } XtSetArg(args[2], XmNminimum, 0); XtSetArg(args[3], XmNmaximum, range); #if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF() XtSetArg(args[4], XmNeditable, False); ++count; XtSetArg(args[5], XmNslidingMode, XmTHERMOMETER); ++count; // XtSetArg(args[6], XmNsliderVisual, XmFOREGROUND_COLOR ); ++count; Widget gaugeWidget = XtCreateManagedWidget("gauge", xmScaleWidgetClass, parentWidget, args, count); #else Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count); #endif m_mainWidget = (WXWidget) gaugeWidget ; XtManageChild (gaugeWidget); int x = pos.x; int y = pos.y; wxSize best = GetBestSize(); if( size.x != wxDefaultCoord ) best.x = size.x; if( size.y != wxDefaultCoord ) best.y = size.y; PostCreation(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, best.x, best.y); return true; }
// Create menubar bool wxMenuBar::CreateMenuBar(wxFrame* parent) { m_parent = parent; // bleach... override it! PreCreation(); m_parent = NULL; if (m_mainWidget) { XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); /* if (!XtIsManaged((Widget) m_mainWidget)) XtManageChild((Widget) m_mainWidget); */ XtMapWidget((Widget) m_mainWidget); return true; } Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(), wxMOTIF_STR("MenuBar"), NULL, 0); m_mainWidget = (WXWidget) menuBarW; size_t menuCount = GetMenuCount(); for (size_t i = 0; i < menuCount; i++) { wxMenu *menu = GetMenu(i); wxString title(m_titles[i]); menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, i, title, true)); if (strcmp (wxStripMenuCodes(title), "Help") == 0) XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL); // tear off menu support #if (XmVersion >= 1002) if ( menu->IsTearOff() ) { XtVaSetValues(GetWidget(menu), XmNtearOffModel, XmTEAR_OFF_ENABLED, NULL); Widget tearOff = XmGetTearOffControl(GetWidget(menu)); wxDoChangeForegroundColour((Widget) tearOff, m_foregroundColour); wxDoChangeBackgroundColour((Widget) tearOff, m_backgroundColour, true); } #endif } PostCreation(); XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL); XtRealizeWidget ((Widget) menuBarW); XtManageChild ((Widget) menuBarW); SetMenuBarFrame(parent); return true; }
bool wxGtkCalendarCtrl::Create(wxWindow *parent, wxWindowID id, const wxDateTime& date, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if (!PreCreation(parent, pos, size) || !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name)) { wxFAIL_MSG(wxT("wxGtkCalendarCtrl creation failed")); return false; } m_widget = gtk_calendar_new(); g_object_ref(m_widget); SetDate(date.IsValid() ? date : wxDateTime::Today()); if (style & wxCAL_NO_MONTH_CHANGE) g_object_set (G_OBJECT (m_widget), "no-month-change", true, NULL); if (style & wxCAL_SHOW_WEEK_NUMBERS) g_object_set (G_OBJECT (m_widget), "show-week-numbers", true, NULL); g_signal_connect_after(m_widget, "day-selected", G_CALLBACK (gtk_day_selected_callback), this); g_signal_connect_after(m_widget, "day-selected-double-click", G_CALLBACK (gtk_day_selected_double_click_callback), this); g_signal_connect_after(m_widget, "month-changed", G_CALLBACK (gtk_month_changed_callback), this); // connect callbacks that send deprecated events g_signal_connect_after(m_widget, "prev-month", G_CALLBACK (gtk_prev_month_callback), this); g_signal_connect_after(m_widget, "next-month", G_CALLBACK (gtk_prev_month_callback), this); g_signal_connect_after(m_widget, "prev-year", G_CALLBACK (gtk_prev_year_callback), this); g_signal_connect_after(m_widget, "next-year", G_CALLBACK (gtk_prev_year_callback), this); m_parent->DoAddChild(this); PostCreation(size); return true; }
bool wxPopupWindow::Create( wxWindow *parent, int style ) { m_needParent = false; if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("popup") )) { wxFAIL_MSG( wxT("wxPopupWindow creation failed") ); return false; } // Unlike windows, top level windows are created hidden by default. m_isShown = false; // All dialogs should really have this style m_windowStyle |= wxTAB_TRAVERSAL; m_insertCallback = (wxInsertChildFunction) wxInsertChildInDialog; m_widget = gtk_window_new( GTK_WINDOW_POPUP ); if ((m_parent) && (GTK_IS_WINDOW(m_parent->m_widget))) gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); m_wxwindow = gtk_pizza_new(); gtk_widget_show( m_wxwindow ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); if (m_parent) m_parent->AddChild( this ); PostCreation(); /* we cannot set MWM hints before the widget has been realized, so we do this directly after realization */ gtk_signal_connect( GTK_OBJECT(m_widget), "realize", GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this ); // disable native tab traversal gtk_signal_connect( GTK_OBJECT(m_widget), "focus", GTK_SIGNAL_FUNC(gtk_dialog_focus_callback), (gpointer)this ); gtk_signal_connect (GTK_OBJECT(m_widget), "button_press_event", GTK_SIGNAL_FUNC(gtk_popup_button_press), (gpointer)this ); return true; }
bool wxArrowButton::Create( wxSpinButton* parent, wxWindowID WXUNUSED(id), ArrowDirection d, const wxPoint& pos, const wxSize& size ) { wxCHECK_MSG( parent, false, wxT("must have a valid parent") ); int arrow_dir = XmARROW_UP; switch( d ) { case wxARROW_UP: arrow_dir = XmARROW_UP; break; case wxARROW_DOWN: arrow_dir = XmARROW_DOWN; break; case wxARROW_LEFT: arrow_dir = XmARROW_LEFT; break; case wxARROW_RIGHT: arrow_dir = XmARROW_RIGHT; break; } parent->AddChild( this ); PreCreation(); Widget parentWidget = (Widget) parent->GetClientWidget(); m_mainWidget = (WXWidget) XtVaCreateManagedWidget( "XmArrowButton", xmArrowButtonWidgetClass, parentWidget, XmNarrowDirection, arrow_dir, XmNborderWidth, 0, XmNshadowThickness, 0, NULL ); XtAddCallback( (Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) SpinButtonCallback, (XtPointer) this ); XtAddCallback( (Widget) m_mainWidget, XmNarmCallback, (XtCallbackProc) StartTimerCallback, (XtPointer) this ); XtAddCallback( (Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) StopTimerCallback, (XtPointer) this ); PostCreation(); AttachWidget( parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y ); return true; }
bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxString& url, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( UseNative() ) { // do validation checks: CheckParams(label, url, style); if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxHyperlinkCtrl creation failed") ); return false; } m_widget = gtk_link_button_new("asdfsaf asdfdsaf asdfdsa"); g_object_ref(m_widget); gtk_widget_show(m_widget); // alignment float x_alignment = 0.5; if (HasFlag(wxHL_ALIGN_LEFT)) x_alignment = 0.0; else if (HasFlag(wxHL_ALIGN_RIGHT)) x_alignment = 1.0; gtk_button_set_alignment(GTK_BUTTON(m_widget), x_alignment, 0.5); // set to non empty strings both the url and the label SetURL(url.empty() ? label : url); SetLabel(label.empty() ? url : label); // our signal handlers: g_signal_connect_after (m_widget, "clicked", G_CALLBACK (gtk_hyperlink_clicked_callback), this); m_parent->DoAddChild( this ); PostCreation(size); SetInitialSize(size); // wxWindowGTK will connect to the enter_notify and leave_notify GTK+ signals // thus overriding GTK+'s internal signal handlers which set the cursor of // the widget - thus we need to manually set it here: SetCursor(wxCursor(wxCURSOR_HAND)); } else return wxGenericHyperlinkCtrl::Create(parent, id, label, url, pos, size, style, name); return true; }
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos, const wxSize &size, long style, const wxValidator& validator, const wxString &name ) { WXValidateStyle( &style ); if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxCheckBox creation failed") ); return false; } if ( style & wxALIGN_RIGHT ) { // VZ: as I don't know a way to create a right aligned checkbox with // GTK we will create a checkbox without label and a label at the // left of it m_widgetCheckbox = gtk_check_button_new(); m_widgetLabel = gtk_label_new(""); gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5); m_widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start(GTK_BOX(m_widget), m_widgetLabel, FALSE, FALSE, 3); gtk_box_pack_start(GTK_BOX(m_widget), m_widgetCheckbox, FALSE, FALSE, 3); gtk_widget_show( m_widgetLabel ); gtk_widget_show( m_widgetCheckbox ); } else { m_widgetCheckbox = gtk_check_button_new_with_label(""); m_widgetLabel = gtk_bin_get_child(GTK_BIN(m_widgetCheckbox)); m_widget = m_widgetCheckbox; } g_object_ref(m_widget); SetLabel( label ); g_signal_connect (m_widgetCheckbox, "toggled", G_CALLBACK (gtk_checkbox_toggled_callback), this); m_parent->DoAddChild( this ); PostCreation(size); return true; }
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if( !wxControl::CreateControl( parent, id, pos, size, style, wxDefaultValidator, name ) ) return false; PreCreation(); FixupStyle(); Widget parentWidget = (Widget) parent->GetClientWidget(); Widget toolbar = XtVaCreateManagedWidget("toolbar", xmBulletinBoardWidgetClass, (Widget) parentWidget, XmNmarginWidth, 0, XmNmarginHeight, 0, XmNresizePolicy, XmRESIZE_NONE, NULL); /* Widget toolbar = XtVaCreateManagedWidget("toolbar", xmFormWidgetClass, (Widget) m_clientWidget, XmNtraversalOn, False, XmNhorizontalSpacing, 0, XmNverticalSpacing, 0, XmNleftOffset, 0, XmNrightOffset, 0, XmNmarginWidth, 0, XmNmarginHeight, 0, NULL); */ m_mainWidget = (WXWidget) toolbar; wxPoint rPos = pos; wxSize rSize = size; if( rPos.x == -1 ) rPos.x = 0; if( rPos.y == -1 ) rPos.y = 0; if( rSize.x == -1 && GetParent() ) rSize.x = GetParent()->GetSize().x; PostCreation(); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, rPos.x, rPos.y, rSize.x, rSize.y); return true; }