]> git.saurik.com Git - wxWidgets.git/blob - src/motif/icon.cpp
Avoid crash during global destruction.
[wxWidgets.git] / src / motif / icon.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: icon.cpp
3 // Purpose: wxIcon class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "icon.h"
14 #endif
15
16 #include "wx/icon.h"
17
18 IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap);
19
20 // ============================================================================
21 // Icons
22 // ============================================================================
23
24 wxIcon::wxIcon()
25 {
26 }
27
28 // Create from XBM data
29 wxIcon::wxIcon(const char bits[], int width, int height)
30 {
31 (void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, 1);
32 }
33
34 // Create from XPM data
35 wxIcon::wxIcon(char **data)
36 {
37 (void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
38 }
39
40 wxIcon::wxIcon(const char **data)
41 {
42 (void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
43 }
44
45 wxIcon::wxIcon(const wxString& icon_file, wxBitmapType type,
46 int desiredWidth, int desiredHeight)
47
48 {
49 LoadFile(icon_file, type, desiredWidth, desiredHeight);
50 }
51
52 void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
53 {
54 wxIcon *icon = (wxIcon*)(&bmp);
55 *this = *icon;
56 }
57
58 wxIcon::~wxIcon()
59 {
60 }
61
62 bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
63 int desiredWidth, int desiredHeight)
64 {
65 UnRef();
66
67 wxBitmapHandler *handler = FindHandler(type);
68
69 if ( handler )
70 return handler->LoadFile(this, filename, type,
71 desiredWidth, desiredHeight);
72 else
73 return FALSE;
74 }