// real construction (Init() must have been called before!) bool wxWindowDFB::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( !m_tlw && parent ) m_tlw = parent->GetTLW(); if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; if ( parent ) parent->AddChild(this); // set the size to something bogus initially, in case some code tries to // create wxWindowDC before SetSize() is called below: m_rect.width = m_rect.height = 1; int x, y, w, h; x = pos.x, y = pos.y; if ( x == -1 ) x = 0; if ( y == -1 ) y = 0; w = WidthDefault(size.x); h = HeightDefault(size.y); SetSize(x, y, w, h); 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 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 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 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 ) { 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; }
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 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.IsOk() ? bitmap : wxBitmap(bogus_xpm)); m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL); if (bitmap.IsOk()) SetBitmap(bitmap); PostCreation(size); m_parent->DoAddChild( this ); return true; }
bool wxTopLevelWindowQt::Create( wxWindow *parent, wxWindowID winId, const wxString &title, const wxPoint &pos, const wxSize &sizeOrig, long style, const wxString &name ) { wxSize size(sizeOrig); if ( !size.IsFullySpecified() ) size.SetDefaults( GetDefaultSize() ); wxTopLevelWindows.Append( this ); if (!CreateBase( parent, winId, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxTopLevelWindowNative creation failed") ); return false; } SetTitle( title ); SetWindowStyleFlag( style ); if (pos != wxDefaultPosition) m_qtWindow->move( pos.x, pos.y ); m_qtWindow->resize( wxQtConvertSize( size ) ); // Prevent automatic deletion of Qt main window on close // (this should be the default, but left just fo enforce it) GetHandle()->setAttribute(Qt::WA_DeleteOnClose, false); // not calling to wxWindow::Create, so do the rest of initialization: if (parent) parent->AddChild( this ); return true; }
// Replaces wxWindow::Create functionality, since we need to use a different // window class bool wxGLCanvas::CreateWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { wxCHECK_MSG( parent, false, wxT("can't create wxWindow without parent") ); if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; parent->AddChild(this); /* A general rule with OpenGL and Win32 is that any window that will have a HGLRC built for it must have two flags: WS_CLIPCHILDREN & WS_CLIPSIBLINGS. You can find references about this within the knowledge base and most OpenGL books that contain the wgl function descriptions. */ WXDWORD exStyle = 0; DWORD msflags = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; msflags |= MSWGetStyle(style, &exStyle); if ( !MSWCreate(wxApp::GetRegisteredClassName(wxT("wxGLCanvas"), -1, CS_OWNDC), NULL, pos, size, msflags, exStyle) ) return false; m_hDC = ::GetDC(GetHwnd()); if ( !m_hDC ) return false; 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 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 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; }
wxGLdummyWin() { hdc = 0; CreateBase(NULL, wxID_ANY); DWORD msflags = WS_CLIPSIBLINGS | WS_CLIPCHILDREN; if( MSWCreate(wxApp::GetRegisteredClassName(wxT("wxGLCanvas"), -1, CS_OWNDC), NULL, wxDefaultPosition, wxDefaultSize, msflags, 0) ) { hdc = ::GetDC(GetHwnd()); } }
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 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; }
// real construction (Init() must have been called before!) bool wxWindowMGL::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) return false; if ( parent ) parent->AddChild(this); int x, y, w, h; x = pos.x, y = pos.y; if ( x == -1 ) x = 0; // FIXME_MGL, something better, see GTK+ if ( y == -1 ) y = 0; // FIXME_MGL, something better, see GTK+ AdjustForParentClientOrigin(x, y, 0); w = WidthDefault(size.x); h = HeightDefault(size.y); long mgl_style = 0; window_t *wnd_parent = parent ? parent->GetHandle() : NULL; if ( style & wxFULL_REPAINT_ON_RESIZE ) { mgl_style |= MGL_WM_FULL_REPAINT_ON_RESIZE; } if ( style & wxSTAY_ON_TOP ) { mgl_style |= MGL_WM_ALWAYS_ON_TOP; } if ( style & wxPOPUP_WINDOW ) { mgl_style |= MGL_WM_ALWAYS_ON_TOP; // it is created hidden as other top level windows m_isShown = false; wnd_parent = NULL; } window_t *wnd = MGL_wmCreateWindow(g_winMng, wnd_parent, x, y, w, h); MGL_wmSetWindowFlags(wnd, mgl_style); MGL_wmShowWindow(wnd, m_isShown); SetMGLwindow_t(wnd); 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); g_signal_connect (sel->ok_button, "clicked", G_CALLBACK (gtk_fontdialog_ok_callback), this); g_signal_connect (sel->cancel_button, "clicked", G_CALLBACK (gtk_fontdialog_cancel_callback), this); g_signal_connect (m_widget, "delete_event", G_CALLBACK (gtk_fontdialog_delete_callback), this); wxFont font = m_fontData.GetInitialFont(); if( font.Ok() ) { const wxNativeFontInfo *info = font.GetNativeFontInfo(); if ( info ) { const wxString& fontname = info->ToString(); gtk_font_selection_dialog_set_font_name(sel, wxGTK_CONV(fontname)); } else { // this is not supposed to happen! wxFAIL_MSG(_T("font is ok but no native font info?")); } } return true; }
bool wxSlider::Create(wxWindow *parent, wxWindowID id, int value, int minValue, int maxValue, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name ) { m_acceptsFocus = true; m_needParent = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxSlider creation failed") ); return false; } m_pos = 0; m_scrollEventType = 0; m_needThumbRelease = false; if (style & wxSL_VERTICAL) m_widget = gtk_vscale_new( (GtkAdjustment *) NULL ); else m_widget = gtk_hscale_new( (GtkAdjustment *) NULL ); gtk_scale_set_draw_value(GTK_SCALE (m_widget), (style & wxSL_LABELS) != 0); // Keep full precision in position value gtk_scale_set_digits(GTK_SCALE (m_widget), -1); if (style & wxSL_INVERSE) gtk_range_set_inverted( GTK_RANGE(m_widget), TRUE ); g_signal_connect(m_widget, "button_press_event", G_CALLBACK(gtk_button_press_event), this); g_signal_connect(m_widget, "button_release_event", G_CALLBACK(gtk_button_release_event), this); g_signal_connect(m_widget, "move_slider", G_CALLBACK(gtk_move_slider), this); g_signal_connect(m_widget, "format_value", G_CALLBACK(gtk_format_value), NULL); g_signal_connect(m_widget, "value_changed", G_CALLBACK(gtk_value_changed), this); gulong handler_id; handler_id = g_signal_connect( m_widget, "event_after", G_CALLBACK(gtk_event_after), this); g_signal_handler_block(m_widget, handler_id); SetRange( minValue, maxValue ); SetValue( value ); m_parent->DoAddChild( this ); PostCreation(size); return true; }
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_label(""); 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; if (GTK_IS_MISC(BUTTON_CHILD(m_widget))) gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)), x_alignment, y_alignment); SetLabel(label); if (style & wxNO_BORDER) gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); gtk_signal_connect_after( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); gtk_signal_connect_after( GTK_OBJECT(m_widget), "style_set", GTK_SIGNAL_FUNC(gtk_button_style_set_callback), (gpointer*) 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 ) { m_needParent = true; m_acceptsFocus = true; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxBitmapButton creation failed") ); return false; } m_bitmaps[State_Normal] = bitmap; m_widget = gtk_button_new(); if (style & wxNO_BORDER) gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); if (bitmap.IsOk()) { OnSetBitmap(); } gtk_signal_connect_after( GTK_OBJECT(m_widget), "clicked", GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "enter", GTK_SIGNAL_FUNC(gtk_bmpbutton_enter_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "leave", GTK_SIGNAL_FUNC(gtk_bmpbutton_leave_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "pressed", GTK_SIGNAL_FUNC(gtk_bmpbutton_press_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_widget), "released", GTK_SIGNAL_FUNC(gtk_bmpbutton_release_callback), (gpointer*)this ); m_parent->DoAddChild( this ); PostCreation(size); return true; }
bool wxNotebook::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) { m_needParent = true; m_acceptsFocus = true; m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook; if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT ) style |= wxBK_TOP; if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { wxFAIL_MSG( wxT("wxNoteBook creation failed") ); return false; } m_widget = gtk_notebook_new(); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); g_signal_connect (m_widget, "switch_page", G_CALLBACK (gtk_notebook_page_changing_callback), this); g_signal_connect_after (m_widget, "switch_page", G_CALLBACK (gtk_notebook_page_changed_callback), this); m_parent->DoAddChild( this ); if (m_windowStyle & wxBK_RIGHT) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_RIGHT ); if (m_windowStyle & wxBK_LEFT) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_LEFT ); if (m_windowStyle & wxBK_BOTTOM) gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM ); g_signal_connect (m_widget, "key_press_event", G_CALLBACK (gtk_notebook_key_press_callback), this); PostCreation(size); g_signal_connect (m_widget, "realize", G_CALLBACK (gtk_notebook_realized_callback), this); return true; }