bool wxBitmap::CreateFromImage(const wxImage& image, int depth) { UnRef(); wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") ) wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") ) if (image.GetWidth() <= 0 || image.GetHeight() <= 0) return false; m_refData = new wxBitmapRefData(); if (depth == 1) { return CreateFromImageAsBitmap(image); } else { #ifdef __WXGTK20__ if (image.HasAlpha()) return CreateFromImageAsPixbuf(image); #endif return CreateFromImageAsPixmap(image); } }
bool wxPalette::Create( int n, const unsigned char* pRed, const unsigned char* pGreen, const unsigned char* pBlue ) { PULONG pualTable; UnRef(); m_refData = new wxPaletteRefData; pualTable = new ULONG[n]; if (!pualTable) return false; for (int i = 0; i < n; i ++) { pualTable[i] = (PC_RESERVED * 16777216) + ((int)pRed[i] * 65536) + ((int)pGreen[i] * 256) + (int)pBlue[i]; } M_PALETTEDATA->m_hPalette = (WXHPALETTE)::GpiCreatePalette( vHabmain ,LCOL_PURECOLOR ,LCOLF_CONSECRGB ,(LONG)n ,pualTable ); delete [] pualTable; return true; } // end of wxPalette::Create
bool wxPlotFunction::Create( const wxPlotFunction& curve ) { wxCHECK_MSG(curve.Ok(), false, wxT("invalid plot function")); UnRef(); Ref(curve); return true; }
cLuaState::cRef::~cRef() { if (m_LuaState != nullptr) { UnRef(); } }
bool wxAnimation::LoadFile(const wxString &name, wxAnimationType WXUNUSED(type)) { UnRef(); m_pixbuf = gdk_pixbuf_animation_new_from_file( wxConvFileName->cWX2MB(name), NULL); return IsOk(); }
bool wxBitmap::Create(int width, int height, int depth ) { UnRef(); m_refData = new wxBitmapRefData(width, height, depth); return true; }
bool wxBitmap::LoadFile(const wxString &name, wxBitmapType type) { UnRef(); wxBitmapHandler *handler = FindHandler(type); if ( handler == NULL ) { wxImage image; if ( !image.LoadFile(name, type) || !image.IsOk() ) { wxLogError(_("No bitmap handler for type %d defined."), type); return false; } else { *this = wxBitmap(image); return true; } } m_refData = new wxBitmapRefData(); return handler->LoadFile(this, name, type, -1, -1); }
cLuaState::cRef::~cRef() { if (m_LuaState != NULL) { UnRef(); } }
void wxGenericPen::Create(const wxGenericColour &colour, int width, wxPenStyle style, wxPenCap cap, wxPenJoin join ) { UnRef(); m_refData = new wxGenericPenRefData(width, style, cap, join); M_GPENDATA->m_colour = colour; }
bool wxBitmap::CreateFromXpm( const char **bits ) { UnRef(); wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") ) GdkVisual *visual = wxTheApp->GetGdkVisual(); m_refData = new wxBitmapRefData(); GdkBitmap *mask = (GdkBitmap*) NULL; M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits ); wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") ); if (mask) { M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask->m_bitmap = mask; } gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); M_BMPDATA->m_bpp = visual->depth; // Can we get a different depth from create_from_xpm_d() ? return TRUE; }
void wxGenericPen::Create(const wxGenericColour &colour, int width, int style, int cap, int join ) { UnRef(); m_refData = new wxGenericPenRefData(width, style, cap, join); M_GPENDATA->m_colour = colour; }
void wxAnimation::SetPixbuf(GdkPixbufAnimation* p) { UnRef(); m_pixbuf = p; if (m_pixbuf) g_object_ref(m_pixbuf); }
bool wxOptionValue::Create( const wxOptionValue &optValue ) { wxCHECK_MSG( optValue.Ok(), false, wxT("Invalid wxOptionValue") ); UnRef(); Ref( optValue ); return Ok(); }
bool wxSheetCellRenderer::Copy(const wxSheetCellRenderer& other) { wxCHECK_MSG(other.Ok(), false, wxT("wxSheetCellRenderer is not created")); UnRef(); m_refData = ((wxSheetCellRendererRefData*)other.m_refData)->Clone(); return true; }
void wxGenericBrush::Create( const wxBitmap &stipple ) { UnRef(); wxCHECK_RET(stipple.Ok(), wxT("Invalid bitmap in wxGenericBrush::Create")); int style = stipple.GetMask() ? wxSTIPPLE_MASK_OPAQUE : wxSTIPPLE; m_refData = new wxGenericBrushRefData(wxNullGenericColour, style); M_GBRUSHDATA->m_stipple = stipple; }
bool wxBitmap::CreateWithFormat(int width, int height, int dfbFormat) { UnRef(); wxCHECK_MSG( width > 0 && height > 0, false, wxT("invalid bitmap size") ); return Create(CreateSurfaceWithFormat(width, height, DFBSurfacePixelFormat(dfbFormat))); }
bool wxFontBase::SetFaceName(const wxString &facename) { if (!wxFontEnumerator::IsValidFacename(facename)) { UnRef(); // make Ok() return false return false; } return true; }
bool wxBitmap::Create(const wxIDirectFBSurfacePtr& surface) { UnRef(); wxCHECK_MSG( surface, false, "invalid surface" ); m_refData = new wxBitmapRefData(); M_BITMAP->m_surface = surface; return true; }
void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) { UnRef(); m_refData = new wxColourRefData( (guint16(red) << SHIFT) + red, (guint16(green) << SHIFT) + green, (guint16(blue) << SHIFT) + blue, alpha); }
void cLuaState::cRef::RefStack(cLuaState & a_LuaState, int a_StackPos) { ASSERT(a_LuaState.IsValid()); if (m_LuaState != nullptr) { UnRef(); } m_LuaState = &a_LuaState; lua_pushvalue(a_LuaState, a_StackPos); // Push a copy of the value at a_StackPos onto the stack m_Ref = luaL_ref(a_LuaState, LUA_REGISTRYINDEX); }
void wxIcon::CopyFromBitmap(const wxBitmap& bmp) { UnRef() ; // as the bitmap owns that ref, we have to acquire it as well IconRef iconRef = bmp.GetBitmapData()->GetIconRef() ; AcquireIconRef( iconRef ) ; m_refData = new wxIconRefData( (WXHICON) iconRef ) ; M_ICONDATA->SetWidth( bmp.GetWidth() ) ; M_ICONDATA->SetHeight( bmp.GetHeight() ) ; }
void wxPlotMarker::Create(int marker_type, const wxRect2DDouble& rect, const wxSize& size, const wxGenericPen& pen, const wxGenericBrush& brush, const wxBitmap& bitmap) { UnRef(); m_refData = new wxPlotMarkerRefData(marker_type, rect); M_PMARKERDATA->m_size = size; M_PMARKERDATA->m_pen = pen; M_PMARKERDATA->m_brush = brush; M_PMARKERDATA->m_bitmap = bitmap; }
bool wxFont::Create(wxSize size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underlined, const wxString& face, wxFontEncoding encoding ) { UnRef(); m_refData = new wxFontRefData(InfoFromLegacyParams(size.GetHeight(), family, style, weight, underlined, face, encoding)); return true; }
bool wxMatrix2D::Create(const wxMatrix2D &source, bool full_copy) { wxCHECK_MSG( source.Ok() && (&source != this), false, wxT("Invalid matrix") ); UnRef(); if (full_copy) Copy(source); else Ref(source); return Ok(); }
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) { wxCHECK_RET( depth == 1, wxT("can only create mono bitmap from XBM data") ); // create bitmap in the device-dependent format if ( !CreateWithFormat(width, height, DSPF_UNKNOWN) ) return; if ( !CopyBitsToSurface((const unsigned char *)bits, width, height, M_BITMAP->m_surface) ) UnRef(); }
bool wxMatrix2D::Create(int width, int height, double *data, bool static_data) { wxCHECK_MSG((width > 0)&&(height > 0)&&(data != (double*)NULL), false, wxT("Invalid wxMatrix2D size or data is NULL")); UnRef(); m_refData = new wxMatrix2DRefData(); M_MATRIXDATA->m_data = data; if (M_MATRIXDATA->m_data) { M_MATRIXDATA->m_width = width; M_MATRIXDATA->m_height = height; M_MATRIXDATA->m_static = static_data; return true; } UnRef(); return false; }
wxAnimation& wxAnimation::operator=(const wxAnimation& that) { if (this != &that) { base_type::operator=(that); UnRef(); m_pixbuf = that.m_pixbuf; if (m_pixbuf) g_object_ref(m_pixbuf); } return *this; }
bool wxFontBase::SetNativeFontInfoUserDesc(const wxString& info) { wxNativeFontInfo fontInfo; if ( !info.empty() && fontInfo.FromUserString(info) ) { SetNativeFontInfo(fontInfo); return true; } UnRef(); return false; }
bool wxBitmap::Create( int width, int height, int depth ) { UnRef(); if ( width <= 0 || height <= 0 ) { return false; } m_refData = new wxBitmapRefData(); return M_BMPDATA->Create(width, height, depth); }
bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, int desiredWidth, int desiredHeight) { UnRef(); wxBitmapHandler *handler = FindHandler(type); if ( handler ) return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); else return false; }