ReactOS 0.4.15-dev-5667-ged97270
StartMenu Struct Reference

#include <startmenu.h>

Inheritance diagram for StartMenu:
Collaboration diagram for StartMenu:

Public Types

typedef ExtContextMenuHandlerT< OwnerDrawParent< DialogWindow > > super
 
- Public Types inherited from ExtContextMenuHandlerT< OwnerDrawParent< DialogWindow > >
typedef OwnerDrawParent< DialogWindowsuper
 
- Public Types inherited from OwnerDrawParent< DialogWindow >
typedef DialogWindow super
 
- Public Types inherited from DialogWindow
typedef Window super
 
- Public Types inherited from Window
typedef map< HWND, Window * > WindowMap
 
typedef Window *(* CREATORFUNC) (HWND)
 
typedef Window *(* CREATORFUNC_INFO) (HWND, const void *)
 

Public Member Functions

 StartMenu (HWND hwnd, int icon_size=ICON_SIZE_SMALL)
 
 StartMenu (HWND hwnd, const StartMenuCreateInfo &create_info, int icon_size=ICON_SIZE_SMALL)
 
 ~StartMenu ()
 
- Public Member Functions inherited from ExtContextMenuHandlerT< OwnerDrawParent< DialogWindow > >
 ExtContextMenuHandlerT (HWND hwnd)
 
 ExtContextMenuHandlerT (HWND hwnd, const PARA &info)
 
LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
 
- Public Member Functions inherited from OwnerDrawParent< DialogWindow >
 OwnerDrawParent (HWND hwnd)
 
LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
 
- Public Member Functions inherited from DialogWindow
 DialogWindow (HWND hwnd)
 
 ~DialogWindow ()
 
- Public Member Functions inherited from Window
 Window (HWND hwnd)
 
virtual ~Window ()
 
LRESULT SendParent (UINT nmsg, WPARAM wparam=0, LPARAM lparam=0)
 
LRESULT PostParent (UINT nmsg, WPARAM wparam=0, LPARAM lparam=0)
 
 Window (INT cx, INT cy, BOOL fAutoHide=FALSE)
 
virtual ~Window ()
 
virtual LRESULT CALLBACK WindowProcDx (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void DoAction ()
 

Static Public Member Functions

static HWND Create (int x, int y, const StartMenuFolders &, HWND hwndParent, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void *info=NULL, const String &filter="")
 
- Static Public Member Functions inherited from Window
static HWND Create (CREATORFUNC creator, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
 
static HWND Create (CREATORFUNC_INFO creator, const void *info, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
 
static Windowcreate_mdi_child (const ChildWndInfo &info, const MDICREATESTRUCT &mcs, CREATORFUNC_INFO creator)
 
static LRESULT CALLBACK WindowWndProc (HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
 
static INT_PTR CALLBACK DialogProc (HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam)
 
static Windowget_window (HWND hwnd)
 get window controller from window handle
 
template<typename CLASS >
static CLASS * get_window (HWND hwnd)
 
static void register_pretranslate (HWND hwnd)
 
static void unregister_pretranslate (HWND hwnd)
 
static BOOL pretranslate_msg (LPMSG pmsg)
 
static void register_dialog (HWND hwnd)
 
static void unregister_dialog (HWND hwnd)
 
static BOOL dispatch_dialog_msg (LPMSG pmsg)
 
static int MessageLoop ()
 
static void CancelModes ()
 
static BOOL DoRegisterClass (HINSTANCE hInstance)
 
static HWND DoCreateMainWnd (HINSTANCE hInstance, LPCTSTR pszText, INT cx, INT cy, DWORD style=WS_POPUP|WS_THICKFRAME|WS_CLIPCHILDREN, DWORD exstyle=WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW|WS_EX_TOPMOST, BOOL fAutoHide=FALSE)
 
static INT DoMainLoop ()
 
static WindowGetAppbarData (HWND hwnd)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static DWORD WINAPI ActionThreadFunc (LPVOID args)
 

Static Public Attributes

static CREATORFUNC_INFO s_def_creator = STARTMENU_CREATOR(StartMenu)
 

Protected Types

enum  SCROLL_MODE { SCROLL_NOT , SCROLL_UP , SCROLL_DOWN }
 

Protected Member Functions

LRESULT Init (LPCREATESTRUCT pcs)
 
LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
 
int Command (int id, int code)
 
void ResizeButtons (int cx)
 
virtual void AddEntries ()
 
ShellEntryMap::iterator AddEntry (const String &title, ICON_ID icon_id, Entry *entry)
 
ShellEntryMap::iterator AddEntry (const String &title, ICON_ID icon_id=ICID_NONE, int id=-1)
 
ShellEntryMap::iterator AddEntry (const ShellFolder folder, ShellEntry *entry)
 
ShellEntryMap::iterator AddEntry (const ShellFolder folder, Entry *entry)
 
void AddShellEntries (const ShellDirectory &dir, int max=-1, const String &ignore="")
 
void AddButton (LPCTSTR title, ICON_ID icon_id=ICID_NONE, bool hasSubmenu=false, int id=-1, bool enabled=true)
 
void AddSeparator ()
 
bool CloseSubmenus ()
 
bool CloseOtherSubmenus (int id=0)
 
void CreateSubmenu (int id, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void *info=NULL)
 
bool CreateSubmenu (int id, int folder, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void *info=NULL)
 
bool CreateSubmenu (int id, int folder1, int folder2, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void *info=NULL)
 
void CreateSubmenu (int id, const StartMenuFolders &new_folders, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void *info=NULL)
 
void ActivateEntry (int id, const ShellEntrySet &entries)
 
virtual void CloseStartMenu (int id=0)
 close all windows of the start menu popup
 
bool GetButtonRect (int id, PRECT prect) const
 
void DrawFloatingButton (HDC hdc)
 
void GetFloatingButtonRect (LPRECT prect)
 
void GetArrowButtonRects (LPRECT prect_up, LPRECT prect_down, int icon_size)
 
void DrawArrows (HDC hdc, int icon_size)
 
void Paint (PaintCanvas &canvas)
 
void UpdateIcons ()
 
- Protected Member Functions inherited from Window
virtual LRESULT Init (LPCREATESTRUCT pcs)
 
virtual LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
 
virtual int Command (int id, int code)
 
virtual int Notify (int id, NMHDR *pnmh)
 
void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
 
void OnPaint (HWND hwnd)
 
void OnRButtonDown (HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
 
void OnKey (HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
 
void OnAppBarCallback (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL AppBar_Register (HWND hwnd)
 
BOOL AppBar_UnRegister (HWND hwnd)
 
BOOL AppBar_SetAutoHide (HWND hwnd, BOOL fHide)
 
BOOL AppBar_AutoHide (HWND hwnd)
 
BOOL AppBar_NoAutoHide (HWND hwnd)
 
BOOL AppBar_SetSide (HWND hwnd, UINT uSide)
 
void AppBar_SetAlwaysOnTop (HWND hwnd, BOOL fOnTop)
 
void AppBar_Hide (HWND hwnd)
 
void AppBar_UnHide (HWND hwnd)
 
void AppBar_SetAutoHideTimer (HWND hwnd)
 
void AppBar_SetAutoUnhideTimer (HWND hwnd)
 
void AppBar_Size (HWND hwnd)
 
void AppBar_QueryPos (HWND hwnd, LPRECT lprc)
 
void AppBar_QuerySetPos (UINT uEdge, LPRECT lprc, PAPPBARDATA pabd, BOOL fMove)
 
void AppBar_PosChanged (PAPPBARDATA pabd)
 
BOOL OnCreate (HWND hwnd, LPCREATESTRUCT lpCreateStruct)
 
void OnActivate (HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized)
 
void OnWindowPosChanged (HWND hwnd, const LPWINDOWPOS lpwpos)
 
void OnSize (HWND hwnd, UINT state, int cx, int cy)
 
void OnMove (HWND hwnd, int x, int y)
 
void OnNCDestroy (HWND hwnd)
 
void OnTimer (HWND hwnd, UINT id)
 
UINT OnNCHitTest (HWND hwnd, int x, int y)
 
void OnLButtonDown (HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
 
void OnMouseMove (HWND hwnd, int x, int y, UINT keyFlags)
 
void OnLButtonUp (HWND hwnd, int x, int y, UINT keyFlags)
 
void GetWorkArea (LPRECT prc) const
 

Static Protected Member Functions

static BtnWindowClassGetWndClasss ()
 
- Static Protected Member Functions inherited from Window
static Windowcreate_controller (HWND hwnd)
 create controller for a new window
 
static StaticWindowDataGetStaticWindowData ()
 
static LRESULT CALLBACK MDICBTHookProc (int code, WPARAM wparam, LPARAM lparam)
 
static LRESULT CALLBACK PropSheetCBTHookProc (int code, WPARAM wparam, LPARAM lparam)
 

Protected Attributes

int _next_id
 
ShellEntryMap _entries
 
StartMenuShellDirs _dirs
 
int _submenu_id
 
WindowHandle _submenu
 
int _border_left
 
int _border_top
 
int _bottom_max
 
bool _floating_btn
 
bool _arrow_btns
 
POINT _last_pos
 
enum StartMenu::SCROLL_MODE _scroll_mode
 
int _scroll_pos
 
int _invisible_lines
 
StartMenuCreateInfo _create_info
 
int _icon_size
 
- Protected Attributes inherited from ExtContextMenuHandlerT< OwnerDrawParent< DialogWindow > >
CtxMenuInterfaces _cm_ifs
 
- Protected Attributes inherited from Window
HWND m_hwnd
 
BOOL m_fAutoHide
 
BOOL m_fOnTop
 
BOOL m_fHiding
 
UINT m_uSide
 
LONG m_cxWidth
 
LONG m_cyHeight
 
LONG m_cxSave
 
LONG m_cySave
 
BOOL m_fAppBarRegd
 
BOOL m_fMoving
 
BOOL m_bDragged
 
POINT m_ptDragOn
 
RECT m_rcAppBar
 
RECT m_rcDrag
 

Additional Inherited Members

- Public Attributes inherited from Window
IAccessible IAccessible_iface
 
IOleWindow IOleWindow_iface
 
IEnumVARIANT IEnumVARIANT_iface
 
LONG ref
 
- Static Protected Attributes inherited from Window
static WindowMap s_wnd_map
 
static const voids_new_info = NULL
 
static CREATORFUNC s_window_creator = NULL
 
static HHOOK s_hcbtHook = 0
 
static WindowSet s_pretranslate_windows
 
static WindowSet s_dialogs
 

Detailed Description

Startmenu window. To create a start menu call its Create() function.

Definition at line 199 of file startmenu.h.

Member Typedef Documentation

◆ super

Member Enumeration Documentation

◆ SCROLL_MODE

Enumerator
SCROLL_NOT 
SCROLL_UP 
SCROLL_DOWN 

Definition at line 245 of file startmenu.h.

enum StartMenu::SCROLL_MODE _scroll_mode
@ SCROLL_NOT
Definition: startmenu.h:245
@ SCROLL_DOWN
Definition: startmenu.h:245

Constructor & Destructor Documentation

◆ StartMenu() [1/2]

StartMenu::StartMenu ( HWND  hwnd,
int  icon_size = ICON_SIZE_SMALL 
)

Definition at line 47 of file startmenu.cpp.

48 : super(hwnd),
50{
52 _submenu_id = 0;
53
54 _border_left = 0;
55 _border_top = 0;
57
58 _floating_btn = false;
59 _arrow_btns = false;
61 _scroll_pos = 0;
63
64 _last_pos = WindowRect(hwnd).pos();
65#ifdef _LIGHT_STARTMENU
66 _selected_id = -1;
67 _last_mouse_pos = 0;
68#endif
69}
#define IDC_FIRST_MENU
Definition: desktopbar.h:64
#define INT_MAX
Definition: limits.h:40
iconPos iconPos icon_size
Definition: startmenu.cpp:1416
ExtContextMenuHandlerT< OwnerDrawParent< DialogWindow > > super
Definition: startmenu.h:209
int _bottom_max
Definition: startmenu.h:239
int _next_id
Definition: startmenu.h:230
int _invisible_lines
Definition: startmenu.h:247
POINT _last_pos
Definition: startmenu.h:244
int _scroll_pos
Definition: startmenu.h:246
bool _arrow_btns
Definition: startmenu.h:242
int _icon_size
Definition: startmenu.h:251
int _border_top
Definition: startmenu.h:238
int _border_left
Definition: startmenu.h:237
bool _floating_btn
Definition: startmenu.h:241
int _submenu_id
Definition: startmenu.h:234
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ StartMenu() [2/2]

StartMenu::StartMenu ( HWND  hwnd,
const StartMenuCreateInfo create_info,
int  icon_size = ICON_SIZE_SMALL 
)

Definition at line 71 of file startmenu.cpp.

72 : super(hwnd),
73 _create_info(create_info),
75{
76 for(StartMenuFolders::const_iterator it=create_info._folders.begin(); it!=create_info._folders.end(); ++it)
77 if (*it)
79
81 _submenu_id = 0;
82
83 _border_left = 0;
84 _border_top = create_info._border_top;
86
87 _floating_btn = create_info._border_top? true: false;
88 _arrow_btns = false;
90 _scroll_pos = 0;
92
93 _last_pos = WindowRect(hwnd).pos();
94#ifdef _LIGHT_STARTMENU
95 _selected_id = -1;
96 _last_mouse_pos = 0;
97#endif
98}
void push_back(const_reference __x)
Definition: _list.h:509
_STLP_PRIV _List_iterator< ShellPath, _Const_traits< ShellPath > > const_iterator
Definition: _list.h:276
iterator begin()
Definition: _list.h:367
iterator end()
Definition: _list.h:370
ShellFolder & GetDesktopFolder()
shell folder entry
Definition: shellfs.h:54
StartMenuFolders _folders
Definition: startmenu.h:141
StartMenuShellDirs _dirs
Definition: startmenu.h:232
StartMenuCreateInfo _create_info
Definition: startmenu.h:249

◆ ~StartMenu()

StartMenu::~StartMenu ( )

Definition at line 100 of file startmenu.cpp.

101{
103}
#define PM_STARTMENU_CLOSED
Definition: startmenu.h:40
LRESULT SendParent(UINT nmsg, WPARAM wparam=0, LPARAM lparam=0)
Definition: window.cpp:657

Member Function Documentation

◆ ActivateEntry()

void StartMenu::ActivateEntry ( int  id,
const ShellEntrySet entries 
)
protected
Todo:
If the user explicitly clicked on a submenu, display this folder as floating start menu.
Todo:
launch in the background; specify correct HWND for error message box titles

Definition at line 1292 of file startmenu.cpp.

1293{
1294 StartMenuFolders new_folders;
1295 String title;
1296
1297 for(ShellEntrySet::const_iterator it=entries.begin(); it!=entries.end(); ++it) {
1298 Entry* entry = const_cast<Entry*>(*it);
1299
1300 if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1301
1303
1304 if (entry->_etype == ET_SHELL)
1305 new_folders.push_back(entry->create_absolute_pidl());
1306 else {
1308
1309 if (entry->get_path(path, COUNTOF(path)))
1310 new_folders.push_back(path);
1311 }
1312
1313 if (title.empty())
1314 title = entry->_display_name;
1315 } else {
1316 // The entry is no subdirectory, so there can only be one shell entry.
1317 assert(entries.size()==1);
1318
1319 HWND hparent = GetParent(_hwnd);
1320 ShellPath shell_path = entry->create_absolute_pidl();
1321
1322 // close start menus when launching the selected entry
1323 CloseStartMenu(id);
1324
1326 SHELLEXECUTEINFO shexinfo;
1327
1328 shexinfo.cbSize = sizeof(SHELLEXECUTEINFO);
1329 shexinfo.fMask = SEE_MASK_IDLIST; // SEE_MASK_INVOKEIDLIST is also possible.
1330 shexinfo.hwnd = hparent;
1331 shexinfo.lpVerb = NULL;
1332 shexinfo.lpFile = NULL;
1333 shexinfo.lpParameters = NULL;
1334 shexinfo.lpDirectory = NULL;
1335 shexinfo.nShow = SW_SHOWNORMAL;
1336
1337 shexinfo.lpIDList = &*shell_path;
1338
1339 // add PIDL to the recent file list
1341
1342 if (!ShellExecuteEx(&shexinfo))
1343 display_error(hparent, GetLastError());
1344
1345 // we may have deleted 'this' - ensure we leave the loop and function
1346 return;
1347 }
1348 }
1349
1350 if (!new_folders.empty()) {
1351 // Only open one submenu at a time.
1352 if (!CloseOtherSubmenus(id))
1353 return;
1354
1355 CreateSubmenu(id, new_folders, title);
1356 }
1357}
bool empty() const
Definition: _list.h:177
iterator end()
Definition: _set.h:152
iterator begin()
Definition: _set.h:151
_Rep_type::const_iterator const_iterator
Definition: _set.h:74
size_type size() const
Definition: _set.h:160
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
#define assert(x)
Definition: debug.h:53
@ ET_SHELL
Definition: entries.h:37
uint32_t entry
Definition: isohybrid.c:63
void display_error(HWND hwnd, DWORD error)
Definition: utility.cpp:98
#define COUNTOF(x)
Definition: utility.h:93
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
static char title[]
Definition: ps.c:92
#define ShellExecuteEx
Definition: shellapi.h:691
SHELLEXECUTEINFOA SHELLEXECUTEINFO
Definition: shellapi.h:678
#define SEE_MASK_IDLIST
Definition: shellapi.h:27
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:809
#define SHARD_PIDL
Definition: shlobj.h:1101
base of all file and directory entries
Definition: entries.h:83
wrapper class for item ID lists
Definition: shellclasses.h:652
void CreateSubmenu(int id, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void *info=NULL)
Definition: startmenu.cpp:1217
bool CloseOtherSubmenus(int id=0)
Definition: startmenu.cpp:1197
virtual void CloseStartMenu(int id=0)
close all windows of the start menu popup
Definition: startmenu.cpp:1361
LPCSTR lpParameters
Definition: shellapi.h:313
LPCSTR lpDirectory
Definition: shellapi.h:314
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define SW_SHOWNORMAL
Definition: winuser.h:764
HWND WINAPI GetParent(_In_ HWND)
char TCHAR
Definition: xmlstorage.h:189

Referenced by Command().

◆ AddButton()

void StartMenu::AddButton ( LPCTSTR  title,
ICON_ID  icon_id = ICID_NONE,
bool  hasSubmenu = false,
int  id = -1,
bool  enabled = true 
)
protected

Definition at line 1137 of file startmenu.cpp.

1138{
1139#ifdef _LIGHT_STARTMENU
1140 _buttons.push_back(SMBtnInfo(title, icon_id, id, hasSubmenu, enabled));
1141#else
1143
1144 WindowRect rect(_hwnd);
1145 ClientRect clnt(_hwnd);
1146
1147 // increase window height to make room for the new button
1149
1150 // move down if we are too high now
1151 if (rect.top < 0) {
1154 }
1155
1156 WindowCanvas canvas(_hwnd);
1157 FontSelection font(canvas, GetStockFont(DEFAULT_GUI_FONT));
1158
1159 // widen window, if it is too small
1160 int text_width = GetStartMenuBtnTextWidth(canvas, title, _hwnd) + icon_size + 10/*placeholder*/ + 16/*arrow*/;
1161
1162 int cx = clnt.right - _border_left;
1163 if (text_width > cx)
1164 rect.right += text_width-cx;
1165
1166 MoveWindow(_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
1167
1168 StartMenuCtrl(_hwnd, _border_left, clnt.bottom, rect.right-rect.left-_border_left,
1169 title, id, g_Globals._icon_cache.get_icon(icon_id)._hIcon, hasSubmenu, style);
1170#endif
1171}
Arabic default style
Definition: afstyles.h:94
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
ExplorerGlobals g_Globals
Definition: explorer.cpp:52
Definition: mk_font.cpp:20
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define BS_OWNERDRAW
Definition: pedump.c:661
#define WS_DISABLED
Definition: pedump.c:621
_Out_opt_ int * cx
Definition: commctrl.h:585
& rect
Definition: startmenu.cpp:1413
int GetStartMenuBtnTextWidth(HDC hdc, LPCTSTR title, HWND hwnd)
Definition: startmenu.cpp:1371
#define STARTMENU_LINE_HEIGHT(icon_size)
Definition: startmenu.h:34
IconCache _icon_cache
Definition: globals.h:285
const Icon & get_icon(int icon_id)
Definition: explorer.cpp:625
#define GetStockFont(i)
Definition: windowsx.h:308
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by StartMenuRoot::AddEntries(), SettingsMenu::AddEntries(), BrowseMenu::AddEntries(), SearchMenu::AddEntries(), FavoritesMenu::AddEntries(), Init(), and StartMenuRoot::Init().

◆ AddEntries()

void StartMenu::AddEntries ( )
protectedvirtual

Reimplemented in StartMenuRoot, SettingsMenu, BrowseMenu, SearchMenu, RecentStartMenu, and FavoritesMenu.

Definition at line 209 of file startmenu.cpp.

210{
211 for(StartMenuShellDirs::iterator it=_dirs.begin(); it!=_dirs.end(); ++it) {
212 StartMenuDirectory& smd = *it;
213 ShellDirectory& dir = smd._dir;
214
215 if (!dir._scanned) {
216 WaitCursor wait;
217
218#ifdef _LAZY_ICONEXTRACT
219 dir.smart_scan(SORT_NAME, SCAN_DONT_EXTRACT_ICONS); // lazy icon extraction, try to read directly from filesystem
220#else
221 dir.smart_scan(SORT_NAME);
222#endif
223 }
224
225 AddShellEntries(dir, -1, smd._ignore);
226 }
227}
unsigned int dir
Definition: maze.c:112
_STLP_PRIV _List_iterator< StartMenuDirectory, _Nonconst_traits< StartMenuDirectory > > iterator
Definition: _list.h:275
@ SCAN_DONT_EXTRACT_ICONS
Definition: entries.h:53
StartMenuDirectory is used to store the base directory of start menus.
Definition: startmenu.h:53
ShellDirectory _dir
Definition: startmenu.h:64
void AddShellEntries(const ShellDirectory &dir, int max=-1, const String &ignore="")
Definition: startmenu.cpp:243
#define SORT_NAME
Definition: xpath.c:439

Referenced by StartMenuRoot::AddEntries(), SettingsMenu::AddEntries(), BrowseMenu::AddEntries(), SearchMenu::AddEntries(), FavoritesMenu::AddEntries(), and Init().

◆ AddEntry() [1/4]

ShellEntryMap::iterator StartMenu::AddEntry ( const ShellFolder  folder,
Entry entry 
)
protected

Definition at line 1124 of file startmenu.cpp.

1125{
1126 ICON_ID icon_id;
1127
1128 if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1129 icon_id = ICID_APPS;
1130 else
1131 icon_id = (ICON_ID)/*@@*/ entry->_icon_id;
1132
1133 return AddEntry(entry->_display_name, icon_id, entry);
1134}
ICON_ID
Definition: globals.h:62
@ ICID_APPS
Definition: globals.h:75
ShellEntryMap::iterator AddEntry(const String &title, ICON_ID icon_id, Entry *entry)
Definition: startmenu.cpp:1068

◆ AddEntry() [2/4]

ShellEntryMap::iterator StartMenu::AddEntry ( const ShellFolder  folder,
ShellEntry entry 
)
protected

Definition at line 1112 of file startmenu.cpp.

1113{
1114 ICON_ID icon_id;
1115
1116 if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1117 icon_id = ICID_APPS;
1118 else
1119 icon_id = (ICON_ID)/*@@*/ entry->_icon_id;
1120
1121 return AddEntry(folder.get_name(entry->_pidl), icon_id, entry);
1122}
Definition: fci.c:116

◆ AddEntry() [3/4]

ShellEntryMap::iterator StartMenu::AddEntry ( const String title,
ICON_ID  icon_id,
Entry entry 
)
protected
Todo:
speed up by using a map indexed by name

Definition at line 1068 of file startmenu.cpp.

1069{
1070 // search for an already existing subdirectory entry with the same name
1071 if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1072 {
1073 for(ShellEntryMap::iterator it=_entries.begin(); it!=_entries.end(); ++it) {
1074 StartMenuEntry& sme = it->second;
1075
1076 if (!_tcsicmp(sme._title, title))
1077 {
1078 for(ShellEntrySet::iterator it2=sme._entries.begin(); it2!=sme._entries.end(); ++it2) {
1079 if ((*it2)->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1080 // merge the new shell entry with the existing of the same name
1081 sme._entries.insert(entry);
1082
1083 return it;
1084 }
1085 }
1086 }
1087 }
1088 }
1089
1090 ShellEntryMap::iterator sme = AddEntry(title, icon_id);
1091
1092 sme->second._entries.insert(entry);
1093
1094 return sme;
1095}
iterator end()
Definition: _map.h:165
_Rep_type::iterator iterator
Definition: _map.h:85
iterator begin()
Definition: _map.h:163
pair< iterator, bool > insert(const value_type &__x)
Definition: _set.h:168
_Rep_type::iterator iterator
Definition: _set.h:73
structure holding information about one start menu entry
Definition: startmenu.h:73
ShellEntrySet _entries
Definition: startmenu.h:78
String _title
Definition: startmenu.h:76
ShellEntryMap _entries
Definition: startmenu.h:231
#define _tcsicmp
Definition: xmlstorage.h:205

Referenced by AddEntry(), and AddShellEntries().

◆ AddEntry() [4/4]

ShellEntryMap::iterator StartMenu::AddEntry ( const String title,
ICON_ID  icon_id = ICID_NONE,
int  id = -1 
)
protected

Definition at line 1097 of file startmenu.cpp.

1098{
1099 if (id == -1)
1100 id = ++_next_id;
1101
1102 StartMenuEntry sme;
1103
1104 sme._title = title;
1105 sme._icon_id = icon_id;
1106
1107 ShellEntryMap::iterator it = _entries.insert(make_pair(id, sme)).first;
1108
1109 return it;
1110}
pair< _T1, _T2 > _STLP_CALL make_pair(_T1 __x, _T2 __y)
Definition: _pair.h:124
pair< iterator, bool > insert(const value_type &__x)
Definition: _map.h:188
ICON_ID _icon_id
Definition: startmenu.h:77

◆ AddSeparator()

void StartMenu::AddSeparator ( )
protected

Definition at line 1173 of file startmenu.cpp.

1174{
1175#ifdef _LIGHT_STARTMENU
1176 _buttons.push_back(SMBtnInfo(NULL, ICID_NONE, -1, false));
1177#else
1178 WindowRect rect(_hwnd);
1179 ClientRect clnt(_hwnd);
1180
1181 // increase window height to make room for the new separator
1183
1184 // move down if we are too high now
1185 if (rect.top < 0) {
1188 }
1189
1190 MoveWindow(_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
1191
1192 StartMenuSeparator(_hwnd, _border_left, clnt.bottom, rect.right-rect.left-_border_left);
1193#endif
1194}
@ ICID_NONE
Definition: globals.h:64
#define STARTMENU_SEP_HEIGHT(icon_size)
Definition: startmenu.h:35
separator between start menu entries
Definition: startmenu.h:124

Referenced by StartMenuRoot::Init().

◆ AddShellEntries()

void StartMenu::AddShellEntries ( const ShellDirectory dir,
int  max = -1,
const String ignore = "" 
)
protected

Definition at line 243 of file startmenu.cpp.

244{
245 TCHAR ignore_path[MAX_PATH], ignore_dir[MAX_PATH], ignore_name[_MAX_FNAME], ignore_ext[_MAX_EXT];
246 TCHAR dir_path[MAX_PATH];
247
248 if (!ignore.empty()) {
249 _tsplitpath_s(ignore, ignore_path, COUNTOF(ignore_path), ignore_dir, COUNTOF(ignore_dir), ignore_name, COUNTOF(ignore_name), ignore_ext, COUNTOF(ignore_ext));
250
251 _tcscat(ignore_path, ignore_dir);
252 _tcscat(ignore_name, ignore_ext);
253
254 dir.get_path(dir_path, COUNTOF(dir_path));
255
256 if (_tcsicmp(trim_path_slash(dir_path), trim_path_slash(ignore_path)))
257 *ignore_name = '\0';
258 } else
259 *ignore_name = '\0';
260
261 String lwr_filter = _create_info._filter;
262 lwr_filter.toLower();
263
264 int cnt = 0;
265 for(Entry*entry=dir._down; entry; entry=entry->_next) {
266 // hide files like "desktop.ini"
267 if (entry->_shell_attribs & SFGAO_HIDDEN)
268 //not appropriate for drive roots: if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
269 continue;
270
271 // hide "Programs" subfolders if requested
272 if (*ignore_name && !_tcsicmp(entry->_data.cFileName, ignore_name))
273 continue;
274
275 // only 'max' entries shall be added.
276 if (++cnt == max)
277 break;
278
279 // filter only non-directory entries
280 if (!(entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && !lwr_filter.empty()) {
281 String lwr_name = entry->_data.cFileName;
282 String lwr_disp = entry->_display_name;
283
284 lwr_name.toLower();
285 lwr_disp.toLower();
286
287 if (!_tcsstr(lwr_name,lwr_filter) && !_tcsstr(lwr_disp,lwr_filter))
288 continue;
289 }
290
291 if (entry->_etype == ET_SHELL)
292 AddEntry(dir._folder, static_cast<ShellEntry*>(entry));
293 else
294 AddEntry(dir._folder, entry);
295 }
296}
#define _tcscat
Definition: tchar.h:622
#define _tsplitpath_s
Definition: tchar.h:687
#define _MAX_FNAME
Definition: utility.h:74
#define _MAX_EXT
Definition: utility.h:76
static LPTSTR trim_path_slash(LPTSTR path)
Definition: startmenu.cpp:230
shell file/directory entry
Definition: shellfs.h:31
#define max(a, b)
Definition: svc.c:63
#define _tcsstr
Definition: xmlstorage.h:199

Referenced by AddEntries(), and RecentStartMenu::AddEntries().

◆ CloseOtherSubmenus()

bool StartMenu::CloseOtherSubmenus ( int  id = 0)
protected

Definition at line 1197 of file startmenu.cpp.

1198{
1199 if (_submenu) {
1200 if (IsWindow(_submenu)) {
1201 if (_submenu_id == id)
1202 return false;
1203 else {
1204 _submenu_id = 0;
1206 // _submenu should be reset automatically by PM_STARTMENU_CLOSED, but safety first...
1207 }
1208 }
1209
1210 _submenu = 0;
1211 }
1212
1213 return true;
1214}
WindowHandle _submenu
Definition: startmenu.h:235
BOOL WINAPI IsWindow(_In_opt_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by ActivateEntry(), CloseSubmenus(), FavoritesMenu::Command(), CreateSubmenu(), StartMenuRoot::ProcessKey(), and WndProc().

◆ CloseStartMenu()

void StartMenu::CloseStartMenu ( int  id = 0)
protectedvirtual

close all windows of the start menu popup

Reimplemented in StartMenuRoot.

Definition at line 1361 of file startmenu.cpp.

1362{
1363 if (!(GetWindowStyle(_hwnd) & WS_CAPTION)) { // don't automatically close floating menus
1364 if (!SendParent(PM_STARTENTRY_LAUNCHED, id, (LPARAM)_hwnd))
1365 DestroyWindow(_hwnd);
1366 } else if (_submenu) // instead close submenus of floating parent menus
1367 CloseSubmenus();
1368}
#define WS_CAPTION
Definition: pedump.c:624
#define PM_STARTENTRY_LAUNCHED
Definition: startmenu.h:41
bool CloseSubmenus()
Definition: startmenu.h:286
LONG_PTR LPARAM
Definition: windef.h:208
#define GetWindowStyle(hwnd)
Definition: windowsx.h:315

Referenced by ActivateEntry(), Command(), StartMenuHandler::Command(), FavoritesMenu::Command(), and WndProc().

◆ CloseSubmenus()

bool StartMenu::CloseSubmenus ( )
inlineprotected

Definition at line 286 of file startmenu.h.

286{return CloseOtherSubmenus();}

Referenced by CloseStartMenu(), StartMenuRoot::CloseStartMenu(), and WndProc().

◆ Command()

int StartMenu::Command ( int  id,
int  code 
)
protectedvirtual

Reimplemented from Window.

Reimplemented in StartMenuHandler, StartMenuRoot, and FavoritesMenu.

Definition at line 1041 of file startmenu.cpp.

1042{
1043#ifndef _LIGHT_STARTMENU
1044 switch(id) {
1045 case IDCANCEL:
1046 CloseStartMenu(id);
1047 break;
1048
1049 default: {
1050#endif
1052
1053 if (found != _entries.end()) {
1054 ActivateEntry(id, found->second._entries);
1055 return 0;
1056 }
1057
1058 return super::Command(id, code);
1059#ifndef _LIGHT_STARTMENU
1060 }
1061 }
1062
1063 return 0;
1064#endif
1065}
_STLP_TEMPLATE_FOR_CONT_EXT iterator find(const _KT &__x)
Definition: _map.h:210
void ActivateEntry(int id, const ShellEntrySet &entries)
Definition: startmenu.cpp:1292
virtual int Command(int id, int code)
Definition: window.cpp:285
Definition: inflate.c:139
#define IDCANCEL
Definition: winuser.h:825

Referenced by StartMenuHandler::Command(), and FavoritesMenu::Command().

◆ Create()

HWND StartMenu::Create ( int  x,
int  y,
const StartMenuFolders folders,
HWND  hwndParent,
LPCTSTR  title,
CREATORFUNC_INFO  creator = s_def_creator,
void info = NULL,
const String filter = "" 
)
static

Definition at line 118 of file startmenu.cpp.

120{
121 UINT style, ex_style;
122 int top_height;
123
124 if (hwndParent) {
126 ex_style = 0;
127 top_height = STARTMENU_TOP_BTN_SPACE;
128 } else {
130 ex_style = WS_EX_TOOLWINDOW;
131 top_height = 0;
132 }
133
136
137#ifndef _LIGHT_STARTMENU
139#endif
140
141 AdjustWindowRectEx(&rect, style, FALSE, ex_style);
142
143 StartMenuCreateInfo create_info;
144
145 create_info._folders = folders;
146 create_info._border_top = top_height;
147 create_info._creator = creator;
148 create_info._info = info;
149 create_info._filter = filter;
150
151 if (title)
152 create_info._title = title;
153
154 HWND hwnd = Window::Create(creator, &create_info, ex_style, GetWndClasss(), title,
155 style, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, hwndParent);
156
157 // make sure the window is not off the screen
159
160 return hwnd;
161}
static HWND hwndParent
Definition: cryptui.c:300
#define FALSE
Definition: types.h:117
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
#define ICON_SIZE_SMALL
Definition: globals.h:169
void MoveVisible(HWND hwnd)
Definition: utility.cpp:72
unsigned int UINT
Definition: ndis.h:50
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_POPUP
Definition: pedump.c:616
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define WS_THICKFRAME
Definition: pedump.c:630
#define STARTMENU_TOP_BTN_SPACE
Definition: startmenu.h:36
#define STARTMENU_WIDTH_MIN
Definition: startmenu.h:33
structor containing information for creating of start menus
Definition: startmenu.h:138
Window::CREATORFUNC_INFO _creator
Definition: startmenu.h:144
static BtnWindowClass & GetWndClasss()
Definition: startmenu.cpp:108
static HWND Create(CREATORFUNC creator, DWORD dwExStyle, LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, int w, int h, HWND hwndParent=0, HMENU hMenu=0)
Definition: window.cpp:87
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)

Referenced by CreateSubmenu(), and WndProc().

◆ CreateSubmenu() [1/4]

void StartMenu::CreateSubmenu ( int  id,
const StartMenuFolders new_folders,
LPCTSTR  title,
CREATORFUNC_INFO  creator = s_def_creator,
void info = NULL 
)
protected

Definition at line 1265 of file startmenu.cpp.

1266{
1267 // Only open one submenu at a time.
1268 if (!CloseOtherSubmenus(id))
1269 return;
1270
1271 RECT rect;
1272 int x, y;
1273
1274 if (GetButtonRect(id, &rect)) {
1275 ClientToScreen(_hwnd, &rect);
1276
1277 x = rect.right; // Submenus should overlap their parent a bit.
1278 const int icon_size = _icon_size;
1279 y = rect.top+STARTMENU_LINE_HEIGHT(icon_size) +_border_top/*own border*/ -STARTMENU_TOP_BTN_SPACE/*border of new submenu*/;
1280 } else {
1281 WindowRect pos(_hwnd);
1282
1283 x = pos.right;
1284 y = pos.top;
1285 }
1286
1287 _submenu_id = id;
1288 _submenu = StartMenu::Create(x, y, new_folders, _hwnd, title, creator, info, _create_info._filter);
1289}
GLuint id
Definition: glext.h:5910
bool GetButtonRect(int id, PRECT prect) const
Definition: startmenu.cpp:781
static HWND Create(int x, int y, const StartMenuFolders &, HWND hwndParent, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void *info=NULL, const String &filter="")
Definition: startmenu.cpp:118
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)

◆ CreateSubmenu() [2/4]

bool StartMenu::CreateSubmenu ( int  id,
int  folder,
LPCTSTR  title,
CREATORFUNC_INFO  creator = s_def_creator,
void info = NULL 
)
protected

Definition at line 1222 of file startmenu.cpp.

1223{
1224 try {
1225 SpecialFolderPath folder(folder_id, _hwnd);
1226
1227 StartMenuFolders new_folders;
1228 new_folders.push_back(folder);
1229
1230 CreateSubmenu(id, new_folders, title, creator, info);
1231
1232 return true;
1233 } catch(COMException&) {
1234 // ignore Exception and don't display anything
1236 _buttons[GetSelectionIndex()]._enabled = false; // disable entries for non-existing folders
1237 return false;
1238 }
1239}
Exception with context information.
Definition: shellclasses.h:114
Retrieval of special shell folder paths.
Definition: shellclasses.h:982

◆ CreateSubmenu() [3/4]

bool StartMenu::CreateSubmenu ( int  id,
int  folder1,
int  folder2,
LPCTSTR  title,
CREATORFUNC_INFO  creator = s_def_creator,
void info = NULL 
)
protected

Definition at line 1241 of file startmenu.cpp.

1242{
1243 StartMenuFolders new_folders;
1244
1245 try {
1246 new_folders.push_back(SpecialFolderPath(folder_id1, _hwnd));
1247 } catch(COMException&) {
1248 }
1249
1250 try {
1251 new_folders.push_back(SpecialFolderPath(folder_id2, _hwnd));
1252 } catch(COMException&) {
1253 }
1254
1255 if (!new_folders.empty()) {
1256 CreateSubmenu(id, new_folders, title, creator, info);
1257 return true;
1258 } else {
1260 _buttons[GetSelectionIndex()]._enabled = false; // disable entries for non-existing folders
1261 return false;
1262 }
1263}

◆ CreateSubmenu() [4/4]

void StartMenu::CreateSubmenu ( int  id,
LPCTSTR  title,
CREATORFUNC_INFO  creator = s_def_creator,
void info = NULL 
)
protected

Definition at line 1217 of file startmenu.cpp.

1218{
1219 CreateSubmenu(id, StartMenuFolders(), title, creator, info);
1220}
list< ShellPath > StartMenuFolders
Definition: startmenu.h:134

Referenced by ActivateEntry(), StartMenuHandler::Command(), FavoritesMenu::Command(), and CreateSubmenu().

◆ DrawArrows()

void StartMenu::DrawArrows ( HDC  hdc,
int  icon_size 
)
protected

Definition at line 835 of file startmenu.cpp.

836{
837 int cx = icon_size / 2;
838 int cy = icon_size / 4;
839
840 ResIconEx arrowUpIcon(IDI_ARROW_UP, cx, cy);
841 ResIconEx arrowDownIcon(IDI_ARROW_DOWN, cx, cy);
842
843 ClientRect clnt(_hwnd);
844
845 DrawIconEx(hdc, clnt.right/2-cx/2, _floating_btn?3:1, arrowUpIcon, cx, cy, 0, 0, DI_NORMAL);
846 DrawIconEx(hdc, clnt.right/2-cx/2, clnt.bottom-cy-1, arrowDownIcon, cx, cy, 0, 0, DI_NORMAL);
847}
#define IDI_ARROW_DOWN
Definition: resource.h:119
#define IDI_ARROW_UP
Definition: resource.h:118
HDC hdc
Definition: main.c:9
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
convenient loading of icon resources with specified sizes
Definition: globals.h:332
#define DI_NORMAL
Definition: wingdi.h:72
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997

Referenced by Paint().

◆ DrawFloatingButton()

void StartMenu::DrawFloatingButton ( HDC  hdc)
protected

Definition at line 816 of file startmenu.cpp.

817{
818 static ResIconEx floatingIcon(IDI_FLOATING, 8, 4);
819
820 ClientRect clnt(_hwnd);
821
822 DrawIconEx(hdc, clnt.right-12, 0, floatingIcon, 8, 4, 0, 0, DI_NORMAL);
823}
#define IDI_FLOATING
Definition: resource.h:80

Referenced by Paint().

◆ GetArrowButtonRects()

void StartMenu::GetArrowButtonRects ( LPRECT  prect_up,
LPRECT  prect_down,
int  icon_size 
)
protected

Definition at line 849 of file startmenu.cpp.

850{
851 int cx = icon_size / 2;
852 int cy = icon_size / 4;
853
854 GetClientRect(_hwnd, prect_up);
855 *prect_down = *prect_up;
856
857// prect_up->left = prect_up->right/2 - cx/2;
858// prect_up->right = prect_up->left + cy;
859 prect_up->right -= cx;
860 prect_up->top = _floating_btn? cy-1: 1;
861 prect_up->bottom = prect_up->top + cy;
862
863// prect_down->left = prect_down->right/2 - cx/2;
864// prect_down->right = prect_down->left + cy;
865 prect_down->right -= cx;
866 prect_down->top = prect_down->bottom - cy - 1;
867}
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by WndProc().

◆ GetButtonRect()

bool StartMenu::GetButtonRect ( int  id,
PRECT  prect 
) const
protected

Definition at line 781 of file startmenu.cpp.

782{
783#ifdef _LIGHT_STARTMENU
784 ClientRect clnt(_hwnd);
785 const int icon_size = _icon_size;
787
788 for(SMBtnVector::const_iterator it=_buttons.begin()+_scroll_pos; it!=_buttons.end(); ++it) {
789 const SMBtnInfo& info = *it;
790
792
793 if (info._id == id) {
794 *prect = rect;
795 return true;
796 }
797
798 rect.top = rect.bottom;
799 }
800
801 return false;
802#else
803 HWND btn = GetDlgItem(_hwnd, id);
804
805 if (btn) {
806 GetWindowRect(btn, prect);
807 ScreenToClient(_hwnd, prect);
808
809 return true;
810 } else
811 return false;
812#endif
813}
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by CreateSubmenu().

◆ GetFloatingButtonRect()

void StartMenu::GetFloatingButtonRect ( LPRECT  prect)
protected

Definition at line 825 of file startmenu.cpp.

826{
827 GetClientRect(_hwnd, prect);
828
829 prect->right -= 4;
830 prect->left = prect->right - 8;
831 prect->bottom = 4;
832}
LONG left
Definition: windef.h:306

Referenced by WndProc().

◆ GetWndClasss()

BtnWindowClass & StartMenu::GetWndClasss ( )
staticprotected

Definition at line 108 of file startmenu.cpp.

109{
110 static BtnWindowClass s_wcStartMenu(CLASSNAME_STARTMENU);
111
112 return s_wcStartMenu;
113}
#define CLASSNAME_STARTMENU
Definition: startmenu.h:29
window class with gray background color
Definition: window.h:249

Referenced by StartMenuRoot::Create(), and Create().

◆ Init()

LRESULT StartMenu::Init ( LPCREATESTRUCT  pcs)
protectedvirtual

Reimplemented from Window.

Reimplemented in StartMenuRoot.

Definition at line 164 of file startmenu.cpp.

165{
166 try {
167 AddEntries();
168
169 if (super::Init(pcs))
170 return 1;
171
172 // create buttons for registered entries in _entries
174 const StartMenuEntry& sme = it->second;
175 bool hasSubmenu = false;
176
177 for(ShellEntrySet::const_iterator it=sme._entries.begin(); it!=sme._entries.end(); ++it)
178 if ((*it)->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
179 hasSubmenu = true;
180
181#ifdef _LIGHT_STARTMENU
182 _buttons.push_back(SMBtnInfo(sme, it->first, hasSubmenu));
183#else
184 AddButton(sme._title, sme._hIcon, hasSubmenu, it->first);
185#endif
186 }
187
188#ifdef _LIGHT_STARTMENU
189 if (_buttons.empty())
190#else
191 if (!GetWindow(_hwnd, GW_CHILD))
192#endif
193 AddButton(ResString(IDS_EMPTY), ICID_NONE, false, 0, false);
194
195#ifdef _LIGHT_STARTMENU
196 ResizeToButtons();
197#endif
198
199#ifdef _LAZY_ICONEXTRACT
200 PostMessage(_hwnd, PM_UPDATE_ICONS, 0, 0);
201#endif
202 } catch(COMException& e) {
203 HandleException(e, pcs->hwndParent); // destroys the start menu window while switching focus
204 }
205
206 return 0;
207}
_Rep_type::const_iterator const_iterator
Definition: _map.h:86
#define e
Definition: ke_i.h:82
#define IDS_EMPTY
Definition: resource.h:17
void HandleException(COMException &e, HWND hwnd)
Exception Handler for COM exceptions.
#define PM_UPDATE_ICONS
Definition: startmenu.h:47
convenient loading of string resources
Definition: globals.h:304
void AddButton(LPCTSTR title, ICON_ID icon_id=ICID_NONE, bool hasSubmenu=false, int id=-1, bool enabled=true)
Definition: startmenu.cpp:1137
virtual void AddEntries()
Definition: startmenu.cpp:209
virtual LRESULT Init(LPCREATESTRUCT pcs)
Definition: window.cpp:241
#define PostMessage
Definition: winuser.h:5822
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define GW_CHILD
Definition: winuser.h:758

Referenced by StartMenuRoot::Init().

◆ Paint()

void StartMenu::Paint ( PaintCanvas &  canvas)
protected

Definition at line 870 of file startmenu.cpp.

871{
872 if (_floating_btn)
873 DrawFloatingButton(canvas);
874
875#ifdef _LIGHT_STARTMENU
876 if (_arrow_btns)
877 DrawArrows(canvas, _icon_size);
878
879 ClientRect clnt(_hwnd);
880 const int icon_size = _icon_size;
882
883 int sep_width = rect.right-rect.left - 4;
884
885 FontSelection font(canvas, GetStockFont(DEFAULT_GUI_FONT));
886 BkMode bk_mode(canvas, TRANSPARENT);
887
888 for(SMBtnVector::const_iterator it=_buttons.begin()+_scroll_pos; it!=_buttons.end(); ++it) {
889 const SMBtnInfo& btn = *it;
890
891 if (rect.top > canvas.rcPaint.bottom)
892 break;
893
894 if (btn._id == -1) { // a separator?
895 rect.bottom = rect.top + STARTMENU_SEP_HEIGHT(icon_size);
896
897 if (rect.bottom > _bottom_max)
898 break;
899
900 BrushSelection brush_sel(canvas, GetSysColorBrush(COLOR_BTNSHADOW));
901 PatBlt(canvas, rect.left+2, rect.top+STARTMENU_SEP_HEIGHT(icon_size)/2-1, sep_width, 1, PATCOPY);
902
904 PatBlt(canvas, rect.left+2, rect.top+STARTMENU_SEP_HEIGHT(icon_size)/2, sep_width, 1, PATCOPY);
905 } else {
907
908 if (rect.bottom > _bottom_max)
909 break;
910
911 if (rect.top >= canvas.rcPaint.top)
912 DrawStartMenuButton(canvas, rect, btn._title, btn, btn._id==_selected_id, false, _icon_size);
913 }
914
915 rect.top = rect.bottom;
916 }
917#endif
918}
void DrawStartMenuButton(HDC hdc, const RECT &rect, LPCTSTR title, HICON hIcon, bool hasSubmenu, bool enabled, bool has_focus, bool pushed, int icon_size)
void DrawArrows(HDC hdc, int icon_size)
Definition: startmenu.cpp:835
void DrawFloatingButton(HDC hdc)
Definition: startmenu.cpp:816
#define SelectBrush(hdc, hbr)
Definition: windowsx.h:515
#define TRANSPARENT
Definition: wingdi.h:950
#define PATCOPY
Definition: wingdi.h:335
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define COLOR_BTNSHADOW
Definition: winuser.h:924
#define COLOR_BTNHIGHLIGHT
Definition: winuser.h:929

Referenced by StartMenuRoot::Paint(), and WndProc().

◆ ResizeButtons()

void StartMenu::ResizeButtons ( int  cx)
protected

Definition at line 1019 of file startmenu.cpp.

1020{
1021 HDWP hdwp = BeginDeferWindowPos(10);
1022
1024 ClientRect rt(ctrl);
1025
1026 if (rt.right != cx) {
1027 int height = rt.bottom - rt.top;
1028
1029 // special handling for separator controls
1031 height = 2;
1032
1034 }
1035 }
1036
1037 EndDeferWindowPos(hdwp);
1038}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ctrl
Definition: input.c:1756
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define SWP_NOMOVE
Definition: winuser.h:1234
#define SS_ETCHEDHORZ
Definition: winuser.h:343
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
#define GW_HWNDNEXT
Definition: winuser.h:756
#define SS_TYPEMASK
Definition: winuser.h:362
#define GetNextWindow(h, c)
Definition: winuser.h:4717
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOZORDER
Definition: winuser.h:1237
HDWP WINAPI BeginDeferWindowPos(_In_ int)

Referenced by WndProc().

◆ UpdateIcons()

void StartMenu::UpdateIcons ( )
protected

Referenced by WndProc().

◆ WndProc()

LRESULT StartMenu::WndProc ( UINT  nmsg,
WPARAM  wparam,
LPARAM  lparam 
)
protectedvirtual
Todo:
do something similar to StartMenuRoot::TrackStartmenu() in order to automatically close submenus when clicking on the desktop background
Todo:
use TrackMouseEvent() and WM_MOUSEHOVER to wait a bit before opening submenus

Reimplemented from Window.

Reimplemented in StartMenuRoot.

Definition at line 299 of file startmenu.cpp.

300{
301 switch(nmsg) {
302 case WM_PAINT: {
303 PaintCanvas canvas(_hwnd);
304 Paint(canvas);
305 break;}
306
307 case WM_SIZE:
309 break;
310
311 case WM_MOVE: {
312 POINTS pos;
313 pos.x = LOWORD(lparam);
314 pos.y = HIWORD(lparam);
315
316 // move open submenus of floating menus
317 if (_submenu) {
318 int dx = pos.x - _last_pos.x;
319 int dy = pos.y - _last_pos.y;
320
321 if (dx || dy) {
322 WindowRect rt(_submenu);
323 SetWindowPos(_submenu, 0, rt.left+dx, rt.top+dy, 0, 0, SWP_NOSIZE|SWP_NOACTIVATE);
324 //MoveVisible(_submenu);
325 }
326 }
327
328 _last_pos.x = pos.x;
329 _last_pos.y = pos.y;
330 goto def;}
331
332 case WM_NCHITTEST: {
334
335 if (res>=HTSIZEFIRST && res<=HTSIZELAST)
336 return HTCLIENT; // disable window resizing
337
338 return res;}
339
340 case WM_LBUTTONDOWN: {
341 RECT rect;
342
343 // check mouse cursor for coordinates of floating button
345
346 if (PtInRect(&rect, Point(lparam))) {
347 // create a floating copy of the current start menu
348 WindowRect pos(_hwnd);
349
353 }
354
355#ifdef _LIGHT_STARTMENU
356 int id = ButtonHitTest(Point(lparam));
357
358 if (id)
359 Command(id, BN_CLICKED);
360#endif
361 break;}
362
363 case WM_SYSCOMMAND:
364 if ((wparam&0xFFF0) == SC_SIZE)
365 return 0; // disable window resizing
366 goto def;
367
368 case WM_ACTIVATEAPP:
369 // close start menu when activating another application
370 if (!wparam)
372 break; // don't call super::WndProc in case "this" has been deleted
373
374 case WM_CANCELMODE:
376
377#ifdef _LIGHT_STARTMENU
378 if (_scroll_mode != SCROLL_NOT) {
380 KillTimer(_hwnd, 0);
381 }
382#endif
383 break;
384
385#ifdef _LIGHT_STARTMENU
386 case WM_MOUSEMOVE: {
387 // automatically set the focus to startmenu entries when moving the mouse over them
388 if (lparam != _last_mouse_pos) { // don't process WM_MOUSEMOVE when opening submenus using keyboard navigation
389 Point pt(lparam);
390
391 if (_arrow_btns) {
392 RECT rect_up, rect_down;
393
394 GetArrowButtonRects(&rect_up, &rect_down, _icon_size);
395
396 SCROLL_MODE scroll_mode = SCROLL_NOT;
397
398 if (PtInRect(&rect_up, pt))
399 scroll_mode = SCROLL_UP;
400 else if (PtInRect(&rect_down, pt))
401 scroll_mode = SCROLL_DOWN;
402
403 if (scroll_mode != _scroll_mode) {
404 if (scroll_mode == SCROLL_NOT) {
406 KillTimer(_hwnd, 0);
407 } else {
409 SetTimer(_hwnd, 0, 150, NULL); // 150 ms scroll interval
410 SetCapture(_hwnd);
411 }
412
413 _scroll_mode = scroll_mode;
414 }
415 }
416
417 int new_id = ButtonHitTest(pt);
418
419 if (new_id>0 && new_id!=_selected_id)
420 SelectButton(new_id);
421
422 _last_mouse_pos = lparam;
423 }
424 break;}
425
426 case WM_TIMER:
427 if (_scroll_mode == SCROLL_UP) {
428 if (_scroll_pos > 0) {
429 --_scroll_pos;
430 InvalidateRect(_hwnd, NULL, TRUE);
431 }
432 } else {
434 ++_scroll_pos;
435 InvalidateRect(_hwnd, NULL, TRUE);
436 }
437 }
438 break;
439
440 case WM_KEYDOWN:
441 ProcessKey(wparam);
442 break;
443#else
444 case PM_STARTENTRY_FOCUSED: {
445 BOOL hasSubmenu = wparam;
446 HWND hctrl = (HWND)lparam;
447
448 // automatically open submenus
449 if (hasSubmenu) {
450 UpdateWindow(_hwnd); // draw focused button before waiting on submenu creation
451 //SendMessage(_hwnd, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hctrl),BN_CLICKED), (LPARAM)hctrl);
453 } else {
454 // close any open submenu
456 }
457 break;}
458#endif
459
460#ifdef _LAZY_ICONEXTRACT
461 case PM_UPDATE_ICONS:
462 UpdateIcons(/*wparam*/);
463 break;
464#endif
465
467 if (GetWindowStyle(_hwnd) & WS_CAPTION) // don't automatically close floating menus
468 return 0;
469
470 // route message to the parent menu and close menus after launching an entry
471 if (!SendParent(nmsg, wparam, lparam))
473 return 1; // signal that we have received and processed the message
474
476 _submenu = 0;
477 break;
478
479 case PM_SELECT_ENTRY:
480 SelectButtonIndex(0, wparam!=0);
481 break;
482
483#ifdef _LIGHT_STARTMENU
484 case WM_CONTEXTMENU: {
485 Point screen_pt(lparam), clnt_pt=screen_pt;
486 ScreenToClient(_hwnd, &clnt_pt);
487
488 int id = ButtonHitTest(clnt_pt);
489
490 if (id) {
491 StartMenuEntry& sme = _entries[id];
492
493 for(ShellEntrySet::iterator it=sme._entries.begin(); it!=sme._entries.end(); ++it) {
494 Entry* entry = *it;
495
496 if (entry) {
497 CHECKERROR(entry->do_context_menu(_hwnd, screen_pt, _cm_ifs)); // may close start menu because of focus loss
499 break;
500 }
501 }
502 }
503 break;}
504#endif
505
506 default: def:
507 return super::WndProc(nmsg, wparam, lparam);
508 }
509
510 return 0;
511}
HANDLE HWND
Definition: compat.h:19
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint res
Definition: glext.h:9613
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
static UINT WPARAM wparam
Definition: combo.c:716
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define LOWORD(l)
Definition: pedump.c:82
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define CHECKERROR(hr)
Definition: shellclasses.h:162
#define PM_SELECT_ENTRY
Definition: startmenu.h:48
#define PM_STARTENTRY_FOCUSED
Definition: startmenu.h:44
Definition: shell.h:41
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
void ResizeButtons(int cx)
Definition: startmenu.cpp:1019
void Paint(PaintCanvas &canvas)
Definition: startmenu.cpp:870
void GetArrowButtonRects(LPRECT prect_up, LPRECT prect_down, int icon_size)
Definition: startmenu.cpp:849
void GetFloatingButtonRect(LPRECT prect)
Definition: startmenu.cpp:825
void UpdateIcons()
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_PAINT
Definition: winuser.h:1610
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define HTSIZELAST
Definition: winuser.h:2486
#define WM_SYSCOMMAND
Definition: winuser.h:1731
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_SIZE
Definition: winuser.h:1601
#define WM_CANCELMODE
Definition: winuser.h:1625
#define WM_NCHITTEST
Definition: winuser.h:1676
#define SWP_NOSIZE
Definition: winuser.h:1235
#define WM_MOUSEMOVE
Definition: winuser.h:1765
#define WM_LBUTTONDOWN
Definition: winuser.h:1766
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define SC_SIZE
Definition: winuser.h:2574
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define WM_TIMER
Definition: winuser.h:1732
BOOL WINAPI UpdateWindow(_In_ HWND)
#define HTCLIENT
Definition: winuser.h:2465
#define HTSIZEFIRST
Definition: winuser.h:2478
#define WM_MOVE
Definition: winuser.h:1600
#define WM_ACTIVATEAPP
Definition: winuser.h:1622
int WINAPI GetDlgCtrlID(_In_ HWND)
#define BN_CLICKED
Definition: winuser.h:1915
#define WM_KEYDOWN
Definition: winuser.h:1705
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by StartMenuRoot::WndProc().

Member Data Documentation

◆ _arrow_btns

bool StartMenu::_arrow_btns
protected

Definition at line 242 of file startmenu.h.

Referenced by Paint(), StartMenu(), and WndProc().

◆ _border_left

int StartMenu::_border_left
protected

◆ _border_top

int StartMenu::_border_top
protected

Definition at line 238 of file startmenu.h.

Referenced by CreateSubmenu(), GetButtonRect(), Paint(), and StartMenu().

◆ _bottom_max

int StartMenu::_bottom_max
protected

Definition at line 239 of file startmenu.h.

Referenced by Paint(), and StartMenu().

◆ _create_info

StartMenuCreateInfo StartMenu::_create_info
protected

Definition at line 249 of file startmenu.h.

Referenced by FavoritesMenu::AddEntries(), AddShellEntries(), CreateSubmenu(), and WndProc().

◆ _dirs

StartMenuShellDirs StartMenu::_dirs
protected

◆ _entries

ShellEntryMap StartMenu::_entries
protected

Definition at line 231 of file startmenu.h.

Referenced by AddEntry(), Command(), Init(), and WndProc().

◆ _floating_btn

bool StartMenu::_floating_btn
protected

Definition at line 241 of file startmenu.h.

Referenced by DrawArrows(), GetArrowButtonRects(), Paint(), and StartMenu().

◆ _icon_size

int StartMenu::_icon_size
protected

◆ _invisible_lines

int StartMenu::_invisible_lines
protected

Definition at line 247 of file startmenu.h.

Referenced by StartMenu(), and WndProc().

◆ _last_pos

POINT StartMenu::_last_pos
protected

Definition at line 244 of file startmenu.h.

Referenced by StartMenu(), and WndProc().

◆ _next_id

int StartMenu::_next_id
protected

Definition at line 230 of file startmenu.h.

Referenced by FavoritesMenu::AddEntries(), AddEntry(), and StartMenu().

◆ _scroll_mode

enum StartMenu::SCROLL_MODE StartMenu::_scroll_mode
protected

Referenced by StartMenu(), and WndProc().

◆ _scroll_pos

int StartMenu::_scroll_pos
protected

Definition at line 246 of file startmenu.h.

Referenced by GetButtonRect(), Paint(), StartMenu(), and WndProc().

◆ _submenu

WindowHandle StartMenu::_submenu
protected

◆ _submenu_id

int StartMenu::_submenu_id
protected

Definition at line 234 of file startmenu.h.

Referenced by CloseOtherSubmenus(), CreateSubmenu(), and StartMenu().

◆ s_def_creator

Window::CREATORFUNC_INFO StartMenu::s_def_creator = STARTMENU_CREATOR(StartMenu)
static

Definition at line 218 of file startmenu.h.


The documentation for this struct was generated from the following files: