ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

startmenu.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2003, 2004 Martin Fuchs
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 
00020  //
00021  // Explorer and Desktop clone
00022  //
00023  // startmenu.h
00024  //
00025  // Martin Fuchs, 16.08.2003
00026  //
00027 
00028 
00029 #define CLASSNAME_STARTMENU     TEXT("ReactosStartmenuClass")
00030 #define TITLE_STARTMENU         TEXT("Start Menu")
00031 
00032 
00033 #define STARTMENU_WIDTH_MIN                 120
00034 #define STARTMENU_LINE_HEIGHT(icon_size)    (icon_size+4)
00035 #define STARTMENU_SEP_HEIGHT(icon_size)     (STARTMENU_LINE_HEIGHT(icon_size)/2)
00036 #define STARTMENU_TOP_BTN_SPACE             8
00037 
00038 
00039  // private message constants
00040 #define PM_STARTMENU_CLOSED     (WM_APP+0x11)
00041 #define PM_STARTENTRY_LAUNCHED  (WM_APP+0x12)
00042 
00043 #ifndef _LIGHT_STARTMENU
00044 #define PM_STARTENTRY_FOCUSED   (WM_APP+0x13)
00045 #endif
00046 
00047 #define PM_UPDATE_ICONS         (WM_APP+0x14)
00048 #define PM_SELECT_ENTRY         (WM_APP+0x15)
00049 
00050 
00052 struct StartMenuDirectory
00053 {
00054     StartMenuDirectory(const ShellDirectory& dir, const String& ignore="")
00055      :  _dir(dir), _ignore(ignore)
00056     {
00057     }
00058 
00059     ~StartMenuDirectory()
00060     {
00061         _dir.free_subentries();
00062     }
00063 
00064     ShellDirectory _dir;
00065     String  _ignore;
00066 };
00067 
00068 typedef list<StartMenuDirectory> StartMenuShellDirs;
00069 typedef set<Entry*> ShellEntrySet;
00070 
00072 struct StartMenuEntry
00073 {
00074     StartMenuEntry() : _icon_id(ICID_UNKNOWN) {}
00075 
00076     String  _title;
00077     ICON_ID _icon_id;
00078     ShellEntrySet _entries;
00079 };
00080 
00081 
00082 extern int GetStartMenuBtnTextWidth(HDC hdc, LPCTSTR title, HWND hwnd);
00083 
00084 
00085 #ifndef _LIGHT_STARTMENU
00086 
00090 struct StartMenuButton : public OwnerdrawnButton
00091 {
00092     typedef OwnerdrawnButton super;
00093 
00094     StartMenuButton(HWND hwnd, ICON_ID icon_id, bool hasSubmenu)
00095      :  super(hwnd), _hIcon(hIcon), _hasSubmenu(hasSubmenu) {}
00096 
00097 protected:
00098     LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
00099     virtual void DrawItem(LPDRAWITEMSTRUCT dis);
00100 
00101     ICON_ID _icon_id;
00102     bool    _hasSubmenu;
00103 };
00104 
00105 
00109 struct StartMenuCtrl : public Button
00110 {
00111     StartMenuCtrl(HWND parent, int x, int y, int w, LPCTSTR title,
00112                     UINT id, HICON hIcon=0, bool hasSubmenu=false, DWORD style=WS_VISIBLE|WS_CHILD|BS_OWNERDRAW, DWORD exStyle=0)
00113      :  Button(parent, title, x, y, w, STARTMENU_LINE_HEIGHT(icon_size), id, style, exStyle)
00114     {
00115         *new StartMenuButton(_hwnd, hIcon, hasSubmenu);
00116 
00117         SetWindowFont(_hwnd, GetStockFont(DEFAULT_GUI_FONT), FALSE);
00118     }
00119 };
00120 
00121 
00123 struct StartMenuSeparator : public Static
00124 {
00125     StartMenuSeparator(HWND parent, int x, int y, int w, DWORD style=WS_VISIBLE|WS_CHILD|WS_DISABLED|SS_ETCHEDHORZ, DWORD exStyle=0)
00126      :  Static(parent, NULL, x, y+STARTMENU_SEP_HEIGHT(icon_size)/2-1, w, 2, -1, style, exStyle)
00127     {
00128     }
00129 };
00130 
00131 #endif
00132 
00133 
00134 typedef list<ShellPath> StartMenuFolders;
00135 
00137 struct StartMenuCreateInfo
00138 {
00139     StartMenuCreateInfo() : _border_top(0) {}
00140 
00141     StartMenuFolders _folders;
00142     int     _border_top;
00143     String  _title;
00144     Window::CREATORFUNC_INFO _creator;
00145     void*   _info;
00146     String  _filter;
00147 };
00148 
00149 #define STARTMENU_CREATOR(WND_CLASS) WINDOW_CREATOR_INFO(WND_CLASS, StartMenuCreateInfo)
00150 
00151 typedef map<int, StartMenuEntry> ShellEntryMap;
00152 
00153 
00154 #ifdef _LIGHT_STARTMENU
00155 
00156 struct SMBtnInfo
00157 {
00158     SMBtnInfo(const StartMenuEntry& entry, int id, bool hasSubmenu=false, bool enabled=true)
00159      :  _title(entry._title),
00160         _icon_id(entry._icon_id),
00161         _id(id),
00162         _hasSubmenu(hasSubmenu),
00163         _enabled(enabled)
00164     {
00165     }
00166 
00167     SMBtnInfo(LPCTSTR title, ICON_ID icon_id, int id, bool hasSubmenu=false, bool enabled=true)
00168      :  _title(title),
00169         _icon_id(icon_id),
00170         _id(id),
00171         _hasSubmenu(hasSubmenu),
00172         _enabled(enabled)
00173     {
00174     }
00175 
00176     String  _title;
00177     ICON_ID _icon_id;
00178     int     _id;
00179     bool    _hasSubmenu;
00180     bool    _enabled;
00181 };
00182 
00183 typedef vector<SMBtnInfo> SMBtnVector;
00184 
00185 extern void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, const SMBtnInfo& btn, bool has_focus, bool pushed, int icon_size);
00186 
00187 #else
00188 
00189 extern void DrawStartMenuButton(HDC hdc, const RECT& rect, LPCTSTR title, HICON hIcon,
00190                                 bool hasSubmenu, bool enabled, bool has_focus, bool pushed, int icon_size);
00191 
00192 #endif
00193 
00194 
00199 struct StartMenu :
00200 #ifdef _LIGHT_STARTMENU
00201     public ExtContextMenuHandlerT<OwnerDrawParent<Window> >
00202 #else
00203     public ExtContextMenuHandlerT<OwnerDrawParent<DialogWindow> >
00204 #endif
00205 {
00206 #ifdef _LIGHT_STARTMENU
00207     typedef ExtContextMenuHandlerT<OwnerDrawParent<Window> > super;
00208 #else
00209     typedef ExtContextMenuHandlerT<OwnerDrawParent<DialogWindow> > super;
00210 #endif
00211 
00212     StartMenu(HWND hwnd, int icon_size=ICON_SIZE_SMALL);
00213     StartMenu(HWND hwnd, const StartMenuCreateInfo& create_info, int icon_size=ICON_SIZE_SMALL);
00214     ~StartMenu();
00215 
00216     static HWND Create(int x, int y, const StartMenuFolders&, HWND hwndParent, LPCTSTR title,
00217                         CREATORFUNC_INFO creator=s_def_creator, void* info=NULL, const String& filter="");
00218     static CREATORFUNC_INFO s_def_creator;
00219 
00220 protected:
00221      // overridden member functions
00222     LRESULT Init(LPCREATESTRUCT pcs);
00223     LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
00224     int     Command(int id, int code);
00225 
00226      // window class
00227     static BtnWindowClass& GetWndClasss();
00228 
00229      // data members
00230     int     _next_id;
00231     ShellEntryMap _entries;
00232     StartMenuShellDirs _dirs;
00233 
00234     int     _submenu_id;
00235     WindowHandle _submenu;
00236 
00237     int     _border_left;   // left border in pixels
00238     int     _border_top;    // top border in pixels
00239     int     _bottom_max;    // limit display area for long start menus
00240 
00241     bool    _floating_btn;
00242     bool    _arrow_btns;
00243 
00244     POINT   _last_pos;
00245     enum SCROLL_MODE {SCROLL_NOT, SCROLL_UP, SCROLL_DOWN} _scroll_mode;
00246     int     _scroll_pos;
00247     int     _invisible_lines;
00248 
00249     StartMenuCreateInfo _create_info;   // copy of the original create info
00250 
00251     int     _icon_size;
00252 
00253 #ifdef _LIGHT_STARTMENU
00254     SMBtnVector _buttons;
00255     int     _selected_id;
00256     LPARAM  _last_mouse_pos;
00257 
00258     void    ResizeToButtons();
00259     int     ButtonHitTest(POINT pt);
00260     void    InvalidateSelection();
00261     const SMBtnInfo* GetButtonInfo(int id) const;
00262     bool    SelectButton(int id, bool open_sub=true);
00263     bool    SelectButtonIndex(int idx, bool open_sub=true);
00264     int     GetSelectionIndex();
00265     virtual void ProcessKey(int vk);
00266     bool    Navigate(int step);
00267     bool    OpenSubmenu(bool select_first=false);
00268     bool    JumpToNextShortcut(char c);
00269 #endif
00270 
00271      // member functions
00272     void    ResizeButtons(int cx);
00273 
00274     virtual void AddEntries();
00275 
00276     ShellEntryMap::iterator AddEntry(const String& title, ICON_ID icon_id, Entry* entry);
00277     ShellEntryMap::iterator AddEntry(const String& title, ICON_ID icon_id=ICID_NONE, int id=-1);
00278     ShellEntryMap::iterator AddEntry(const ShellFolder folder, ShellEntry* entry);
00279     ShellEntryMap::iterator AddEntry(const ShellFolder folder, Entry* entry);
00280 
00281     void    AddShellEntries(const ShellDirectory& dir, int max=-1, const String& ignore="");
00282 
00283     void    AddButton(LPCTSTR title, ICON_ID icon_id=ICID_NONE, bool hasSubmenu=false, int id=-1, bool enabled=true);
00284     void    AddSeparator();
00285 
00286     bool    CloseSubmenus() {return CloseOtherSubmenus();}
00287     bool    CloseOtherSubmenus(int id=0);
00288     void    CreateSubmenu(int id, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void*info=NULL);
00289     bool    CreateSubmenu(int id, int folder, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void*info=NULL);
00290     bool    CreateSubmenu(int id, int folder1, int folder2, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void*info=NULL);
00291     void    CreateSubmenu(int id, const StartMenuFolders& new_folders, LPCTSTR title, CREATORFUNC_INFO creator=s_def_creator, void*info=NULL);
00292     void    ActivateEntry(int id, const ShellEntrySet& entries);
00293     virtual void CloseStartMenu(int id=0);
00294 
00295     bool    GetButtonRect(int id, PRECT prect) const;
00296 
00297     void    DrawFloatingButton(HDC hdc);
00298     void    GetFloatingButtonRect(LPRECT prect);
00299     void    GetArrowButtonRects(LPRECT prect_up, LPRECT prect_down, int icon_size);
00300 
00301     void    DrawArrows(HDC hdc, int icon_size);
00302 
00303     void    Paint(PaintCanvas& canvas);
00304     void    UpdateIcons(/*int idx*/);
00305 };
00306 
00307 
00308  // declare shell32's "Run..." dialog export function
00309 typedef void (WINAPI* RUNFILEDLG)(HWND hwndOwner, HICON hIcon, LPCSTR lpstrDirectory, LPCSTR lpstrTitle, LPCSTR lpstrDescription, UINT uFlags);
00310 
00311  //
00312  // Flags for RunFileDlg
00313  //
00314 
00315 #define RFF_NOBROWSE        0x01    // Removes the browse button.
00316 #define RFF_NODEFAULT       0x02    // No default item selected.
00317 #define RFF_CALCDIRECTORY   0x04    // Calculates the working directory from the file name.
00318 #define RFF_NOLABEL         0x08    // Removes the edit box label.
00319 #define RFF_NOSEPARATEMEM   0x20    // Removes the Separate Memory Space check box (Windows NT only).
00320 
00321 
00322  // declare more previously undocumented shell32 functions
00323 typedef void (WINAPI* EXITWINDOWSDLG)(HWND hwndOwner);
00324 typedef int (WINAPI* LOGOFFWINDOWSDIALOG)(UINT flags);
00325 typedef int (WINAPI* RESTARTWINDOWSDLG)(HWND hwndOwner, LPCWSTR reason, UINT flags);
00326 typedef int (WINAPI* RESTARTWINDOWSDLGEX)(HWND hWndOwner, LPCWSTR lpwstrReason, DWORD uFlags, DWORD uReason);
00327 typedef BOOL (WINAPI* SHFINDFILES)(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch);
00328 typedef BOOL (WINAPI* SHFINDCOMPUTER)(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch);
00329 
00330 
00332 struct StartMenuHandler : public StartMenu
00333 {
00334     typedef StartMenu super;
00335 
00336     StartMenuHandler(HWND hwnd, int icon_size=ICON_SIZE_SMALL)
00337      :  super(hwnd, icon_size)
00338     {
00339     }
00340 
00341     StartMenuHandler(HWND hwnd, const StartMenuCreateInfo& create_info, int icon_size=ICON_SIZE_SMALL)
00342      :  super(hwnd, create_info, icon_size)
00343     {
00344     }
00345 
00346 protected:
00347     int     Command(int id, int code);
00348 
00349     static void ShowLaunchDialog(HWND hwndOwner);
00350     static void ShowLogoffDialog(HWND hwndOwner);
00351     static void ShowRestartDialog(HWND hwndOwner, UINT flags);
00352     static void ShowSearchDialog();
00353     static void ShowSearchComputer();
00354 };
00355 
00356 
00357 struct StartMenuRootCreateInfo
00358 {
00359     int _icon_size;
00360 };
00361 
00362 
00364 struct StartMenuRoot : public StartMenuHandler
00365 {
00366     typedef StartMenuHandler super;
00367 
00368     StartMenuRoot(HWND hwnd, const StartMenuRootCreateInfo& info);
00369 
00370     static HWND Create(HWND hwndDesktopBar, int icon_size);
00371     void    TrackStartmenu();
00372     void    CloseStartMenu(int id=0);
00373     bool    IsStartMenuVisible() const;
00374     int Command(int id, int code);
00375 
00376     HWND    _hwndStartButton;
00377 
00378 protected:
00379     LRESULT Init(LPCREATESTRUCT pcs);
00380     LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
00381 
00382     SIZE    _logo_size;
00383 
00384     virtual void AddEntries();
00385     virtual void ProcessKey(int vk);
00386 
00387     void    Paint(PaintCanvas& canvas);
00388     
00389 
00390     void    ReadLogoSize();
00391     UINT    GetLogoResId();
00392 };
00393 
00394 
00396 struct SettingsMenu : public StartMenuHandler
00397 {
00398     typedef StartMenuHandler super;
00399 
00400     SettingsMenu(HWND hwnd, const StartMenuCreateInfo& create_info)
00401      :  super(hwnd, create_info)
00402     {
00403     }
00404 
00405 protected:
00406     virtual void AddEntries();
00407 };
00408 
00409 
00411 struct BrowseMenu : public StartMenuHandler
00412 {
00413     typedef StartMenuHandler super;
00414 
00415     BrowseMenu(HWND hwnd, const StartMenuCreateInfo& create_info)
00416      :  super(hwnd, create_info)
00417     {
00418     }
00419 
00420 protected:
00421     virtual void AddEntries();
00422 };
00423 
00424 
00426 struct SearchMenu : public StartMenuHandler
00427 {
00428     typedef StartMenuHandler super;
00429 
00430     SearchMenu(HWND hwnd, const StartMenuCreateInfo& create_info)
00431      :  super(hwnd, create_info)
00432     {
00433     }
00434 
00435 protected:
00436     virtual void AddEntries();
00437 };
00438 
00439 
00440 #define RECENT_DOCS_COUNT   20  ///@todo read max. count of entries from registry
00441 
00443 struct RecentStartMenu : public StartMenu
00444 {
00445     typedef StartMenu super;
00446 
00447     RecentStartMenu(HWND hwnd, const StartMenuCreateInfo& create_info)
00448      :  super(hwnd, create_info)
00449     {
00450     }
00451 
00452 protected:
00453     virtual void AddEntries();
00454 };
00455 
00456 
00457 #ifndef _SHELL32_FAVORITES
00458 
00459 typedef map<int, BookmarkNode> BookmarkMap;
00460 
00462 struct FavoritesMenu : public StartMenu
00463 {
00464     typedef StartMenu super;
00465 
00466     FavoritesMenu(HWND hwnd, const StartMenuCreateInfo& create_info)
00467      :  super(hwnd, create_info),
00468         _bookmarks(*(BookmarkList*)create_info._info)
00469     {
00470     }
00471 
00472 protected:
00473     virtual int Command(int id, int code);
00474     virtual void AddEntries();
00475 
00476     BookmarkList _bookmarks;
00477     BookmarkMap _entries;
00478 };
00479 
00480 #endif

Generated on Fri May 25 2012 04:16:47 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.