]> git.saurik.com Git - wxWidgets.git/blame - src/mac/icon.cpp
added unimplemented error messages
[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 21
76a5e5d2
SC
22#include "wx/mac/private.h"
23
24
e9576ca5
SC
25/*
26 * Icons
27 */
28
e9576ca5
SC
29wxIcon::wxIcon()
30{
31}
32
3dec57ad 33wxIcon::wxIcon(const char bits[], int width, int height) :
d84afea9 34 wxBitmap(bits, width, height)
e9576ca5 35{
3dec57ad 36
e9576ca5
SC
37}
38
3dec57ad 39wxIcon::wxIcon( const char **bits ) :
d84afea9 40 wxBitmap(bits)
2f1ae414
SC
41{
42}
43
3dec57ad 44wxIcon::wxIcon( char **bits ) :
d84afea9 45 wxBitmap(bits)
2f1ae414
SC
46{
47}
48
76a5e5d2 49wxIcon::wxIcon(const wxString& icon_file, int flags,
e9576ca5 50 int desiredWidth, int desiredHeight)
e9576ca5 51{
76a5e5d2 52 LoadFile(icon_file, (wxBitmapType) flags, desiredWidth, desiredHeight);
e9576ca5
SC
53}
54
55wxIcon::~wxIcon()
56{
57}
58
76a5e5d2 59bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
e9576ca5
SC
60 int desiredWidth, int desiredHeight)
61{
62 UnRef();
63
3dec57ad 64 m_refData = new wxBitmapRefData;
e9576ca5 65
90b959ae 66 wxBitmapHandler *handler = FindHandler((wxBitmapType)type);
e9576ca5
SC
67
68 if ( handler )
69 return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
70 else
71 return FALSE;
72}
73
d062e17f
GD
74void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
75{
76 wxIcon *icon = (wxIcon*)(&bmp);
77 *this = *icon;
78}
79
519cb848
SC
80IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
81
82bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
83 int desiredWidth, int desiredHeight)
84{
3dec57ad 85 short theId = -1 ;
c2edb18a 86 if ( name == "wxICON_INFORMATION" )
3dec57ad
SC
87 {
88 theId = kNoteIcon ;
89 }
90 else if ( name == "wxICON_QUESTION" )
91 {
92 theId = kCautionIcon ;
93 }
94 else if ( name == "wxICON_WARNING" )
95 {
96 theId = kCautionIcon ;
97 }
98 else if ( name == "wxICON_ERROR" )
99 {
100 theId = kStopIcon ;
101 }
102 else
103 {
104 Str255 theName ;
105 OSType theType ;
106
107 #if TARGET_CARBON
108 c2pstrcpy( (StringPtr) theName , name ) ;
109 #else
110 strcpy( (char *) theName , name ) ;
111 c2pstr( (char *) theName ) ;
112 #endif
113
114 Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
115 if ( resHandle != 0L )
116 {
117 GetResInfo( resHandle , &theId , &theType , theName ) ;
118 ReleaseResource( resHandle ) ;
119 }
120 }
121 if ( theId != -1 )
519cb848 122 {
2f1ae414
SC
123 CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
124 if ( theIcon )
125 {
3dec57ad
SC
126 M_BITMAPHANDLERDATA->m_hIcon = theIcon ;
127 M_BITMAPHANDLERDATA->m_width = 32 ;
128 M_BITMAPHANDLERDATA->m_height = 32 ;
2f1ae414 129
3dec57ad
SC
130 M_BITMAPHANDLERDATA->m_depth = 8 ;
131 M_BITMAPHANDLERDATA->m_ok = true ;
132 M_BITMAPHANDLERDATA->m_numColors = 256 ;
133 M_BITMAPHANDLERDATA->m_bitmapType = kMacBitmapTypeIcon ;
2f1ae414
SC
134 return TRUE ;
135 }
519cb848
SC
136 }
137 return FALSE ;
03e11df5 138}