]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/icon.cpp
wxRadioBox fixed on mac
[wxWidgets.git] / src / mac / carbon / icon.cpp
CommitLineData
e9576ca5
SC
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
2f1ae414 18#if !USE_SHARED_LIBRARIES
e9576ca5 19IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
2f1ae414 20#endif
e9576ca5
SC
21
22/*
23 * Icons
24 */
25
26
27wxIconRefData::wxIconRefData()
28{
519cb848
SC
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 ;
e9576ca5
SC
38}
39
40wxIconRefData::~wxIconRefData()
41{
519cb848
SC
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 }
e9576ca5
SC
53}
54
55wxIcon::wxIcon()
56{
57}
58
59wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
60{
61}
62
2f1ae414
SC
63wxIcon::wxIcon( const char **bits, int width, int height )
64{
65}
66
67wxIcon::wxIcon( char **bits, int width, int height )
68{
69}
70
e9576ca5
SC
71wxIcon::wxIcon(const wxString& icon_file, long flags,
72 int desiredWidth, int desiredHeight)
73
74{
75 LoadFile(icon_file, flags, desiredWidth, desiredHeight);
76}
77
78wxIcon::~wxIcon()
79{
80}
81
82bool 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
519cb848
SC
97IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
98
99bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
100 int desiredWidth, int desiredHeight)
101{
102 Str255 theName ;
103 short theId ;
104 OSType theType ;
03e11df5
GD
105
106#if TARGET_CARBON
107 c2pstrcpy( (StringPtr) theName , name ) ;
108#else
109 strcpy( (char *) theName , name ) ;
110 c2pstr( (char *) theName ) ;
111#endif
519cb848
SC
112
113 Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
2f1ae414 114 if ( resHandle != 0L )
519cb848 115 {
2f1ae414
SC
116 GetResInfo( resHandle , &theId , &theType , theName ) ;
117 ReleaseResource( resHandle ) ;
519cb848 118
2f1ae414
SC
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 }
519cb848
SC
131 }
132 return FALSE ;
03e11df5 133}