ReactOS  0.4.14-dev-41-g31d7680
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 
31 using namespace XMLStorage;
32 
33 #include "taskbar/favorites.h"
34 
35 
37 struct FileTypeInfo {
41 };
42 
43 struct FileTypeManager : public map<String, FileTypeInfo>
44 {
45  typedef map<String, FileTypeInfo> super;
46 
47  const FileTypeInfo& operator[](String ext);
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 
55 enum ICON_TYPE {
60 };
61 
62 enum ICON_ID {
65 
67  //ICID_DOCUMENT,
70 
92 
94 };
95 
96 struct 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;
107  int add_to_imagelist(HIMAGELIST himl, HDC hdc_wnd, COLORREF bk_color=GetSysColor(COLOR_WINDOW), HBRUSH bk_brush=GetSysColorBrush(COLOR_WINDOW)) 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 
115 protected:
119  int _sys_idx;
120 };
121 
122 struct SysCacheIcon : public Icon {
123  SysCacheIcon(int id, int sys_idx)
124  : Icon(IT_SYSCACHE, id, sys_idx) {}
125 };
126 
127 struct IconCache {
128  IconCache() : _himlSys_small(0) {}
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 
143  HIMAGELIST get_sys_imagelist() const {return _himlSys_small;}
144 
145  void free_icon(int icon_id);
146 
147 protected:
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 
180 extern HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd/*, int icon_size*/);
181 
183 extern int ImageList_AddAlphaIcon(HIMAGELIST himl, HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd);
184 
187 extern HICON get_window_icon_big(HWND hwnd, bool allow_from_class=true);
188 
189 
191 #ifdef _USE_HDESK
192 
193 typedef auto_ptr<struct DesktopThread> DesktopThreadPtr;
194 
195 struct 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 
206 typedef auto_ptr<Desktop> DesktopPtr;
207 typedef DesktopPtr DesktopRef;
208 
210 struct DesktopThread : public Thread
211 {
212  DesktopThread(Desktop& desktop)
213  : _desktop(desktop)
214  {
215  }
216 
217  int Run();
218 
219 protected:
220  Desktop& _desktop;
221 };
222 
223 #else
224 
226 
227 struct Desktop
228 {
230  WindowHandle _hwndForeground;
231  list<MinimizeStruct> _minimized;
232 };
234 
235 #endif
236 
237 
238 #define DESKTOP_COUNT 4
239 
240 struct 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 
258 extern struct ExplorerGlobals
259 {
260  ExplorerGlobals();
261 
262  void init(HINSTANCE hInstance);
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 
282  DWORD(STDAPICALLTYPE* _SHRestricted)(RESTRICTIONS);
283 
286 
290 
292 
296 
299 } g_Globals;
300 
301 
303 struct ResString : public String
304 {
305  ResString(UINT nid);
306 };
307 
309 struct ResIcon
310 {
311  ResIcon(UINT nid);
312 
313  operator HICON() const {return _hicon;}
314 
315 protected:
317 };
318 
320 struct SmallIcon
321 {
322  SmallIcon(UINT nid);
323 
324  operator HICON() const {return _hicon;}
325 
326 protected:
328 };
329 
331 struct ResIconEx
332 {
333  ResIconEx(UINT nid, int w, int h);
334 
335  operator HICON() const {return _hicon;}
336 
337 protected:
339 };
340 
342 extern void SetWindowIcon(HWND hwnd, UINT nid);
343 
345 struct ResBitmap
346 {
347  ResBitmap(UINT nid);
349 
350  operator HBITMAP() const {return _hBmp;}
351 
352 protected:
354 };
int add
Definition: i386-dis.c:3122
management of file types
Definition: globals.h:37
String _cfg_path
Definition: globals.h:295
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
ATOM _hframeClass
Definition: globals.h:274
static HICON
Definition: imagelist.c:84
convenient loading of standard (32x32) icon resources
Definition: globals.h:309
bool _neverShowExt
Definition: globals.h:40
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
HWND _hwndShellView
Definition: globals.h:288
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
bool _desktop_mode
Definition: globals.h:276
SysCacheIcon(int id, int sys_idx)
Definition: globals.h:123
String _cfg_dir
Definition: globals.h:294
list< MinimizeStruct > _minimized
Definition: globals.h:231
FileTypeManager _ftype_mgr
Definition: globals.h:284
NOTIFYICONDATA nid
Definition: magnifier.c:44
WORD ATOM
Definition: dimm.idl:113
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
HICON _hicon
Definition: globals.h:118
ICON_ID
Definition: globals.h:62
map< PidlCacheKey, ICON_ID > PidlCacheMap
Definition: globals.h:162
ICON_TYPE
Definition: globals.h:55
Desktop DesktopRef
Definition: globals.h:233
int _sys_idx
Definition: globals.h:119
PathCacheMap _pathCache
Definition: globals.h:155
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
static HDC
Definition: imagelist.c:92
HICON get_window_icon_big(HWND hwnd, bool allow_from_class=true)
Definition: taskbar.cpp:347
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
IconMap _icons
Definition: globals.h:151
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HICON _hicon
Definition: globals.h:338
static WCHAR String[]
Definition: stringtable.c:55
HBITMAP _hBmp
Definition: globals.h:353
HIMAGELIST himl
#define COLOR_WINDOW
Definition: winuser.h:908
#define DWORD
Definition: nt_native.h:44
DWORD WINAPI GetSysColor(_In_ int)
static int init
Definition: wintirpc.c:33
iterator for XML trees
Definition: xmlstorage.h:1493
BOOL extract(char *filename, const bin_file *bin)
Definition: mspatcha.c:158
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
RESTRICTIONS
Definition: shlobj.h:1537
HICON _hicon
Definition: globals.h:316
HIMAGELIST _himlSys_small
Definition: globals.h:165
set< HWND > _windows
Definition: globals.h:229
HINSTANCE hInstance
Definition: charmap.c:20
COLORREF bk_color
Definition: startmenu.cpp:1409
int _current_desktop
Definition: globals.h:253
ICON_TYPE _itype
Definition: globals.h:117
pair< HWND, DWORD > MinimizeStruct
desktop management
Definition: globals.h:225
String _displayname
Definition: globals.h:39
unsigned int idx
Definition: utils.c:41
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
convenient loading of icon resources with specified sizes
Definition: globals.h:331
char ext[3]
Definition: mkdosfs.c:358
struct tagRun Run
HICON get_hicon() const
Definition: globals.h:110
static CHAR Desktop[MAX_PATH]
Definition: dem.c:256
ICON_ID _id
Definition: globals.h:116
pair< String, pair< int, int > > IdxCacheKey
Definition: globals.h:157
convenient loading of small (16x16) icon resources
Definition: globals.h:320
map< IdxCacheKey, ICON_ID > IdxCacheMap
Definition: globals.h:158
XMLDoc _cfg
Definition: globals.h:293
DWORD COLORREF
Definition: windef.h:285
HWND _hwndDesktopBar
Definition: globals.h:287
bool _prescan_nodes
Definition: globals.h:277
PidlCacheMap _pidlcache
Definition: globals.h:163
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
UINT _cfStrFName
Definition: globals.h:271
map< CacheKey, ICON_ID > PathCacheMap
Definition: globals.h:154
Favorites _favorites
Definition: globals.h:297
map< int, Icon > IconMap
Definition: globals.h:150
GLbitfield flags
Definition: glext.h:7161
HINSTANCE _hInstance
Definition: globals.h:270
ICONCACHE_FLAGS
Definition: entries.h:66
WindowHandle _hwndForeground
Definition: globals.h:230
HDC hdc
Definition: main.c:9
#define STDAPICALLTYPE
Definition: guid.c:3
convenient loading of bitmap resources
Definition: globals.h:345
XML document holder.
Definition: xmlstorage.h:2702
uint32_t entry
Definition: isohybrid.c:63
pair< ShellPath, int > PidlCacheKey
Definition: globals.h:161
ICON_TYPE get_icontype() const
Definition: globals.h:111
map< String, FileTypeInfo > super
Definition: globals.h:45
static BOOL is_exe_file(LPCWSTR ext)
Definition: winefile.c:2856
HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd)
create a bitmap from an icon
Definition: explorer.cpp:332
structure containing global variables of Explorer
Definition: globals.h:258
pair< String, int > CacheKey
Definition: globals.h:153
HICON hIcon
Definition: msconfig.c:44
~ResBitmap()
Definition: globals.h:348
Definition: services.c:325
HWND _hMainWnd
Definition: globals.h:275
static HBITMAP create_bitmap(INT cx, INT cy, COLORREF color, const char *comment)
Definition: imagelist.c:940
Definition: _pair.h:47
unsigned int UINT
Definition: ndis.h:50
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
IdxCacheMap _idxCache
Definition: globals.h:159
Definition: globals.h:96
bool destroy()
Definition: globals.h:113
_Out_opt_ int * cx
Definition: commctrl.h:570
HICON _hicon
Definition: globals.h:327
Desktops _desktops
Definition: globals.h:291
GLenum GLuint id
Definition: glext.h:5579
int get_sysiml_idx() const
Definition: globals.h:109
static HBITMAP
Definition: button.c:44
HBRUSH bk_brush
Definition: startmenu.cpp:1410
convenient loading of string resources
Definition: globals.h:303
FILE * _log
Definition: globals.h:280
IconCache()
Definition: globals.h:128
HBRUSH WINAPI GetSysColorBrush(_In_ int)
Definition: _set.h:46
String _classname
Definition: globals.h:38
struct ExplorerGlobals g_Globals
static int s_next_id
Definition: globals.h:148
HWND _hwndDesktop
Definition: globals.h:289
HICON get_window_icon_small(HWND hwnd)
retrieve icon from window
Definition: taskbar.cpp:323
wrapper class for item ID lists
Definition: shellclasses.h:651
void SetWindowIcon(HWND hwnd, UINT nid)
set big and small icons out of the resources for a window
Definition: explorer.cpp:689
base of all file and directory entries
Definition: entries.h:82
String _favorites_path
Definition: globals.h:298
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
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
IconCache _icon_cache
Definition: globals.h:285
iconPos iconPos icon_size
Definition: startmenu.cpp:1416
HIMAGELIST get_sys_imagelist() const
Definition: globals.h:143