wxCocoa: Better icon support
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25400 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
58203fa6b8
commit
b5df4fc722
13
Makefile.in
13
Makefile.in
@ -145,7 +145,7 @@ WXJPEG_OBJECTS = \
|
|||||||
wxjpeg_jquant1.o \
|
wxjpeg_jquant1.o \
|
||||||
wxjpeg_jquant2.o \
|
wxjpeg_jquant2.o \
|
||||||
wxjpeg_jdmerge.o
|
wxjpeg_jdmerge.o
|
||||||
WXTIFF_CFLAGS = $(CPPFLAGS) $(CFLAGS)
|
WXTIFF_CFLAGS = $(__INC_ZLIB_p) $(__INC_JPEG_p) $(CPPFLAGS) $(CFLAGS)
|
||||||
WXTIFF_OBJECTS = \
|
WXTIFF_OBJECTS = \
|
||||||
$(__TIFF_PLATFORM_SRC_OBJECTS) \
|
$(__TIFF_PLATFORM_SRC_OBJECTS) \
|
||||||
wxtiff_tif_aux.o \
|
wxtiff_tif_aux.o \
|
||||||
@ -1149,6 +1149,7 @@ COND_TOOLKIT_X11_LOWLEVEL_HDR = \
|
|||||||
wx/x11/window.h
|
wx/x11/window.h
|
||||||
@COND_TOOLKIT_X11@LOWLEVEL_HDR = $(COND_TOOLKIT_X11_LOWLEVEL_HDR)
|
@COND_TOOLKIT_X11@LOWLEVEL_HDR = $(COND_TOOLKIT_X11_LOWLEVEL_HDR)
|
||||||
COND_TOOLKIT_COCOA_GUI_HDR = \
|
COND_TOOLKIT_COCOA_GUI_HDR = \
|
||||||
|
wx/cocoa/NSApplication.h \
|
||||||
wx/cocoa/NSBox.h \
|
wx/cocoa/NSBox.h \
|
||||||
wx/cocoa/NSButton.h \
|
wx/cocoa/NSButton.h \
|
||||||
wx/cocoa/NSControl.h \
|
wx/cocoa/NSControl.h \
|
||||||
@ -1195,6 +1196,7 @@ COND_TOOLKIT_COCOA_GUI_HDR = \
|
|||||||
wx/cocoa/radiobox.h \
|
wx/cocoa/radiobox.h \
|
||||||
wx/cocoa/radiobut.h \
|
wx/cocoa/radiobut.h \
|
||||||
wx/cocoa/region.h \
|
wx/cocoa/region.h \
|
||||||
|
wx/cocoa/slider.h \
|
||||||
wx/cocoa/spinbutt.h \
|
wx/cocoa/spinbutt.h \
|
||||||
wx/cocoa/statbmp.h \
|
wx/cocoa/statbmp.h \
|
||||||
wx/cocoa/statbox.h \
|
wx/cocoa/statbox.h \
|
||||||
@ -1205,6 +1207,7 @@ COND_TOOLKIT_COCOA_GUI_HDR = \
|
|||||||
wx/cocoa/toplevel.h \
|
wx/cocoa/toplevel.h \
|
||||||
wx/cocoa/window.h \
|
wx/cocoa/window.h \
|
||||||
wx/generic/caret.h \
|
wx/generic/caret.h \
|
||||||
|
wx/generic/dirdlgg.h \
|
||||||
wx/generic/fdrepdlg.h \
|
wx/generic/fdrepdlg.h \
|
||||||
wx/generic/fontdlgg.h \
|
wx/generic/fontdlgg.h \
|
||||||
wx/generic/imaglist.h \
|
wx/generic/imaglist.h \
|
||||||
@ -8163,7 +8166,7 @@ monodll_xtixml.o: $(srcdir)/src/common/xtixml.cpp $(MONODLL_ODEP)
|
|||||||
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_icon.o: $(srcdir)/src/mac/icon.cpp $(MONODLL_ODEP)
|
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_icon.o: $(srcdir)/src/mac/icon.cpp $(MONODLL_ODEP)
|
||||||
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $<
|
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $<
|
||||||
|
|
||||||
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_icon.o: $(srcdir)/src/cocoa/icon.cpp $(MONODLL_ODEP)
|
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monodll_icon.o: $(srcdir)/src/cocoa/icon.mm $(MONODLL_ODEP)
|
||||||
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $<
|
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $<
|
||||||
|
|
||||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_icon.o: $(srcdir)/src/os2/icon.cpp $(MONODLL_ODEP)
|
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_icon.o: $(srcdir)/src/os2/icon.cpp $(MONODLL_ODEP)
|
||||||
@ -10767,7 +10770,7 @@ monolib_xtixml.o: $(srcdir)/src/common/xtixml.cpp $(MONOLIB_ODEP)
|
|||||||
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_icon.o: $(srcdir)/src/mac/icon.cpp $(MONOLIB_ODEP)
|
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_icon.o: $(srcdir)/src/mac/icon.cpp $(MONOLIB_ODEP)
|
||||||
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $<
|
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $<
|
||||||
|
|
||||||
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_icon.o: $(srcdir)/src/cocoa/icon.cpp $(MONOLIB_ODEP)
|
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@monolib_icon.o: $(srcdir)/src/cocoa/icon.mm $(MONOLIB_ODEP)
|
||||||
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $<
|
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $<
|
||||||
|
|
||||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_icon.o: $(srcdir)/src/os2/icon.cpp $(MONOLIB_ODEP)
|
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_icon.o: $(srcdir)/src/os2/icon.cpp $(MONOLIB_ODEP)
|
||||||
@ -13635,7 +13638,7 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP)
|
|||||||
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_icon.o: $(srcdir)/src/mac/icon.cpp $(COREDLL_ODEP)
|
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_icon.o: $(srcdir)/src/mac/icon.cpp $(COREDLL_ODEP)
|
||||||
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $<
|
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $<
|
||||||
|
|
||||||
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_icon.o: $(srcdir)/src/cocoa/icon.cpp $(COREDLL_ODEP)
|
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@coredll_icon.o: $(srcdir)/src/cocoa/icon.mm $(COREDLL_ODEP)
|
||||||
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $<
|
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $<
|
||||||
|
|
||||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_icon.o: $(srcdir)/src/os2/icon.cpp $(COREDLL_ODEP)
|
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_icon.o: $(srcdir)/src/os2/icon.cpp $(COREDLL_ODEP)
|
||||||
@ -15744,7 +15747,7 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP)
|
|||||||
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_icon.o: $(srcdir)/src/mac/icon.cpp $(CORELIB_ODEP)
|
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_icon.o: $(srcdir)/src/mac/icon.cpp $(CORELIB_ODEP)
|
||||||
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $<
|
@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $<
|
||||||
|
|
||||||
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_icon.o: $(srcdir)/src/cocoa/icon.cpp $(CORELIB_ODEP)
|
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@corelib_icon.o: $(srcdir)/src/cocoa/icon.mm $(CORELIB_ODEP)
|
||||||
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $<
|
@COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $<
|
||||||
|
|
||||||
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_icon.o: $(srcdir)/src/os2/icon.cpp $(CORELIB_ODEP)
|
@COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_icon.o: $(srcdir)/src/os2/icon.cpp $(CORELIB_ODEP)
|
||||||
|
@ -1736,7 +1736,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
|||||||
src/cocoa/frame.mm
|
src/cocoa/frame.mm
|
||||||
src/cocoa/gauge.mm
|
src/cocoa/gauge.mm
|
||||||
src/cocoa/gdiobj.cpp
|
src/cocoa/gdiobj.cpp
|
||||||
src/cocoa/icon.cpp
|
src/cocoa/icon.mm
|
||||||
src/cocoa/listbox.mm
|
src/cocoa/listbox.mm
|
||||||
src/cocoa/main.cpp
|
src/cocoa/main.cpp
|
||||||
src/cocoa/mbarman.mm
|
src/cocoa/mbarman.mm
|
||||||
|
@ -86,6 +86,9 @@ public:
|
|||||||
// Convert from wxImage:
|
// Convert from wxImage:
|
||||||
wxBitmap(const wxImage& image, int depth = -1)
|
wxBitmap(const wxImage& image, int depth = -1)
|
||||||
{ CreateFromImage(image, depth); }
|
{ CreateFromImage(image, depth); }
|
||||||
|
// Convert from wxIcon
|
||||||
|
wxBitmap(const wxIcon& icon) { CopyFromIcon(icon); }
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
~wxBitmap();
|
~wxBitmap();
|
||||||
|
|
||||||
|
@ -1,62 +1,66 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: wx/cocoa/icon.h
|
// Name: wx/cocoa/icon.h
|
||||||
// Purpose: wxIcon class
|
// Purpose: wxIcon class
|
||||||
// Author: AUTHOR
|
// Author: David Elliott
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: ??/??/98
|
// Created: 2003/08/11
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) AUTHOR
|
// Copyright: (c) 2003 David Elliott
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_ICON_H_
|
#ifndef _WX_COCOA_ICON_H__
|
||||||
#define _WX_ICON_H_
|
#define _WX_COCOA_ICON_H__
|
||||||
|
|
||||||
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
#include "wx/gdicmn.h"
|
||||||
#pragma interface "icon.h"
|
#include "wx/gdiobj.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/bitmap.h"
|
// ========================================================================
|
||||||
|
// wxIcon
|
||||||
// Icon
|
// ========================================================================
|
||||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
class WXDLLEXPORT wxIcon: public wxGDIObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxIcon)
|
DECLARE_DYNAMIC_CLASS(wxIcon)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxIcon();
|
wxIcon();
|
||||||
|
|
||||||
// Copy constructors
|
// Copy constructors
|
||||||
wxIcon(const wxIcon& icon)
|
wxIcon(const wxIcon& icon)
|
||||||
: wxBitmap()
|
{ Ref(icon); }
|
||||||
{ Ref(icon); }
|
|
||||||
|
|
||||||
wxIcon(const char **data);
|
wxIcon(const char **data) { CreateFromXpm(data); }
|
||||||
wxIcon(char **data);
|
wxIcon(char **data) { CreateFromXpm((const char**)data); }
|
||||||
wxIcon(const char bits[], int width , int height );
|
wxIcon(const char bits[], int width , int height );
|
||||||
wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE,
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
int desiredWidth = -1, int desiredHeight = -1);
|
||||||
wxIcon(const wxIconLocation& loc)
|
wxIcon(const wxIconLocation& loc)
|
||||||
{
|
{
|
||||||
LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
|
LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ICON);
|
||||||
}
|
}
|
||||||
~wxIcon();
|
~wxIcon();
|
||||||
|
|
||||||
bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
|
bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ ,
|
||||||
int desiredWidth /* = -1 */ , int desiredHeight = -1);
|
int desiredWidth /* = -1 */ , int desiredHeight = -1);
|
||||||
bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE )
|
bool LoadFile(const wxString& name, wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE )
|
||||||
{ return LoadFile( name , flags , -1 , -1 ) ; }
|
{ return LoadFile( name , flags , -1 , -1 ) ; }
|
||||||
|
|
||||||
wxIcon& operator=(const wxIcon& icon)
|
wxIcon& operator=(const wxIcon& icon)
|
||||||
{ if (this != &icon) Ref(icon); return *this; }
|
{ if (this != &icon) Ref(icon); return *this; }
|
||||||
bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
|
bool operator==(const wxIcon& icon) const
|
||||||
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
|
{ return m_refData == icon.m_refData; }
|
||||||
|
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
|
||||||
|
|
||||||
// create from bitmap (which should have a mask unless it's monochrome):
|
// create from bitmap (which should have a mask unless it's monochrome):
|
||||||
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
|
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
|
||||||
// ctors, assignment operators...), but it's ok to have such function
|
// ctors, assignment operators...), but it's ok to have such function
|
||||||
void CopyFromBitmap(const wxBitmap& bmp);
|
void CopyFromBitmap(const wxBitmap& bmp);
|
||||||
|
|
||||||
|
bool Ok() const;
|
||||||
|
int GetWidth() const;
|
||||||
|
int GetHeight() const;
|
||||||
|
|
||||||
|
WX_NSImage GetNSImage() const;
|
||||||
|
bool CreateFromXpm(const char **bits);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // _WX_COCOA_ICON_H__
|
||||||
// _WX_ICON_H_
|
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Name: icon.cpp
|
|
||||||
// Purpose: wxIcon class
|
|
||||||
// Author: AUTHOR
|
|
||||||
// Modified by:
|
|
||||||
// Created: ??/??/98
|
|
||||||
// RCS-ID: $Id$
|
|
||||||
// Copyright: (c) AUTHOR
|
|
||||||
// Licence: wxWindows licence
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation "icon.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/icon.h"
|
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARIES
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Icons
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
wxIcon::wxIcon()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIcon::wxIcon(const char **xpm)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIcon::wxIcon(char **xpm)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIcon::wxIcon(const wxString& icon_file, int flags,
|
|
||||||
int desiredWidth, int desiredHeight)
|
|
||||||
|
|
||||||
{
|
|
||||||
LoadFile(icon_file, (wxBitmapType)flags, desiredWidth, desiredHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIcon::~wxIcon()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
|
||||||
int desiredWidth, int desiredHeight)
|
|
||||||
{
|
|
||||||
UnRef();
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxIcon::CopyFromBitmap(const wxBitmap& icno)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
156
src/cocoa/icon.mm
Normal file
156
src/cocoa/icon.mm
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/cocoa/icon.mm
|
||||||
|
// Purpose: wxIcon class
|
||||||
|
// Author: David Elliott
|
||||||
|
// Modified by:
|
||||||
|
// Created: 2003/08/11
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2003 David Elliott
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/icon.h"
|
||||||
|
#endif //WX_PRECOMP
|
||||||
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
|
#import <AppKit/NSImage.h>
|
||||||
|
|
||||||
|
// ========================================================================
|
||||||
|
// wxIconRefData
|
||||||
|
// ========================================================================
|
||||||
|
class wxIconRefData: public wxGDIRefData
|
||||||
|
{
|
||||||
|
friend class wxIcon;
|
||||||
|
public:
|
||||||
|
wxIconRefData();
|
||||||
|
wxIconRefData( const wxIconRefData& data );
|
||||||
|
virtual ~wxIconRefData();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int m_width;
|
||||||
|
int m_height;
|
||||||
|
int m_depth;
|
||||||
|
bool m_ok;
|
||||||
|
int m_numColors;
|
||||||
|
int m_quality;
|
||||||
|
WX_NSImage m_cocoaNSImage;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define M_ICONDATA ((wxIconRefData *)m_refData)
|
||||||
|
|
||||||
|
wxIconRefData::wxIconRefData()
|
||||||
|
{
|
||||||
|
m_ok = FALSE;
|
||||||
|
m_width = 0;
|
||||||
|
m_height = 0;
|
||||||
|
m_depth = 0;
|
||||||
|
m_quality = 0;
|
||||||
|
m_numColors = 0;
|
||||||
|
m_cocoaNSImage = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxIconRefData::wxIconRefData( const wxIconRefData& data)
|
||||||
|
{
|
||||||
|
m_width = data.m_width;
|
||||||
|
m_height = data.m_height;
|
||||||
|
m_depth = data.m_depth;
|
||||||
|
m_ok = data.m_ok;
|
||||||
|
m_numColors = data.m_numColors;
|
||||||
|
m_quality = data.m_quality;
|
||||||
|
m_cocoaNSImage = [data.m_cocoaNSImage copyWithZone:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
wxIconRefData::~wxIconRefData()
|
||||||
|
{
|
||||||
|
[m_cocoaNSImage release];
|
||||||
|
m_cocoaNSImage = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ========================================================================
|
||||||
|
// wxIcon
|
||||||
|
// ========================================================================
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxGDIObject)
|
||||||
|
|
||||||
|
wxIcon::wxIcon()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxIcon::wxIcon(const wxString& icon_file, int flags,
|
||||||
|
int desiredWidth, int desiredHeight)
|
||||||
|
|
||||||
|
{
|
||||||
|
LoadFile(icon_file, (wxBitmapType)flags, desiredWidth, desiredHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxIcon::~wxIcon()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxIcon::CreateFromXpm(const char **xpm)
|
||||||
|
{
|
||||||
|
wxBitmap bitmap(xpm);
|
||||||
|
CopyFromBitmap(bitmap);
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
|
||||||
|
int desiredWidth, int desiredHeight)
|
||||||
|
{
|
||||||
|
UnRef();
|
||||||
|
|
||||||
|
m_refData = new wxIconRefData;
|
||||||
|
M_ICONDATA->m_width = 5;
|
||||||
|
M_ICONDATA->m_height = 5;
|
||||||
|
M_ICONDATA->m_cocoaNSImage = [[NSImage alloc] initWithSize:NSMakeSize(5,5)];
|
||||||
|
M_ICONDATA->m_ok = true;
|
||||||
|
M_ICONDATA->m_numColors = 0;
|
||||||
|
M_ICONDATA->m_quality = 0;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxIcon::CopyFromBitmap(const wxBitmap& bitmap)
|
||||||
|
{
|
||||||
|
UnRef();
|
||||||
|
m_refData = new wxIconRefData;
|
||||||
|
M_ICONDATA->m_width = bitmap.GetWidth();
|
||||||
|
M_ICONDATA->m_height = bitmap.GetHeight();
|
||||||
|
M_ICONDATA->m_cocoaNSImage = bitmap.GetNSImage(true);
|
||||||
|
M_ICONDATA->m_ok = bitmap.Ok();
|
||||||
|
M_ICONDATA->m_numColors = 0;
|
||||||
|
M_ICONDATA->m_quality = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxIcon::Ok() const
|
||||||
|
{
|
||||||
|
return m_refData && M_ICONDATA->m_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxIcon::GetWidth() const
|
||||||
|
{
|
||||||
|
if(!m_refData)
|
||||||
|
return 0;
|
||||||
|
return M_ICONDATA->m_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxIcon::GetHeight() const
|
||||||
|
{
|
||||||
|
if(!m_refData)
|
||||||
|
return 0;
|
||||||
|
return M_ICONDATA->m_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
WX_NSImage wxIcon::GetNSImage() const
|
||||||
|
{
|
||||||
|
if(!M_ICONDATA)
|
||||||
|
return nil;
|
||||||
|
return M_ICONDATA->m_cocoaNSImage;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user