]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/icon.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxIcon class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
27 #include "wx/os2/private.h"
32 IMPLEMENT_DYNAMIC_CLASS(wxIcon
, wxIconBase
)
34 // ============================================================================
36 // ============================================================================
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 void wxIconRefData::Free()
45 ::WinFreeFileIcon((HPOINTER
)m_hIcon
);
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
57 const char WXUNUSED(bits
)[]
58 , int WXUNUSED(nWidth
)
59 , int WXUNUSED(nHeight
)
65 const wxString
& rIconFile
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.
76 wxString sOs2Name
= rIconFile
.Mid(0, rIconFile
.Length() - 3);
78 sOs2Name
+= "Os2.ico";
90 void wxIcon::CreateIconFromXpm(
94 wxBitmap
vBmp(ppData
);
97 } // end of wxIcon::CreateIconFromXpm
99 void wxIcon::CopyFromBitmap(
103 wxMask
* pMask
= rBmp
.GetMask();
108 // We must have a mask for an icon, so even if it's probably incorrect,
109 // do create it (grey is the "standard" transparent colour)
111 pMask
= new wxMask( rBmp
116 POINTERINFO vIconInfo
;
118 memset(&vIconInfo
, '\0', sizeof(POINTERINFO
));
119 vIconInfo
.fPointer
= FALSE
; // we want an icon, not a pointer
120 vIconInfo
.hbmColor
= GetHbitmapOf(rBmp
);
122 SIZEL vSize
= {0, 0};
123 DEVOPENSTRUC vDop
= {0L, "DISPLAY", NULL
, 0L, 0L, 0L, 0L, 0L, 0L};
124 HDC hDCSrc
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
125 HDC hDCDst
= ::DevOpenDC(vHabmain
, OD_MEMORY
, "*", 5L, (PDEVOPENDATA
)&vDop
, NULLHANDLE
);
126 HPS hPSSrc
= ::GpiCreatePS(vHabmain
, hDCSrc
, &vSize
, PU_PELS
| GPIA_ASSOC
);
127 HPS hPSDst
= ::GpiCreatePS(vHabmain
, hDCDst
, &vSize
, PU_PELS
| GPIA_ASSOC
);
128 POINTL vPoint
[4] = { 0, 0, rBmp
.GetWidth(), rBmp
.GetHeight(),
129 0, 0, rBmp
.GetWidth(), rBmp
.GetHeight()
131 ::GpiSetBitmap(hPSSrc
, (HBITMAP
) pMask
->GetMaskBitmap());
132 ::GpiSetBitmap(hPSDst
, (HBITMAP
) vIconInfo
.hbmColor
);
141 ::GpiSetBitmap(hPSSrc
, NULL
);
142 ::GpiSetBitmap(hPSDst
, NULL
);
143 ::GpiDestroyPS(hPSSrc
);
144 ::GpiDestroyPS(hPSDst
);
145 ::DevCloseDC(hDCSrc
);
146 ::DevCloseDC(hDCDst
);
148 HICON hIcon
= ::WinCreatePointerIndirect( HWND_DESKTOP
154 wxLogLastError(wxT("WinCreatePointerIndirect"));
158 SetHICON((WXHICON
)hIcon
);
159 SetSize( rBmp
.GetWidth()
167 // We created the mask, now delete it
171 } // end of wxIcon::CopyFromBitmap
173 bool wxIcon::LoadFile(
174 const wxString
& rFilename
180 HPS hPs
= NULLHANDLE
;
184 wxGDIImageHandler
* pHandler
= FindHandler(lType
);
187 return(pHandler
->Load( this