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