1 /********************************************************************************
2 *                                                                               *
3 *                        I C O   I c o n   O b j e c t                          *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 2001,2006 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.27 2006/01/22 17:58:31 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 // Suggested mime type
56 const FXchar FXICOIcon::mimeType[]="image/ico";
57 
58 
59 // Object implementation
60 FXIMPLEMENT(FXICOIcon,FXIcon,NULL,0)
61 
62 
63 // Initialize nicely
FXICOIcon(FXApp * a,const void * pix,FXColor clr,FXuint opts,FXint w,FXint h)64 FXICOIcon::FXICOIcon(FXApp* a,const void *pix,FXColor clr,FXuint opts,FXint w,FXint h):FXIcon(a,NULL,clr,opts,w,h){
65   if(pix){
66     FXMemoryStream ms;
67     ms.open(FXStreamLoad,(FXuchar*)pix);
68     loadPixels(ms);
69     ms.close();
70     }
71   }
72 
73 
74 // Save object to stream
savePixels(FXStream & store) const75 bool FXICOIcon::savePixels(FXStream& store) const {
76   if(fxsaveICO(store,data,width,height,0,0)){
77     return true;
78     }
79   return false;
80   }
81 
82 
83 // Load object from stream
loadPixels(FXStream & store)84 bool FXICOIcon::loadPixels(FXStream& store){
85   FXColor *pixels; FXint w,h,hotx,hoty;
86   if(fxloadICO(store,pixels,w,h,hotx,hoty)){
87     setData(pixels,IMAGE_OWNED,w,h);
88     if(options&IMAGE_ALPHAGUESS) transp=guesstransp();
89     return true;
90     }
91   return false;
92   }
93 
94 
95 // Clean up
~FXICOIcon()96 FXICOIcon::~FXICOIcon(){
97   }
98 
99 }
100