icon support moved to wxBitmap, allowing for fully transparent usage
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10180 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -201,6 +201,7 @@ wxBitmapRefData::wxBitmapRefData()
|
||||
m_bitmapMask = NULL;
|
||||
m_hBitmap = NULL ;
|
||||
m_hPict = NULL ;
|
||||
m_hIcon = NULL ;
|
||||
m_bitmapType = kMacBitmapTypeUnknownType ;
|
||||
}
|
||||
|
||||
@@ -226,6 +227,13 @@ wxBitmapRefData::~wxBitmapRefData()
|
||||
}
|
||||
}
|
||||
break ;
|
||||
case kMacBitmapTypeIcon :
|
||||
if ( m_hIcon )
|
||||
{
|
||||
DisposeCIcon( m_hIcon ) ;
|
||||
m_hIcon = NULL ;
|
||||
}
|
||||
|
||||
default :
|
||||
// unkown type ?
|
||||
break ;
|
||||
@@ -488,7 +496,7 @@ void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
|
||||
{
|
||||
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
|
||||
M_BITMAPDATA->m_hBitmap = bmp ;
|
||||
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
||||
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
||||
}
|
||||
|
||||
bool wxBitmap::LoadFile(const wxString& filename, long type)
|
||||
|
||||
@@ -52,36 +52,44 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_buttonBitmap = bitmap;
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||
|
||||
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 ,
|
||||
kControlBehaviorOffsetContents + kControlContentPictHandle , 0,
|
||||
kControlBehaviorOffsetContents +
|
||||
( bmap->m_bitmapType == kMacBitmapTypeIcon ? kControlContentCIconHandle : kControlContentPictHandle ) , 0,
|
||||
(( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
|
||||
wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
|
||||
|
||||
m_buttonBitmap = bitmap;
|
||||
PicHandle icon = NULL ;
|
||||
ControlButtonContentInfo info ;
|
||||
|
||||
|
||||
if ( m_buttonBitmap.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||
if ( bmap->m_bitmapType == kMacBitmapTypePict )
|
||||
icon = bmap->m_hPict ;
|
||||
if ( bmap->m_bitmapType == kMacBitmapTypePict ) {
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
info.u.picture = bmap->m_hPict ;
|
||||
}
|
||||
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||
{
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
if ( m_buttonBitmap.GetMask() )
|
||||
{
|
||||
icon = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
|
||||
info.u.picture = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = MakePict( bmap->m_hBitmap , NULL ) ;
|
||||
info.u.picture = MakePict( bmap->m_hBitmap , NULL ) ;
|
||||
}
|
||||
}
|
||||
else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
|
||||
{
|
||||
info.contentType = kControlContentCIconHandle ;
|
||||
info.u.cIconHandle = bmap->m_hIcon ;
|
||||
}
|
||||
}
|
||||
ControlButtonContentInfo info ;
|
||||
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
info.u.picture = icon ;
|
||||
|
||||
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
|
||||
@@ -92,30 +100,36 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
ControlButtonContentInfo info ;
|
||||
m_buttonBitmap = bitmap;
|
||||
PicHandle icon = NULL ;
|
||||
|
||||
if ( m_buttonBitmap.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||
if ( bmap->m_bitmapType == kMacBitmapTypePict )
|
||||
icon = bmap->m_hPict ;
|
||||
{
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
info.u.picture = bmap->m_hPict ;
|
||||
}
|
||||
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||
{
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
if ( m_buttonBitmap.GetMask() )
|
||||
{
|
||||
icon = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
|
||||
info.u.picture = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = MakePict( bmap->m_hBitmap , NULL ) ;
|
||||
info.u.picture = MakePict( bmap->m_hBitmap , NULL ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
ControlButtonContentInfo info ;
|
||||
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
info.u.picture = icon ;
|
||||
|
||||
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
|
||||
{
|
||||
info.contentType = kControlContentCIconHandle ;
|
||||
info.u.cIconHandle = bmap->m_hIcon ;
|
||||
}
|
||||
|
||||
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,7 @@ wxBitmapRefData::wxBitmapRefData()
|
||||
m_bitmapMask = NULL;
|
||||
m_hBitmap = NULL ;
|
||||
m_hPict = NULL ;
|
||||
m_hIcon = NULL ;
|
||||
m_bitmapType = kMacBitmapTypeUnknownType ;
|
||||
}
|
||||
|
||||
@@ -226,6 +227,13 @@ wxBitmapRefData::~wxBitmapRefData()
|
||||
}
|
||||
}
|
||||
break ;
|
||||
case kMacBitmapTypeIcon :
|
||||
if ( m_hIcon )
|
||||
{
|
||||
DisposeCIcon( m_hIcon ) ;
|
||||
m_hIcon = NULL ;
|
||||
}
|
||||
|
||||
default :
|
||||
// unkown type ?
|
||||
break ;
|
||||
@@ -488,7 +496,7 @@ void wxBitmap::SetHBITMAP(WXHBITMAP bmp)
|
||||
{
|
||||
M_BITMAPDATA->m_bitmapType = kMacBitmapTypeGrafWorld ;
|
||||
M_BITMAPDATA->m_hBitmap = bmp ;
|
||||
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
||||
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_hBitmap != NULL ) ;
|
||||
}
|
||||
|
||||
bool wxBitmap::LoadFile(const wxString& filename, long type)
|
||||
|
||||
@@ -52,36 +52,44 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_buttonBitmap = bitmap;
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||
|
||||
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 ,
|
||||
kControlBehaviorOffsetContents + kControlContentPictHandle , 0,
|
||||
kControlBehaviorOffsetContents +
|
||||
( bmap->m_bitmapType == kMacBitmapTypeIcon ? kControlContentCIconHandle : kControlContentPictHandle ) , 0,
|
||||
(( style & wxBU_AUTODRAW ) ? kControlBevelButtonSmallBevelProc : kControlBevelButtonNormalBevelProc ), (long) this ) ;
|
||||
wxASSERT_MSG( m_macControl != NULL , "No valid mac control" ) ;
|
||||
|
||||
m_buttonBitmap = bitmap;
|
||||
PicHandle icon = NULL ;
|
||||
ControlButtonContentInfo info ;
|
||||
|
||||
|
||||
if ( m_buttonBitmap.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||
if ( bmap->m_bitmapType == kMacBitmapTypePict )
|
||||
icon = bmap->m_hPict ;
|
||||
if ( bmap->m_bitmapType == kMacBitmapTypePict ) {
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
info.u.picture = bmap->m_hPict ;
|
||||
}
|
||||
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||
{
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
if ( m_buttonBitmap.GetMask() )
|
||||
{
|
||||
icon = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
|
||||
info.u.picture = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = MakePict( bmap->m_hBitmap , NULL ) ;
|
||||
info.u.picture = MakePict( bmap->m_hBitmap , NULL ) ;
|
||||
}
|
||||
}
|
||||
else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
|
||||
{
|
||||
info.contentType = kControlContentCIconHandle ;
|
||||
info.u.cIconHandle = bmap->m_hIcon ;
|
||||
}
|
||||
}
|
||||
ControlButtonContentInfo info ;
|
||||
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
info.u.picture = icon ;
|
||||
|
||||
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
|
||||
@@ -92,30 +100,36 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
ControlButtonContentInfo info ;
|
||||
m_buttonBitmap = bitmap;
|
||||
PicHandle icon = NULL ;
|
||||
|
||||
if ( m_buttonBitmap.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||
if ( bmap->m_bitmapType == kMacBitmapTypePict )
|
||||
icon = bmap->m_hPict ;
|
||||
{
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
info.u.picture = bmap->m_hPict ;
|
||||
}
|
||||
else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
|
||||
{
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
if ( m_buttonBitmap.GetMask() )
|
||||
{
|
||||
icon = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
|
||||
info.u.picture = MakePict( bmap->m_hBitmap , m_buttonBitmap.GetMask()->GetMaskBitmap() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
icon = MakePict( bmap->m_hBitmap , NULL ) ;
|
||||
info.u.picture = MakePict( bmap->m_hBitmap , NULL ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
ControlButtonContentInfo info ;
|
||||
|
||||
info.contentType = kControlContentPictHandle ;
|
||||
info.u.picture = icon ;
|
||||
|
||||
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
else if ( bmap->m_bitmapType == kMacBitmapTypeIcon )
|
||||
{
|
||||
info.contentType = kControlContentCIconHandle ;
|
||||
info.u.cIconHandle = bmap->m_hIcon ;
|
||||
}
|
||||
|
||||
UMASetControlData( m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,12 +39,11 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||
m_ok = FALSE;
|
||||
};
|
||||
|
||||
wxMemoryDC::~wxMemoryDC(void)
|
||||
wxMemoryDC::~wxMemoryDC()
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
|
||||
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
|
||||
UnlockPixels( GetGWorldPixMap(m_selected.GetHBITMAP()) );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,16 +51,14 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
|
||||
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
|
||||
UnlockPixels( GetGWorldPixMap(m_selected.GetHBITMAP()) );
|
||||
}
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
|
||||
if ( bmap->m_hBitmap )
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
if ( m_selected.GetHBITMAP() )
|
||||
{
|
||||
m_macPort = (GrafPtr) bmap->m_hBitmap ;
|
||||
m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
||||
wxMask * mask = bitmap.GetMask() ;
|
||||
if ( mask )
|
||||
@@ -69,18 +66,17 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
m_macMask = mask->GetMaskBitmap() ;
|
||||
}
|
||||
m_ok = TRUE ;
|
||||
// SetBackground(wxBrush(*wxWHITE, wxSOLID));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_ok = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ok = FALSE;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void wxMemoryDC::DoGetSize( int *width, int *height ) const
|
||||
{
|
||||
@@ -93,7 +89,7 @@ void wxMemoryDC::DoGetSize( int *width, int *height ) const
|
||||
{
|
||||
if (width) (*width) = 0;
|
||||
if (height) (*height) = 0;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,48 +23,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
||||
* Icons
|
||||
*/
|
||||
|
||||
|
||||
wxIconRefData::wxIconRefData()
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_depth = 0;
|
||||
m_quality = 0;
|
||||
m_numColors = 0;
|
||||
m_bitmapMask = NULL;
|
||||
m_hBitmap = NULL ;
|
||||
m_hIcon = NULL ;
|
||||
}
|
||||
|
||||
wxIconRefData::~wxIconRefData()
|
||||
{
|
||||
if ( m_hIcon )
|
||||
{
|
||||
DisposeCIcon( m_hIcon ) ;
|
||||
m_hIcon = NULL ;
|
||||
}
|
||||
|
||||
if (m_bitmapMask)
|
||||
{
|
||||
delete m_bitmapMask;
|
||||
m_bitmapMask = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
wxIcon::wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
|
||||
wxIcon::wxIcon(const char bits[], int width, int height) :
|
||||
wxBitmap(bits,width,height )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( const char **bits ) :
|
||||
wxBitmap(bits )
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( const char **bits, int width, int height )
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( char **bits, int width, int height )
|
||||
wxIcon::wxIcon( char **bits ) :
|
||||
wxBitmap(bits )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -84,7 +59,7 @@ bool wxIcon::LoadFile(const wxString& filename, long type,
|
||||
{
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxIconRefData;
|
||||
m_refData = new wxBitmapRefData;
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
|
||||
@@ -99,33 +74,55 @@ IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
||||
bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
Str255 theName ;
|
||||
short theId ;
|
||||
OSType theType ;
|
||||
short theId = -1 ;
|
||||
if ( name == "wxICON_INFO" )
|
||||
{
|
||||
theId = kNoteIcon ;
|
||||
}
|
||||
else if ( name == "wxICON_QUESTION" )
|
||||
{
|
||||
theId = kCautionIcon ;
|
||||
}
|
||||
else if ( name == "wxICON_WARNING" )
|
||||
{
|
||||
theId = kCautionIcon ;
|
||||
}
|
||||
else if ( name == "wxICON_ERROR" )
|
||||
{
|
||||
theId = kStopIcon ;
|
||||
}
|
||||
else
|
||||
{
|
||||
Str255 theName ;
|
||||
OSType theType ;
|
||||
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) theName , name ) ;
|
||||
#else
|
||||
strcpy( (char *) theName , name ) ;
|
||||
c2pstr( (char *) theName ) ;
|
||||
#endif
|
||||
|
||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||
if ( resHandle != 0L )
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) theName , name ) ;
|
||||
#else
|
||||
strcpy( (char *) theName , name ) ;
|
||||
c2pstr( (char *) theName ) ;
|
||||
#endif
|
||||
|
||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||
if ( resHandle != 0L )
|
||||
{
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
}
|
||||
}
|
||||
if ( theId != -1 )
|
||||
{
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
|
||||
CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
|
||||
if ( theIcon )
|
||||
{
|
||||
M_ICONHANDLERDATA->m_hIcon = theIcon ;
|
||||
M_ICONHANDLERDATA->m_width = 32 ;
|
||||
M_ICONHANDLERDATA->m_height = 32 ;
|
||||
M_BITMAPHANDLERDATA->m_hIcon = theIcon ;
|
||||
M_BITMAPHANDLERDATA->m_width = 32 ;
|
||||
M_BITMAPHANDLERDATA->m_height = 32 ;
|
||||
|
||||
M_ICONHANDLERDATA->m_depth = 8 ;
|
||||
M_ICONHANDLERDATA->m_ok = true ;
|
||||
M_ICONHANDLERDATA->m_numColors = 256 ;
|
||||
M_BITMAPHANDLERDATA->m_depth = 8 ;
|
||||
M_BITMAPHANDLERDATA->m_ok = true ;
|
||||
M_BITMAPHANDLERDATA->m_numColors = 256 ;
|
||||
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||
m_foregroundColour = parent->GetForegroundColour() ;
|
||||
|
||||
m_messageBitmap = bitmap;
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
@@ -66,19 +65,20 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
||||
m_messageBitmap = bitmap;
|
||||
SetSizeOrDefault();
|
||||
}
|
||||
|
||||
void wxStaticBitmap::OnPaint( wxPaintEvent &event )
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
PrepareDC(dc);
|
||||
dc.SetPalette( *m_messageBitmap.GetPalette() ) ;
|
||||
dc.DrawBitmap( m_messageBitmap , 0 , 0 , TRUE ) ;
|
||||
|
||||
dc.DrawBitmap( m_messageBitmap , 0 , 0 , TRUE ) ;
|
||||
}
|
||||
|
||||
wxSize wxStaticBitmap::DoGetBestSize() const
|
||||
{
|
||||
if ( m_messageBitmap.Ok() )
|
||||
return wxSize(m_messageBitmap.GetWidth(), m_messageBitmap.GetHeight());
|
||||
else
|
||||
return wxSize(16, 16); // completely arbitrary
|
||||
if ( m_messageBitmap.Ok() )
|
||||
return wxSize(m_messageBitmap.GetWidth(), m_messageBitmap.GetHeight());
|
||||
else
|
||||
return wxSize(16, 16); // completely arbitrary
|
||||
}
|
||||
|
||||
|
||||
756
src/mac/dc.cpp
756
src/mac/dc.cpp
File diff suppressed because it is too large
Load Diff
@@ -39,12 +39,11 @@ wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
|
||||
m_ok = FALSE;
|
||||
};
|
||||
|
||||
wxMemoryDC::~wxMemoryDC(void)
|
||||
wxMemoryDC::~wxMemoryDC()
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
|
||||
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
|
||||
UnlockPixels( GetGWorldPixMap(m_selected.GetHBITMAP()) );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -52,16 +51,14 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
{
|
||||
if ( m_selected.Ok() )
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
|
||||
UnlockPixels( GetGWorldPixMap( (CGrafPtr) bmap->m_hBitmap ) ) ;
|
||||
UnlockPixels( GetGWorldPixMap(m_selected.GetHBITMAP()) );
|
||||
}
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) (m_selected.GetRefData()) ;
|
||||
if ( bmap->m_hBitmap )
|
||||
m_selected = bitmap;
|
||||
if (m_selected.Ok())
|
||||
{
|
||||
if ( m_selected.GetHBITMAP() )
|
||||
{
|
||||
m_macPort = (GrafPtr) bmap->m_hBitmap ;
|
||||
m_macPort = (GrafPtr) m_selected.GetHBITMAP() ;
|
||||
LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ;
|
||||
wxMask * mask = bitmap.GetMask() ;
|
||||
if ( mask )
|
||||
@@ -69,18 +66,17 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
m_macMask = mask->GetMaskBitmap() ;
|
||||
}
|
||||
m_ok = TRUE ;
|
||||
// SetBackground(wxBrush(*wxWHITE, wxSOLID));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_ok = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ok = FALSE;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void wxMemoryDC::DoGetSize( int *width, int *height ) const
|
||||
{
|
||||
@@ -93,7 +89,7 @@ void wxMemoryDC::DoGetSize( int *width, int *height ) const
|
||||
{
|
||||
if (width) (*width) = 0;
|
||||
if (height) (*height) = 0;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
111
src/mac/icon.cpp
111
src/mac/icon.cpp
@@ -23,48 +23,23 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
||||
* Icons
|
||||
*/
|
||||
|
||||
|
||||
wxIconRefData::wxIconRefData()
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_width = 0;
|
||||
m_height = 0;
|
||||
m_depth = 0;
|
||||
m_quality = 0;
|
||||
m_numColors = 0;
|
||||
m_bitmapMask = NULL;
|
||||
m_hBitmap = NULL ;
|
||||
m_hIcon = NULL ;
|
||||
}
|
||||
|
||||
wxIconRefData::~wxIconRefData()
|
||||
{
|
||||
if ( m_hIcon )
|
||||
{
|
||||
DisposeCIcon( m_hIcon ) ;
|
||||
m_hIcon = NULL ;
|
||||
}
|
||||
|
||||
if (m_bitmapMask)
|
||||
{
|
||||
delete m_bitmapMask;
|
||||
m_bitmapMask = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
wxIcon::wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
|
||||
wxIcon::wxIcon(const char bits[], int width, int height) :
|
||||
wxBitmap(bits,width,height )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( const char **bits ) :
|
||||
wxBitmap(bits )
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( const char **bits, int width, int height )
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon( char **bits, int width, int height )
|
||||
wxIcon::wxIcon( char **bits ) :
|
||||
wxBitmap(bits )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -84,7 +59,7 @@ bool wxIcon::LoadFile(const wxString& filename, long type,
|
||||
{
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxIconRefData;
|
||||
m_refData = new wxBitmapRefData;
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
|
||||
@@ -99,33 +74,55 @@ IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
|
||||
bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
Str255 theName ;
|
||||
short theId ;
|
||||
OSType theType ;
|
||||
short theId = -1 ;
|
||||
if ( name == "wxICON_INFO" )
|
||||
{
|
||||
theId = kNoteIcon ;
|
||||
}
|
||||
else if ( name == "wxICON_QUESTION" )
|
||||
{
|
||||
theId = kCautionIcon ;
|
||||
}
|
||||
else if ( name == "wxICON_WARNING" )
|
||||
{
|
||||
theId = kCautionIcon ;
|
||||
}
|
||||
else if ( name == "wxICON_ERROR" )
|
||||
{
|
||||
theId = kStopIcon ;
|
||||
}
|
||||
else
|
||||
{
|
||||
Str255 theName ;
|
||||
OSType theType ;
|
||||
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) theName , name ) ;
|
||||
#else
|
||||
strcpy( (char *) theName , name ) ;
|
||||
c2pstr( (char *) theName ) ;
|
||||
#endif
|
||||
|
||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||
if ( resHandle != 0L )
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) theName , name ) ;
|
||||
#else
|
||||
strcpy( (char *) theName , name ) ;
|
||||
c2pstr( (char *) theName ) ;
|
||||
#endif
|
||||
|
||||
Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
|
||||
if ( resHandle != 0L )
|
||||
{
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
}
|
||||
}
|
||||
if ( theId != -1 )
|
||||
{
|
||||
GetResInfo( resHandle , &theId , &theType , theName ) ;
|
||||
ReleaseResource( resHandle ) ;
|
||||
|
||||
CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
|
||||
if ( theIcon )
|
||||
{
|
||||
M_ICONHANDLERDATA->m_hIcon = theIcon ;
|
||||
M_ICONHANDLERDATA->m_width = 32 ;
|
||||
M_ICONHANDLERDATA->m_height = 32 ;
|
||||
M_BITMAPHANDLERDATA->m_hIcon = theIcon ;
|
||||
M_BITMAPHANDLERDATA->m_width = 32 ;
|
||||
M_BITMAPHANDLERDATA->m_height = 32 ;
|
||||
|
||||
M_ICONHANDLERDATA->m_depth = 8 ;
|
||||
M_ICONHANDLERDATA->m_ok = true ;
|
||||
M_ICONHANDLERDATA->m_numColors = 256 ;
|
||||
M_BITMAPHANDLERDATA->m_depth = 8 ;
|
||||
M_BITMAPHANDLERDATA->m_ok = true ;
|
||||
M_BITMAPHANDLERDATA->m_numColors = 256 ;
|
||||
M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ;
|
||||
return TRUE ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||
m_foregroundColour = parent->GetForegroundColour() ;
|
||||
|
||||
m_messageBitmap = bitmap;
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
@@ -66,19 +65,20 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
||||
m_messageBitmap = bitmap;
|
||||
SetSizeOrDefault();
|
||||
}
|
||||
|
||||
void wxStaticBitmap::OnPaint( wxPaintEvent &event )
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
PrepareDC(dc);
|
||||
dc.SetPalette( *m_messageBitmap.GetPalette() ) ;
|
||||
dc.DrawBitmap( m_messageBitmap , 0 , 0 , TRUE ) ;
|
||||
|
||||
dc.DrawBitmap( m_messageBitmap , 0 , 0 , TRUE ) ;
|
||||
}
|
||||
|
||||
wxSize wxStaticBitmap::DoGetBestSize() const
|
||||
{
|
||||
if ( m_messageBitmap.Ok() )
|
||||
return wxSize(m_messageBitmap.GetWidth(), m_messageBitmap.GetHeight());
|
||||
else
|
||||
return wxSize(16, 16); // completely arbitrary
|
||||
if ( m_messageBitmap.Ok() )
|
||||
return wxSize(m_messageBitmap.GetWidth(), m_messageBitmap.GetHeight());
|
||||
else
|
||||
return wxSize(16, 16); // completely arbitrary
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user