void wxBitmap::SetPalette(const wxPalette& palette) { wxCHECK_RET( IsOk(), wxT("invalid bitmap") ); wxCHECK_RET( GetDepth() > 1 && GetDepth() <= 8, wxT("cannot set palette for bitmap of this depth") ); AllocExclusive(); wxDELETE(M_BITMAP->m_palette); if ( !palette.IsOk() ) return; M_BITMAP->m_palette = new wxPalette(palette); }
bool wxGLCanvas::Create(wxWindow *parent, const wxGLAttributes& dispAttrs, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, const wxPalette& palette) { #if wxUSE_PALETTE wxASSERT_MSG( !palette.IsOk(), wxT("palettes not supported") ); #endif // wxUSE_PALETTE wxUnusedVar(palette); // Unused when wxDEBUG_LEVEL==0 m_exposed = false; m_noExpose = true; m_nativeSizeEvent = true; #ifdef __WXGTK3__ m_cairoPaintContext = NULL; m_backgroundStyle = wxBG_STYLE_PAINT; #endif if ( !InitVisual(dispAttrs) ) return false; // watch for the "parent-set" signal on m_wxwindow so we can set colormap // before m_wxwindow is realized (which will occur before // wxWindow::Create() returns if parent is already visible) unsigned sig_id = g_signal_lookup("parent-set", GTK_TYPE_WIDGET); g_signal_add_emission_hook(sig_id, 0, parent_set_hook, this, NULL); wxWindow::Create( parent, id, pos, size, style, name ); gtk_widget_set_double_buffered(m_wxwindow, false); #if WXWIN_COMPATIBILITY_2_8 g_signal_connect(m_wxwindow, "realize", G_CALLBACK(gtk_glwindow_realized_callback), this); #endif // WXWIN_COMPATIBILITY_2_8 #ifdef __WXGTK3__ g_signal_connect(m_wxwindow, "draw", G_CALLBACK(draw), this); #else g_signal_connect(m_wxwindow, "map", G_CALLBACK(gtk_glwindow_map_callback), this); g_signal_connect(m_wxwindow, "expose_event", G_CALLBACK(gtk_glwindow_expose_callback), this); #endif g_signal_connect(m_widget, "size_allocate", G_CALLBACK(gtk_glcanvas_size_callback), this); #if WXWIN_COMPATIBILITY_2_8 // if our parent window is already visible, we had been realized before we // connected to the "realize" signal and hence our m_glContext hasn't been // initialized yet and we have to do it now if (gtk_widget_get_realized(m_wxwindow)) gtk_glwindow_realized_callback( m_wxwindow, this ); #endif // WXWIN_COMPATIBILITY_2_8 #ifndef __WXGTK3__ if (gtk_widget_get_mapped(m_wxwindow)) gtk_glwindow_map_callback( m_wxwindow, this ); #endif return true; }