1 /********************************************************************************
2 * *
3 * I C O I c o n O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2001,2005 by Janusz Ganczarski. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXICOIcon.cpp,v 1.22 2005/01/16 16:06:07 fox Exp $ *
23 ********************************************************************************/
24 #include "xincs.h"
25 #include "fxver.h"
26 #include "fxdefs.h"
27 #include "FXHash.h"
28 #include "FXThread.h"
29 #include "FXMemoryStream.h"
30 #include "FXStream.h"
31 #include "FXString.h"
32 #include "FXSize.h"
33 #include "FXPoint.h"
34 #include "FXRectangle.h"
35 #include "FXRegistry.h"
36 #include "FXApp.h"
37 #include "FXICOIcon.h"
38
39
40 /*
41 Notes:
42 */
43
44 using namespace FX;
45
46 /*******************************************************************************/
47
48 namespace FX {
49
50
51 // Suggested file extension
52 const FXchar FXICOIcon::fileExt[]="ico";
53
54
55 // Object implementation
56 FXIMPLEMENT(FXICOIcon,FXIcon,NULL,0)
57
58
59 // Initialize nicely
FXICOIcon(FXApp * a,const void * pix,FXColor clr,FXuint opts,FXint w,FXint h)60 FXICOIcon::FXICOIcon(FXApp* a,const void *pix,FXColor clr,FXuint opts,FXint w,FXint h):FXIcon(a,NULL,clr,opts,w,h){
61 if(pix){
62 FXMemoryStream ms;
63 ms.open(FXStreamLoad,(FXuchar*)pix);
64 loadPixels(ms);
65 ms.close();
66 }
67 }
68
69
70 // Save object to stream
savePixels(FXStream & store) const71 FXbool FXICOIcon::savePixels(FXStream& store) const {
72 if(fxsaveICO(store,data,width,height,0,0)){
73 return TRUE;
74 }
75 return FALSE;
76 }
77
78
79 // Load object from stream
loadPixels(FXStream & store)80 FXbool FXICOIcon::loadPixels(FXStream& store){
81 FXColor *pixels; FXint w,h,hotx,hoty;
82 if(fxloadICO(store,pixels,w,h,hotx,hoty)){
83 setData(pixels,IMAGE_OWNED,w,h);
84 if(options&IMAGE_ALPHAGUESS) transp=guesstransp();
85 return TRUE;
86 }
87 return FALSE;
88 }
89
90
91 // Clean up
~FXICOIcon()92 FXICOIcon::~FXICOIcon(){
93 }
94
95 }
96