X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/655719367ac5e131d9642e5783f3ecf64d1a3385..83c5d35ff3f22735f483edd56956b7a3baa6a798:/src/mgl/brush.cpp diff --git a/src/mgl/brush.cpp b/src/mgl/brush.cpp index 8579529fc8..9415eea448 100644 --- a/src/mgl/brush.cpp +++ b/src/mgl/brush.cpp @@ -1,16 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: brush.cpp +// Name: src/mgl/brush.cpp // Purpose: // Author: Vaclav Slavik // Id: $Id$ // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "brush.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -30,13 +26,13 @@ // This function converts wxBitmap into pixpattern24_t representation // (used by wxBrush and wxPen) -void wxBitmapToPixPattern(const wxBitmap& bitmap, +void wxBitmapToPixPattern(const wxBitmap& bitmap, pixpattern24_t *pix, pattern_t *mask) { wxMemoryDC mem; MGLDevCtx *dc; int x, y; - + if ( pix != NULL ) { mem.SelectObject(bitmap); @@ -45,16 +41,16 @@ void wxBitmapToPixPattern(const wxBitmap& bitmap, dc->beginPixel(); for (y = 0; y < 8; y++) for (x = 0; x < 8; x++) - dc->unpackColorFast(dc->getPixelFast(x, y), + dc->unpackColorFast(dc->getPixelFast(x, y), pix->p[y][x][2], - pix->p[y][x][1], + pix->p[y][x][1], pix->p[y][x][0]); dc->endPixel(); } if ( mask && bitmap.GetMask() ) { - mem.SelectObject(*bitmap.GetMask()->GetBitmap()); + mem.SelectObject(bitmap.GetMask()->GetBitmap()); dc = mem.GetMGLDC(); wxCurrentDCSwitcher curDC(dc); dc->beginPixel(); @@ -63,7 +59,7 @@ void wxBitmapToPixPattern(const wxBitmap& bitmap, mask->p[y] = 0; for (x = 0; x < 8; x++) if ( dc->getPixelFast(x, y) != 0 ) - mask->p[y] |= 1 << (7 - x); + mask->p[y] = (uchar)(mask->p[y] | (1 << (7 - x))); } dc->endPixel(); } @@ -131,32 +127,20 @@ wxBrush::wxBrush(const wxColour &colour, int style) wxBrush::wxBrush(const wxBitmap &stippleBitmap) { wxCHECK_RET( stippleBitmap.Ok(), _T("invalid bitmap") ); - wxCHECK_RET( stippleBitmap.GetWidth() == 8 && stippleBitmap.GetHeight() == 8, + wxCHECK_RET( stippleBitmap.GetWidth() == 8 && stippleBitmap.GetHeight() == 8, _T("stipple bitmap must be 8x8") ); m_refData = new wxBrushRefData(); M_BRUSHDATA->m_colour = *wxBLACK; - + M_BRUSHDATA->m_stipple = stippleBitmap; - wxBitmapToPixPattern(stippleBitmap, &(M_BRUSHDATA->m_pixPattern), + wxBitmapToPixPattern(stippleBitmap, &(M_BRUSHDATA->m_pixPattern), &(M_BRUSHDATA->m_maskPattern)); if (M_BRUSHDATA->m_stipple.GetMask()) - M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE; - else - M_BRUSHDATA->m_style = wxSTIPPLE; -} - -wxBrush::wxBrush(const wxBrush &brush) -{ - Ref(brush); -} - -wxBrush& wxBrush::operator = (const wxBrush& brush) -{ - if (*this == brush) return (*this); - Ref(brush); - return *this; + M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE; + else + M_BRUSHDATA->m_style = wxSTIPPLE; } bool wxBrush::operator == (const wxBrush& brush) const @@ -169,7 +153,7 @@ bool wxBrush::operator != (const wxBrush& brush) const return m_refData != brush.m_refData; } -bool wxBrush::Ok() const +bool wxBrush::IsOk() const { return ((m_refData) && M_BRUSHDATA->m_colour.Ok()); } @@ -244,7 +228,7 @@ void wxBrush::SetStipple(const wxBitmap& stipple) AllocExclusive(); wxCHECK_RET( stipple.Ok(), _T("invalid bitmap") ); - wxCHECK_RET( stipple.GetWidth() == 8 && stipple.GetHeight() == 8, + wxCHECK_RET( stipple.GetWidth() == 8 && stipple.GetHeight() == 8, _T("stipple bitmap must be 8x8") ); M_BRUSHDATA->m_stipple = stipple; @@ -266,4 +250,3 @@ wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const { return new wxBrushRefData(*(wxBrushRefData *)data); } -