]> git.saurik.com Git - wxWidgets.git/blob - src/mac/icon.cpp
Made wxWindow::Enable recursive in order to solve colouring problems; forced the...
[wxWidgets.git] / src / mac / icon.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: icon.cpp
3 // Purpose: wxIcon class
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "icon.h"
14 #endif
15
16 #include "wx/icon.h"
17
18 #if !USE_SHARED_LIBRARIES
19 IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
20 #endif
21
22 /*
23 * Icons
24 */
25
26
27 wxIconRefData::wxIconRefData()
28 {
29 m_ok = FALSE;
30 m_width = 0;
31 m_height = 0;
32 m_depth = 0;
33 m_quality = 0;
34 m_numColors = 0;
35 m_bitmapMask = NULL;
36 m_hBitmap = NULL ;
37 m_hIcon = NULL ;
38 }
39
40 wxIconRefData::~wxIconRefData()
41 {
42 if ( m_hIcon )
43 {
44 DisposeCIcon( m_hIcon ) ;
45 m_hIcon = NULL ;
46 }
47
48 if (m_bitmapMask)
49 {
50 delete m_bitmapMask;
51 m_bitmapMask = NULL;
52 }
53 }
54
55 wxIcon::wxIcon()
56 {
57 }
58
59 wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
60 {
61 }
62
63 wxIcon::wxIcon( const char **bits, int width, int height )
64 {
65 }
66
67 wxIcon::wxIcon( char **bits, int width, int height )
68 {
69 }
70
71 wxIcon::wxIcon(const wxString& icon_file, long flags,
72 int desiredWidth, int desiredHeight)
73
74 {
75 LoadFile(icon_file, flags, desiredWidth, desiredHeight);
76 }
77
78 wxIcon::~wxIcon()
79 {
80 }
81
82 bool wxIcon::LoadFile(const wxString& filename, long type,
83 int desiredWidth, int desiredHeight)
84 {
85 UnRef();
86
87 m_refData = new wxIconRefData;
88
89 wxBitmapHandler *handler = FindHandler(type);
90
91 if ( handler )
92 return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
93 else
94 return FALSE;
95 }
96
97 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
98
99 bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
100 int desiredWidth, int desiredHeight)
101 {
102 Str255 theName ;
103 short theId ;
104 OSType theType ;
105
106 #if TARGET_CARBON
107 c2pstrcpy( (StringPtr) theName , name ) ;
108 #else
109 strcpy( (char *) theName , name ) ;
110 c2pstr( (char *) theName ) ;
111 #endif
112
113 Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
114 if ( resHandle != 0L )
115 {
116 GetResInfo( resHandle , &theId , &theType , theName ) ;
117 ReleaseResource( resHandle ) ;
118
119 CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
120 if ( theIcon )
121 {
122 M_ICONHANDLERDATA->m_hIcon = theIcon ;
123 M_ICONHANDLERDATA->m_width = 32 ;
124 M_ICONHANDLERDATA->m_height = 32 ;
125
126 M_ICONHANDLERDATA->m_depth = 8 ;
127 M_ICONHANDLERDATA->m_ok = true ;
128 M_ICONHANDLERDATA->m_numColors = 256 ;
129 return TRUE ;
130 }
131 }
132 return FALSE ;
133 }