/** * @file XTPSkinObject.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(_XTPSKINOBJECT_H__) # define _XTPSKINOBJECT_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPSkinManager; class CXTPSkinManagerClass; class CXTPSkinManagerMetrics; class CXTPSkinManagerSchema; /** @cond */ // Internal enumerator /** * @brief * Defines skin default window procedure. */ enum XTPSkinDefaultProc { xtpSkinDefaultHookMessage, /**< Specifies HookMessage as a default window procedure. */ xtpSkinDefaultCallWindowProc, /**< Specifies CallWindowProc as a default window procedure. */ xtpSkinDefaultDefWindowProc, /**< Specifies DefWindowProc as a default window procedure. */ xtpSkinDefaultDefMDIChildProc, /**< Specifies DefMDIChildProc as a default window procedure. */ xtpSkinDefaultDefFrameProc, /**< Specifies DefFrameProc as a default window procedure. */ xtpSkinDefaultDefDlgProc /**< Specifies DefDlgProc as a default window procedure. */ }; class _XTP_EXT_CLASS CXTPSkinObjectPaintDC : public CDC { // Constructors public: CXTPSkinObjectPaintDC(CWnd* pWnd); virtual ~CXTPSkinObjectPaintDC(); // Attributes protected: HWND m_hWnd; public: PAINTSTRUCT m_ps; }; /** @endcond */ /** * @brief * CXTPSkinObject is a CWnd derived class. It represents the * base class for all skinable windows. */ class _XTP_EXT_CLASS CXTPSkinObject : public CWnd , public CXTPSynchronized { DECLARE_DYNAMIC(CXTPSkinObject); protected: /** * @brief * Constructs a CXTPSkinObject object. */ CXTPSkinObject(); /** * @brief * Destroys a CXTPSkinObject object, handles cleanup and deallocation. */ ~CXTPSkinObject(); public: /** * @brief * Gets the parent CXTPSkinManager object. * @return * A pointer to the parent CXTPSkinManager object. */ CXTPSkinManager* GetSkinManager() const; /** * @brief * Gets own class name. * @return * Own class name. * @see * GetSkinClass */ CString GetClassName() const; /** * @brief * Gets the CXTPSkinManagerClass object associated with own class name. * @return * A pointer to the CXTPSkinManagerClass object associated with own class name. * @see * GetClassName */ CXTPSkinManagerClass* GetSkinClass() const; /** * @brief * Gets the skin metrics. * @return * A pointer to the CXTPSkinManagerMetrics class containing the skin metrics. */ CXTPSkinManagerMetrics* GetMetrics() const; CXTPSkinManagerSchema* GetSchema() const; /** * @brief * Retrieves the specified system color. * @param nIndex Index of the system color to retrieve, as described in the * GetSysColor function documentation from the Windows SDK. * @return * The specified system color. */ COLORREF GetColor(int nIndex) const; BOOL IsSkinEnabled() const; protected: /** * @brief * This method is called when the skin is changed. * @param bPrevState TRUE if the previous skin was installed. * @param bNewState TRUE if the current skin is installed. */ virtual void OnSkinChanged(BOOL bPrevState, BOOL bNewState); /** * @brief * This method is called when visual metrics are changed. */ virtual void RefreshMetrics(); /** * @brief * This method is called when the hook is attached. * @param lpcs Pointer to a LPCREATESTRUCT structure that contains * information about the CWnd object being created. * @param bAuto TRUE to automatically skin the window when a new * window is created or when the user manually skins * the existing window. */ virtual void OnHookAttached(LPCREATESTRUCT lpcs, BOOL bAuto); /** * @brief * This method is called when the hook is detached. * @param bAuto TRUE to automatically skin the window when a new * window is created or when the user manually skins * the existing window. */ virtual void OnHookDetached(BOOL bAuto); BOOL IsDrawingEnabled(BOOL bForceUpdateStatus = FALSE) const; /** @cond */ public: UINT GetHeadMessage(); protected: virtual BOOL CheckDrawingEnabled(); virtual BOOL OnHookMessage(UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); virtual BOOL OnHookDefWindowProc(UINT nMessage, WPARAM& wParam, LPARAM& lParam, LRESULT& lResult); void AttachHook(HWND hWnd, LPCREATESTRUCT lpcs, BOOL bAuto); void UnattachHook(BOOL bAuto); virtual void OnFinalRelease(); virtual WNDPROC* GetSuperWndProcAddr(); virtual BOOL IsDefWindowProcAvail(int nMessage) const; virtual LRESULT DefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam); virtual BOOL PreHookMessage(UINT nMessage); # ifdef _DEBUG virtual void AssertValid() const { } # endif void SetWindowProc(); void OnBeginHook(UINT nMessage, XTPSkinDefaultProc defProc, PROC defProcAddr, LPVOID defProcPrevWndFunc); void OnEndHook(); LRESULT DoDefWindowProc(UINT nMsg, WPARAM wParam, LPARAM lParam); static CString AFX_CDECL GetWndClassTreePath(HWND hWnd, BOOL bPathOnly = FALSE); /** @endcond */ public: static const UINT m_nMsgQuerySkinState; static const UINT m_nMsgUpdateSkinState; static const UINT m_nMsgSkinChanged; protected: WNDPROC m_pOldWndProc; /**< Old window window handler. */ CXTPSkinManager* m_pManager; /**< Parent CXTPSkinManager object. */ CString m_strClassName; /**< Own class name. */ BOOL m_bActiveX; /**< TRUE if ActiveX controls. */ BOOL m_bWindowsForms; /**< TRUE if .NET controls. */ BOOL m_bCustomDraw; BOOL m_bUnicode; CRITICAL_SECTION m_csDescriptors; BOOL m_bSystemWindowModule; BOOL m_bWindowProcAttached; BOOL m_bSetWindowProc; CXTPSkinManagerSchema* m_pSchema; private: struct DEFWINDOW_DESCRIPTIOR { XTPSkinDefaultProc defProc; PROC defProcAddr; LPVOID lpPrev; UINT nMessage; }; CList m_arrDescriptors; BOOL m_bDrawingEnabled; protected: friend class CXTPSkinManager; friend class CXTPSkinManagerApiHookBase; friend class CXTPSkinObjectClassInfoActiveX; }; /** @cond */ class CXTPSkinObjectClassMap; class _XTP_EXT_CLASS CXTPSkinObjectClassInfo : public CXTPCmdTarget , public CXTPSynchronized { public: CXTPSkinObjectClassInfo(CRuntimeClass* pClass); public: virtual CXTPSkinObject* CreateObject(LPCTSTR lpszClassName, LPCREATESTRUCT lpcs); public: void AddClass(LPCTSTR lpszClassName); void Remove(); protected: CRuntimeClass* m_pClass; CXTPSkinObjectClassMap* m_pMap; friend class CXTPSkinObjectClassMap; }; class _XTP_EXT_CLASS CXTPSkinObjectClassInfoActiveX : public CXTPSkinObjectClassInfo { public: CXTPSkinObjectClassInfoActiveX(CRuntimeClass* pClass, BOOL bSysModule, BOOL bSetWindowProc) : CXTPSkinObjectClassInfo(pClass) { m_bSysModule = bSysModule; m_bSetWindowProc = bSetWindowProc; } virtual CXTPSkinObject* CreateObject(LPCTSTR lpszClassName, LPCREATESTRUCT lpcs) { CXTPSkinObject* pObject = CXTPSkinObjectClassInfo::CreateObject(lpszClassName, lpcs); if (pObject) { pObject->m_bActiveX = TRUE; if (m_bSysModule) pObject->m_bSystemWindowModule = TRUE; if (m_bSetWindowProc) pObject->m_bSetWindowProc = TRUE; } return pObject; } BOOL m_bSysModule; BOOL m_bSetWindowProc; }; /** @endcond */ /** * @brief * CXTPSkinObjectClassMap is a standalone class that helps map windows controls * to skin framework classes. * @details * CXTPSkinManager uses this class to find what skin framework class needs * to apply to a new window in order to skin it properly. For example, * if a new window were to be created with the class name of "BUTTON", * then CXTPSkinObjectClassMap::Lookup would retrieve the runtime class * of CXTPSkinObjectButton to apply it to the new window and skin it. * @see * CXTPSkinManager, CXTPSkinObject, CXTPSkinManager::GetClassMap */ class _XTP_EXT_CLASS CXTPSkinObjectClassMap : public CXTPSynchronized { public: /** * @brief * Constructs a CXTPSkinObjectClassMap object. */ CXTPSkinObjectClassMap(); /** * @brief * Destroys a CXTPSkinObjectClassMap object, handles cleanup and deallocation. */ ~CXTPSkinObjectClassMap(); public: /** * @brief * This method is called by the framework to add all standard window classes. * @details * CXTPSkinManager calls this method to add standard window classes such as * "BUTTON", "LISTBOX", and "SCROLLBAR". */ void AddStandardClasses(); public: /** * @brief * Maps a window class name to a skin framework class. * @param lpszClassName Window class name. * @param pInfo Pointer to the skin framework class. * * Example: *
pClassMap->AddClass(_T("ListBox"), new
	 * CXTPSkinObjectClassInfo(RUNTIME_CLASS(CXTPSkinObjectListBox)));
* @return A requested skin object class information object pointer, or NULL if failed. * @see * AddSynonymClass, AddStandardClasses */ CXTPSkinObjectClassInfo* AddClass(LPCTSTR lpszClassName, CXTPSkinObjectClassInfo* pInfo); /** * @brief * Maps a window class name to another window class name. * @param lpszClassNameSynonym New window class name. * @param lpszClassName Standard window class name. * * Example: *
pClassMap->AddSynonymClass(_T("SysDateTimePick32"), _T("Edit"));
* @see * AddClass */ void AddSynonymClass(LPCTSTR lpszClassNameSynonym, LPCTSTR lpszClassName); /** * @brief * Removes a window class. * @param lpszClassName Window class name to remove. * @see * AddClass */ void RemoveClass(LPCTSTR lpszClassName); /** * @brief * Removes a skin framework class. * @param pInfo Pointer to the skin framework class. * @see * AddClass */ void RemoveClass(CXTPSkinObjectClassInfo* pInfo); /** * @brief * Removes all classes. * @see * AddClass */ void RemoveAll(); /** * @brief * Searches for a Skin Object Class Information object by a specified name. * @param lpszClassName Name of the class to lookup. * @return * A pointer to the CXTPSkinObjectClassInfo object if found, otherwise NULL. */ CXTPSkinObjectClassInfo* Lookup(LPCTSTR lpszClassName); protected: CMapStringToPtr m_mapInfo; /**< General map. */ }; AFX_INLINE CXTPSkinManager* CXTPSkinObject::GetSkinManager() const { return m_pManager; } AFX_INLINE CString CXTPSkinObject::GetClassName() const { return m_strClassName; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(_XTPSKINOBJECT_H__) /** @endcond */