]> git.saurik.com Git - wxWidgets.git/blob - src/os2/icon.cpp
more minimal stuff
[wxWidgets.git] / src / os2 / icon.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: icon.cpp
3 // Purpose: wxIcon class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/09/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/defs.h"
21 #include "wx/list.h"
22 #include "wx/utils.h"
23 #include "wx/app.h"
24 #include "wx/icon.h"
25 #endif
26
27 #include "wx/os2/private.h"
28 #include "assert.h"
29
30 #include "wx/icon.h"
31
32 IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxIconBase)
33
34 // ============================================================================
35 // implementation
36 // ============================================================================
37
38 // ----------------------------------------------------------------------------
39 // wxIconRefData
40 // ----------------------------------------------------------------------------
41
42 void wxIconRefData::Free()
43 {
44 if (m_hIcon)
45 ::WinFreeFileIcon((HPOINTER)m_hIcon);
46 }
47
48 // ----------------------------------------------------------------------------
49 // wxIcon
50 // ----------------------------------------------------------------------------
51
52 wxIcon::wxIcon()
53 {
54 }
55
56 wxIcon::wxIcon(
57 const char WXUNUSED(bits)[]
58 , int WXUNUSED(nWidth)
59 , int WXUNUSED(nHeight)
60 )
61 {
62 }
63
64 wxIcon::wxIcon(
65 const wxString& rIconFile
66 , long lFlags
67 , int nDesiredWidth
68 , int nDesiredHeight
69 )
70 {
71 //
72 // A very poor hack, but we have to have separate icon files from windows
73 // So we have a modified name where replace the last three characters
74 // with os2. Also need the extension.
75 //
76 wxString sOs2Name = rIconFile.Mid(0, rIconFile.Length() - 3);
77
78 sOs2Name += "Os2.ico";
79 LoadFile( sOs2Name
80 ,lFlags
81 ,nDesiredWidth
82 ,nDesiredHeight
83 );
84 }
85
86 wxIcon::~wxIcon()
87 {
88 }
89
90 bool wxIcon::LoadFile(
91 const wxString& rFilename
92 , long lType
93 , int nDesiredWidth
94 , int nDesiredHeight
95 )
96 {
97 wxGDIImageHandler* pHandler = FindHandler(lType);
98 HPS hPs = NULLHANDLE;
99
100 UnRef();
101 m_refData = new wxIconRefData;
102
103 if (pHandler)
104 return(pHandler->Load( this
105 ,rFilename
106 ,hPs
107 ,lType
108 ,nDesiredWidth
109 ,nDesiredHeight
110 ));
111 else
112 return(FALSE);
113 }
114