]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/icon.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[wxWidgets.git] / src / mac / carbon / icon.cpp
... / ...
CommitLineData
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#if !USE_SHARED_LIBRARIES
19IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
20#endif
21
22/*
23 * Icons
24 */
25
26
27wxIconRefData::wxIconRefData()
28{
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 ;
38}
39
40wxIconRefData::~wxIconRefData()
41{
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 }
53}
54
55wxIcon::wxIcon()
56{
57}
58
59wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
60{
61}
62
63wxIcon::wxIcon(const wxString& icon_file, long flags,
64 int desiredWidth, int desiredHeight)
65
66{
67 LoadFile(icon_file, flags, desiredWidth, desiredHeight);
68}
69
70wxIcon::~wxIcon()
71{
72}
73
74bool wxIcon::LoadFile(const wxString& filename, long type,
75 int desiredWidth, int desiredHeight)
76{
77 UnRef();
78
79 m_refData = new wxIconRefData;
80
81 wxBitmapHandler *handler = FindHandler(type);
82
83 if ( handler )
84 return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
85 else
86 return FALSE;
87}
88
89IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)
90
91bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
92 int desiredWidth, int desiredHeight)
93{
94 Str255 theName ;
95 short theId ;
96 OSType theType ;
97 strcpy( (char*) theName , name ) ;
98 c2pstr( (char*) theName ) ;
99
100 Handle resHandle = GetNamedResource( 'cicn' , theName ) ;
101 GetResInfo( resHandle , &theId , &theType , theName ) ;
102 ReleaseResource( resHandle ) ;
103
104 CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ;
105 if ( theIcon )
106 {
107 M_ICONHANDLERDATA->m_hIcon = theIcon ;
108 M_ICONHANDLERDATA->m_width = 32 ;
109 M_ICONHANDLERDATA->m_height = 32 ;
110
111 M_ICONHANDLERDATA->m_depth = 8 ;
112 M_ICONHANDLERDATA->m_ok = true ;
113 M_ICONHANDLERDATA->m_numColors = 256 ;
114 return TRUE ;
115 }
116 return FALSE ;
117}