]> git.saurik.com Git - wxWidgets.git/blame - src/mac/icon.cpp
Added wxChoice::GetCount() and Select()
[wxWidgets.git] / src / mac / 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 ;
105 strcpy( (char*) theName , name ) ;
106 c2pstr( (char*) theName ) ;
107
108 Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
2f1ae414 109 if ( resHandle != 0L )
519cb848 110 {
2f1ae414
SC
111 GetResInfo( resHandle , &theId , &theType , theName ) ;
112 ReleaseResource( resHandle ) ;
519cb848 113
2f1ae414
SC
114 CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
115 if ( theIcon )
116 {
117 M_ICONHANDLERDATA->m_hIcon = theIcon ;
118 M_ICONHANDLERDATA->m_width = 32 ;
119 M_ICONHANDLERDATA->m_height = 32 ;
120
121 M_ICONHANDLERDATA->m_depth = 8 ;
122 M_ICONHANDLERDATA->m_ok = true ;
123 M_ICONHANDLERDATA->m_numColors = 256 ;
124 return TRUE ;
125 }
519cb848
SC
126 }
127 return FALSE ;
2f1ae414 128}