]> git.saurik.com Git - wxWidgets.git/blame - src/os2/icon.cpp
Distrib corrections,
[wxWidgets.git] / src / os2 / icon.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: icon.cpp
3// Purpose: wxIcon class
fb9010ed 4// Author: David Webster
0e320a79 5// Modified by:
fb9010ed 6// Created: 10/09/99
0e320a79 7// RCS-ID: $Id$
fb9010ed
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
fb9010ed
DW
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 <stdio.h>
21#include "wx/setup.h"
22#include "wx/list.h"
23#include "wx/utils.h"
24#include "wx/app.h"
25#include "wx/icon.h"
0e320a79
DW
26#endif
27
fb9010ed
DW
28#include "wx/os2/private.h"
29#include "assert.h"
30
0e320a79
DW
31#include "wx/icon.h"
32
33#if !USE_SHARED_LIBRARIES
34IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
fb9010ed
DW
35IMPLEMENT_DYNAMIC_CLASS(wxICOFileHandler, wxBitmapHandler)
36IMPLEMENT_DYNAMIC_CLASS(wxICOResourceHandler, wxBitmapHandler)
0e320a79
DW
37#endif
38
39/*
40 * Icons
41 */
42
0e320a79
DW
43wxIconRefData::wxIconRefData()
44{
fb9010ed 45 m_hIcon = (WXHICON) NULL ;
0e320a79
DW
46}
47
48wxIconRefData::~wxIconRefData()
49{
fb9010ed
DW
50 if ( m_hIcon )
51 return;
52 // TODO ::DestroyIcon((HICON) m_hIcon);
0e320a79
DW
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 )
fb9010ed
DW
84 return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
85 else
86 return FALSE;
87}
88
89void wxIcon::SetHICON(WXHICON ico)
90{
91 if ( !M_ICONDATA )
92 m_refData = new wxIconRefData;
93
94 M_ICONDATA->m_hIcon = ico;
95}
96
97bool wxICOFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
98 int desiredWidth, int desiredHeight)
99{
100 return FALSE;
101}
102
103bool wxICOResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
104 int desiredWidth, int desiredHeight)
105{
106// TODO
107/*
108 if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
109 {
110 if (desiredWidth > -1 && desiredHeight > -1)
111 {
112 M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadImage(wxGetInstance(), name, IMAGE_ICON, desiredWidth, desiredHeight, LR_DEFAULTCOLOR);
113 }
114 else
115 {
116 M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadIcon(wxGetInstance(), name);
117 }
118
119 ICONINFO info ;
120 if (::GetIconInfo((HICON) M_ICONHANDLERDATA->m_hIcon, &info))
121 {
122 HBITMAP ms_bitmap = info.hbmMask ;
123 if (ms_bitmap)
124 {
125 BITMAP bm;
126 ::GetObject(ms_bitmap, sizeof(BITMAP), (LPSTR) &bm);
127 M_ICONHANDLERDATA->m_width = bm.bmWidth;
128 M_ICONHANDLERDATA->m_height = bm.bmHeight;
129 }
130 if (info.hbmMask)
131 ::DeleteObject(info.hbmMask) ;
132 if (info.hbmColor)
133 ::DeleteObject(info.hbmColor) ;
134 }
135 }
136 // Override the found values with desired values
137 if (desiredWidth > -1 && desiredHeight > -1)
138 {
139 M_ICONHANDLERDATA->m_width = desiredWidth;
140 M_ICONHANDLERDATA->m_height = desiredHeight;
141 }
142
143 M_ICONHANDLERDATA->m_ok = (M_ICONHANDLERDATA->m_hIcon != 0);
144 return M_ICONHANDLERDATA->m_ok;
145 }
0e320a79 146 else
fb9010ed
DW
147*/
148 return FALSE;
0e320a79
DW
149}
150