]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/icon.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: Julian Smart
5 // Modified by: 20.11.99 (VZ): don't derive from wxBitmap any more
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "icon.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
39 #include "wx/msw/private.h"
41 #if wxUSE_RESOURCE_LOADING_IN_MSW
42 #include "wx/msw/curico.h"
43 #include "wx/msw/curicop.h"
46 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
50 IMPLEMENT_DYNAMIC_CLASS(wxIcon
, wxIconBase
)
52 // ============================================================================
54 // ============================================================================
56 // ----------------------------------------------------------------------------
58 // ----------------------------------------------------------------------------
60 void wxIconRefData::Free()
64 ::DestroyIcon((HICON
) m_hIcon
);
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 wxIcon::wxIcon(const char bits
[], int width
, int height
)
76 wxBitmap
bmp(bits
, width
, height
);
80 wxIcon::wxIcon(const wxString
& iconfile
,
86 LoadFile(iconfile
, flags
, desiredWidth
, desiredHeight
);
93 void wxIcon::CopyFromBitmap(const wxBitmap
& bmp
)
96 wxMask
*mask
= bmp
.GetMask();
99 // we must have a mask for an icon, so even if it's probably incorrect,
100 // do create it (grey is the "standard" transparent colour)
101 mask
= new wxMask(bmp
, *wxLIGHT_GREY
);
105 iconInfo
.fIcon
= TRUE
; // we want an icon, not a cursor
106 iconInfo
.hbmMask
= wxInvertMask((HBITMAP
)mask
->GetMaskBitmap());
107 iconInfo
.hbmColor
= GetHbitmapOf(bmp
);
109 HICON hicon
= ::CreateIconIndirect(&iconInfo
);
112 wxLogLastError("CreateIconIndirect");
116 SetHICON((WXHICON
)hicon
);
117 SetSize(bmp
.GetWidth(), bmp
.GetHeight());
120 if ( !bmp
.GetMask() )
122 // we created the mask, now delete it
126 // there are some functions in curico.cpp which probably could be used
128 wxFAIL_MSG("not implemented");
132 void wxIcon::CreateIconFromXpm(const char **data
)
138 bool wxIcon::LoadFile(const wxString
& filename
,
140 int desiredWidth
, int desiredHeight
)
144 wxGDIImageHandler
*handler
= FindHandler(type
);
152 return handler
->Load(this, filename
, type
, desiredWidth
, desiredHeight
);