diff --git a/reactos/subsys/system/explorer/dialogs/searchprogram.cpp b/reactos/subsys/system/explorer/dialogs/searchprogram.cpp index 2edc86ef44d..24a64247db9 100644 --- a/reactos/subsys/system/explorer/dialogs/searchprogram.cpp +++ b/reactos/subsys/system/explorer/dialogs/searchprogram.cpp @@ -344,7 +344,7 @@ int FindProgramDlg::Notify(int id, NMHDR* pnmh) Entry* entry = cache_entry._entry; if (entry->_icon_id == ICID_UNKNOWN) - entry->extract_icon(); + entry->extract_icon(false); pDispInfo->item.iImage = g_Globals._icon_cache.get_icon(entry->_icon_id).get_sysiml_idx(); pDispInfo->item.mask |= LVIF_DI_SETITEM; diff --git a/reactos/subsys/system/explorer/doc/changes.txt b/reactos/subsys/system/explorer/doc/changes.txt index 9a51dbcb130..e175f8cb64a 100644 --- a/reactos/subsys/system/explorer/doc/changes.txt +++ b/reactos/subsys/system/explorer/doc/changes.txt @@ -164,3 +164,4 @@ If you search for more information, look into the Subversion repository. 06.10.2005 m. fuchs implemented command line parser for Explorer 09.10.2005 m. fuchs Fix for Bugzilla Entry 330: Correctly handle WM_COMMAND messages in web windows without web control m. fuchs replace "search computer" start menu entry by a "not yet implemented" message +01.11.2005 m. fuchs String::str(), String::toLower() to allow conventient and WINE compatible string conversions diff --git a/reactos/subsys/system/explorer/explorer.cpp b/reactos/subsys/system/explorer/explorer.cpp index d8c342542bb..7d5826cfa35 100644 --- a/reactos/subsys/system/explorer/explorer.cpp +++ b/reactos/subsys/system/explorer/explorer.cpp @@ -246,10 +246,10 @@ Icon::Icon() { } -Icon::Icon(ICON_ID id, UINT nid) +Icon::Icon(ICON_ID id, UINT nid) //, int cx, int cy : _id(id), _itype(IT_STATIC), - _hicon(SmallIcon(nid)) + _hicon(ResIcon(nid)) // ResIconEx(nid, cx, cy) { } @@ -322,7 +322,24 @@ int Icon::add_to_imagelist(HIMAGELIST himl, HDC hdc_wnd, COLORREF bk_color, HBRU return ret; } -HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd) +HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd/*, bool big_icons*/) +{ + int cx = GetSystemMetrics(SM_CXSMICON); //ICON_SIZE_X; + int cy = GetSystemMetrics(SM_CYSMICON); //ICON_SIZE_Y; + HBITMAP hbmp = CreateCompatibleBitmap(hdc_wnd, cx, cy); + + MemCanvas canvas; + BitmapSelection sel(canvas, hbmp); + + RECT rect = {0, 0, cx, cy}; + FillRect(canvas, &rect, hbrush_bkgnd); + + DrawIconEx(canvas, 0, 0, hIcon, cx, cy, 0, hbrush_bkgnd, DI_NORMAL); + + return hbmp; +} + +HBITMAP create_small_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd) { int cx = GetSystemMetrics(SM_CXSMICON); int cy = GetSystemMetrics(SM_CYSMICON); @@ -379,7 +396,7 @@ void IconCache::init() } -const Icon& IconCache::extract(const String& path) +const Icon& IconCache::extract(LPCTSTR path, bool big_icons) { PathMap::iterator found = _pathMap.find(path); @@ -388,24 +405,32 @@ const Icon& IconCache::extract(const String& path) SHFILEINFO sfi; -#if 1 // use system image list - the "search program dialog" needs it - HIMAGELIST himlSys = (HIMAGELIST) SHGetFileInfo(path, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX|SHGFI_SMALLICON); + if (big_icons) { + if (SHGetFileInfo(path, 0, &sfi, sizeof(sfi), SHGFI_ICON)) { + const Icon& icon = add(sfi.hIcon, IT_CACHED); - if (himlSys) { - _himlSys = himlSys; + ///@todo limit cache size + _pathMap[path] = icon; - const Icon& icon = add(sfi.iIcon/*, IT_SYSCACHE*/); -#else - if (SHGetFileInfo(path, 0, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_SMALLICON)) { - const Icon& icon = add(sfi.hIcon, IT_CACHED); -#endif + return icon; + } + } else { + // use system image list - the "search program dialog" needs it + HIMAGELIST himlSys_small = (HIMAGELIST) SHGetFileInfo(path, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX|SHGFI_SMALLICON); - ///@todo limit cache size - _pathMap[path] = icon; + if (himlSys_small) { + _himlSys_small = himlSys_small; - return icon; - } else - return _icons[ICID_NONE]; + const Icon& icon = add(sfi.iIcon/*, IT_SYSCACHE*/); + + ///@todo limit cache size + _pathMap[path] = icon; + + return icon; + } + } + + return _icons[ICID_NONE]; } const Icon& IconCache::extract(LPCTSTR path, int idx) @@ -435,16 +460,23 @@ const Icon& IconCache::extract(LPCTSTR path, int idx) } } -const Icon& IconCache::extract(IExtractIcon* pExtract, LPCTSTR path, int idx) +const Icon& IconCache::extract(IExtractIcon* pExtract, LPCTSTR path, int idx, bool big_icons) { HICON hIconLarge = 0; HICON hIcon; - HRESULT hr = pExtract->Extract(path, idx, &hIconLarge, &hIcon, MAKELONG(0/*GetSystemMetrics(SM_CXICON)*/,GetSystemMetrics(SM_CXSMICON))); + HRESULT hr = pExtract->Extract(path, idx, &hIconLarge, &hIcon, MAKELONG(GetSystemMetrics(SM_CXICON), ICON_SIZE_X)); if (hr == NOERROR) { //@@ oder SUCCEEDED(hr) ? - if (hIconLarge) - DestroyIcon(hIconLarge); + if (big_icons) { //@@ OK? + if (hIcon) + DestroyIcon(hIcon); + + hIcon = hIconLarge; + } else { + if (hIconLarge) + DestroyIcon(hIconLarge); + } if (hIcon) return add(hIcon); diff --git a/reactos/subsys/system/explorer/globals.h b/reactos/subsys/system/explorer/globals.h index e28a9c3b2f8..89c400f38f0 100644 --- a/reactos/subsys/system/explorer/globals.h +++ b/reactos/subsys/system/explorer/globals.h @@ -114,19 +114,20 @@ struct SysCacheIcon : public Icon { }; struct IconCache { - IconCache() : _himlSys(0) {} + IconCache() : _himlSys_small(0) {} void init(); - const Icon& extract(const String& path); + const Icon& extract(LPCTSTR path, bool big_icons); const Icon& extract(LPCTSTR path, int idx); - const Icon& extract(IExtractIcon* pExtract, LPCTSTR path, int idx); + const Icon& extract(IExtractIcon* pExtract, LPCTSTR path, int idx, bool big_icons); const Icon& add(HICON hIcon, ICON_TYPE type=IT_DYNAMIC); const Icon& add(int sys_idx/*, ICON_TYPE type=IT_SYSCACHE*/); const Icon& get_icon(int icon_id); - HIMAGELIST get_sys_imagelist() const {return _himlSys;} + + HIMAGELIST get_sys_imagelist() const {return _himlSys_small;} void free_icon(int icon_id); @@ -143,12 +144,16 @@ protected: typedef map PathIdxMap; PathIdxMap _pathIdxMap; - HIMAGELIST _himlSys; + HIMAGELIST _himlSys_small; }; +#define ICON_SIZE_X GetSystemMetrics(big_icons? SM_CXICON: SM_CXSMICON) +#define ICON_SIZE_Y GetSystemMetrics(big_icons? SM_CYICON: SM_CYSMICON) + + /// create a bitmap from an icon -extern HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd); +extern HBITMAP create_bitmap_from_icon(HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd/*, bool big_icons*/); /// add icon with alpha channel to imagelist using the specified background color extern int ImageList_AddAlphaIcon(HIMAGELIST himl, HICON hIcon, HBRUSH hbrush_bkgnd, HDC hdc_wnd); diff --git a/reactos/subsys/system/explorer/res/arrow.ico b/reactos/subsys/system/explorer/res/arrow.ico index b4d86c69669..93f52e91db5 100644 Binary files a/reactos/subsys/system/explorer/res/arrow.ico and b/reactos/subsys/system/explorer/res/arrow.ico differ diff --git a/reactos/subsys/system/explorer/res/arrow_dwn.ico b/reactos/subsys/system/explorer/res/arrow_dwn.ico index e6a982ddad1..0932f7f3a59 100644 Binary files a/reactos/subsys/system/explorer/res/arrow_dwn.ico and b/reactos/subsys/system/explorer/res/arrow_dwn.ico differ diff --git a/reactos/subsys/system/explorer/res/arrow_up.ico b/reactos/subsys/system/explorer/res/arrow_up.ico index d5244d6a659..9e2ee4cd376 100644 Binary files a/reactos/subsys/system/explorer/res/arrow_up.ico and b/reactos/subsys/system/explorer/res/arrow_up.ico differ diff --git a/reactos/subsys/system/explorer/res/arrowsel.ico b/reactos/subsys/system/explorer/res/arrowsel.ico index ec7d66db93d..4235911bb6b 100644 Binary files a/reactos/subsys/system/explorer/res/arrowsel.ico and b/reactos/subsys/system/explorer/res/arrowsel.ico differ diff --git a/reactos/subsys/system/explorer/shell/entries.cpp b/reactos/subsys/system/explorer/shell/entries.cpp index f6c54a8e32b..829c77fdaae 100644 --- a/reactos/subsys/system/explorer/shell/entries.cpp +++ b/reactos/subsys/system/explorer/shell/entries.cpp @@ -319,14 +319,14 @@ void Entry::smart_scan(SORT_ORDER sortOrder, int scan_flags) } -void Entry::extract_icon() +void Entry::extract_icon(bool big_icons) { TCHAR path[MAX_PATH]; ICON_ID icon_id = ICID_NONE; if (get_path(path, COUNTOF(path)) && _tcsncmp(path,TEXT("::{"),3)) - icon_id = g_Globals._icon_cache.extract(path); + icon_id = g_Globals._icon_cache.extract(path, big_icons); if (icon_id == ICID_NONE) { IExtractIcon* pExtract; @@ -336,7 +336,7 @@ void Entry::extract_icon() if (SUCCEEDED(pExtract->GetIconLocation(GIL_FORSHELL, path, MAX_PATH, &idx, &flags))) { if (flags & GIL_NOTFILENAME) - icon_id = g_Globals._icon_cache.extract(pExtract, path, idx); + icon_id = g_Globals._icon_cache.extract(pExtract, path, idx, big_icons); else { if (idx == -1) idx = 0; // special case for some control panel applications ("System") @@ -374,11 +374,11 @@ void Entry::extract_icon() const ShellPath& pidl_abs = create_absolute_pidl(); LPCITEMIDLIST pidl = pidl_abs; - HIMAGELIST himlSys = (HIMAGELIST) SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX|SHGFI_PIDL|SHGFI_SMALLICON); + HIMAGELIST himlSys = (HIMAGELIST) SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX|SHGFI_PIDL|(big_icons? SHGFI_SMALLICON: 0)); if (himlSys) icon_id = g_Globals._icon_cache.add(sfi.iIcon); /* - if (SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_ICON|SHGFI_SMALLICON)) + if (SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_ICON|(g_Globals._big_icons? SHGFI_SMALLICON: 0))) icon_id = g_Globals._icon_cache.add(sfi.hIcon)._id; */ } diff --git a/reactos/subsys/system/explorer/shell/entries.h b/reactos/subsys/system/explorer/shell/entries.h index aaa10a7443a..40ff3c15411 100644 --- a/reactos/subsys/system/explorer/shell/entries.h +++ b/reactos/subsys/system/explorer/shell/entries.h @@ -48,7 +48,7 @@ enum SORT_ORDER { }; enum SCAN_FLAGS { - SCAN_EXTRACT_ICONS = 1, +// SCAN_EXTRACT_ICONS = 1, SCAN_DO_ACCESS = 2, SCAN_ALL = 3, @@ -103,7 +103,7 @@ public: Entry* read_tree(const void* path, SORT_ORDER sortOrder=SORT_NAME, int scan_flags=SCAN_ALL); void sort_directory(SORT_ORDER sortOrder); void smart_scan(SORT_ORDER sortOrder=SORT_NAME, int scan_flags=SCAN_ALL); - void extract_icon(); + void extract_icon(bool big_icons); virtual void read_directory(int scan_flags=SCAN_ALL) {} virtual const void* get_next_path_component(const void*) const {return NULL;} @@ -115,7 +115,7 @@ public: virtual HRESULT do_context_menu(HWND hwnd, const POINT& pos, CtxMenuInterfaces& cm_ifs); protected: - bool get_path_base(PTSTR path, size_t path_count, ENTRY_TYPE etype) const; + bool get_path_base(PTSTR path, size_t path_count, ENTRY_TYPE etype) const; }; diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index 5f96d669a04..1904203fcc2 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -149,9 +149,10 @@ int MainFrameBase::OpenShellFolders(LPIDA pida, HWND hFrameWnd) MainFrameBase::MainFrameBase(HWND hwnd) - : super(hwnd), - _himl(ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0)) + : super(hwnd) { + _himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0); + _hMenuFrame = GetMenu(hwnd); _hMenuWindow = GetSubMenu(_hMenuFrame, GetMenuItemCount(_hMenuFrame)-3); diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index cd63816fa0e..3da4962e0b4 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -252,13 +252,13 @@ void ShellBrowser::OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh) lpdi->item.pszText = entry->_data.cFileName; */ if (lpdi->item.mask & TVIF_IMAGE) - if ((HIMAGELIST)SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_LINKOVERLAY) == _himl) + if ((HIMAGELIST)SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_SYSICONINDEX|SHGFI_LINKOVERLAY|SHGFI_SMALLICON) == _himl) lpdi->item.iImage = sfi.iIcon; else lpdi->item.iImage = -1; if (lpdi->item.mask & TVIF_SELECTEDIMAGE) - if ((HIMAGELIST)SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_OPENICON) == _himl) + if ((HIMAGELIST)SHGetFileInfo((LPCTSTR)pidl, 0, &sfi, sizeof(sfi), SHGFI_PIDL|SHGFI_SYSICONINDEX|SHGFI_OPENICON|SHGFI_SMALLICON) == _himl) lpdi->item.iSelectedImage = sfi.iIcon; else lpdi->item.iSelectedImage = -1; diff --git a/reactos/subsys/system/explorer/shell/shellfs.cpp b/reactos/subsys/system/explorer/shell/shellfs.cpp index f0e5b421744..8fe89e19188 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.cpp +++ b/reactos/subsys/system/explorer/shell/shellfs.cpp @@ -58,38 +58,40 @@ bool ShellDirectory::fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN if (SUCCEEDED(hr)) { LPCTSTR path = (LPCTSTR)GlobalLock(medium.UNION_MEMBER(hGlobal)); - // fill with drive names "C:", ... - assert(_tcslen(path) < GlobalSize(medium.UNION_MEMBER(hGlobal))); - _tcscpy(pw32fdata->cFileName, path); + if (path) { + // fill with drive names "C:", ... + assert(_tcslen(path) < GlobalSize(medium.UNION_MEMBER(hGlobal))); + _tcscpy(pw32fdata->cFileName, path); - UINT sem_org = SetErrorMode(SEM_FAILCRITICALERRORS); + UINT sem_org = SetErrorMode(SEM_FAILCRITICALERRORS); - if (GetFileAttributesEx(path, GetFileExInfoStandard, &fad)) { - pw32fdata->dwFileAttributes = fad.dwFileAttributes; - pw32fdata->ftCreationTime = fad.ftCreationTime; - pw32fdata->ftLastAccessTime = fad.ftLastAccessTime; - pw32fdata->ftLastWriteTime = fad.ftLastWriteTime; + if (GetFileAttributesEx(path, GetFileExInfoStandard, &fad)) { + pw32fdata->dwFileAttributes = fad.dwFileAttributes; + pw32fdata->ftCreationTime = fad.ftCreationTime; + pw32fdata->ftLastAccessTime = fad.ftLastAccessTime; + pw32fdata->ftLastWriteTime = fad.ftLastWriteTime; - if (!(fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - pw32fdata->nFileSizeLow = fad.nFileSizeLow; - pw32fdata->nFileSizeHigh = fad.nFileSizeHigh; + if (!(fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { + pw32fdata->nFileSizeLow = fad.nFileSizeLow; + pw32fdata->nFileSizeHigh = fad.nFileSizeHigh; + } } + + HANDLE hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + + if (hFile != INVALID_HANDLE_VALUE) { + if (GetFileInformationByHandle(hFile, pbhfi)) + bhfi_valid = true; + + CloseHandle(hFile); + } + + SetErrorMode(sem_org); + + GlobalUnlock(medium.UNION_MEMBER(hGlobal)); + GlobalFree(medium.UNION_MEMBER(hGlobal)); } - - HANDLE hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, - 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); - - if (hFile != INVALID_HANDLE_VALUE) { - if (GetFileInformationByHandle(hFile, pbhfi)) - bhfi_valid = true; - - CloseHandle(hFile); - } - - SetErrorMode(sem_org); - - GlobalUnlock(medium.UNION_MEMBER(hGlobal)); - GlobalFree(medium.UNION_MEMBER(hGlobal)); } } } @@ -322,13 +324,13 @@ void ShellDirectory::read_directory(int scan_flags) if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) entry->_icon_id = ICID_FOLDER; - else if (scan_flags & SCAN_EXTRACT_ICONS) +/* else if (scan_flags & SCAN_EXTRACT_ICONS) try { - entry->extract_icon(); + entry->extract_icon(big_icons); } catch(COMException&) { // ignore unexpected exceptions while extracting icons } - +*/ last = entry; } while(FindNextFile(hFind, &w32fd)); @@ -428,13 +430,13 @@ void ShellDirectory::read_directory(int scan_flags) // get icons for files and virtual objects if (!(entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || !(attribs & SFGAO_FILESYSTEM)) { - if (scan_flags & SCAN_EXTRACT_ICONS) +/* if (scan_flags & SCAN_EXTRACT_ICONS) try { - entry->extract_icon(); + entry->extract_icon(big_icons); } catch(COMException&) { // ignore unexpected exceptions while extracting icons } - } else if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) +*/ } else if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) entry->_icon_id = ICID_FOLDER; else entry->_icon_id = ICID_NONE; // don't try again later @@ -486,13 +488,13 @@ Entry* ShellDirectory::find_entry(const void* p) return NULL; } -int ShellDirectory::extract_icons() +int ShellDirectory::extract_icons(bool big_icons) { int cnt = 0; for(Entry*entry=_down; entry; entry=entry->_next) if (entry->_icon_id == ICID_UNKNOWN) { - entry->extract_icon(); + entry->extract_icon(big_icons); if (entry->_icon_id != ICID_NONE) ++cnt; diff --git a/reactos/subsys/system/explorer/shell/shellfs.h b/reactos/subsys/system/explorer/shell/shellfs.h index 8b830c690ac..528b697cbbe 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.h +++ b/reactos/subsys/system/explorer/shell/shellfs.h @@ -105,7 +105,7 @@ struct ShellDirectory : public ShellEntry, public Directory virtual bool get_path(PTSTR path, size_t path_count) const; - int extract_icons(); + int extract_icons(bool big_icons); ShellFolder _folder; HWND _hwnd; diff --git a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp index 897547b8e02..6febe381bde 100644 --- a/reactos/subsys/system/explorer/taskbar/desktopbar.cpp +++ b/reactos/subsys/system/explorer/taskbar/desktopbar.cpp @@ -161,7 +161,7 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs) RegisterHotkeys(); // prepare Startmenu, but hide it for now - _startMenuRoot = GET_WINDOW(StartMenuRoot, StartMenuRoot::Create(_hwnd)); + _startMenuRoot = GET_WINDOW(StartMenuRoot, StartMenuRoot::Create(_hwnd, true)); //@@ _big_icons return 0; } diff --git a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp index ecfa6f3819f..9de2bf94e81 100644 --- a/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp +++ b/reactos/subsys/system/explorer/taskbar/quicklaunch.cpp @@ -105,7 +105,15 @@ void QuickLaunchBar::AddShortcuts() RecursiveCreateDirectory(path); _dir = new ShellDirectory(GetDesktopFolder(), path, _hwnd); - _dir->smart_scan(SORT_NAME, SCAN_EXTRACT_ICONS|SCAN_FILESYSTEM); + _dir->smart_scan(SORT_NAME, /*SCAN_EXTRACT_ICONS|*/SCAN_FILESYSTEM); + + // immediatelly extract the shortcut icons + for(Entry*entry=_dir->_down; entry; entry=entry->_next) + try { + entry->extract_icon(false); + } catch(COMException&) { + // ignore unexpected exceptions while extracting icons + } } catch(COMException&) { return; } diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index f13b11ce9da..02180850f06 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -46,8 +46,9 @@ #define SHELLPATH_NET_CONNECTIONS TEXT("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}") -StartMenu::StartMenu(HWND hwnd) - : super(hwnd) +StartMenu::StartMenu(HWND hwnd, bool big_icons) + : super(hwnd), + _big_icons(big_icons) { _next_id = IDC_FIRST_MENU; _submenu_id = 0; @@ -69,9 +70,10 @@ StartMenu::StartMenu(HWND hwnd) #endif } -StartMenu::StartMenu(HWND hwnd, const StartMenuCreateInfo& create_info) +StartMenu::StartMenu(HWND hwnd, const StartMenuCreateInfo& create_info, bool big_icons) : super(hwnd), - _create_info(create_info) + _create_info(create_info), + _big_icons(big_icons) { for(StartMenuFolders::const_iterator it=create_info._folders.begin(); it!=create_info._folders.end(); ++it) if (*it) @@ -115,7 +117,8 @@ BtnWindowClass& StartMenu::GetWndClasss() Window::CREATORFUNC_INFO StartMenu::s_def_creator = STARTMENU_CREATOR(StartMenu); -HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndParent, LPCTSTR title, CREATORFUNC_INFO creator, void* info, const String& filter) +HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndParent, LPCTSTR title, bool parent_big_icons, + CREATORFUNC_INFO creator, void* info, const String& filter) { UINT style, ex_style; int top_height; @@ -130,6 +133,7 @@ HWND StartMenu::Create(int x, int y, const StartMenuFolders& folders, HWND hwndP top_height = 0; } + bool big_icons = false; RECT rect = {x, y-STARTMENU_LINE_HEIGHT-top_height, x+STARTMENU_WIDTH_MIN, y}; #ifndef _LIGHT_STARTMENU @@ -344,7 +348,7 @@ LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) WindowRect pos(_hwnd); ///@todo do something similar to StartMenuRoot::TrackStartmenu() in order to automatically close submenus when clicking on the desktop background - StartMenu::Create(pos.left+3, pos.bottom-3, _create_info._folders, 0, _create_info._title, _create_info._creator, _create_info._info); + StartMenu::Create(pos.left+3, pos.bottom-3, _create_info._folders, 0, _create_info._title, _big_icons, _create_info._creator, _create_info._info); CloseStartMenu(); } @@ -511,6 +515,7 @@ LRESULT StartMenu::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) int StartMenu::ButtonHitTest(POINT pt) { ClientRect clnt(_hwnd); + const bool big_icons = _big_icons; RECT rect = {_border_left, _border_top, clnt.right, STARTMENU_LINE_HEIGHT}; if (pt.xrect.right) @@ -542,6 +547,7 @@ void StartMenu::InvalidateSelection() return; ClientRect clnt(_hwnd); + const bool big_icons = _big_icons; RECT rect = {_border_left, _border_top, clnt.right, STARTMENU_LINE_HEIGHT}; for(SMBtnVector::const_iterator it=_buttons.begin()+_scroll_pos; it!=_buttons.end(); ++it) { @@ -767,6 +773,7 @@ bool StartMenu::GetButtonRect(int id, PRECT prect) const { #ifdef _LIGHT_STARTMENU ClientRect clnt(_hwnd); + const bool big_icons = _big_icons; RECT rect = {_border_left, _border_top, clnt.right, STARTMENU_LINE_HEIGHT}; for(SMBtnVector::const_iterator it=_buttons.begin()+_scroll_pos; it!=_buttons.end(); ++it) { @@ -816,15 +823,18 @@ void StartMenu::GetFloatingButtonRect(LPRECT prect) } -void StartMenu::DrawArrows(HDC hdc) +void StartMenu::DrawArrows(HDC hdc, bool big_icons) { - static ResIconEx arrowUpIcon(IDI_ARROW_UP, 8, 4); - static ResIconEx arrowDownIcon(IDI_ARROW_DOWN, 8, 4); + int cx = big_icons? 16: 8; + int cy = big_icons? 8: 4; + + ResIconEx arrowUpIcon(IDI_ARROW_UP, cx, cy); + ResIconEx arrowDownIcon(IDI_ARROW_DOWN, cx, cy); ClientRect clnt(_hwnd); - DrawIconEx(hdc, clnt.right/2-4, _floating_btn?3:1, arrowUpIcon, 8, 4, 0, 0, DI_NORMAL); - DrawIconEx(hdc, clnt.right/2-4, clnt.bottom-5, arrowDownIcon, 8, 4, 0, 0, DI_NORMAL); + DrawIconEx(hdc, clnt.right/2-cx/2, _floating_btn?3:1, arrowUpIcon, cx, cy, 0, 0, DI_NORMAL); + DrawIconEx(hdc, clnt.right/2-cx/2, clnt.bottom-cy-1, arrowDownIcon, cx, cy, 0, 0, DI_NORMAL); } void StartMenu::GetArrowButtonRects(LPRECT prect_up, LPRECT prect_down) @@ -852,9 +862,10 @@ void StartMenu::Paint(PaintCanvas& canvas) #ifdef _LIGHT_STARTMENU if (_arrow_btns) - DrawArrows(canvas); + DrawArrows(canvas, _big_icons); ClientRect clnt(_hwnd); + const bool big_icons = _big_icons; RECT rect = {_border_left, _border_top, clnt.right, STARTMENU_LINE_HEIGHT}; int sep_width = rect.right-rect.left - 4; @@ -886,7 +897,7 @@ void StartMenu::Paint(PaintCanvas& canvas) break; if (rect.top >= canvas.rcPaint.top) - DrawStartMenuButton(canvas, rect, btn._title, btn, btn._id==_selected_id, false); + DrawStartMenuButton(canvas, rect, btn._title, btn, btn._id==_selected_id, false, _big_icons); } rect.top = rect.bottom; @@ -917,7 +928,7 @@ void StartMenu::UpdateIcons(/*int idx*/) if (entry->_icon_id == ICID_UNKNOWN) try { - entry->extract_icon(); + entry->extract_icon(_big_icons); } catch(COMException&) { // ignore unexpected exceptions while extracting icons } @@ -933,7 +944,7 @@ void StartMenu::UpdateIcons(/*int idx*/) break; WindowCanvas canvas(_hwnd); - DrawStartMenuButton(canvas, rect, NULL, btn, btn._id==_selected_id, false); + DrawStartMenuButton(canvas, rect, NULL, btn, btn._id==_selected_id, false, _big_icons); //InvalidateRect(_hwnd, &rect, FALSE); //UpdateWindow(_hwnd); @@ -1134,7 +1145,7 @@ void StartMenu::AddButton(LPCTSTR title, ICON_ID icon_id, bool hasSubmenu, int i FontSelection font(canvas, GetStockFont(DEFAULT_GUI_FONT)); // widen window, if it is too small - int text_width = GetStartMenuBtnTextWidth(canvas, title, _hwnd) + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/; + int text_width = GetStartMenuBtnTextWidth(canvas, title, _hwnd) + ICON_SIZE_X + 10/*placeholder*/ + 16/*arrow*/; int cx = clnt.right - _border_left; if (text_width > cx) @@ -1252,6 +1263,7 @@ void StartMenu::CreateSubmenu(int id, const StartMenuFolders& new_folders, LPCTS ClientToScreen(_hwnd, &rect); x = rect.right; // Submenus should overlap their parent a bit. + const bool big_icons = _big_icons; y = rect.top+STARTMENU_LINE_HEIGHT +_border_top/*own border*/ -STARTMENU_TOP_BTN_SPACE/*border of new submenu*/; } else { WindowRect pos(_hwnd); @@ -1261,7 +1273,7 @@ void StartMenu::CreateSubmenu(int id, const StartMenuFolders& new_folders, LPCTS } _submenu_id = id; - _submenu = StartMenu::Create(x, y, new_folders, _hwnd, title, creator, info, _create_info._filter); + _submenu = StartMenu::Create(x, y, new_folders, _hwnd, title, _big_icons, creator, info, _create_info._filter); } @@ -1353,10 +1365,10 @@ int GetStartMenuBtnTextWidth(HDC hdc, LPCTSTR title, HWND hwnd) } #ifdef _LIGHT_STARTMENU -void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, const SMBtnInfo& btn, bool has_focus, bool pushed) +void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, const SMBtnInfo& btn, bool has_focus, bool pushed, bool big_icons) #else void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, HICON hIcon, - bool hasSubmenu, bool enabled, bool has_focus, bool pushed); + bool hasSubmenu, bool enabled, bool has_focus, bool pushed, bool big_icons); #endif { UINT style = DFCS_BUTTONPUSH; @@ -1364,8 +1376,8 @@ void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, HICON hIcon, if (!btn._enabled) style |= DFCS_INACTIVE; - POINT iconPos = {rect.left+2, (rect.top+rect.bottom-16)/2}; - RECT textRect = {rect.left+16+4, rect.top+2, rect.right-4, rect.bottom-4}; + POINT iconPos = {rect.left+2, (rect.top+rect.bottom-ICON_SIZE_Y)/2}; + RECT textRect = {rect.left+ICON_SIZE_X+4, rect.top+2, rect.right-4, rect.bottom-4}; if (pushed) { style |= DFCS_PUSHED; @@ -1389,16 +1401,16 @@ void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, HICON hIcon, FillRect(hdc, &rect, bk_brush); if (btn._icon_id > ICID_NONE) - g_Globals._icon_cache.get_icon(btn._icon_id).draw(hdc, iconPos.x, iconPos.y, 16, 16, bk_color, bk_brush); + g_Globals._icon_cache.get_icon(btn._icon_id).draw(hdc, iconPos.x, iconPos.y, ICON_SIZE_X, ICON_SIZE_Y, bk_color, bk_brush/*, big_icons*/); // draw submenu arrow at the right if (btn._hasSubmenu) { - static SmallIcon arrowIcon(IDI_ARROW); - static SmallIcon selArrowIcon(IDI_ARROW_SELECTED); + ResIconEx arrowIcon(IDI_ARROW, ICON_SIZE_X, ICON_SIZE_Y); + ResIconEx selArrowIcon(IDI_ARROW_SELECTED, ICON_SIZE_X, ICON_SIZE_Y); - DrawIconEx(hdc, rect.right-16, iconPos.y, + DrawIconEx(hdc, rect.right-ICON_SIZE_X, iconPos.y, has_focus? selArrowIcon: arrowIcon, - 16, 16, 0, bk_brush, DI_NORMAL); + ICON_SIZE_X, ICON_SIZE_Y, 0, bk_brush, DI_NORMAL); } if (title) { @@ -1423,6 +1435,8 @@ void StartMenu::ResizeToButtons() WindowCanvas canvas(_hwnd); FontSelection font(canvas, GetStockFont(DEFAULT_GUI_FONT)); + const bool big_icons = _big_icons; + int max_width = STARTMENU_WIDTH_MIN; int height = 0; @@ -1439,7 +1453,7 @@ void StartMenu::ResizeToButtons() } // calculate new window size - int text_width = max_width + 16/*icon*/ + 10/*placeholder*/ + 16/*arrow*/; + int text_width = max_width + ICON_SIZE_X + 10/*placeholder*/ + 16/*arrow*/; RECT rt_hgt = {rect.left, rect.bottom-_border_top-height, rect.left+_border_left+text_width, rect.bottom}; AdjustWindowRectEx(&rt_hgt, GetWindowStyle(_hwnd), FALSE, GetWindowExStyle(_hwnd)); @@ -1529,7 +1543,7 @@ void StartMenuButton::DrawItem(LPDRAWITEMSTRUCT dis) StartMenuRoot::StartMenuRoot(HWND hwnd) - : super(hwnd) + : super(hwnd, true) ///@todo big icons in start menu root { #ifndef __MINGW32__ // SHRestricted() missing in MinGW (as of 29.10.2003) if (!g_Globals._SHRestricted || !SHRestricted(REST_NOCOMMONGROUPS)) @@ -1566,7 +1580,7 @@ void StartMenuRoot::ReadLogoSize() } -static void CalculateStartPos(HWND hwndOwner, RECT& rect) +static void CalculateStartPos(HWND hwndOwner, RECT& rect, bool big_icons) { WindowRect pos(hwndOwner); @@ -1582,11 +1596,11 @@ static void CalculateStartPos(HWND hwndOwner, RECT& rect) AdjustWindowRectEx(&rect, WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN|WS_VISIBLE, FALSE, 0); } -HWND StartMenuRoot::Create(HWND hwndOwner) +HWND StartMenuRoot::Create(HWND hwndOwner, bool big_icons) { RECT rect; - CalculateStartPos(hwndOwner, rect); + CalculateStartPos(hwndOwner, rect, big_icons); return Window::Create(WINDOW_CREATOR(StartMenuRoot), 0, GetWndClasss(), TITLE_STARTMENU, WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN, @@ -1607,7 +1621,7 @@ void StartMenuRoot::TrackStartmenu() // recalculate start menu root position RECT rect; - CalculateStartPos(GetParent(hwnd), rect); + CalculateStartPos(GetParent(hwnd), rect, _big_icons); SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, 0); diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.h b/reactos/subsys/system/explorer/taskbar/startmenu.h index 3c52bda10b3..53f8c2df999 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.h +++ b/reactos/subsys/system/explorer/taskbar/startmenu.h @@ -36,7 +36,7 @@ #define STARTMENU_WIDTH_MIN 120 -#define STARTMENU_LINE_HEIGHT 20 +#define STARTMENU_LINE_HEIGHT (ICON_SIZE_X+4) #define STARTMENU_SEP_HEIGHT (STARTMENU_LINE_HEIGHT/2) #define STARTMENU_TOP_BTN_SPACE 8 @@ -187,12 +187,12 @@ struct SMBtnInfo typedef vector SMBtnVector; -extern void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, const SMBtnInfo& btn, bool has_focus, bool pushed); +extern void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, const SMBtnInfo& btn, bool has_focus, bool pushed, bool big_icons); #else extern void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, HICON hIcon, - bool hasSubmenu, bool enabled, bool has_focus, bool pushed); + bool hasSubmenu, bool enabled, bool has_focus, bool pushed, bool big_icons); #endif @@ -214,11 +214,11 @@ struct StartMenu : typedef ExtContextMenuHandlerT > super; #endif - StartMenu(HWND hwnd); - StartMenu(HWND hwnd, const StartMenuCreateInfo& create_info); + StartMenu(HWND hwnd, bool big_icons=false); + StartMenu(HWND hwnd, const StartMenuCreateInfo& create_info, bool big_icons=false); ~StartMenu(); - static HWND Create(int x, int y, const StartMenuFolders&, HWND hwndParent, LPCTSTR title, + static HWND Create(int x, int y, const StartMenuFolders&, HWND hwndParent, LPCTSTR title, bool parent_big_icons, CREATORFUNC_INFO creator=s_def_creator, void* info=NULL, const String& filter=""); static CREATORFUNC_INFO s_def_creator; @@ -253,6 +253,8 @@ protected: StartMenuCreateInfo _create_info; // copy of the original create info + bool _big_icons; + #ifdef _LIGHT_STARTMENU SMBtnVector _buttons; int _selected_id; @@ -301,7 +303,7 @@ protected: void GetFloatingButtonRect(LPRECT prect); void GetArrowButtonRects(LPRECT prect_up, LPRECT prect_down); - void DrawArrows(HDC hdc); + void DrawArrows(HDC hdc, bool big_icons); void Paint(PaintCanvas& canvas); void UpdateIcons(/*int idx*/); @@ -336,13 +338,13 @@ struct StartMenuHandler : public StartMenu { typedef StartMenu super; - StartMenuHandler(HWND hwnd) - : super(hwnd) + StartMenuHandler(HWND hwnd, bool big_icons=false) + : super(hwnd, big_icons) { } - StartMenuHandler(HWND hwnd, const StartMenuCreateInfo& create_info) - : super(hwnd, create_info) + StartMenuHandler(HWND hwnd, const StartMenuCreateInfo& create_info, bool big_icons=false) + : super(hwnd, create_info, big_icons) { } @@ -363,7 +365,7 @@ struct StartMenuRoot : public StartMenuHandler StartMenuRoot(HWND hwnd); - static HWND Create(HWND hwndDesktopBar); + static HWND Create(HWND hwndDesktopBar, bool big_icons); void TrackStartmenu(); protected: