ReactOS 0.4.16-dev-336-gb667d82
globals.h
Go to the documentation of this file.
1/*
2 * Copyright 2003, 2004 Martin Fuchs
3 *
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.
8 *
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.
13 *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19
20 //
21 // Explorer clone
22 //
23 // globals.h
24 //
25 // Martin Fuchs, 23.07.2003
26 //
27
28
29#include "utility/xmlstorage.h"
30
31using namespace XMLStorage;
32
33#include "taskbar/favorites.h"
34
35
41};
42
43struct FileTypeManager : public map<String, FileTypeInfo>
44{
45 typedef map<String, FileTypeInfo> super;
46
48
49 static bool is_exe_file(LPCTSTR ext);
50
51 LPCTSTR set_type(struct Entry* entry, bool dont_hide_ext=false);
52};
53
54
60};
61
62enum ICON_ID {
65
67 //ICID_DOCUMENT,
70
92
94};
95
96struct Icon {
97 Icon();
98 Icon(ICON_ID id, UINT nid);
99 Icon(ICON_ID id, UINT nid, int icon_size);
100 Icon(ICON_TYPE itype, int id, HICON hIcon);
101 Icon(ICON_TYPE itype, int id, int sys_idx);
102
103 operator ICON_ID() const {return _id;}
104
105 void draw(HDC hdc, int x, int y, int cx, int cy, COLORREF bk_color, HBRUSH bk_brush) const;
106 HBITMAP create_bitmap(COLORREF bk_color, HBRUSH hbrBkgnd, HDC hdc_wnd) const;
108
109 int get_sysiml_idx() const {return _itype==IT_SYSCACHE? _sys_idx: -1;}
110 HICON get_hicon() const {return _itype!=IT_SYSCACHE? _hicon: 0;}
111 ICON_TYPE get_icontype() const { return _itype; }
112
113 bool destroy() {if (_itype == IT_DYNAMIC) {DestroyIcon(_hicon); return true;} else return false;}
114
115protected:
120};
121
122struct SysCacheIcon : public Icon {
123 SysCacheIcon(int id, int sys_idx)
124 : Icon(IT_SYSCACHE, id, sys_idx) {}
125};
126
127struct IconCache {
129
130 virtual ~IconCache();
131 void init();
132
134 const Icon& extract(LPCTSTR path, int icon_idx, ICONCACHE_FLAGS flags=ICF_HICON);
135 const Icon& extract(IExtractIcon* pExtract, LPCTSTR path, int icon_idx, ICONCACHE_FLAGS flags=ICF_HICON);
137
139 const Icon& add(int sys_idx/*, ICON_TYPE type=IT_SYSCACHE*/);
140
141 const Icon& get_icon(int icon_id);
142
144
145 void free_icon(int icon_id);
146
147protected:
148 static int s_next_id;
149
150 typedef map<int, Icon> IconMap;
152
153 typedef pair<String,int/*ICONCACHE_FLAGS*/> CacheKey;
154 typedef map<CacheKey, ICON_ID> PathCacheMap;
156
157 typedef pair<String,pair<int,int/*ICONCACHE_FLAGS*/> > IdxCacheKey;
158 typedef map<IdxCacheKey, ICON_ID> IdxCacheMap;
160
161 typedef pair<ShellPath,int/*ICONCACHE_FLAGS*/> PidlCacheKey;
162 typedef map<PidlCacheKey, ICON_ID> PidlCacheMap;
164
166};
167
168
169#define ICON_SIZE_SMALL 16 // GetSystemMetrics(SM_CXSMICON)
170#define ICON_SIZE_MIDDLE 24 // special size for start menu root icons
171#define ICON_SIZE_LARGE 32 // GetSystemMetrics(SM_CXICON)
172
173#define STARTMENUROOT_ICON_SIZE ICON_SIZE_MIDDLE // ICON_SIZE_LARGE
174
175#define ICON_SIZE_FROM_ICF(flags) (flags&ICF_LARGE? ICON_SIZE_LARGE: flags&ICF_MIDDLE? ICON_SIZE_MIDDLE: ICON_SIZE_SMALL)
176#define ICF_FROM_ICON_SIZE(size) (size>=ICON_SIZE_LARGE? ICF_LARGE: size>=ICON_SIZE_MIDDLE? ICF_MIDDLE: (ICONCACHE_FLAGS)0)
177
178
180extern HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd/*, int icon_size*/);
181
183extern int ImageList_AddAlphaIcon(HIMAGELIST himl, HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd);
184
187extern HICON get_window_icon_big(HWND hwnd, bool allow_from_class=true);
188
189
191#ifdef _USE_HDESK
192
193typedef auto_ptr<struct DesktopThread> DesktopThreadPtr;
194
195struct Desktop
196{
197 HDESK _hdesktop;
198// HWINSTA _hwinsta;
199 DesktopThreadPtr _pThread;
200 WindowHandle _hwndDesktop;
201
202 Desktop(HDESK hdesktop=0/*, HWINSTA hwinsta=0*/);
203 ~Desktop();
204};
205
206typedef auto_ptr<Desktop> DesktopPtr;
207typedef DesktopPtr DesktopRef;
208
210struct DesktopThread : public Thread
211{
212 DesktopThread(Desktop& desktop)
213 : _desktop(desktop)
214 {
215 }
216
217 int Run();
218
219protected:
220 Desktop& _desktop;
221};
222
223#else
224
226
228{
230 WindowHandle _hwndForeground;
232};
234
235#endif
236
237
238#define DESKTOP_COUNT 4
239
240struct Desktops : public vector<DesktopRef>
241{
242 Desktops();
243 ~Desktops();
244
245 void init();
246 void SwitchToDesktop(int idx);
247 void ToggleMinimize();
248
249#ifdef _USE_HDESK
250 DesktopRef& get_current_Desktop() {return (*this)[_current_desktop];}
251#endif
252
254};
255
256
258extern struct ExplorerGlobals
259{
261
263
264 void read_persistent();
265 void write_persistent();
266
267 XMLPos get_cfg();
268 XMLPos get_cfg(const char* path);
269
272
273#ifndef ROSSHELL
278#endif
279
281
283
286
290
292
296
300
301
303struct ResString : public String
304{
306};
307
310{
312
313 operator HICON() const {return _hicon;}
314
315protected:
317};
318
321{
323
324 operator HICON() const {return _hicon;}
325
326protected:
328};
329
332{
333 ResIconEx(UINT nid, int w, int h);
334
335 operator HICON() const {return _hicon;}
336
337protected:
339};
340
342extern void SetWindowIcon(HWND hwnd, UINT nid);
343
346{
349
350 operator HBITMAP() const {return _hBmp;}
351
352protected:
354};
HIMAGELIST himl
HINSTANCE hInstance
Definition: charmap.c:19
Definition: list.h:37
Definition: _set.h:50
WORD ATOM
Definition: dimm.idl:113
unsigned int idx
Definition: utils.c:41
static const WCHAR *const ext[]
Definition: module.c:53
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define STDAPICALLTYPE
Definition: guid.c:3
ICONCACHE_FLAGS
Definition: entries.h:66
@ ICF_HICON
Definition: entries.h:72
@ ICF_NORMAL
Definition: entries.h:67
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLbitfield flags
Definition: glext.h:7161
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLuint id
Definition: glext.h:5910
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum map
Definition: glfuncs.h:262
uint32_t entry
Definition: isohybrid.c:63
NOTIFYICONDATA nid
Definition: magnifier.c:44
pair< HWND, DWORD > MinimizeStruct
desktop management
Definition: globals.h:225
void SetWindowIcon(HWND hwnd, UINT nid)
set big and small icons out of the resources for a window
Definition: explorer.cpp:689
int ImageList_AddAlphaIcon(HIMAGELIST himl, HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd)
add icon with alpha channel to imagelist using the specified background color
Definition: explorer.cpp:366
Desktop DesktopRef
Definition: globals.h:233
ICON_ID
Definition: globals.h:62
@ ICID_INFO
Definition: globals.h:74
@ ICID_NETWORK
Definition: globals.h:80
@ ICID_DOCUMENTS
Definition: globals.h:72
@ ICID_DYNAMIC
Definition: globals.h:93
@ ICID_RECENT
Definition: globals.h:91
@ ICID_PRINTER
Definition: globals.h:79
@ ICID_CONTROLPAN
Definition: globals.h:87
@ ICID_RESTART
Definition: globals.h:84
@ ICID_SHUTDOWN
Definition: globals.h:83
@ ICID_EXPLORER
Definition: globals.h:69
@ ICID_SEARCH_DOC
Definition: globals.h:78
@ ICID_ACTION
Definition: globals.h:77
@ ICID_CONFIG
Definition: globals.h:71
@ ICID_FAVORITES
Definition: globals.h:73
@ ICID_COMPUTER
Definition: globals.h:81
@ ICID_SEARCH
Definition: globals.h:76
@ ICID_ADMIN
Definition: globals.h:90
@ ICID_DESKSETTING
Definition: globals.h:88
@ ICID_LOGOFF
Definition: globals.h:82
@ ICID_APP
Definition: globals.h:68
@ ICID_BOOKMARK
Definition: globals.h:85
@ ICID_UNKNOWN
Definition: globals.h:63
@ ICID_MINIMIZE
Definition: globals.h:86
@ ICID_NONE
Definition: globals.h:64
@ ICID_FOLDER
Definition: globals.h:66
@ ICID_APPS
Definition: globals.h:75
@ ICID_NETCONNS
Definition: globals.h:89
ICON_TYPE
Definition: globals.h:55
@ IT_SYSCACHE
Definition: globals.h:59
@ IT_DYNAMIC
Definition: globals.h:58
@ IT_STATIC
Definition: globals.h:56
@ IT_CACHED
Definition: globals.h:57
HICON get_window_icon_small(HWND hwnd)
retrieve icon from window
Definition: taskbar.cpp:323
HICON get_window_icon_big(HWND hwnd, bool allow_from_class=true)
Definition: taskbar.cpp:347
struct ExplorerGlobals g_Globals
HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd)
create a bitmap from an icon
Definition: explorer.cpp:332
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
static HBITMAP create_bitmap(void)
Definition: clipboard.c:534
HICON hIcon
Definition: msconfig.c:44
unsigned int UINT
Definition: ndis.h:50
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
RESTRICTIONS
Definition: shlobj.h:1641
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
iconPos iconPos icon_size
Definition: startmenu.cpp:1416
COLORREF bk_color
Definition: startmenu.cpp:1409
HBRUSH bk_brush
Definition: startmenu.cpp:1410
set< HWND > _windows
Definition: globals.h:229
list< MinimizeStruct > _minimized
Definition: globals.h:231
WindowHandle _hwndForeground
Definition: globals.h:230
void SwitchToDesktop(int idx)
Definition: desktop.cpp:163
void ToggleMinimize()
minimize/restore all windows on the desktop
Definition: desktop.cpp:229
void init()
Definition: desktop.cpp:77
Desktops()
Definition: desktop.cpp:64
int _current_desktop
Definition: globals.h:253
~Desktops()
Definition: desktop.cpp:69
base of all file and directory entries
Definition: entries.h:83
structure containing global variables of Explorer
Definition: globals.h:259
HINSTANCE _hInstance
Definition: globals.h:270
IconCache _icon_cache
Definition: globals.h:285
HWND _hwndDesktopBar
Definition: globals.h:287
Desktops _desktops
Definition: globals.h:291
String _favorites_path
Definition: globals.h:298
String _cfg_dir
Definition: globals.h:294
ATOM _hframeClass
Definition: globals.h:274
bool _prescan_nodes
Definition: globals.h:277
FileTypeManager _ftype_mgr
Definition: globals.h:284
XMLDoc _cfg
Definition: globals.h:293
void write_persistent()
Definition: explorer.cpp:109
FILE * _log
Definition: globals.h:280
UINT _cfStrFName
Definition: globals.h:271
void read_persistent()
Definition: explorer.cpp:84
bool _desktop_mode
Definition: globals.h:276
String _cfg_path
Definition: globals.h:295
HWND _hwndShellView
Definition: globals.h:288
DWORD(STDAPICALLTYPE *_SHRestricted)(RESTRICTIONS)
XMLPos get_cfg()
Definition: explorer.cpp:119
Favorites _favorites
Definition: globals.h:297
HWND _hwndDesktop
Definition: globals.h:289
HWND _hMainWnd
Definition: globals.h:275
management of file types
Definition: globals.h:37
String _classname
Definition: globals.h:38
bool _neverShowExt
Definition: globals.h:40
String _displayname
Definition: globals.h:39
map< String, FileTypeInfo > super
Definition: globals.h:45
static bool is_exe_file(LPCTSTR ext)
Definition: explorer.cpp:150
const FileTypeInfo & operator[](String ext)
Definition: explorer.cpp:179
LPCTSTR set_type(struct Entry *entry, bool dont_hide_ext=false)
Definition: explorer.cpp:213
pair< String, pair< int, int > > IdxCacheKey
Definition: globals.h:157
static int s_next_id
Definition: globals.h:148
pair< String, int > CacheKey
Definition: globals.h:153
map< int, Icon > IconMap
Definition: globals.h:150
void init()
Definition: explorer.cpp:381
virtual ~IconCache()
Definition: explorer.cpp:630
PathCacheMap _pathCache
Definition: globals.h:155
IconCache()
Definition: globals.h:128
pair< ShellPath, int > PidlCacheKey
Definition: globals.h:161
IdxCacheMap _idxCache
Definition: globals.h:159
map< PidlCacheKey, ICON_ID > PidlCacheMap
Definition: globals.h:162
const Icon & add(HICON hIcon, ICON_TYPE type=IT_DYNAMIC)
Definition: explorer.cpp:611
map< CacheKey, ICON_ID > PathCacheMap
Definition: globals.h:154
PidlCacheMap _pidlcache
Definition: globals.h:163
const Icon & extract(LPCTSTR path, ICONCACHE_FLAGS flags=ICF_NORMAL)
Definition: explorer.cpp:416
const Icon & get_icon(int icon_id)
Definition: explorer.cpp:625
map< IdxCacheKey, ICON_ID > IdxCacheMap
Definition: globals.h:158
IconMap _icons
Definition: globals.h:151
HIMAGELIST _himlSys_small
Definition: globals.h:165
void free_icon(int icon_id)
Definition: explorer.cpp:650
HIMAGELIST get_sys_imagelist() const
Definition: globals.h:143
Definition: globals.h:96
void draw(HDC hdc, int x, int y, int cx, int cy, COLORREF bk_color, HBRUSH bk_brush) const
Definition: explorer.cpp:277
Icon()
Definition: explorer.cpp:242
int get_sysiml_idx() const
Definition: globals.h:109
HICON get_hicon() const
Definition: globals.h:110
ICON_TYPE _itype
Definition: globals.h:117
int add_to_imagelist(HIMAGELIST himl, HDC hdc_wnd, COLORREF bk_color=GetSysColor(COLOR_WINDOW), HBRUSH bk_brush=GetSysColorBrush(COLOR_WINDOW)) const
Definition: explorer.cpp:306
bool destroy()
Definition: globals.h:113
ICON_TYPE get_icontype() const
Definition: globals.h:111
HICON _hicon
Definition: globals.h:118
ICON_ID _id
Definition: globals.h:116
int _sys_idx
Definition: globals.h:119
convenient loading of bitmap resources
Definition: globals.h:346
HBITMAP _hBmp
Definition: globals.h:353
~ResBitmap()
Definition: globals.h:348
convenient loading of icon resources with specified sizes
Definition: globals.h:332
HICON _hicon
Definition: globals.h:338
convenient loading of standard (32x32) icon resources
Definition: globals.h:310
HICON _hicon
Definition: globals.h:316
convenient loading of string resources
Definition: globals.h:304
wrapper class for item ID lists
Definition: shellclasses.h:652
convenient loading of small (16x16) icon resources
Definition: globals.h:321
HICON _hicon
Definition: globals.h:327
SysCacheIcon(int id, int sys_idx)
Definition: globals.h:123
XML document holder.
Definition: xmlstorage.h:2703
iterator for XML trees
Definition: xmlstorage.h:1494
Definition: _pair.h:47
struct tagRun Run
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:300
static int init
Definition: wintirpc.c:33
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_WINDOW
Definition: winuser.h:921
HBRUSH WINAPI GetSysColorBrush(_In_ int)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2105
const CHAR * LPCTSTR
Definition: xmlstorage.h:193