2 * Copyright 2003, 2004 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // Martin Fuchs, 23.07.2003
29 #include "utility/xmlstorage.h"
31 using namespace XMLStorage
;
33 #include "taskbar/favorites.h"
36 /// management of file types
43 struct FileTypeManager
: public map
<String
, FileTypeInfo
>
45 typedef map
<String
, FileTypeInfo
> super
;
47 const FileTypeInfo
& operator[](String ext
);
49 static bool is_exe_file(LPCTSTR ext
);
51 LPCTSTR
set_type(struct Entry
* entry
, bool dont_hide_ext
=false);
90 Icon(ICON_ID id
, UINT nid
);
91 Icon(ICON_TYPE itype
, int id
, HICON hIcon
);
92 Icon(ICON_TYPE itype
, int id
, int sys_idx
);
94 operator ICON_ID() const {return _id
;}
96 void draw(HDC hdc
, int x
, int y
, int cx
, int cy
, COLORREF bk_color
, HBRUSH bk_brush
) const;
97 HBITMAP
create_bitmap(COLORREF bk_color
, HBRUSH hbrBkgnd
, HDC hdc_wnd
) const;
98 int add_to_imagelist(HIMAGELIST himl
, HDC hdc_wnd
, COLORREF bk_color
=GetSysColor(COLOR_WINDOW
), HBRUSH bk_brush
=GetSysColorBrush(COLOR_WINDOW
)) const;
100 int get_sysiml_idx() const {return _itype
==IT_SYSCACHE
? _sys_idx
: -1;}
102 bool destroy() {if (_itype
== IT_DYNAMIC
) {DestroyIcon(_hicon
); return true;} else return false;}
111 struct SysCacheIcon
: public Icon
{
112 SysCacheIcon(int id
, int sys_idx
)
113 : Icon(IT_SYSCACHE
, id
, sys_idx
) {}
117 IconCache() : _himlSys(0) {}
121 const Icon
& extract(const String
& path
);
122 const Icon
& extract(LPCTSTR path
, int idx
);
123 const Icon
& extract(IExtractIcon
* pExtract
, LPCTSTR path
, int idx
);
125 const Icon
& add(HICON hIcon
, ICON_TYPE type
=IT_DYNAMIC
);
126 const Icon
& add(int sys_idx
/*, ICON_TYPE type=IT_SYSCACHE*/);
128 const Icon
& get_icon(int icon_id
);
129 HIMAGELIST
get_sys_imagelist() const {return _himlSys
;}
131 void free_icon(int icon_id
);
134 static int s_next_id
;
136 typedef map
<int, Icon
> IconMap
;
139 typedef map
<String
, ICON_ID
> PathMap
;
142 typedef pair
<String
, int> CachePair
;
143 typedef map
<CachePair
, ICON_ID
> PathIdxMap
;
144 PathIdxMap _pathIdxMap
;
150 /// create a bitmap from an icon
151 extern HBITMAP
create_bitmap_from_icon(HICON hIcon
, HBRUSH hbrush_bkgnd
, HDC hdc_wnd
);
153 /// add icon with alpha channel to imagelist using the specified background color
154 extern int ImageList_AddAlphaIcon(HIMAGELIST himl
, HICON hIcon
, HBRUSH hbrush_bkgnd
, HDC hdc_wnd
);
156 /// retrieve icon from window
157 extern HICON
get_window_icon_small(HWND hwnd
);
158 extern HICON
get_window_icon_big(HWND hwnd
, bool allow_from_class
=true);
161 /// desktop management
164 typedef auto_ptr
<struct DesktopThread
> DesktopThreadPtr
;
170 DesktopThreadPtr _pThread
;
171 WindowHandle _hwndDesktop
;
173 Desktop(HDESK hdesktop
=0/*, HWINSTA hwinsta=0*/);
177 typedef auto_ptr
<Desktop
> DesktopPtr
;
178 typedef DesktopPtr DesktopRef
;
180 /// Thread class for additional desktops
181 struct DesktopThread
: public Thread
183 DesktopThread(Desktop
& desktop
)
196 typedef pair
<HWND
, DWORD
> MinimizeStruct
;
201 WindowHandle _hwndForeground
;
202 list
<MinimizeStruct
> _minimized
;
204 typedef Desktop DesktopRef
;
209 #define DESKTOP_COUNT 4
211 struct Desktops
: public vector
<DesktopRef
>
217 void SwitchToDesktop(int idx
);
218 void ToggleMinimize();
221 DesktopRef
& get_current_Desktop() {return (*this)[_current_desktop
];}
224 int _current_desktop
;
228 /// structure containing global variables of Explorer
229 extern struct ExplorerGlobals
233 void init(HINSTANCE hInstance
);
235 void read_persistent();
236 void write_persistent();
239 XMLPos
get_cfg(const char* path
);
241 HINSTANCE _hInstance
;
253 #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003)
254 DWORD(STDAPICALLTYPE
* _SHRestricted
)(RESTRICTIONS
);
257 FileTypeManager _ftype_mgr
;
258 IconCache _icon_cache
;
260 HWND _hwndDesktopBar
;
270 Favorites _favorites
;
271 String _favorites_path
;
275 /// convenient loading of string resources
276 struct ResString
: public String
281 /// convenient loading of standard (32x32) icon resources
286 operator HICON() const {return _hicon
;}
292 /// convenient loading of small (16x16) icon resources
297 operator HICON() const {return _hicon
;}
303 /// convenient loading of icon resources with specified sizes
306 ResIconEx(UINT nid
, int w
, int h
);
308 operator HICON() const {return _hicon
;}
314 /// set big and small icons out of the resources for a window
315 extern void SetWindowIcon(HWND hwnd
, UINT nid
);
317 /// convenient loading of bitmap resources
321 ~ResBitmap() {DeleteObject(_hBmp
);}
323 operator HBITMAP() const {return _hBmp
;}