]> git.saurik.com Git - wxWidgets.git/blob - src/mac/icon.cpp
1. corrections for compilation of the wxBase apps with wxApp
[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 IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
19
20 /*
21 * Icons
22 */
23
24
25 wxIconRefData::wxIconRefData()
26 {
27 m_ok = FALSE;
28 m_width = 0;
29 m_height = 0;
30 m_depth = 0;
31 m_quality = 0;
32 m_numColors = 0;
33 m_bitmapMask = NULL;
34 m_hBitmap = NULL ;
35 m_hIcon = NULL ;
36 }
37
38 wxIconRefData::~wxIconRefData()
39 {
40 if ( m_hIcon )
41 {
42 DisposeCIcon( m_hIcon ) ;
43 m_hIcon = NULL ;
44 }
45
46 if (m_bitmapMask)
47 {
48 delete m_bitmapMask;
49 m_bitmapMask = NULL;
50 }
51 }
52
53 wxIcon::wxIcon()
54 {
55 }
56
57 wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
58 {
59 }
60
61 wxIcon::wxIcon(const wxString& icon_file, long flags,
62 int desiredWidth, int desiredHeight)
63
64 {
65 LoadFile(icon_file, flags, desiredWidth, desiredHeight);
66 }
67
68 wxIcon::~wxIcon()
69 {
70 }
71
72 bool wxIcon::LoadFile(const wxString& filename, long type,
73 int desiredWidth, int desiredHeight)
74 {
75 UnRef();
76
77 m_refData = new wxIconRefData;
78
79 wxBitmapHandler *handler = FindHandler(type);
80
81 if ( handler )
82 return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
83 else
84 return FALSE;
85 }
86
87 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
88
89 bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
90 int desiredWidth, int desiredHeight)
91 {
92 Str255 theName ;
93 short theId ;
94 OSType theType ;
95 strcpy( (char*) theName , name ) ;
96 c2pstr( (char*) theName ) ;
97
98 Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
99 GetResInfo( resHandle , &theId , &theType , theName ) ;
100 ReleaseResource( resHandle ) ;
101
102 CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
103 if ( theIcon )
104 {
105 M_ICONHANDLERDATA->m_hIcon = theIcon ;
106 M_ICONHANDLERDATA->m_width = 32 ;
107 M_ICONHANDLERDATA->m_height = 32 ;
108
109 M_ICONHANDLERDATA->m_depth = 8 ;
110 M_ICONHANDLERDATA->m_ok = true ;
111 M_ICONHANDLERDATA->m_numColors = 256 ;
112 return TRUE ;
113 }
114 return FALSE ;
115 }