soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SApp.h
Go to the documentation of this file.
1/**
2 * Copyright (C) 2014-2050 SOUI团队
3 * All rights reserved.
4 *
5 * @file sapp.h
6 * @brief
7 * @version v4.0
8 * @author soui
9 * @date 2022-06-20
10 *
11 * Describe SOUI应用程序入口
12 */
13
14#ifndef __SAPP__H__
15#define __SAPP__H__
16#include <windows.h>
17#include <core/SSingleton.h>
18#include <interface/sapp-i.h>
19
20#include <res.mgr/SResProviderMgr.h>
21#include <res.mgr/SNamedValue.h>
22
23#include <core/SMsgLoop.h>
24#include <core/SObjectFactory.h>
25#include <helper/obj-ref-impl.hpp>
27
28#define GETRESPROVIDER SNS::SApplication::getSingletonPtr()
29#define GETRENDERFACTORY SNS::SApplication::getSingleton().GetRenderFactory()
30#define GETREALWNDHANDLER SNS::SApplication::getSingleton().GetRealWndHander()
31#define GETTOOLTIPFACTORY SNS::SApplication::getSingleton().GetToolTipFactory()
32
33#define LOADXML(p1, p2) SNS::SApplication::getSingleton().LoadXmlDocment(p1, p2)
34#define LOADIMAGE(p1,p2) ((IResProviderMgr*)SNS::SApplication::getSingletonPtr())->LoadImage(p1,p2)
35#define LOADIMAGE2(p1) SNS::SApplication::getSingleton().LoadImage2(p1)
36#define LOADICON(p1, p2) SNS::SApplication::getSingleton().LoadIcon(p1, p2, p2)
37#define LOADICON2(p1) SNS::SApplication::getSingleton().LoadIcon2(p1)
38#define TR(p1, p2) SNS::SApplication::getSingleton().tr(p1, p2)
39#define STR2ID(p1) SNS::SApplication::getSingleton().Str2ID(p1)
40
41
42#define CREATEINTERPOLATOR(x) SNS::SApplication::getSingleton().CreateInterpolatorByName(x)
43
44SNSBEGIN
45
46struct IAccProxy;
47
48/**
49 * @interface ISystemObjectRegister
50 * @brief Interface for registering various system objects in SOUI.
51 *
52 * This interface defines methods to register different types of system objects
53 * such as layouts, skins, windows, interpolators, animations, and value animators
54 * into the system's object factory.
55 */
56interface SOUI_EXP ISystemObjectRegister
57{
58 /**
59 * @brief Register layout objects into the object factory.
60 * @param objFactory Pointer to the object factory manager.
61 */
62 virtual void RegisterLayouts(SObjectFactoryMgr * objFactory) const PURE;
63
64 /**
65 * @brief Register skin objects into the object factory.
66 * @param objFactory Pointer to the object factory manager.
67 */
68 virtual void RegisterSkins(SObjectFactoryMgr * objFactory) const PURE;
69
70 /**
71 * @brief Register window objects into the object factory.
72 * @param objFactory Pointer to the object factory manager.
73 */
74 virtual void RegisterWindows(SObjectFactoryMgr * objFactory) const PURE;
75
76 /**
77 * @brief Register interpolator objects into the object factory.
78 * @param objFactory Pointer to the object factory manager.
79 */
80 virtual void RegisterInterpolator(SObjectFactoryMgr * objFactory) const PURE;
81
82 /**
83 * @brief Register animation objects into the object factory.
84 * @param objFactory Pointer to the object factory manager.
85 */
86 virtual void RegisterAnimation(SObjectFactoryMgr * objFactory) const PURE;
87
88 /**
89 * @brief Register value animator objects into the object factory.
90 * @param objFactory Pointer to the object factory manager.
91 */
92 virtual void RegisterValueAnimator(SObjectFactoryMgr * objFactory) const PURE;
93};
94
95/**
96 * @class SObjectDefaultRegister
97 * @brief Default implementation of ISystemObjectRegister.
98 *
99 * This class provides a default implementation for registering various system
100 * objects into the object factory by implementing the ISystemObjectRegister interface.
101 */
102class SOUI_EXP SObjectDefaultRegister : public ISystemObjectRegister {
103 public:
104 /**
105 * @brief Register window objects into the object factory.
106 * @param objFactory Pointer to the object factory manager.
107 */
108 void RegisterWindows(SObjectFactoryMgr *objFactory) const;
109
110 /**
111 * @brief Register skin objects into the object factory.
112 * @param objFactory Pointer to the object factory manager.
113 */
114 void RegisterSkins(SObjectFactoryMgr *objFactory) const;
115
116 /**
117 * @brief Register layout objects into the object factory.
118 * @param objFactory Pointer to the object factory manager.
119 */
120 void RegisterLayouts(SObjectFactoryMgr *objFactory) const;
121
122 /**
123 * @brief Register interpolator objects into the object factory.
124 * @param objFactory Pointer to the object factory manager.
125 */
126 void RegisterInterpolator(SObjectFactoryMgr *objFactory) const;
127
128 /**
129 * @brief Register animation objects into the object factory.
130 * @param objFactory Pointer to the object factory manager.
131 */
132 void RegisterAnimation(SObjectFactoryMgr *objFactory) const;
133
134 /**
135 * @brief Register value animator objects into the object factory.
136 * @param objFactory Pointer to the object factory manager.
137 */
138 void RegisterValueAnimator(SObjectFactoryMgr *objFactory) const;
139};
140
141 /**
142 * @class SApplication
143 * @brief SOUI Application
144 *
145 * Describe SOUI Application
146 */
147 class SOUI_EXP SApplication
148 : public SSingleton<SApplication>
149 , public TObjRefImpl<IApplication>
150 , public SResProviderMgr
151 , public SObjectFactoryMgr {
152 public:
153 /**
154 * @brief Constructor for SApplication
155 * @param pRendFactory Pointer to the render factory
156 * @param hInst Handle to the application instance
157 * @param pszHostClassName Default window class name for SOUI windows
158 * @param sysObjRegister System object register
159 * @param bImeApp Boolean indicating if the application is an IME application
160 */
161 SApplication(IRenderFactory *pRendFactory,
162 HINSTANCE hInst,
163 LPCTSTR pszHostClassName = _T("SOUIHOST"),
164 const ISystemObjectRegister &sysObjRegister = SObjectDefaultRegister(),
165 BOOL bImeApp = FALSE);
166
167 /**
168 * @brief Destructor for SApplication
169 */
170 ~SApplication(void);
171
172 public:
173 /**
174 * @brief Get the render factory
175 * @return Pointer to the render factory
176 */
177 STDMETHOD_(IRenderFactory *, GetRenderFactory)(THIS) OVERRIDE;
178
179 /**
180 * @brief Set the render factory
181 * @param renderFac Pointer to the new render factory
182 * @return TRUE if successful, FALSE otherwise
183 */
184 STDMETHOD_(BOOL, SetRenderFactory)(THIS_ IRenderFactory * renderFac) OVERRIDE;
185
186 /**
187 * @brief Get the module handle
188 * @return Module handle
189 */
190 STDMETHOD_(HMODULE, GetModule)(THIS) SCONST OVERRIDE;
191
192 /**
193 * @brief Load system named resources
194 * @param pResProvider Resource provider
195 * @return Number of resources loaded
196 */
197 STDMETHOD_(UINT, LoadSystemNamedResource)(THIS_ IResProvider *pResProvider) OVERRIDE;
198
199 /**
200 * @brief Get the translator manager
201 * @return Pointer to the translator manager
202 */
203 STDMETHOD_(ITranslatorMgr *, GetTranslator)(THIS) OVERRIDE;
204
205 /**
206 * @brief Set the translator manager
207 * @param pTrans Pointer to the new translator manager
208 */
209 STDMETHOD_(void, SetTranslator)(THIS_ ITranslatorMgr *pTrans) OVERRIDE;
210
211 /**
212 * @brief Get the tooltip factory
213 * @return Pointer to the tooltip factory
214 */
215 STDMETHOD_(IToolTipFactory *, GetToolTipFactory)(THIS) OVERRIDE;
216
217 /**
218 * @brief Set the tooltip factory
219 * @param pToolTipFac Pointer to the new tooltip factory
220 */
221 STDMETHOD_(void, SetToolTipFactory)(THIS_ IToolTipFactory *pToolTipFac) OVERRIDE;
222
223 /**
224 * @brief Set the message loop factory
225 * @param pMsgLoopFac Pointer to the new message loop factory
226 * @return TRUE if successful, FALSE otherwise
227 */
228 STDMETHOD_(BOOL, SetMsgLoopFactory)(THIS_ IMsgLoopFactory *pMsgLoopFac) OVERRIDE;
229
230 /**
231 * @brief Get the message loop factory
232 * @return Pointer to the message loop factory
233 */
234 STDMETHOD_(IMsgLoopFactory *, GetMsgLoopFactory)(THIS) OVERRIDE;
235
236 /**
237 * @brief Set the log manager
238 * @param pLogMgr Pointer to the new log manager
239 */
240 STDMETHOD_(void, SetLogManager)(THIS_ ILogMgr *pLogMgr) OVERRIDE;
241
242 /**
243 * @brief Get the log manager
244 * @return Pointer to the log manager
245 */
246 STDMETHOD_(ILogMgr *, GetLogManager)(THIS) OVERRIDE;
247
248 /**
249 * @brief Set the attribute storage factory
250 * @param pAttrStorageFactory Pointer to the new attribute storage factory
251 */
252 STDMETHOD_(void, SetAttrStorageFactory)
253 (THIS_ IAttrStorageFactory *pAttrStorageFactory) OVERRIDE;
254
255 /**
256 * @brief Get the attribute storage factory
257 * @return Pointer to the attribute storage factory
258 */
259 STDMETHOD_(IAttrStorageFactory *, GetAttrStorageFactory)(THIS) OVERRIDE;
260
261 /**
262 * @brief Run the application message loop
263 * @param hMainWnd Handle to the main window
264 * @return Exit code of the application
265 */
266 STDMETHOD_(int, Run)(THIS_ HWND hMainWnd) OVERRIDE;
267
268 /**
269 * @brief Quit the application
270 * @param nCode Exit code
271 */
272 STDMETHOD_(void,Quit)(THIS_ int nCode) OVERRIDE;
273
274 /**
275 * @brief Get the main window handle
276 * @return Handle to the main window
277 */
278 STDMETHOD_(HWND, GetMainWnd)(THIS) OVERRIDE;
279
280 /**
281 * @brief Add a message loop
282 * @param pMsgLoop Pointer to the message loop to add
283 * @param bReplace Boolean indicating if the existing message loop should be replaced
284 * @return TRUE if successful, FALSE otherwise
285 */
286 STDMETHOD_(BOOL, AddMsgLoop)(THIS_ IMessageLoop *pMsgLoop,BOOL bReplace DEF_VAL(FALSE)) OVERRIDE;
287
288 /**
289 * @brief Remove the current message loop
290 * @return TRUE if successful, FALSE otherwise
291 */
292 STDMETHOD_(BOOL, RemoveMsgLoop)(THIS) OVERRIDE;
293
294 /**
295 * @brief Get the message loop for a specific thread
296 * @param tid Thread ID
297 * @return Pointer to the message loop
298 */
299 STDMETHOD_(IMessageLoop *, GetMsgLoop)
300 (THIS_ tid_t tid = ::GetCurrentThreadId()) SCONST OVERRIDE;
301
302 /**
303 * @brief Get the resource provider manager
304 * @return Pointer to the resource provider manager
305 */
306 STDMETHOD_(IResProviderMgr *, GetResProviderMgr)(THIS) OVERRIDE;
307
308 /**
309 * @brief Get the real window handler
310 * @return Pointer to the real window handler
311 */
312 STDMETHOD_(IRealWndHandler *, GetRealWndHander)(THIS) OVERRIDE;
313
314 /**
315 * @brief Set the real window handler
316 * @param pRealHandler Pointer to the new real window handler
317 */
318 STDMETHOD_(void, SetRealWndHandler)(THIS_ IRealWndHandler *pRealHandler) OVERRIDE;
319
320 /**
321 * @brief Set the script factory
322 * @param pScriptModule Pointer to the new script factory
323 */
324 STDMETHOD_(void, SetScriptFactory)(THIS_ IScriptFactory *pScriptModule) OVERRIDE;
325
326 /**
327 * @brief Initialize XML named IDs from arrays
328 * @param pNames Array of names
329 * @param nIds Array of IDs
330 * @param nCount Number of elements in the arrays
331 */
332 STDMETHOD_(void, InitXmlNamedID)
333 (THIS_ const LPCWSTR *pNames, const int *nIds, int nCount) OVERRIDE;
334
335 /**
336 * @brief Load an XML document from a resource
337 * @param strResId Resource ID of the XML document
338 * @return Pointer to the loaded XML document
339 */
340 STDMETHOD_(IXmlDoc *, LoadXmlDocment)(THIS_ LPCTSTR strResId) OVERRIDE;
341
342 /**
343 * @brief Load an XML document from a UTF-8 encoded resource
344 * @param strResId Resource ID of the XML document
345 * @return Pointer to the loaded XML document
346 */
347 STDMETHOD_(IXmlDoc *, LoadXmlDocmentU8)(THIS_ LPCSTR strResId) OVERRIDE
348 {
349 SStringT str = S_CA2T(strResId, CP_UTF8);
350 return LoadXmlDocment(str);
351 }
352
353 /**
354 * @brief Load an animation from a resource
355 * @param strResId Resource ID of the animation
356 * @return Pointer to the loaded animation
357 */
358 STDMETHOD_(IAnimation *, LoadAnimation)(THIS_ LPCTSTR strResId) OVERRIDE;
359
360 /**
361 * @brief Load an animation from a UTF-8 encoded resource
362 * @param strResId Resource ID of the animation
363 * @return Pointer to the loaded animation
364 */
365 STDMETHOD_(IAnimation *, LoadAnimationU8)(THIS_ LPCSTR strResId) OVERRIDE
366 {
367 SStringT str = S_CA2T(strResId, CP_UTF8);
368 return LoadAnimation(str);
369 }
370
371 /**
372 * @brief Load an image from a resource
373 * @param strResId Resource ID of the image
374 * @return Pointer to the loaded image
375 */
376 STDMETHOD_(IBitmapS *, LoadImage)(THIS_ LPCTSTR strResId) OVERRIDE
377 {
378 SStringW wcsResId = S_CT2W(strResId);
379 return SResProviderMgr::LoadImage2(wcsResId);
380 }
381
382 /**
383 * @brief Load an image from a UTF-8 encoded resource
384 * @param strResId Resource ID of the image
385 * @return Pointer to the loaded image
386 */
387 STDMETHOD_(IBitmapS *, LoadImageU8)(THIS_ LPCSTR strResId) OVERRIDE
388 {
389 SStringT str = S_CA2T(strResId, CP_UTF8);
390 return LoadImage(str);
391 }
392
393 /**
394 * @brief Load a value animator from a resource
395 * @param strResId Resource ID of the value animator
396 * @return Pointer to the loaded value animator
397 */
398 STDMETHOD_(IValueAnimator *, LoadValueAnimator)(THIS_ LPCTSTR strResId) OVERRIDE;
399
400 /**
401 * @brief Load a value animator from a UTF-8 encoded resource
402 * @param strResId Resource ID of the value animator
403 * @return Pointer to the loaded value animator
404 */
405 STDMETHOD_(IValueAnimator *, LoadValueAnimatorU8)(THIS_ LPCSTR strResId) OVERRIDE
406 {
407 SStringT str = S_CA2T(strResId, CP_UTF8);
408 return LoadValueAnimator(str);
409 }
410
411 /**
412 * @brief Load a translator from a resource
413 * @param strResId Resource ID of the translator
414 * @return Pointer to the loaded translator
415 */
416 STDMETHOD_(ITranslator *,LoadTranslator)(THIS_ LPCTSTR strResId) OVERRIDE;
417
418 /**
419 * @brief Load a translator from a UTF-8 encoded resource
420 * @param strResId Resource ID of the translator
421 * @return Pointer to the loaded translator
422 */
423 STDMETHOD_(ITranslator *, LoadTranslatorU8)(THIS_ LPCSTR strResId) OVERRIDE
424 {
425 SStringT str = S_CA2T(strResId, CP_UTF8);
426 return LoadTranslator(str);
427 }
428
429 /**
430 * @brief Install a translator
431 * @param trModule Pointer to the translator module
432 * @return TRUE if successful, FALSE otherwise
433 */
434 STDMETHOD_(BOOL,InstallTranslator)(THIS_ ITranslator * trModule) OVERRIDE;
435
436 /**
437 * @brief Uninstall a translator by language ID
438 * @param langId Language ID
439 * @return TRUE if successful, FALSE otherwise
440 */
441 STDMETHOD_(BOOL,UnnstallTranslator)(THIS_ REFGUID langId) OVERRIDE;
442
443 /**
444 * @brief Enable or disable the notification center
445 * @param bEnable Boolean indicating if the notification center should be enabled
446 * @param interval Interval for notifications
447 */
448 STDMETHOD_(void,EnableNotifyCenter)(THIS_ BOOL bEnable,int interval DEF_VAL(20)) OVERRIDE;
449
450 /**
451 * @brief Get an inner singleton
452 * @param nType Type of the singleton
453 * @return Pointer to the singleton
454 */
455 STDMETHOD_(void *,GetInnerSingleton)(THIS_ SingletonType nType) OVERRIDE;
456
457 /**
458 * @brief Create an object by name and type
459 * @param pszName Name of the object
460 * @param nType Type of the object
461 * @return Pointer to the created object
462 */
463 STDMETHOD_(IObject *,CreateObject)(THIS_ LPCWSTR pszName,SObjectType nType) SCONST OVERRIDE;
464
465 /**
466 * @brief Set the callback for creating objects
467 * @param cbCreateObj Callback function
468 */
469 STDMETHOD_(void,SetCreateObjectCallback)(THIS_ FunCreateObject cbCreateObj) OVERRIDE;
470
471 /**
472 * @brief Register an object factory
473 * @param objFac Pointer to the object factory
474 * @param bReplace Boolean indicating if the existing factory should be replaced
475 * @return TRUE if successful, FALSE otherwise
476 */
477 STDMETHOD_(BOOL,RegisterObjFactory)(THIS_ const IObjectFactory *objFac,BOOL bReplace DEF_VAL(FALSE)) OVERRIDE;
478
479 /**
480 * @brief Unregister an object factory
481 * @param objFac Pointer to the object factory
482 * @return TRUE if successful, FALSE otherwise
483 */
484 STDMETHOD_(BOOL,UnregisterObjFactory)(THIS_ const IObjectFactory *objFac) OVERRIDE;
485
486 /**
487 * @brief Set the default font information
488 * @param pszFontInfo Font information string
489 */
490 STDMETHOD_(void,SetDefaultFontInfo)(THIS_ LPCWSTR pszFontInfo) OVERRIDE;
491
492 /**
493 * @brief Create task loops
494 * @param nCount Number of task loops to create
495 * @param priority Priority of the task loops
496 * @param bAutoStart Boolean indicating if the task loops should start automatically
497 * @return TRUE if successful, FALSE otherwise
498 */
499 STDMETHOD_(BOOL,CreateTaskLoop)(THIS_ int nCount,Priority priority,BOOL bAutoStart DEF_VAL(TRUE)) OVERRIDE;
500
501 /**
502 * @brief Get a task loop by index
503 * @param iTaskLoop Index of the task loop
504 * @return Pointer to the task loop
505 */
506 STDMETHOD_(ITaskLoop *, GetTaskLoop)(THIS_ int iTaskLoop DEF_VAL(0)) OVERRIDE;
507
508 /**
509 * @brief Set the callback for creating task loops
510 * @param cbCreateTaskLoop Callback function
511 */
512 STDMETHOD_(void, SetCreateTaskLoopCallback)(THIS_ FunCrateTaskLoop cbCreateTaskLoop) OVERRIDE;
513
514 /**
515 * @brief Create a script module
516 * @param ppScriptModule Pointer to the created script module
517 * @return HRESULT indicating success or failure
518 */
519 STDMETHOD_(HRESULT,CreateScriptModule)(THIS_ IScriptModule **ppScriptModule) OVERRIDE;
520
521 /**
522 * @brief Set the resource ID for the edit context menu template
523 * @param resId Resource ID of the template
524 * @param pResProvider Resource provider
525 * @return TRUE if successful, FALSE otherwise
526 */
527 STDMETHOD_(BOOL,SetEditCtxMenuTemplateResId)(THIS_ LPCTSTR resId,IResProvider *pResProvider DEF_VAL(NULL)) OVERRIDE;
528
529 /**
530 * @brief Set the resource ID for the message box template
531 * @param resId Resource ID of the template
532 * @param pResProvider Resource provider
533 * @return TRUE if successful, FALSE otherwise
534 */
535 STDMETHOD_(BOOL,SetMessageBoxTemplateResId)(THIS_ LPCTSTR resId,IResProvider *pResProvider DEF_VAL(NULL)) OVERRIDE;
536
537 public:
538 /**
539 * @brief Initialize XML named IDs from an array of named values
540 * @param pNamedValue Array of named values
541 * @param nCount Number of elements in the array
542 * @param bSorted Boolean indicating if the array is sorted
543 */
544 void InitXmlNamedID(const SNamedID::NAMEDVALUE *pNamedValue, int nCount, BOOL bSorted);
545
546 /**
547 * @brief Load an XML document from a resource
548 * @param xmlDoc Output XML document object
549 * @param strResId Resource ID of the XML document
550 * @param pResProvider Resource provider
551 * @return TRUE if successful, FALSE otherwise
552 */
553 BOOL LoadXmlDocment(SXmlDoc &xmlDoc, const SStringT &strResId, IResProvider *pResProvider = NULL);
554
555 /**
556 * @brief Set the application directory
557 * @param strAppDir Application directory path
558 */
559 void SetAppDir(const SStringT &strAppDir);
560
561 /**
562 * @brief Get the application directory
563 * @return Application directory path
564 */
565 SStringT GetAppDir() const;
566
567 /**
568 * @brief Register a window class
569 * @tparam T Window class type
570 * @return TRUE if successful, FALSE otherwise
571 */
572 template <class T>
574 {
575 if (T::GetClassType() != Window)
576 return FALSE;
577 return TplRegisterFactory<T>();
578 }
579
580 /**
581 * @brief Unregister a window class
582 * @tparam T Window class type
583 * @return TRUE if successful, FALSE otherwise
584 */
585 template <class T>
587 {
588 if (T::GetClassType() != Window)
589 return FALSE;
591 }
592
593 /**
594 * @brief Register a skin class
595 * @tparam T Skin class type
596 * @return TRUE if successful, FALSE otherwise
597 */
598 template <class T>
600 {
601 if (T::GetClassType() != Skin)
602 return FALSE;
603 return TplRegisterFactory<T>();
604 }
605
606 /**
607 * @brief Unregister a skin class
608 * @tparam T Skin class type
609 * @return TRUE if successful, FALSE otherwise
610 */
611 template <class T>
613 {
614 if (T::GetClassType() != Skin)
615 return FALSE;
617 }
618
619 /**
620 * @brief Convert a string to an ID
621 * @param str Source string
622 * @return ID corresponding to the string
623 */
624 int Str2ID(const SStringW &str);
625
626 /**
627 * @brief Get the message box template XML node
628 * @return XML node for the message box template
629 */
630 SXmlNode GetMessageBoxTemplate() const;
631
632 /**
633 * @brief Get the edit context menu template XML node
634 * @return XML node for the edit context menu template
635 */
636 SXmlNode GetEditCtxMenuTemplate() const;
637
638 /**
639 * @brief Translate a string with context
640 * @param strSrc Source string
641 * @param strCtx Context string
642 * @return Translated string
643 */
644 SStringW tr(const SStringW &strSrc, const SStringW &strCtx) const;
645
646 /**
647 * @brief Create a window by name
648 * @param pszWndClass Name of the window class
649 * @return Pointer to the created window
650 */
651 virtual IWindow *CreateWindowByName(LPCWSTR pszWndClass) const;
652
653 /**
654 * @brief Create a skin by name
655 * @param pszSkinClass Name of the skin class
656 * @return Pointer to the created skin
657 */
658 virtual ISkinObj *CreateSkinByName(LPCWSTR pszSkinClass) const;
659
660 /**
661 * @brief Create an interpolator by name
662 * @param pszName Name of the interpolator
663 * @return Pointer to the created interpolator
664 */
665 virtual IInterpolator *CreateInterpolatorByName(LPCWSTR pszName) const;
666
667 /**
668 * @brief Create an animation by name
669 * @param pszName Name of the animation
670 * @return Pointer to the created animation
671 */
672 virtual IAnimation *CreateAnimationByName(LPCWSTR pszName) const;
673
674 /**
675 * @brief Create a value animator by name
676 * @param pszName Name of the value animator
677 * @return Pointer to the created value animator
678 */
679 virtual IValueAnimator *CreateValueAnimatorByName(LPCWSTR pszName) const;
680
681#ifdef _WIN32
682 /**
683 * @brief Create an accessibility proxy for a window
684 * @param pWnd Pointer to the window
685 * @return Pointer to the created accessibility proxy
686 */
687 virtual IAccProxy *CreateAccProxy(IWindow *pWnd) const;
688
689 /**
690 * @brief Create an accessible object for a window
691 * @param pWnd Pointer to the window
692 * @return Pointer to the created accessible object
693 */
694 virtual IAccessible *CreateAccessible(IWindow *pWnd) const;
695#endif
696 protected:
697 /**
698 * @brief Creates and initializes all singletons required by the application.
699 */
700 void _CreateSingletons();
701
702 /**
703 * @brief Destroys and cleans up all singletons used by the application.
704 */
705 void _DestroySingletons();
706
707 /**
708 * @brief Loads an XML document from a resource.
709 * @param pszXmlName The name of the XML resource.
710 * @param pszType The type of the XML resource.
711 * @param xmlDoc The output XML document object.
712 * @param pResProvider The resource provider to use for loading the resource.
713 * @return TRUE if the XML document is loaded successfully, FALSE otherwise.
714 * @details This protected method is used internally to load an XML document from a specified resource.
715 * It takes the name and type of the XML resource, an output XML document object, and an optional
716 * resource provider. If no resource provider is specified, the default resource provider is used.
717 */
718 BOOL _LoadXmlDocment(LPCTSTR pszXmlName,
719 LPCTSTR pszType,
720 SXmlDoc &xmlDoc,
721 IResProvider *pResProvider = NULL);
722
723 /**
724 * @brief Pointer to the real window handler.
725 */
727
728 /**
729 * @brief Pointer to the script factory.
730 */
732
733 /**
734 * @brief Pointer to the render factory.
735 */
737
738 /**
739 * @brief Pointer to the translator manager.
740 */
742
743 /**
744 * @brief Pointer to the tooltip factory.
745 */
747
748 /**
749 * @brief Pointer to the message loop factory.
750 */
752
753 /**
754 * @brief Pointer to the log manager.
755 */
757
758 /**
759 * @brief Pointer to the attribute storage factory.
760 */
762
763 /**
764 * @brief Named ID manager.
765 */
767
768 /**
769 * @brief Application directory path.
770 */
771 SStringT m_strAppDir;
772
773 /**
774 * @brief Module handle.
775 */
776 HMODULE m_hInst;
777
778 /**
779 * @brief Handle to the main window.
780 */
782
783 /**
784 * @brief Critical section for thread-safe operations.
785 */
787
788 /**
789 * @brief Map of message loops for different threads.
790 */
791 typedef SMap<tid_t, SAutoRefPtr<IMessageLoop>> MsgLoopMap;
792 MsgLoopMap m_msgLoopMap;
793
794 /**
795 * @brief Callback function for creating objects.
796 */
797 FunCreateObject m_cbCreateObj;
798
799 /**
800 * @brief Callback function for creating task loops.
801 */
802 FunCrateTaskLoop m_cbCreateTaskLoop;
803
804 /**
805 * @brief List of task loops.
806 */
807 SArray<SAutoRefPtr<ITaskLoop>> m_lstTaskLoop; // task loop list
808
809 /**
810 * @brief Array of singleton pointers.
811 */
812 void *m_pSingletons[SINGLETON_COUNT];
813
814 /**
815 * @brief XML document for the edit context menu template.
816 */
818
819 /**
820 * @brief XML document for the message box template.
821 */
823};
824
825SNSEND
826#endif // __SAPP__H__
virtual void RegisterValueAnimator(SObjectFactoryMgr *objFactory) const PURE
Register value animator objects into the object factory.
virtual void RegisterInterpolator(SObjectFactoryMgr *objFactory) const PURE
Register interpolator objects into the object factory.
virtual void RegisterSkins(SObjectFactoryMgr *objFactory) const PURE
Register skin objects into the object factory.
virtual void RegisterWindows(SObjectFactoryMgr *objFactory) const PURE
Register window objects into the object factory.
virtual void RegisterAnimation(SObjectFactoryMgr *objFactory) const PURE
Register animation objects into the object factory.
Object Factory Management.
Singleton Template.
Interface for Skin Objects.
SAutoRefPtr< IScriptFactory > m_pScriptFactory
Pointer to the script factory.
Definition SApp.h:731
UINT LoadSystemNamedResource(IResProvider *pResProvider) OVERRIDE
Load system named resources.
Definition SApp.cpp:462
ITranslatorMgr * GetTranslator() OVERRIDE
Get the translator manager.
Definition SApp.cpp:532
SMap< tid_t, SAutoRefPtr< IMessageLoop > > MsgLoopMap
Map of message loops for different threads.
Definition SApp.h:791
void Quit(int nCode) OVERRIDE
Quit the application.
Definition SApp.cpp:511
HMODULE m_hInst
Module handle.
Definition SApp.h:776
ITranslator * LoadTranslator(LPCTSTR strResId) OVERRIDE
Load a translator from a resource.
Definition SApp.cpp:421
IValueAnimator * LoadValueAnimatorU8(LPCSTR strResId) OVERRIDE
Load a value animator from a UTF-8 encoded resource.
Definition SApp.h:405
IBitmapS * LoadImage(LPCTSTR strResId) OVERRIDE
Load an image from a resource.
Definition SApp.h:376
BOOL AddMsgLoop(IMessageLoop *pMsgLoop, BOOL bReplace=FALSE) OVERRIDE
Add a message loop.
Definition SApp.cpp:694
HWND m_hMainWnd
Handle to the main window.
Definition SApp.h:781
SAutoRefPtr< ITranslatorMgr > m_translator
Pointer to the translator manager.
Definition SApp.h:741
IMessageLoop * GetMsgLoop(tid_t tid=::GetCurrentThreadId()) SCONST OVERRIDE
Get the message loop for a specific thread.
Definition SApp.cpp:718
SApplication(IRenderFactory *pRendFactory, HINSTANCE hInst, LPCTSTR pszHostClassName=_T("SOUIHOST"), const ISystemObjectRegister &sysObjRegister=SObjectDefaultRegister(), BOOL bImeApp=FALSE)
Constructor for SApplication.
Definition SApp.cpp:233
SNamedID m_namedID
Named ID manager.
Definition SApp.h:766
IResProviderMgr * GetResProviderMgr() OVERRIDE
Get the resource provider manager.
Definition SApp.cpp:727
SXmlDoc m_xmlMessageBoxTemplate
XML document for the message box template.
Definition SApp.h:822
IAttrStorageFactory * GetAttrStorageFactory() OVERRIDE
Get the attribute storage factory.
Definition SApp.cpp:684
IAnimation * LoadAnimationU8(LPCSTR strResId) OVERRIDE
Load an animation from a UTF-8 encoded resource.
Definition SApp.h:365
void * m_pSingletons[SINGLETON_COUNT]
Array of singleton pointers.
Definition SApp.h:812
int Run(HWND hMainWnd) OVERRIDE
Run the application message loop.
Definition SApp.cpp:498
SStringT m_strAppDir
Application directory path.
Definition SApp.h:771
SAutoRefPtr< ILogMgr > m_logManager
Pointer to the log manager.
Definition SApp.h:756
IToolTipFactory * GetToolTipFactory() OVERRIDE
Get the tooltip factory.
Definition SApp.cpp:573
BOOL UnregisterWindowClass()
Unregister a window class.
Definition SApp.h:586
BOOL RegisterWindowClass()
Register a window class.
Definition SApp.h:573
IBitmapS * LoadImageU8(LPCSTR strResId) OVERRIDE
Load an image from a UTF-8 encoded resource.
Definition SApp.h:387
SAutoRefPtr< IRealWndHandler > m_pRealWndHandler
Pointer to the real window handler.
Definition SApp.h:726
SXmlDoc m_xmlEditCtxMenuTemplate
XML document for the edit context menu template.
Definition SApp.h:817
IMsgLoopFactory * GetMsgLoopFactory() OVERRIDE
Get the message loop factory.
Definition SApp.cpp:598
void SetAttrStorageFactory(IAttrStorageFactory *pAttrStorageFactory) OVERRIDE
Set the attribute storage factory.
Definition SApp.cpp:689
BOOL SetRenderFactory(IRenderFactory *renderFac) OVERRIDE
Set the render factory.
Definition SApp.cpp:554
HWND GetMainWnd() OVERRIDE
Get the main window handle.
Definition SApp.cpp:583
SCriticalSection m_cs
Critical section for thread-safe operations.
Definition SApp.h:786
FunCrateTaskLoop m_cbCreateTaskLoop
Callback function for creating task loops.
Definition SApp.h:802
BOOL RemoveMsgLoop() OVERRIDE
Remove the current message loop.
Definition SApp.cpp:706
SAutoRefPtr< IToolTipFactory > m_tooltipFactory
Pointer to the tooltip factory.
Definition SApp.h:746
FunCreateObject m_cbCreateObj
Callback function for creating objects.
Definition SApp.h:797
void SetLogManager(ILogMgr *pLogMgr) OVERRIDE
Set the log manager.
Definition SApp.cpp:664
ITranslator * LoadTranslatorU8(LPCSTR strResId) OVERRIDE
Load a translator from a UTF-8 encoded resource.
Definition SApp.h:423
IValueAnimator * LoadValueAnimator(LPCTSTR strResId) OVERRIDE
Load a value animator from a resource.
Definition SApp.cpp:408
IXmlDoc * LoadXmlDocment(LPCTSTR strResId) OVERRIDE
Load an XML document from a resource.
Definition SApp.cpp:371
IRealWndHandler * GetRealWndHander() OVERRIDE
Get the real window handler.
Definition SApp.cpp:568
ILogMgr * GetLogManager() OVERRIDE
Get the log manager.
Definition SApp.cpp:669
IRenderFactory * GetRenderFactory() OVERRIDE
Get the render factory.
Definition SApp.cpp:549
IXmlDoc * LoadXmlDocmentU8(LPCSTR strResId) OVERRIDE
Load an XML document from a UTF-8 encoded resource.
Definition SApp.h:347
SAutoRefPtr< IMsgLoopFactory > m_msgLoopFactory
Pointer to the message loop factory.
Definition SApp.h:751
BOOL UnregisterSkinClass()
Unregister a skin class.
Definition SApp.h:612
void SetScriptFactory(IScriptFactory *pScriptModule) OVERRIDE
Set the script factory.
Definition SApp.cpp:537
void SetToolTipFactory(IToolTipFactory *pToolTipFac) OVERRIDE
Set the tooltip factory.
Definition SApp.cpp:578
SArray< SAutoRefPtr< ITaskLoop > > m_lstTaskLoop
List of task loops.
Definition SApp.h:807
BOOL SetMsgLoopFactory(IMsgLoopFactory *pMsgLoopFac) OVERRIDE
Set the message loop factory.
Definition SApp.cpp:588
SAutoRefPtr< IAttrStorageFactory > m_pAttrStroageFactory
Pointer to the attribute storage factory.
Definition SApp.h:761
void SetRealWndHandler(IRealWndHandler *pRealHandler) OVERRIDE
Set the real window handler.
Definition SApp.cpp:563
void InitXmlNamedID(const LPCWSTR *pNames, const int *nIds, int nCount) OVERRIDE
Initialize XML named IDs from arrays.
Definition SApp.cpp:608
void SetTranslator(ITranslatorMgr *pTrans) OVERRIDE
Set the translator manager.
Definition SApp.cpp:527
IAnimation * LoadAnimation(LPCTSTR strResId) OVERRIDE
Load an animation from a resource.
Definition SApp.cpp:395
SAutoRefPtr< IRenderFactory > m_RenderFactory
Pointer to the render factory.
Definition SApp.h:736
HMODULE GetModule() SCONST OVERRIDE
Get the module handle.
Definition SApp.cpp:522
BOOL RegisterSkinClass()
Register a skin class.
Definition SApp.h:599
Smart pointer class for managing COM-style reference-counted objects.
Wrapper class for a critical section.
Manages named integer IDs.
Default implementation of ISystemObjectRegister.
Definition SApp.h:102
void RegisterLayouts(SObjectFactoryMgr *objFactory) const
Register layout objects into the object factory.
Definition SApp.cpp:187
Manager for object factories.
SObjectFactoryMgr(void)
Constructor for SObjectFactoryMgr.
BOOL TplUnregisterFactory()
Template method to unregister a factory for a specific object type.
BOOL TplRegisterFactory()
Template method to register a factory for a specific object type.
IBitmapS * LoadImage2(const SStringW &strImgID)
Loads an image using a type:name formatted string.
SResProviderMgr(void)
Constructor.
A class representing an ASCII string.
Definition sstringw.h:96
Implementation of IXmlDoc.
Definition SXml.h:912
Class representing an XML node.
Definition SXml.h:352
Interface for registering various system objects in SOUI.
Bitmap object interface.
Definition SRender-i.h:420
Interface for message loops.
Definition SMsgLoop-i.h:42
Interface for creating message loops.
Definition SMsgLoop-i.h:181
Interface for handling real window operations.
RenderFactory object.
Definition SRender-i.h:2018
ResProvider对象
Interface for Skin Objects.
Definition SSkinobj-i.h:29
Interface for Tooltip Factory.
Definition stooltip-i.h:112
Language Translation Interface.
Language Translation Interface Manager.
Interface for XML Document.
Definition sxml-i.h:472