7#include "res.mgr/SUiDef.h"
8#include "res.mgr/SObjDefAttr.h"
10#include "helper/STimerGenerator.h"
12#include "helper/SToolTip.h"
13#include "helper/SAppDir.h"
14#include "helper/SwndFinder.h"
15#include "helper/SHostMgr.h"
16#include "event/SNotifyCenter.h"
18#include "control/SMessageBox.h"
19#include "helper/SplitString.h"
22#include "control/SouiCtrls.h"
23#include "layout/SouiLayout.h"
24#include "layout/SLinearLayout.h"
25#include "layout/SGridLayout.h"
26#include "animation/SInterpolatorImpl.h"
27#include "core/SWndAccessible.h"
29#include "msaa/SAccProxyWindow.h"
30#include "msaa/SAccProxyCmnCtrl.h"
32#include "animation/SAnimation.h"
33#include "animation/SAnimationSet.h"
34#include "animation/ScaleAnimation.h"
35#include "animation/SRotateAnimation.h"
36#include "animation/SAlphaAnimation.h"
37#include "animation/STranslateAnimation.h"
39#include "core/SHostPresenter.h"
43class SNullTranslator :
public TObjRefImpl<ITranslatorMgr> {
45 STDMETHOD_(BOOL, IsValid)(CTHIS) SCONST
50 STDMETHOD_(
void, SetLanguage)(THIS_ LPCWSTR strLang)
53 STDMETHOD_(
void, SetLanguageA)(THIS_ LPCSTR strLang)
56 STDMETHOD_(
void, GetLanguage)(THIS_
wchar_t szOut[TR_MAX_NAME_LEN]) SCONST
60 STDMETHOD_(
void, GetLanguageA)(THIS_ IStringA *out) SCONST
64 STDMETHOD_(BOOL, CreateTranslator)(THIS_ ITranslator **ppTranslator)
68 STDMETHOD_(BOOL, InstallTranslator)(THIS_ ITranslator *ppTranslator)
72 STDMETHOD_(BOOL, UninstallTranslator)(THIS_ REFGUID id)
77 (THIS_
const IStringW *strSrc,
const IStringW *strCtx,
wchar_t *pszOut,
int nLen) SCONST
83class SDefToolTipFactory :
public TObjRefImpl<IToolTipFactory> {
85 STDMETHOD_(IToolTip *, CreateToolTip)(THIS_ HWND hHost) OVERRIDE
87 STipCtrl *pTipCtrl =
new STipCtrl;
96 STDMETHOD_(
void, DestroyToolTip)(THIS_ IToolTip *pToolTip) OVERRIDE
100 STipCtrl *pTipCtrl = (STipCtrl *)pToolTip;
106class SDefMsgLoopFactory :
public TObjRefImpl<IMsgLoopFactory> {
108 STDMETHOD_(HRESULT, CreateMsgLoop)(THIS_ IMessageLoop **ppRet, IMessageLoop *pParentLoop) OVERRIDE
110 *ppRet =
new SMessageLoop(pParentLoop);
167#if defined(_WIN32) && !defined(__MINGW32__)
243 SRichEdit::InitTextService();
258 sysObjRegister.RegisterLayouts(
this);
259 sysObjRegister.RegisterSkins(
this);
260 sysObjRegister.RegisterWindows(
this);
261 sysObjRegister.RegisterInterpolator(
this);
262 sysObjRegister.RegisterAnimation(
this);
263 sysObjRegister.RegisterValueAnimator(
this);
270 SRichEdit::UninitTextService();
282#define DELETE_SINGLETON(x) \
283 delete (x *)m_pSingletons[x::GetType()]; \
284 m_pSingletons[x::GetType()] = NULL;
299IAccProxy *SApplication::CreateAccProxy(IWindow *pWnd)
const
301#ifdef SOUI_ENABLE_ACC
304 return new SAccProxyProgress(pWnd);
308 return new SAccProxySlideBar(pWnd);
312 return new SAccProxyButton(pWnd);
316 return new SAccProxyCombobox(pWnd);
320 return new SAccProxyEdit(pWnd);
324 return new SAccProxyCheckButton(pWnd);
328 return new SAccProxyRadioButton(pWnd);
331 return new SAccProxyWindow(pWnd);
337IAccessible *SApplication::CreateAccessible(IWindow *pWnd)
const
339#ifdef SOUI_ENABLE_ACC
340 return new SAccessible(pWnd);
349 if (nType < 0 || nType >= SINGLETON_COUNT)
357 if (!
LoadRawBuffer(pszType, pszXmlName, pResProvider, xmlBuf))
360 bool bLoad = xmlDoc.
load_buffer(xmlBuf, xmlBuf.
size(), xml_parse_default, enc_auto);
363 XmlParseResult result;
366 SASSERT_MSGA(bLoad, strMsg);
389 if (2 == ParseResID(strResId, strLst))
404 pRet->InitFromXml(&xmlNode);
417 pRet->InitFromXml(&xmlNode);
432 pRet->
Load(&xmlNode, 1);
445 trModule->getFontInfo(&strFontInfo);
448 GETUIDEF->SetDefFontInfo(strFontInfo);
469 if (
_LoadXmlDocment(_T(
"SYS_XML_SKIN"), _T(
"XML"), xmlDoc, pResProvider))
471 ISkinPool *p = GETUIDEF->GetBuiltinSkinPool();
473 p->LoadSkins(&xmlSkin);
503 int nRet = pMsgLoop->Run();
514 SPOSITION pos = m_msgLoopMap.GetStartPosition();
517 IMessageLoop *pMsgLoop = m_msgLoopMap.GetNextValue(pos);
518 pMsgLoop->
Quit(nCode);
559 GETUIDEF->SetRenderFactory(renderFac);
605 m_namedID.Init2(pNamedValue, nCount, bSorted);
610 m_namedID.Init3(pNames, nIds, nCount, TRUE);
635 strClsName = strClsName.
Left(nPos);
636 IWindow *pRet = (IWindow *)
CreateObject(strClsName, Window);
637 if (pRet && nPos != -1)
639 pRet->SetAttribute(L
"class", pszWndClass, TRUE);
651 return (IInterpolator *)
CreateObject(pszName, Interpolator);
661 return (IValueAnimator *)
CreateObject(pszName, ValueAnimator);
697 SASSERT(pMsgLoop != NULL);
698 tid_t dwThreadID = ::GetCurrentThreadId();
699 if (m_msgLoopMap.Lookup(dwThreadID) != NULL && !bReplace)
702 m_msgLoopMap[dwThreadID] = pMsgLoop;
709 MsgLoopMap::CPair *p = m_msgLoopMap.Lookup(::GetCurrentThreadId());
714 m_msgLoopMap.RemoveKey(p->m_key);
721 const MsgLoopMap::CPair *p = m_msgLoopMap.Lookup(dwThreadID);
780 GETUIDEF->SetDefFontInfo(pszFontInfo);
795 for (
int i = 0; i < nCount; i++)
808 if (iTaskLoop >= 0 && iTaskLoop < (
int)
m_lstTaskLoop.GetCount())
Header file for the SAutoBuf class, a smart buffer management class.
SOUI Font Management Module.
Interface and Implementation for Native Window Handling.
SNSBEGIN SOUI_EXP SObjectInfo ObjInfo_New(LPCWSTR name, int type, LPCWSTR alise=NULL)
Creates a new object information structure.
Provides a simple timing engine for running animations which calculate animated values and set them o...
An interpolator where the rate of change starts and ends slowly, accelerating in the middle.
An interpolator where the rate of change starts slow and accelerates.
Class for embedding ActiveX controls in SUI windows.
An animation that controls the alpha level of an object.
Abstraction for an Animation that can be applied to Views, Surfaces, or other objects.
Represents a group of Animations that should be played together.
An interpolator where the change starts backward before moving forward.
An interpolator where the change starts backward before moving forward and overshoots the target.
const SStringT & AppDir()
获取应用程序目录路径
~SApplication(void)
Destructor for SApplication.
SAutoRefPtr< IScriptFactory > m_pScriptFactory
Pointer to the script factory.
void EnableNotifyCenter(BOOL bEnable, int interval=20) OVERRIDE
Enable or disable the notification center.
virtual ISkinObj * CreateSkinByName(LPCWSTR pszSkinClass) const
Create a skin by name.
int Str2ID(const SStringW &str)
Convert a string to an ID.
ITaskLoop * GetTaskLoop(int iTaskLoop=0) OVERRIDE
Get a task loop by index.
UINT LoadSystemNamedResource(IResProvider *pResProvider) OVERRIDE
Load system named resources.
ITranslatorMgr * GetTranslator() OVERRIDE
Get the translator manager.
virtual IInterpolator * CreateInterpolatorByName(LPCWSTR pszName) const
Create an interpolator by name.
void Quit(int nCode) OVERRIDE
Quit the application.
HMODULE m_hInst
Module handle.
ITranslator * LoadTranslator(LPCTSTR strResId) OVERRIDE
Load a translator from a resource.
BOOL UnnstallTranslator(REFGUID langId) OVERRIDE
Uninstall a translator by language ID.
BOOL AddMsgLoop(IMessageLoop *pMsgLoop, BOOL bReplace=FALSE) OVERRIDE
Add a message loop.
HWND m_hMainWnd
Handle to the main window.
SAutoRefPtr< ITranslatorMgr > m_translator
Pointer to the translator manager.
IMessageLoop * GetMsgLoop(tid_t tid=::GetCurrentThreadId()) SCONST OVERRIDE
Get the message loop for a specific thread.
SApplication(IRenderFactory *pRendFactory, HINSTANCE hInst, LPCTSTR pszHostClassName=_T("SOUIHOST"), const ISystemObjectRegister &sysObjRegister=SObjectDefaultRegister(), BOOL bImeApp=FALSE)
Constructor for SApplication.
SNamedID m_namedID
Named ID manager.
IResProviderMgr * GetResProviderMgr() OVERRIDE
Get the resource provider manager.
BOOL UnregisterObjFactory(const IObjectFactory *objFac) OVERRIDE
Unregister an object factory.
SStringW tr(const SStringW &strSrc, const SStringW &strCtx) const
Translate a string with context.
SXmlDoc m_xmlMessageBoxTemplate
XML document for the message box template.
virtual IAnimation * CreateAnimationByName(LPCWSTR pszName) const
Create an animation by name.
IAttrStorageFactory * GetAttrStorageFactory() OVERRIDE
Get the attribute storage factory.
BOOL _LoadXmlDocment(LPCTSTR pszXmlName, LPCTSTR pszType, SXmlDoc &xmlDoc, IResProvider *pResProvider=NULL)
Loads an XML document from a resource.
SXmlNode GetMessageBoxTemplate() const
Get the message box template XML node.
SXmlNode GetEditCtxMenuTemplate() const
Get the edit context menu template XML node.
void * m_pSingletons[SINGLETON_COUNT]
Array of singleton pointers.
int Run(HWND hMainWnd) OVERRIDE
Run the application message loop.
SStringT m_strAppDir
Application directory path.
SAutoRefPtr< ILogMgr > m_logManager
Pointer to the log manager.
void _CreateSingletons()
Creates and initializes all singletons required by the application.
BOOL SetMessageBoxTemplateResId(LPCTSTR resId, IResProvider *pResProvider=NULL) OVERRIDE
Set the resource ID for the message box template.
IToolTipFactory * GetToolTipFactory() OVERRIDE
Get the tooltip factory.
void _DestroySingletons()
Destroys and cleans up all singletons used by the application.
void * GetInnerSingleton(SingletonType nType) OVERRIDE
Get an inner singleton.
BOOL SetEditCtxMenuTemplateResId(LPCTSTR resId, IResProvider *pResProvider=NULL) OVERRIDE
Set the resource ID for the edit context menu template.
void SetCreateTaskLoopCallback(FunCrateTaskLoop cbCreateTaskLoop) OVERRIDE
Set the callback for creating task loops.
SAutoRefPtr< IRealWndHandler > m_pRealWndHandler
Pointer to the real window handler.
void SetCreateObjectCallback(FunCreateObject cbCreateObj) OVERRIDE
Set the callback for creating objects.
SXmlDoc m_xmlEditCtxMenuTemplate
XML document for the edit context menu template.
IMsgLoopFactory * GetMsgLoopFactory() OVERRIDE
Get the message loop factory.
void SetAttrStorageFactory(IAttrStorageFactory *pAttrStorageFactory) OVERRIDE
Set the attribute storage factory.
BOOL SetRenderFactory(IRenderFactory *renderFac) OVERRIDE
Set the render factory.
HWND GetMainWnd() OVERRIDE
Get the main window handle.
SCriticalSection m_cs
Critical section for thread-safe operations.
FunCrateTaskLoop m_cbCreateTaskLoop
Callback function for creating task loops.
BOOL RemoveMsgLoop() OVERRIDE
Remove the current message loop.
BOOL CreateTaskLoop(int nCount, Priority priority, BOOL bAutoStart=TRUE) OVERRIDE
Create task loops.
SAutoRefPtr< IToolTipFactory > m_tooltipFactory
Pointer to the tooltip factory.
FunCreateObject m_cbCreateObj
Callback function for creating objects.
void SetLogManager(ILogMgr *pLogMgr) OVERRIDE
Set the log manager.
IValueAnimator * LoadValueAnimator(LPCTSTR strResId) OVERRIDE
Load a value animator from a resource.
IXmlDoc * LoadXmlDocment(LPCTSTR strResId) OVERRIDE
Load an XML document from a resource.
IRealWndHandler * GetRealWndHander() OVERRIDE
Get the real window handler.
ILogMgr * GetLogManager() OVERRIDE
Get the log manager.
virtual IWindow * CreateWindowByName(LPCWSTR pszWndClass) const
Create a window by name.
IRenderFactory * GetRenderFactory() OVERRIDE
Get the render factory.
void SetDefaultFontInfo(LPCWSTR pszFontInfo) OVERRIDE
Set the default font information.
BOOL InstallTranslator(ITranslator *trModule) OVERRIDE
Install a translator.
void SetAppDir(const SStringT &strAppDir)
Set the application directory.
SAutoRefPtr< IMsgLoopFactory > m_msgLoopFactory
Pointer to the message loop factory.
IObject * CreateObject(LPCWSTR pszName, SObjectType nType) SCONST OVERRIDE
Create an object by name and type.
virtual IValueAnimator * CreateValueAnimatorByName(LPCWSTR pszName) const
Create a value animator by name.
BOOL RegisterObjFactory(const IObjectFactory *objFac, BOOL bReplace=FALSE) OVERRIDE
Register an object factory.
void SetScriptFactory(IScriptFactory *pScriptModule) OVERRIDE
Set the script factory.
void SetToolTipFactory(IToolTipFactory *pToolTipFac) OVERRIDE
Set the tooltip factory.
SArray< SAutoRefPtr< ITaskLoop > > m_lstTaskLoop
List of task loops.
BOOL SetMsgLoopFactory(IMsgLoopFactory *pMsgLoopFac) OVERRIDE
Set the message loop factory.
HRESULT CreateScriptModule(IScriptModule **ppScriptModule) OVERRIDE
Create a script module.
SAutoRefPtr< IAttrStorageFactory > m_pAttrStroageFactory
Pointer to the attribute storage factory.
void SetRealWndHandler(IRealWndHandler *pRealHandler) OVERRIDE
Set the real window handler.
void InitXmlNamedID(const LPCWSTR *pNames, const int *nIds, int nCount) OVERRIDE
Initialize XML named IDs from arrays.
void SetTranslator(ITranslatorMgr *pTrans) OVERRIDE
Set the translator manager.
IAnimation * LoadAnimation(LPCTSTR strResId) OVERRIDE
Load an animation from a resource.
SAutoRefPtr< IRenderFactory > m_RenderFactory
Pointer to the render factory.
HMODULE GetModule() SCONST OVERRIDE
Get the module handle.
SStringT GetAppDir() const
Get the application directory.
A smart buffer management class that automatically handles memory allocation and deallocation.
size_t size()
Returns the size of the managed buffer.
Auto-lock class for managing critical sections.
Smart pointer class for managing COM-style reference-counted objects.
An interpolator where the change bounces at the end.
Animator for COLORREF values.
Editable ComboBox Control.
Edit Control Embedded in ComboBox.
ComboBox Control with ListView.
An interpolator where the change repeats a specified number of cycles.
An interpolator where the rate of change starts fast and decelerates.
Animator for float values.
void DispatchMessage(UINT uMsg, WPARAM wp=0, LPARAM lp=0)
分发消息到宿主窗口
Animator for integer values.
An interpolator where the rate of change is constant.
Multi-Column List View Control.
static void InitWndClass(HINSTANCE hInst, LPCTSTR pszSimpleWndName, BOOL bImeWnd)
Initializes the window class.
BOOL DestroyWindow() OVERRIDE
Destroys the window.
void RegisterValueAnimator(SObjectFactoryMgr *objFactory) const
Register value animator objects into the object factory.
void RegisterInterpolator(SObjectFactoryMgr *objFactory) const
Register interpolator objects into the object factory.
void RegisterSkins(SObjectFactoryMgr *objFactory) const
Register skin objects into the object factory.
void RegisterLayouts(SObjectFactoryMgr *objFactory) const
Register layout objects into the object factory.
void RegisterWindows(SObjectFactoryMgr *objFactory) const
Register window objects into the object factory.
void RegisterAnimation(SObjectFactoryMgr *objFactory) const
Register animation objects into the object factory.
Manager for object factories.
BOOL UnregisterFactory(const SObjectInfo &objInfo)
Unregisters an object factory.
virtual IObject * CreateObject(const SObjectInfo &objInfo) const
Creates an object based on the given object information.
BOOL TplRegisterFactory()
Template method to register a factory for a specific object type.
BOOL RegisterFactory(const IObjectFactory *objFactory, BOOL bReplace=false)
Registers an object factory.
static LPCWSTR GetClassName()
An interpolator where the change overshoots the target and then comes back.
Panel with Scrollbar Support.
Animator for POINT values.
Animator for RECT values.
void RemoveResProvider(IResProvider *pResProvider) OVERRIDE
Removes a resource provider.
void AddResProvider(IResProvider *pResProvider, LPCTSTR pszUidef=_T("uidef:xml_init")) OVERRIDE
Adds a resource provider with a specified UI definition.
void RemoveAll() OVERRIDE
Removes all resource providers.
BOOL LoadRawBuffer(LPCTSTR pszType, LPCTSTR pszResName, IResProvider *pResProvider, SAutoBuf &buf)
Loads the raw buffer for a resource using a specified resource provider.
An animation that controls the rotation of an object. This rotation takes place in the X-Y plane.
Represents a group of skins for different states.
An animation that controls the scale of an object. You can specify the point to use for the center of...
static SHostMgr * getSingletonPtr(void)
static T * ms_Singleton
Static pointer to the singleton instance.
Animator for SIZE values.
Enhanced Image Frame Skin.
A pane within a split window.
A horizontal split window.
A split window that can contain multiple panes.
A page within a stack view.
A stack view that can contain multiple pages.
A class representing an ASCII string.
BOOL __cdecl Format(HINSTANCE hInst, UINT nFormatID,...)
Formats a string using a format string and variable arguments.
A class representing an ASCII string.
void ReleaseBuffer(int nNewLength=-1)
Releases the buffer and sets the new length of the string.
BOOL IsEmpty() SCONST
Checks if the string is empty.
wchar_t * GetBufferSetLength(int nNewLength)
Retrieves a modifiable buffer for the string and sets the new length.
SStringW Left(int nCount) const
Extracts the leftmost part of the string.
int ReverseFind(wchar_t ch) SCONST
Finds the last occurrence of a character in the string.
A switch control class derived from SWindow.
A tab control for managing multiple tab pages.
A tab page within a tab control.
A tile view control for displaying items in a grid layout.
An animation that controls the position of an object.
A tree control for displaying hierarchical data.
Class representing a tree view control.
Manages UI definitions, including skins, styles, templates, gradients, and named values.
Base class for SOUI DUI windows.
Manages DUI windows in the SOUI system.
const wchar_t * value() const
Gets the attribute value.
Implementation of IXmlDoc.
static const char * GetErrDesc(XmlStatus status)
Retrieves the error description for a given XML status.
void GetParseResult(XmlParseResult *pResult) SCONST OVERRIDE
Retrieves the result of the last parsing operation.
SXmlNode root() const
Retrieves the root node of the document.
void Reset() OVERRIDE
Resets the document, removing all nodes.
bool load_buffer(const void *contents, size_t size, unsigned int options=xml_parse_default, XmlEncoding encoding=enc_auto)
Loads the document from a buffer.
Class representing an XML node.
SXmlNode first_child() const
Gets the first child node of the node.
const wchar_t * name() const
Gets the name of the node.
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Template class implementing the IObjRef interface.
XmlStatus status
Parsing status (see XmlStatus).
ptrdiff_t offset
Last parsed offset (in char_t units from the start of input data).
Interface for message loops.
void Quit(int exitCode=0) PURE
Quits the message loop.
Interface for creating message loops.
HRESULT CreateMsgLoop(IMessageLoop **ppMsgLoop, IMessageLoop *pParentLoop=NULL) PURE
Creates a message loop.
Interface for handling real window operations.
Interface for Skin Objects.
Language Translation Interface.
BOOL Load(LPVOID pData, UINT uType) PURE
Loads language translation data from a resource.
Language Translation Interface Manager.
BOOL InstallTranslator(ITranslator *ppTranslator) PURE
Installs a language translation object into the manager.
BOOL UninstallTranslator(REFGUID id) PURE
Uninstalls a language translation object from the manager.
Interface for XML Document.