soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SHostDialog.h
Go to the documentation of this file.
1/**
2 * Copyright (C) 2014-2050
3 * All rights reserved.
4 *
5 * @file SHostDialog.h
6 * @brief SOUI Dialog Module
7 * @version v1.0
8 * @author SOUI group
9 * @date 2014/08/02
10 *
11 * @details This file defines the SHostDialog class, which manages dialog windows in the SOUI framework.
12 */
13
14#ifndef __SHOSTDIALOG__H__
15#define __SHOSTDIALOG__H__
16
17#include <core/SHostWnd.h>
18#include <core/SMsgLoop.h>
19#include <proxy/SHostWndProxy.h>
20
21SNSBEGIN
22
23/**
24 * @class SHostDialog
25 * @brief Dialog host window class
26 *
27 * @details This class manages dialog windows in the SOUI framework. It inherits from `THostWndProxy<IHostDialog>`
28 * and provides methods for handling dialog messages and events.
29 */
30class SOUI_EXP SHostDialog : public THostWndProxy<IHostDialog> {
31 public:
32 /**
33 * @brief Constructor
34 * @param pszXmlName Name of the XML file for the dialog layout (wide character version)
35 *
36 * @details Initializes the dialog with the specified XML layout file.
37 */
38 SHostDialog(LPCWSTR pszXmlName = NULL);
39
40 /**
41 * @brief Constructor
42 * @param pszXmlName Name of the XML file for the dialog layout (narrow character version)
43 *
44 * @details Initializes the dialog with the specified XML layout file.
45 */
46 SHostDialog(LPCSTR pszXmlName);
47
48 /**
49 * @brief Destructor
50 *
51 * @details Cleans up the dialog object.
52 */
53 ~SHostDialog(void);
54
55 public:
56 /**
57 * @brief Gets the message loop for the dialog
58 * @return Pointer to the message loop
59 *
60 * @details Returns the message loop associated with the dialog.
61 */
62 STDMETHOD_(IMessageLoop *, GetMsgLoop)(THIS) OVERRIDE;
63
64 /**
65 * @brief Displays the dialog as a modal window
66 * @param hParent Handle to the parent window
67 * @param dwStyle Window style
68 * @param dwExStyle Extended window style
69 * @return Result code of the dialog
70 *
71 * @details Displays the dialog as a modal window and returns the result code.
72 */
73 STDMETHOD_(INT_PTR, DoModal)(THIS_ HWND hParent DEF_VAL(0), DWORD dwStyle DEF_VAL(WS_POPUP | WS_CLIPCHILDREN), DWORD dwExStyle DEF_VAL(0)) OVERRIDE;
74
75 /**
76 * @brief Ends the dialog
77 * @param nResult Result code to return from the dialog
78 *
79 * @details Ends the dialog and sets the result code.
80 */
81 STDMETHOD_(void, EndDialog)(THIS_ INT_PTR nResult) OVERRIDE;
82
83 /**
84 * @brief Casts the object to SHostWnd
85 * @return Pointer to the SHostWnd object
86 *
87 * @details Casts the SHostDialog object to an SHostWnd object.
88 */
90 {
91 return this;
92 }
93
94 protected:
95 /**
96 * @brief Handles the key down event
97 * @param nChar Virtual key code
98 * @param nRepCnt Repeat count
99 * @param nFlags Flags associated with the key event
100 *
101 * @details Handles the key down event for the dialog.
102 */
103 void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
104
105 /**
106 * @brief Handles the OK button click event
107 *
108 * @details Handles the click event for the OK button, typically ending the dialog with a result code.
109 */
110 void OnOK();
111
112 /**
113 * @brief Handles the Cancel button click event
114 *
115 * @details Handles the click event for the Cancel button, typically ending the dialog with a result code.
116 */
117 void OnCancel();
118
119 EVENT_MAP_BEGIN()
120 EVENT_ID_COMMAND(IDOK, OnOK) /**< Maps the IDOK command to the OnOK method. */
121 EVENT_ID_COMMAND(IDCANCEL, OnCancel) /**< Maps the IDCANCEL command to the OnCancel method. */
122 EVENT_MAP_END2(SHostWnd)
123
124 BEGIN_MSG_MAP_EX(SHostDialog)
125 MSG_WM_CLOSE(OnCancel) /**< Maps the WM_CLOSE message to the OnCancel method. */
126 MSG_WM_KEYDOWN(OnKeyDown) /**< Maps the WM_KEYDOWN message to the OnKeyDown method. */
127 CHAIN_MSG_MAP(SHostWnd) /**< Chains message map to the base class SHostWnd. */
128 REFLECT_NOTIFICATIONS_EX() /**< Reflects notifications to the dialog. */
129 END_MSG_MAP()
130
131 protected:
132 INT_PTR m_nRetCode; /**< Result code of the dialog. */
133 SAutoRefPtr<IMessageLoop> m_MsgLoop; /**< Message loop for the dialog. */
134};
135
136SNSEND
137
138#endif // __SHOSTDIALOG__H__
Smart pointer class for managing COM-style reference-counted objects.
Dialog host window class.
Definition SHostDialog.h:30
SAutoRefPtr< IMessageLoop > m_MsgLoop
INT_PTR m_nRetCode
INT_PTR DoModal(HWND hParent=0, DWORD dwStyle=WS_POPUP|WS_CLIPCHILDREN, DWORD dwExStyle=0) OVERRIDE
Displays the dialog as a modal window.
void EndDialog(INT_PTR nResult) OVERRIDE
Ends the dialog.
IMessageLoop * GetMsgLoop() OVERRIDE
Gets the message loop for the dialog.
SHostDialog(LPCWSTR pszXmlName=NULL)
Constructor.
SHostWnd * toSHostWnd()
Casts the object to SHostWnd.
Definition SHostDialog.h:89
The main host window class responsible for managing the layout, events, and rendering of SOUI windows...
Definition SHostWnd.h:318
SHostWnd(LPCWSTR pszResName=NULL)
Constructs a SHostWnd object with an optional resource name.
Definition shostwnd.cpp:313
Interface for message loops.
Definition SMsgLoop-i.h:42