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:
parent
513903c4f9
commit
3dec57adfd
@ -69,7 +69,7 @@ protected:
|
||||
WXHBITMAP m_maskBitmap;
|
||||
};
|
||||
|
||||
enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict } ;
|
||||
enum { kMacBitmapTypeUnknownType , kMacBitmapTypeGrafWorld, kMacBitmapTypePict , kMacBitmapTypeIcon } ;
|
||||
|
||||
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
||||
{
|
||||
@ -92,6 +92,7 @@ public:
|
||||
int m_bitmapType ;
|
||||
PicHandle m_hPict ;
|
||||
WXHBITMAP m_hBitmap;
|
||||
WXHICON m_hIcon ;
|
||||
wxMask * m_bitmapMask; // Optional mask
|
||||
};
|
||||
|
||||
@ -211,6 +212,8 @@ protected:
|
||||
public:
|
||||
void SetHBITMAP(WXHBITMAP bmp);
|
||||
WXHBITMAP GetHBITMAP() const;
|
||||
void SetHICON(WXHICON ico);
|
||||
inline WXHICON GetHICON() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_hIcon : 0); }
|
||||
|
||||
PicHandle GetPict() const;
|
||||
|
||||
|
@ -72,7 +72,7 @@ class WXDLLEXPORT wxDC: public wxDCBase
|
||||
|
||||
virtual void Clear();
|
||||
|
||||
virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; };
|
||||
virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; }
|
||||
virtual void EndDoc(void) {};
|
||||
|
||||
virtual void StartPage(void) {};
|
||||
@ -235,21 +235,22 @@ protected:
|
||||
wxCoord xoffset, wxCoord yoffset,
|
||||
int fillStyle = wxODDEVEN_RULE);
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
public:
|
||||
//begin wxmac
|
||||
protected:
|
||||
//begin wxmac
|
||||
// Variables used for scaling
|
||||
double m_mm_to_pix_x,m_mm_to_pix_y;
|
||||
bool m_needComputeScaleX,m_needComputeScaleY; // not yet used
|
||||
long m_internalDeviceOriginX,m_internalDeviceOriginY; // If un-scrolled is non-zero or
|
||||
// d.o. changes with scrolling.
|
||||
// Set using SetInternalDeviceOrigin().
|
||||
// not yet used
|
||||
bool m_needComputeScaleX,m_needComputeScaleY;
|
||||
// If un-scrolled is non-zero or d.o. changes with scrolling.
|
||||
// Set using SetInternalDeviceOrigin().
|
||||
long m_internalDeviceOriginX,m_internalDeviceOriginY;
|
||||
// To be set by external classes such as wxScrolledWindow
|
||||
// using SetDeviceOrigin()
|
||||
long m_externalDeviceOriginX,m_externalDeviceOriginY;
|
||||
|
||||
// Begin implementation for Mac
|
||||
public:
|
||||
|
||||
long m_externalDeviceOriginX,m_externalDeviceOriginY; // To be set by external classes
|
||||
// such as wxScrolledWindow
|
||||
// using SetDeviceOrigin()
|
||||
GrafPtr m_macPort ;
|
||||
GWorldPtr m_macMask ;
|
||||
|
||||
|
@ -18,21 +18,6 @@
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
class WXDLLEXPORT wxIconRefData: public wxBitmapRefData
|
||||
{
|
||||
friend class WXDLLEXPORT wxBitmap;
|
||||
friend class WXDLLEXPORT wxIcon;
|
||||
public:
|
||||
wxIconRefData();
|
||||
~wxIconRefData();
|
||||
|
||||
public:
|
||||
WXHICON m_hIcon;
|
||||
};
|
||||
|
||||
#define M_ICONDATA ((wxIconRefData *)m_refData)
|
||||
#define M_ICONHANDLERDATA ((wxIconRefData *)bitmap->GetRefData())
|
||||
|
||||
// Icon
|
||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
||||
{
|
||||
@ -44,8 +29,8 @@ public:
|
||||
// Copy constructors
|
||||
inline wxIcon(const wxIcon& icon) { Ref(icon); }
|
||||
|
||||
wxIcon( const char **bits, int width=-1, int height=-1 );
|
||||
wxIcon( char **bits, int width=-1, int height=-1 );
|
||||
wxIcon( const char **data );
|
||||
wxIcon( char **data );
|
||||
wxIcon(const char bits[], int width, int height);
|
||||
wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
||||
int desiredWidth = -1, int desiredHeight = -1);
|
||||
@ -59,11 +44,6 @@ public:
|
||||
inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
|
||||
inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
|
||||
inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
|
||||
|
||||
void SetHICON(WXHICON ico);
|
||||
inline WXHICON GetHICON() const { return (M_ICONDATA ? M_ICONDATA->m_hIcon : 0); }
|
||||
|
||||
virtual bool Ok() const { return (m_refData != NULL) ; }
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -50,21 +50,9 @@ class WXDLLEXPORT wxStaticBitmap: public wxControl
|
||||
virtual void OnPaint( wxPaintEvent &event ) ;
|
||||
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
inline wxBitmap& GetBitmap() const { return (wxBitmap&) m_messageBitmap; }
|
||||
|
||||
// for compatibility with wxMSW
|
||||
const wxIcon& GetIcon() const
|
||||
{
|
||||
// don't use wxDynamicCast, icons and bitmaps are really the same thing
|
||||
// in wxGTK
|
||||
return (const wxIcon &)m_messageBitmap;
|
||||
}
|
||||
|
||||
// for compatibility with wxMSW
|
||||
void SetIcon(const wxIcon& icon)
|
||||
{
|
||||
SetBitmap( (const wxBitmap&) icon );
|
||||
}
|
||||
inline wxBitmap& GetBitmap() const { return m_messageBitmap; }
|
||||
const wxIcon& GetIcon() const { return (const wxIcon&) GetBitmap() ; }
|
||||
void SetIcon(const wxIcon& icon) {SetBitmap( icon ) ; }
|
||||
|
||||
// overriden base class virtuals
|
||||
virtual bool AcceptsFocus() const { return FALSE; }
|
||||
|
@ -747,7 +747,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
|
||||
panel = new wxPanel(m_notebook);
|
||||
|
||||
#if !defined(__WXMOTIF__) && !defined(__WXMAC__) && !defined(__WIN16__) // wxStaticBitmap not working under Motif yet; and icons not allowed under WIN16.
|
||||
#if !defined(__WXMOTIF__) && !defined(__WIN16__) // wxStaticBitmap not working under Motif yet; and icons not allowed under WIN16.
|
||||
wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
|
||||
wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon,
|
||||
wxPoint(10, 10));
|
||||
|
@ -25,8 +25,11 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifndef __WXMAC__
|
||||
// does this not give redefine errors on other platforms ?
|
||||
#define wxInt32 int
|
||||
#define wxUint32 unsigned int
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
@ -57,12 +60,23 @@ static wxInt32 read_char(FILE *f)
|
||||
|
||||
static wxInt32 read_short(FILE *f)
|
||||
{
|
||||
return (read_char(f)<<8) | read_char(f);
|
||||
// the execution path was not always correct
|
||||
// when using the direct evaluation in the return statement
|
||||
wxInt32 first = read_char(f) ;
|
||||
wxInt32 second = read_char(f) ;
|
||||
|
||||
return (first<<8) | second ;
|
||||
}
|
||||
|
||||
static wxInt32 read_long(FILE *f)
|
||||
{
|
||||
return (read_char(f)<<24) | (read_char(f)<<16) | (read_char(f)<<8) | read_char(f);
|
||||
// the execution path was not always correct
|
||||
// when using the direct evaluation in the return statement
|
||||
wxInt32 first = read_char(f) ;
|
||||
wxInt32 second = read_char(f) ;
|
||||
wxInt32 third = read_char(f) ;
|
||||
wxInt32 fourth = read_char(f) ;
|
||||
return (first<<24) | (second<<16) | (third<<8) | fourth ;
|
||||
}
|
||||
|
||||
static GLfloat read_float(FILE *f)
|
||||
|
@ -20,7 +20,11 @@
|
||||
#ifndef LW_H
|
||||
#define LW_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
#ifdef __WXMAC__
|
||||
#include <glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#define LW_MAX_POINTS 200
|
||||
#define LW_MAX_NAME_LEN 500
|
||||
|
@ -30,7 +30,11 @@
|
||||
#endif
|
||||
|
||||
#include "penguin.h"
|
||||
#ifdef __WXMAC__
|
||||
#include <glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#define VIEW_ASPECT 1.3
|
||||
|
||||
@ -147,16 +151,9 @@ void TestGLCanvas::OnPaint( wxPaintEvent& event )
|
||||
|
||||
void TestGLCanvas::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
int width, height;
|
||||
GetClientSize(& width, & height);
|
||||
|
||||
#ifndef __WXMOTIF__
|
||||
if (GetContext())
|
||||
#endif
|
||||
{
|
||||
SetCurrent();
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
// the viewport must be initialized this way, not glViewport
|
||||
// this is also necessary to update the context on some platforms
|
||||
wxGLCanvas::OnSize(event);
|
||||
}
|
||||
|
||||
void TestGLCanvas::OnEraseBackground(wxEraseEvent& event)
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user