soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SMenuBar.h
1#ifndef __SMENUBAR__H__
2#define __SMENUBAR__H__
3
4#include <core/SWnd.h>
5#include <helper/SMenu.h>
6
7SNSBEGIN
8
9/**
10 * @class SMenuBarItem
11 * @brief Menu Bar Item
12 * @details Represents an item in the menu bar.
13 */
14class SMenuBarItem;
15
16/**
17 * @class SMenuBar
18 * @brief Menu Bar Control
19 * @details A control that displays a menu bar with multiple menu items.
20 */
21class SOUI_EXP SMenuBar : public SWindow {
22 DEF_SOBJECT(SWindow, L"menubar")
23 friend class SMenuBarItem;
24
25 public:
26 /**
27 * @brief Constructor
28 */
29 SMenuBar();
30
31 /**
32 * @brief Destructor
33 */
34 ~SMenuBar();
35
36 /**
37 * @brief Insert a menu item by title and resource name
38 * @param pszTitle Title of the menu item
39 * @param pszResName Resource name of the menu item
40 * @param iPos Position to insert the menu item, -1 for end
41 * @return TRUE if successful, FALSE otherwise
42 */
43 BOOL Insert(LPCTSTR pszTitle, LPCTSTR pszResName, int iPos = -1);
44
45 /**
46 * @brief Insert a menu item from an XML node
47 * @param pNode XML node containing the menu item configuration
48 * @param iPos Position to insert the menu item, -1 for end
49 * @return TRUE if successful, FALSE otherwise
50 */
51 BOOL Insert(IXmlNode *pNode, int iPos = -1);
52
53 /**
54 * @brief Get the menu at a specific position
55 * @param dwPos Position of the menu
56 * @return Pointer to the menu, NULL if not found
57 */
58 SMenu *GetMenu(DWORD dwPos);
59
60 /**
61 * @brief Hit test to determine the menu item under the mouse
62 * @param pt Mouse coordinates
63 * @return Index of the menu item if found, -1 otherwise
64 */
65 int HitTest(CPoint pt);
66
67 protected:
68 /**
69 * @brief Get the menu bar item at a specific position
70 * @param dwPos Position of the menu item
71 * @return Pointer to the menu bar item, NULL if not found
72 */
73 SMenuBarItem *GetMenuItem(DWORD dwPos);
74
75 /**
76 * @brief Create child items from XML configuration
77 * @param xmlNode XML node for the child items
78 * @return TRUE if successful, FALSE otherwise
79 */
80 virtual BOOL CreateChildren(SXmlNode xmlNode);
81
82 /**
83 * @brief Callback function for menu switch
84 * @param code Hook code
85 * @param wParam Additional message-specific information
86 * @param lParam Additional message-specific information
87 * @return Result of the message processing
88 */
89 static LRESULT CALLBACK MenuSwitch(int code, WPARAM wParam, LPARAM lParam);
90
91 protected:
92 SArray<SMenuBarItem *> m_lstMenuItem; /**< Array of menu bar items */
93 HWND m_hWnd; /**< Handle to the window */
94 SXmlDoc m_xmlStyle; /**< XML document for style configuration */
95 BOOL m_bIsShow; /**< Flag indicating if the menu bar is shown */
96 SMenuBarItem *m_pNowMenu; /**< Pointer to the currently active menu item */
97 int m_iNowMenu; /**< Index of the currently active menu item */
98 CPoint m_ptMouse; /**< Mouse coordinates */
99
100 static HHOOK m_hMsgHook; /**< Handle to the message hook */
101 static SMenuBar *m_pMenuBar; /**< Pointer to the current menu bar instance */
102};
103
104SNSEND
105
106#endif // __SMENUBAR__H__
SOUI基础DUI窗口模块
BOOL m_bIsShow
Definition SMenuBar.h:95
int HitTest(CPoint pt)
Hit test to determine the menu item under the mouse.
Definition SMenuBar.cpp:277
SMenuBar()
Constructor.
Definition SMenuBar.cpp:176
HWND m_hWnd
Definition SMenuBar.h:93
static SMenuBar * m_pMenuBar
Definition SMenuBar.h:101
SMenu * GetMenu(DWORD dwPos)
Get the menu at a specific position.
Definition SMenuBar.cpp:271
static HHOOK m_hMsgHook
Definition SMenuBar.h:100
int m_iNowMenu
Definition SMenuBar.h:97
SMenuBarItem * m_pNowMenu
Definition SMenuBar.h:96
SMenuBarItem * GetMenuItem(DWORD dwPos)
Get the menu bar item at a specific position.
Definition SMenuBar.cpp:288
SXmlDoc m_xmlStyle
Definition SMenuBar.h:94
SArray< SMenuBarItem * > m_lstMenuItem
Definition SMenuBar.h:92
CPoint m_ptMouse
Definition SMenuBar.h:98
BOOL Insert(LPCTSTR pszTitle, LPCTSTR pszResName, int iPos=-1)
Insert a menu item by title and resource name.
Definition SMenuBar.cpp:194
static LRESULT CALLBACK MenuSwitch(int code, WPARAM wParam, LPARAM lParam)
Callback function for menu switch.
Definition SMenuBar.cpp:316
Menu Bar Item.
Definition SMenuBar.cpp:17
菜单类
Definition SMenu.h:399
SWindow()
Constructor.
Definition Swnd.cpp:104
virtual BOOL CreateChildren(SXmlNode xmlNode)
Create child windows from XML node.
Definition Swnd.cpp:823
Implementation of IXmlDoc.
Definition SXml.h:912
Class representing an XML node.
Definition SXml.h:352
Interface for XML nodes.
Definition sxml-i.h:128