soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SDropDown.h
1#ifndef __SDROPDOWN__H__
2#define __SDROPDOWN__H__
3
4#include <core/SHostWnd.h>
5
6SNSBEGIN
7
8class SDropDownWnd;
9
10/**
11 * @struct ISDropDownOwner
12 * @brief Interface for Dropdown Owner
13 * @details This interface defines the methods that a dropdown owner must implement.
14 */
16{
17 /**
18 * @brief Get the dropdown owner window
19 * @return Pointer to the dropdown owner window
20 */
21 virtual SWindow *GetDropDownOwner() = 0;
22
23 /**
24 * @brief Notify that the dropdown window has been created
25 * @param pDropDown Pointer to the dropdown window
26 */
27 virtual void OnCreateDropDown(SDropDownWnd *pDropDown) = 0;
28
29 /**
30 * @brief Notify that the dropdown window is being destroyed
31 * @param pDropDown Pointer to the dropdown window
32 */
33 virtual void OnDestroyDropDown(SDropDownWnd *pDropDown) = 0;
34};
35
36/**
37 * @class SDropDownWnd
38 * @brief Dropdown Window Class
39 * @details A base class for dropdown windows. Derive from this class to create custom dropdown windows.
40 */
41class SOUI_EXP SDropDownWnd
42 : public SHostWnd
43 , public IMsgFilter {
44 typedef SHostWnd __baseCls;
45
46 public:
47 /**
48 * @brief Constructor
49 * @param pOwner Pointer to the dropdown owner
50 */
52
53 /**
54 * @brief Destructor
55 */
56 virtual ~SDropDownWnd();
57
58 /**
59 * @brief Get the dropdown owner window
60 * @return Pointer to the dropdown owner window
61 */
63
64 /**
65 * @brief Create the dropdown window
66 * @param lpRect Rectangle for the dropdown window
67 * @param lParam Associated data for the dropdown window
68 * @param dwStyle Window style
69 * @param dwExStyle Extended window style
70 * @return TRUE if successful, FALSE otherwise
71 */
72 virtual BOOL Create(LPCRECT lpRect, LPVOID lParam, DWORD dwStyle = WS_POPUP, DWORD dwExStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST);
73
74 /**
75 * @brief End the dropdown window
76 * @param uCode Exit code for the dropdown window
77 */
78 void EndDropDown(UINT uCode = IDCANCEL);
79
80 /**
81 * @brief Get the exit code of the dropdown window
82 * @return Exit code
83 */
84 UINT GetExitCode() const
85 {
86 return m_uExitCode;
87 }
88
89 /**
90 * @brief Get the value of the dropdown window
91 * @return Value of the dropdown window (default is 0)
92 */
93 virtual int GetValue() const
94 {
95 return 0;
96 }
97
98 protected:
99 /**
100 * @brief Get the message loop
101 * @return Pointer to the message loop
102 */
103 STDMETHOD_(IMessageLoop *, GetMsgLoop)();
104
105 /**
106 * @brief Prevent the window from releasing capture
107 * @return TRUE if successful, FALSE otherwise
108 */
109 STDMETHOD_(BOOL, OnReleaseSwndCapture)();
110
111 /**
112 * @brief Pre-translate messages
113 * @param pMsg Pointer to the message
114 * @return TRUE if the message is handled, FALSE otherwise
115 */
116 virtual BOOL WINAPI PreTranslateMessage(MSG *pMsg);
117
118 /**
119 * @brief Handle left mouse button down event
120 * @param nFlags Flags
121 * @param point Mouse coordinates
122 */
123 void OnLButtonDown(UINT nFlags, CPoint point);
124
125 /**
126 * @brief Handle left mouse button up event
127 * @param nFlags Flags
128 * @param point Mouse coordinates
129 */
130 void OnLButtonUp(UINT nFlags, CPoint point);
131
132 /**
133 * @brief Handle key down event
134 * @param nChar Key code
135 * @param nRepCnt Repeat count
136 * @param nFlags Flags
137 */
138 void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
139
140 /**
141 * @brief Handle kill focus event
142 * @param wndFocus Handle to the window receiving focus
143 */
144 void OnKillFocus(HWND wndFocus);
145
146 /**
147 * @brief Handle destroy event
148 */
149 void OnDestroy();
150
151 /**
152 * @brief Handle activate application event
153 * @param bActive Activation flag
154 * @param dwThreadID Thread ID
155 */
156 void OnActivateApp(BOOL bActive, DWORD dwThreadID);
157
158 /**
159 * @brief Handle mouse activate event
160 * @param wndTopLevel Handle to the top-level window
161 * @param nHitTest Hit test code
162 * @param message Mouse message code
163 * @return Activation code
164 */
165 int OnMouseActivate(HWND wndTopLevel, UINT nHitTest, UINT message);
166
167 /**
168 * @brief Handle activate event
169 * @param nState Activation state
170 * @param bMinimized Minimized flag
171 * @param wndOther Handle to the previous active window
172 */
173 void OnActivate(UINT nState, BOOL bMinimized, HWND wndOther)
174 {
175 } // Interrupt message processing to prevent setting focus
176
177 /**
178 * @brief Handle final message
179 * @param hwnd Handle to the window
180 */
181 virtual void OnFinalMessage(HWND hwnd);
182
183 protected:
184 ISDropDownOwner *m_pOwner; /**< Pointer to the dropdown owner */
185 BOOL m_bClick; /**< Click state */
186 UINT m_uExitCode; /**< Exit code */
187
188 BEGIN_MSG_MAP_EX(SDropDownWnd)
189 MSG_WM_LBUTTONDOWN(OnLButtonDown)
190 MSG_WM_LBUTTONUP(OnLButtonUp)
191 MSG_WM_KEYDOWN(OnKeyDown)
192 MSG_WM_KILLFOCUS(OnKillFocus)
193 MSG_WM_DESTROY(OnDestroy)
194 MSG_WM_ACTIVATE(OnActivate)
195 MSG_WM_ACTIVATEAPP(OnActivateApp)
196 MSG_WM_MOUSEACTIVATE(OnMouseActivate)
197 CHAIN_MSG_MAP(SHostWnd)
198 END_MSG_MAP()
199};
200
201SNSEND
202
203#endif // __SDROPDOWN__H__
Dropdown Window Class.
Definition SDropDown.h:43
void OnDestroy()
Handle destroy event.
UINT GetExitCode() const
Get the exit code of the dropdown window.
Definition SDropDown.h:84
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
Handle key down event.
Definition SDropDown.cpp:91
void OnActivateApp(BOOL bActive, DWORD dwThreadID)
Handle activate application event.
void OnActivate(UINT nState, BOOL bMinimized, HWND wndOther)
Handle activate event.
Definition SDropDown.h:173
int OnMouseActivate(HWND wndTopLevel, UINT nHitTest, UINT message)
Handle mouse activate event.
SWindow * GetDropDownOwner()
Get the dropdown owner window.
Definition SDropDown.cpp:45
void OnKillFocus(HWND wndFocus)
Handle kill focus event.
Definition SDropDown.cpp:37
void OnLButtonDown(UINT nFlags, CPoint point)
Handle left mouse button down event.
Definition SDropDown.cpp:62
ISDropDownOwner * m_pOwner
Definition SDropDown.h:184
virtual int GetValue() const
Get the value of the dropdown window.
Definition SDropDown.h:93
UINT m_uExitCode
Definition SDropDown.h:186
void EndDropDown(UINT uCode=IDCANCEL)
End the dropdown window.
void OnLButtonUp(UINT nFlags, CPoint point)
Handle left mouse button up event.
Definition SDropDown.cpp:77
SDropDownWnd(ISDropDownOwner *pOwner)
Constructor.
Definition SDropDown.cpp:20
void OnDestroy()
Handles the WM_DESTROY message.
Definition shostwnd.cpp:901
LRESULT OnActivateApp(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles the WM_ACTIVATEAPP message.
SHostWnd(LPCWSTR pszResName=NULL)
Constructs a SHostWnd object with an optional resource name.
Definition shostwnd.cpp:313
HWND Create(HWND hWndParent, int x=0, int y=0, int nWidth=0, int nHeight=0) OVERRIDE
Creates the host window.
Definition shostwnd.cpp:402
void OnKillFocus(HWND wndFocus)
Handles the WM_KILLFOCUS message.
virtual void OnFinalMessage(HWND hWnd)
Handles the final message for the window.
Base class for SOUI DUI windows.
Definition SWnd.h:286
Interface for message loops.
Definition SMsgLoop-i.h:42
Interface for message filtering.
Definition SMsgLoop-i.h:15
BOOL PreTranslateMessage(MSG *pMsg) PURE
Preprocesses a message.
Interface for Dropdown Owner.
Definition SDropDown.h:16
virtual void OnDestroyDropDown(SDropDownWnd *pDropDown)=0
Notify that the dropdown window is being destroyed.
virtual SWindow * GetDropDownOwner()=0
Get the dropdown owner window.
virtual void OnCreateDropDown(SDropDownWnd *pDropDown)=0
Notify that the dropdown window has been created.