├── Duilib ├── Bin │ └── DuiLib.dll ├── Control │ ├── RollTextUI.cpp │ ├── RollTextUI.h │ ├── UIActiveX.cpp │ ├── UIActiveX.h │ ├── UIAnimation.cpp │ ├── UIAnimation.h │ ├── UIButton.cpp │ ├── UIButton.h │ ├── UIColorPalette.cpp │ ├── UIColorPalette.h │ ├── UICombo.cpp │ ├── UICombo.h │ ├── UIComboBox.cpp │ ├── UIComboBox.h │ ├── UIComboEX.cpp │ ├── UIComboEX.h │ ├── UIDateTime.cpp │ ├── UIDateTime.h │ ├── UIEdit.cpp │ ├── UIEdit.h │ ├── UIFadeButton.cpp │ ├── UIFadeButton.h │ ├── UIFlash.cpp │ ├── UIFlash.h │ ├── UIGifAnim.cpp │ ├── UIGifAnim.h │ ├── UIGifAnimEx.cpp │ ├── UIGifAnimEx.h │ ├── UIGroupBox.cpp │ ├── UIGroupBox.h │ ├── UIHotKey.cpp │ ├── UIHotKey.h │ ├── UIIPAddress.cpp │ ├── UIIPAddress.h │ ├── UILabel.cpp │ ├── UILabel.h │ ├── UIList.cpp │ ├── UIList.h │ ├── UIListEx.cpp │ ├── UIListEx.h │ ├── UIList_3.0.cpp │ ├── UIList_3.0.h │ ├── UIMenu - 副本.cpp │ ├── UIMenu - 副本.h │ ├── UIMenu.cpp │ ├── UIMenu.h │ ├── UIOption.cpp │ ├── UIOption.h │ ├── UIProgress.cpp │ ├── UIProgress.h │ ├── UIRichEdit.cpp │ ├── UIRichEdit.h │ ├── UIScrollBar.cpp │ ├── UIScrollBar.h │ ├── UISlider.cpp │ ├── UISlider.h │ ├── UIText.cpp │ ├── UIText.h │ ├── UITreeView.cpp │ ├── UITreeView.h │ ├── UIWebBrowser.cpp │ └── UIWebBrowser.h ├── Core │ ├── ControlFactory.cpp │ ├── ControlFactory.h │ ├── UIBase.cpp │ ├── UIBase.h │ ├── UIContainer.cpp │ ├── UIContainer.h │ ├── UIControl.cpp │ ├── UIControl.h │ ├── UIDefine.h │ ├── UIDlgBuilder.cpp │ ├── UIDlgBuilder.h │ ├── UIManager.cpp │ ├── UIManager.h │ ├── UIMarkup.cpp │ ├── UIMarkup.h │ ├── UIRender.cpp │ ├── UIRender.h │ ├── UIResourceManager.cpp │ ├── UIResourceManager.h │ ├── UITimer.cpp │ └── UITimer.h ├── DuiLib.sln ├── DuiLib.v11.suo ├── DuiLib.vcxproj ├── DuiLib.vcxproj.filters ├── DuiLib.vcxproj.user ├── Layout │ ├── UIAnimationTabLayout.cpp │ ├── UIAnimationTabLayout.h │ ├── UIChildLayout.cpp │ ├── UIChildLayout.h │ ├── UIHorizontalLayout.cpp │ ├── UIHorizontalLayout.h │ ├── UITabLayout.cpp │ ├── UITabLayout.h │ ├── UITileLayout.cpp │ ├── UITileLayout.h │ ├── UIVerticalLayout.cpp │ └── UIVerticalLayout.h ├── Lib │ ├── DuiLib.lib │ └── DuiLib_d.lib ├── StdAfx.cpp ├── StdAfx.h ├── UILib.cpp ├── UIlib.h └── Utils │ ├── DragDropImpl.cpp │ ├── DragDropImpl.h │ ├── DuiTrayIcon.cpp │ ├── DuiTrayIcon.h │ ├── Flash11.tlb │ ├── FlashEventHandler.h │ ├── TrayIcon.cpp │ ├── TrayIcon.h │ ├── UIDelegate.cpp │ ├── UIDelegate.h │ ├── UIShadow.cpp │ ├── UIShadow.h │ ├── Utils.cpp │ ├── Utils.h │ ├── WebBrowserEventHandler.h │ ├── WinImplBase.cpp │ ├── WinImplBase.h │ ├── WndShadow.cpp │ ├── WndShadow.h │ ├── XUnzip.cpp │ ├── downloadmgr.h │ ├── flash11.tlh │ ├── observer_impl_base.h │ └── stb_image.h ├── DuilibPreview.sln ├── DuilibPreview ├── App.cpp ├── App.h ├── DuiLib.dll ├── DuiLib.lib ├── DuiLib_u.dll ├── DuilibPreview.vcproj ├── DuilibPreview.vcxproj ├── DuilibPreview.vcxproj.filters ├── DuilibPreview.vcxproj.user ├── MainWnd.cpp ├── MainWnd.h ├── PreviewWnd.cpp ├── PreviewWnd.h ├── PreviewXml.cpp ├── PreviewXml.h ├── StringTools.cpp ├── StringTools.h ├── WinImplBase.hpp ├── resource.h ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── Lib └── DuiLib.lib ├── Readme.md └── Release └── skin ├── MainDlg.xml ├── shadow.png ├── shadow2.png ├── sys_btn_close.png ├── sys_btn_max.png ├── sys_btn_min.png └── sys_btn_restore.png /Duilib/Bin/DuiLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Bin/DuiLib.dll -------------------------------------------------------------------------------- /Duilib/Control/RollTextUI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/RollTextUI.cpp -------------------------------------------------------------------------------- /Duilib/Control/RollTextUI.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITEXTSCROLLH__ 2 | #define __UITEXTSCROLLH__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | #define ROLLTEXT_LEFT 0 9 | #define ROLLTEXT_RIGHT 1 10 | #define ROLLTEXT_UP 2 11 | #define ROLLTEXT_DOWN 3 12 | 13 | #define ROLLTEXT_TIMERID 20 14 | #define ROLLTEXT_TIMERID_SPAN 50U 15 | 16 | #define ROLLTEXT_ROLL_END 21 17 | #define ROLLTEXT_ROLL_END_SPAN 1000*6U 18 | 19 | class UILIB_API CRollTextUI : public CLabelUI 20 | { 21 | DECLARE_DUICONTROL(CRollTextUI) 22 | public: 23 | CRollTextUI(void); 24 | ~CRollTextUI(void); 25 | 26 | public: 27 | LPCTSTR GetClass() const; 28 | LPVOID GetInterface(LPCTSTR pstrName); 29 | 30 | public: 31 | virtual void PaintText(HDC hDC); 32 | virtual void DoEvent(TEventUI& event); 33 | virtual void SetPos(RECT rc); 34 | 35 | public: 36 | void BeginRoll(int nDirect = ROLLTEXT_RIGHT, LONG lMaxTimeLimited = 60); 37 | void EndRoll(); 38 | 39 | private: 40 | int m_nStep; 41 | int m_nScrollYPos; 42 | int m_nScrollXPos; 43 | BOOL m_bUseRoll; 44 | int m_nRollDirection; 45 | int m_nTextHeight; 46 | int m_nTextWidth; 47 | BOOL m_bTextInfoGotten; 48 | BOOL m_bRollPosSetted; 49 | int m_oldX; 50 | int m_oldY; 51 | }; 52 | 53 | } // namespace DuiLib 54 | 55 | #endif // __UITEXTSCROLLH__ -------------------------------------------------------------------------------- /Duilib/Control/UIActiveX.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIActiveX.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIActiveX.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIACTIVEX_H__ 2 | #define __UIACTIVEX_H__ 3 | 4 | #pragma once 5 | 6 | struct IOleObject; 7 | 8 | 9 | namespace DuiLib { 10 | ///////////////////////////////////////////////////////////////////////////////////// 11 | // 12 | 13 | class CActiveXCtrl; 14 | 15 | template< class T > 16 | class CSafeRelease 17 | { 18 | public: 19 | CSafeRelease(T* p) : m_p(p) { }; 20 | ~CSafeRelease() { if( m_p != NULL ) m_p->Release(); }; 21 | T* Detach() { T* t = m_p; m_p = NULL; return t; }; 22 | T* m_p; 23 | }; 24 | 25 | ///////////////////////////////////////////////////////////////////////////////////// 26 | // 27 | 28 | class UILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI 29 | { 30 | DECLARE_DUICONTROL(CActiveXUI) 31 | 32 | friend class CActiveXCtrl; 33 | public: 34 | CActiveXUI(); 35 | virtual ~CActiveXUI(); 36 | 37 | LPCTSTR GetClass() const; 38 | LPVOID GetInterface(LPCTSTR pstrName); 39 | 40 | HWND GetHostWindow() const; 41 | 42 | bool IsDelayCreate() const; 43 | void SetDelayCreate(bool bDelayCreate = true); 44 | 45 | bool CreateControl(const CLSID clsid); 46 | bool CreateControl(LPCTSTR pstrCLSID); 47 | HRESULT GetControl(const IID iid, LPVOID* ppRet); 48 | CLSID GetClisd() const; 49 | CDuiString GetModuleName() const; 50 | void SetModuleName(LPCTSTR pstrText); 51 | 52 | void SetVisible(bool bVisible = true); 53 | void SetInternVisible(bool bVisible = true); 54 | void SetPos(RECT rc, bool bNeedInvalidate = true); 55 | void Move(SIZE szOffset, bool bNeedInvalidate = true); 56 | void DoPaint(HDC hDC, const RECT& rcPaint); 57 | 58 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 59 | 60 | LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled); 61 | 62 | protected: 63 | virtual void ReleaseControl(); 64 | virtual bool DoCreateControl(); 65 | 66 | protected: 67 | CLSID m_clsid; 68 | CDuiString m_sModuleName; 69 | bool m_bCreated; 70 | bool m_bDelayCreate; 71 | IOleObject* m_pUnk; 72 | CActiveXCtrl* m_pControl; 73 | HWND m_hwndHost; 74 | }; 75 | 76 | } // namespace DuiLib 77 | 78 | #endif // __UIACTIVEX_H__ 79 | -------------------------------------------------------------------------------- /Duilib/Control/UIAnimation.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIAnimation.h" 3 | #include 4 | #include 5 | 6 | namespace DuiLib { 7 | struct CUIAnimation::Imp 8 | { 9 | std::vector m_arAnimations; 10 | }; 11 | 12 | CUIAnimation::CUIAnimation(CControlUI* pOwner):m_pImp(new CUIAnimation::Imp()) 13 | { 14 | ASSERT(pOwner != NULL); 15 | m_pControl = pOwner; 16 | } 17 | CUIAnimation:: ~CUIAnimation() 18 | { 19 | if(m_pImp) 20 | { 21 | delete m_pImp; 22 | m_pImp = NULL; 23 | } 24 | } 25 | BOOL CUIAnimation::StartAnimation(int nElapse, int nTotalFrame, int nAnimationID /*= 0*/, BOOL bLoop/* = FALSE*/) 26 | { 27 | CAnimationData* pData = GetAnimationDataByID(nAnimationID); 28 | if( NULL != pData 29 | || nElapse <= 0 30 | || nTotalFrame <= 0 31 | || NULL == m_pControl ) 32 | { 33 | ASSERT(FALSE); 34 | return FALSE; 35 | } 36 | 37 | CAnimationData* pAnimation = new CAnimationData(nElapse, nTotalFrame, nAnimationID, bLoop); 38 | if( NULL == pAnimation ) return FALSE; 39 | 40 | if(m_pControl->GetManager()->SetTimer( m_pControl, nAnimationID, nElapse )) 41 | { 42 | m_pImp->m_arAnimations.push_back(pAnimation); 43 | return TRUE; 44 | } 45 | return FALSE; 46 | } 47 | 48 | void CUIAnimation::StopAnimation(int nAnimationID /*= 0*/) 49 | { 50 | if(m_pControl == NULL) return; 51 | 52 | if(nAnimationID != 0) 53 | { 54 | CAnimationData* pData = GetAnimationDataByID(nAnimationID); 55 | if( NULL != pData ) 56 | { 57 | m_pControl->GetManager()->KillTimer( m_pControl, nAnimationID ); 58 | m_pImp->m_arAnimations.erase(std::remove(m_pImp->m_arAnimations.begin(), m_pImp->m_arAnimations.end(), pData), m_pImp->m_arAnimations.end()); 59 | return; 60 | } 61 | } 62 | else 63 | { 64 | int nCount = m_pImp->m_arAnimations.size(); 65 | for(int i=0; iGetManager()->KillTimer( m_pControl, m_pImp->m_arAnimations[i]->m_nAnimationID ); 68 | } 69 | m_pImp->m_arAnimations.clear(); 70 | } 71 | } 72 | 73 | BOOL CUIAnimation::IsAnimationRunning(int nAnimationID) 74 | { 75 | CAnimationData* pData = GetAnimationDataByID(nAnimationID); 76 | return NULL != pData; 77 | } 78 | 79 | int CUIAnimation::GetCurrentFrame(int nAnimationID/* = 0*/) 80 | { 81 | CAnimationData* pData = GetAnimationDataByID(nAnimationID); 82 | if( NULL == pData ) 83 | { 84 | ASSERT(FALSE); 85 | return -1; 86 | } 87 | return pData->m_nCurFrame; 88 | } 89 | 90 | BOOL CUIAnimation::SetCurrentFrame(int nFrame, int nAnimationID/* = 0*/) 91 | { 92 | CAnimationData* pData = GetAnimationDataByID(nAnimationID); 93 | if( NULL == pData) 94 | { 95 | ASSERT(FALSE); 96 | return FALSE; 97 | } 98 | 99 | if(nFrame >= 0 && nFrame <= pData->m_nTotalFrame) 100 | { 101 | pData->m_nCurFrame = nFrame; 102 | return TRUE; 103 | } 104 | else 105 | { 106 | ASSERT(FALSE); 107 | } 108 | return FALSE; 109 | } 110 | 111 | void CUIAnimation::OnAnimationElapse(int nAnimationID) 112 | { 113 | if(m_pControl == NULL) return; 114 | 115 | CAnimationData* pData = GetAnimationDataByID(nAnimationID); 116 | if( NULL == pData ) return; 117 | 118 | int nCurFrame = pData->m_nCurFrame; 119 | if(nCurFrame == 0) 120 | { 121 | OnAnimationStart(nAnimationID, pData->m_bFirstLoop); 122 | pData->m_bFirstLoop = FALSE; 123 | } 124 | 125 | OnAnimationStep(pData->m_nTotalFrame, nCurFrame, nAnimationID); 126 | 127 | if(nCurFrame >= pData->m_nTotalFrame) 128 | { 129 | OnAnimationStop(nAnimationID); 130 | if(pData->m_bLoop) 131 | { 132 | pData->m_nCurFrame = 0; 133 | } 134 | else 135 | { 136 | m_pControl->GetManager()->KillTimer( m_pControl, nAnimationID ); 137 | m_pImp->m_arAnimations.erase(std::remove(m_pImp->m_arAnimations.begin(), m_pImp->m_arAnimations.end(), pData), m_pImp->m_arAnimations.end()); 138 | pData = NULL; 139 | } 140 | } 141 | 142 | if( NULL != pData ) 143 | { 144 | ++(pData->m_nCurFrame); 145 | } 146 | } 147 | 148 | CAnimationData* CUIAnimation::GetAnimationDataByID(int nAnimationID) 149 | { 150 | CAnimationData* pRet = NULL; 151 | int nCount = m_pImp->m_arAnimations.size(); 152 | for(int i=0; im_arAnimations[i]->m_nAnimationID == nAnimationID) 155 | { 156 | pRet = m_pImp->m_arAnimations[i]; 157 | break; 158 | } 159 | } 160 | 161 | return pRet; 162 | } 163 | 164 | } // namespace DuiLib -------------------------------------------------------------------------------- /Duilib/Control/UIAnimation.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIANIMATION_H__ 2 | #define __UIANIMATION_H__ 3 | 4 | #include "UIButton.h" 5 | #pragma once 6 | 7 | namespace DuiLib { 8 | 9 | class UILIB_API IUIAnimation 10 | { 11 | public: 12 | virtual ~IUIAnimation() { NULL; } 13 | 14 | virtual BOOL StartAnimation(int nElapse, int nTotalFrame, int nAnimationID = 0, BOOL bLoop = FALSE) = 0; 15 | virtual void StopAnimation(int nAnimationID = 0) = 0; 16 | virtual BOOL IsAnimationRunning(int nAnimationID) = 0; 17 | virtual int GetCurrentFrame(int nAnimationID = 0) = 0; 18 | virtual BOOL SetCurrentFrame(int nFrame, int nAnimationID = 0) = 0; 19 | 20 | virtual void OnAnimationStep(int nTotalFrame, int nCurFrame, int nAnimationID) = 0; 21 | virtual void OnAnimationStart(int nAnimationID, BOOL bFirstLoop) = 0; 22 | virtual void OnAnimationStop(int nAnimationID) = 0; 23 | 24 | virtual void OnAnimationElapse(int nAnimationID) = 0; 25 | }; 26 | 27 | class UILIB_API CAnimationData 28 | { 29 | public: 30 | CAnimationData(int nElipse, int nFrame, int nID, BOOL bLoop) 31 | { 32 | m_bFirstLoop = TRUE; 33 | m_nCurFrame = 0; 34 | m_nElapse = nElipse; 35 | m_nTotalFrame = nFrame; 36 | m_bLoop = bLoop; 37 | m_nAnimationID = nID; 38 | } 39 | 40 | //protected: 41 | public: 42 | friend class CDUIAnimation; 43 | 44 | int m_nAnimationID; 45 | int m_nElapse; 46 | 47 | int m_nTotalFrame; 48 | int m_nCurFrame; 49 | 50 | BOOL m_bLoop; 51 | BOOL m_bFirstLoop; 52 | }; 53 | 54 | class UILIB_API CUIAnimation: public IUIAnimation 55 | { 56 | struct Imp; 57 | public: 58 | CUIAnimation(CControlUI* pOwner); 59 | ~CUIAnimation(); 60 | 61 | virtual BOOL StartAnimation(int nElapse, int nTotalFrame, int nAnimationID = 0, BOOL bLoop = FALSE); 62 | virtual void StopAnimation(int nAnimationID = 0); 63 | virtual BOOL IsAnimationRunning(int nAnimationID); 64 | virtual int GetCurrentFrame(int nAnimationID = 0); 65 | virtual BOOL SetCurrentFrame(int nFrame, int nAnimationID = 0); 66 | 67 | virtual void OnAnimationStart(int nAnimationID, BOOL bFirstLoop) {}; 68 | virtual void OnAnimationStep(int nTotalFrame, int nCurFrame, int nAnimationID) {}; 69 | virtual void OnAnimationStop(int nAnimationID) {}; 70 | 71 | virtual void OnAnimationElapse(int nAnimationID); 72 | 73 | protected: 74 | CAnimationData* GetAnimationDataByID(int nAnimationID); 75 | 76 | protected: 77 | CControlUI* m_pControl; 78 | Imp * m_pImp; 79 | }; 80 | 81 | } // namespace DuiLib 82 | 83 | #endif // __UIANIMATION_H__ -------------------------------------------------------------------------------- /Duilib/Control/UIButton.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIButton.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIButton.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIBUTTON_H__ 2 | #define __UIBUTTON_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CButtonUI : public CLabelUI 9 | { 10 | DECLARE_DUICONTROL(CButtonUI) 11 | 12 | public: 13 | CButtonUI(); 14 | 15 | LPCTSTR GetClass() const; 16 | LPVOID GetInterface(LPCTSTR pstrName); 17 | UINT GetControlFlags() const; 18 | 19 | bool Activate(); 20 | void SetEnabled(bool bEnable = true); 21 | void DoEvent(TEventUI& event); 22 | 23 | virtual LPCTSTR GetNormalImage(); 24 | virtual void SetNormalImage(LPCTSTR pStrImage); 25 | virtual LPCTSTR GetHotImage(); 26 | virtual void SetHotImage(LPCTSTR pStrImage); 27 | virtual LPCTSTR GetPushedImage(); 28 | virtual void SetPushedImage(LPCTSTR pStrImage); 29 | virtual LPCTSTR GetFocusedImage(); 30 | virtual void SetFocusedImage(LPCTSTR pStrImage); 31 | virtual LPCTSTR GetDisabledImage(); 32 | virtual void SetDisabledImage(LPCTSTR pStrImage); 33 | virtual LPCTSTR GetHotForeImage(); 34 | virtual void SetHotForeImage(LPCTSTR pStrImage); 35 | 36 | void BindTabIndex(int _BindTabIndex); 37 | void BindTabLayoutName(LPCTSTR _TabLayoutName); 38 | void BindTriggerTabSel(int _SetSelectIndex = -1); 39 | void RemoveBindTabIndex(); 40 | int GetBindTabLayoutIndex(); 41 | LPCTSTR GetBindTabLayoutName(); 42 | 43 | void SetHotBkColor(DWORD dwColor); 44 | DWORD GetHotBkColor() const; 45 | void SetPushedBkColor(DWORD dwColor); 46 | DWORD GetPushedBkColor() const; 47 | void SetHotTextColor(DWORD dwColor); 48 | DWORD GetHotTextColor() const; 49 | void SetPushedTextColor(DWORD dwColor); 50 | DWORD GetPushedTextColor() const; 51 | void SetFocusedTextColor(DWORD dwColor); 52 | DWORD GetFocusedTextColor() const; 53 | //SIZE EstimateSize(SIZE szAvailable); 54 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 55 | 56 | void PaintText(HDC hDC); 57 | void PaintStatusImage(HDC hDC); 58 | BOOL MOUSEENTER; 59 | BOOL Mousecur; 60 | 61 | protected: 62 | UINT m_uButtonState; 63 | 64 | DWORD m_dwHotBkColor; 65 | DWORD m_dwPushedBkColor; 66 | DWORD m_dwHotTextColor; 67 | DWORD m_dwPushedTextColor; 68 | DWORD m_dwFocusedTextColor; 69 | 70 | CDuiString m_sNormalImage; 71 | CDuiString m_sHotImage; 72 | CDuiString m_sHotForeImage; 73 | CDuiString m_sPushedImage; 74 | CDuiString m_sPushedForeImage; 75 | CDuiString m_sFocusedImage; 76 | CDuiString m_sDisabledImage; 77 | 78 | int m_iBindTabIndex; 79 | CDuiString m_sBindTabLayoutName; 80 | }; 81 | 82 | } // namespace DuiLib 83 | 84 | #endif // __UIBUTTON_H__ -------------------------------------------------------------------------------- /Duilib/Control/UIColorPalette.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIColorPalette.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIColorPalette.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIColorPalette.h -------------------------------------------------------------------------------- /Duilib/Control/UICombo.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UICombo.cpp -------------------------------------------------------------------------------- /Duilib/Control/UICombo.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICOMBO_H__ 2 | #define __UICOMBO_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | ///////////////////////////////////////////////////////////////////////////////////// 8 | // 9 | 10 | class CComboWnd; 11 | 12 | class UILIB_API CComboUI : public CContainerUI, public IListOwnerUI 13 | { 14 | DECLARE_DUICONTROL(CComboUI) 15 | friend class CComboWnd; 16 | public: 17 | CComboUI(); 18 | 19 | LPCTSTR GetClass() const; 20 | LPVOID GetInterface(LPCTSTR pstrName); 21 | 22 | void DoInit(); 23 | UINT GetControlFlags() const; 24 | 25 | CDuiString GetText() const; 26 | void SetEnabled(bool bEnable = true); 27 | 28 | void SetTextStyle(UINT uStyle); 29 | UINT GetTextStyle() const; 30 | void SetTextColor(DWORD dwTextColor); 31 | DWORD GetTextColor() const; 32 | void SetDisabledTextColor(DWORD dwTextColor); 33 | DWORD GetDisabledTextColor() const; 34 | void SetFont(int index); 35 | int GetFont() const; 36 | RECT GetTextPadding() const; 37 | void SetTextPadding(RECT rc); 38 | bool IsShowHtml(); 39 | void SetShowHtml(bool bShowHtml = true); 40 | 41 | CDuiString GetDropBoxAttributeList(); 42 | void SetDropBoxAttributeList(LPCTSTR pstrList); 43 | SIZE GetDropBoxSize() const; 44 | void SetDropBoxSize(SIZE szDropBox); 45 | 46 | int GetCurSel() const; 47 | bool SelectItem(int iIndex, bool bTakeFocus = false); 48 | bool SelectMultiItem(int iIndex, bool bTakeFocus = false); 49 | bool UnSelectItem(int iIndex, bool bOthers = false); 50 | bool SetItemIndex(CControlUI* pControl, int iIndex); 51 | bool Add(CControlUI* pControl); 52 | bool AddAt(CControlUI* pControl, int iIndex); 53 | bool Remove(CControlUI* pControl); 54 | bool RemoveAt(int iIndex); 55 | void RemoveAll(); 56 | 57 | bool Activate(); 58 | 59 | LPCTSTR GetNormalImage() const; 60 | void SetNormalImage(LPCTSTR pStrImage); 61 | LPCTSTR GetHotImage() const; 62 | void SetHotImage(LPCTSTR pStrImage); 63 | LPCTSTR GetPushedImage() const; 64 | void SetPushedImage(LPCTSTR pStrImage); 65 | LPCTSTR GetFocusedImage() const; 66 | void SetFocusedImage(LPCTSTR pStrImage); 67 | LPCTSTR GetDisabledImage() const; 68 | void SetDisabledImage(LPCTSTR pStrImage); 69 | 70 | TListInfoUI* GetListInfo(); 71 | void SetItemFont(int index); 72 | void SetItemTextStyle(UINT uStyle); 73 | RECT GetItemTextPadding() const; 74 | void SetItemTextPadding(RECT rc); 75 | DWORD GetItemTextColor() const; 76 | void SetItemTextColor(DWORD dwTextColor); 77 | DWORD GetItemBkColor() const; 78 | void SetItemBkColor(DWORD dwBkColor); 79 | LPCTSTR GetItemBkImage() const; 80 | void SetItemBkImage(LPCTSTR pStrImage); 81 | bool IsAlternateBk() const; 82 | void SetAlternateBk(bool bAlternateBk); 83 | DWORD GetSelectedItemTextColor() const; 84 | void SetSelectedItemTextColor(DWORD dwTextColor); 85 | DWORD GetSelectedItemBkColor() const; 86 | void SetSelectedItemBkColor(DWORD dwBkColor); 87 | LPCTSTR GetSelectedItemImage() const; 88 | void SetSelectedItemImage(LPCTSTR pStrImage); 89 | DWORD GetHotItemTextColor() const; 90 | void SetHotItemTextColor(DWORD dwTextColor); 91 | DWORD GetHotItemBkColor() const; 92 | void SetHotItemBkColor(DWORD dwBkColor); 93 | LPCTSTR GetHotItemImage() const; 94 | void SetHotItemImage(LPCTSTR pStrImage); 95 | DWORD GetDisabledItemTextColor() const; 96 | void SetDisabledItemTextColor(DWORD dwTextColor); 97 | DWORD GetDisabledItemBkColor() const; 98 | void SetDisabledItemBkColor(DWORD dwBkColor); 99 | LPCTSTR GetDisabledItemImage() const; 100 | void SetDisabledItemImage(LPCTSTR pStrImage); 101 | DWORD GetItemLineColor() const; 102 | void SetItemLineColor(DWORD dwLineColor); 103 | bool IsItemShowHtml(); 104 | void SetItemShowHtml(bool bShowHtml = true); 105 | 106 | SIZE EstimateSize(SIZE szAvailable); 107 | void SetPos(RECT rc, bool bNeedInvalidate = true); 108 | void Move(SIZE szOffset, bool bNeedInvalidate = true); 109 | void DoEvent(TEventUI& event); 110 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 111 | 112 | void DoPaint(HDC hDC, const RECT& rcPaint); 113 | void PaintText(HDC hDC); 114 | void PaintStatusImage(HDC hDC); 115 | BOOL MOUSEENTER; 116 | protected: 117 | CComboWnd* m_pWindow; 118 | 119 | int m_iCurSel; 120 | DWORD m_dwTextColor; 121 | DWORD m_dwDisabledTextColor; 122 | int m_iFont; 123 | UINT m_uTextStyle; 124 | RECT m_rcTextPadding; 125 | bool m_bShowHtml; 126 | CDuiString m_sDropBoxAttributes; 127 | SIZE m_szDropBox; 128 | UINT m_uButtonState; 129 | 130 | CDuiString m_sNormalImage; 131 | CDuiString m_sHotImage; 132 | CDuiString m_sPushedImage; 133 | CDuiString m_sFocusedImage; 134 | CDuiString m_sDisabledImage; 135 | 136 | TListInfoUI m_ListInfo; 137 | }; 138 | 139 | } // namespace DuiLib 140 | 141 | #endif // __UICOMBO_H__ 142 | -------------------------------------------------------------------------------- /Duilib/Control/UIComboBox.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIComboBox.h" 3 | 4 | namespace DuiLib 5 | { 6 | IMPLEMENT_DUICONTROL(CComboBoxUI) 7 | 8 | CComboBoxUI::CComboBoxUI() 9 | { 10 | m_nArrowWidth = 0; 11 | } 12 | 13 | LPCTSTR CComboBoxUI::GetClass() const 14 | { 15 | return _T("ComboBoxUI"); 16 | } 17 | 18 | void CComboBoxUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 19 | { 20 | if (_tcsicmp(pstrName, _T("arrowimage")) == 0) 21 | m_sArrowImage = pstrValue; 22 | else 23 | CComboUI::SetAttribute(pstrName, pstrValue); 24 | } 25 | 26 | void CComboBoxUI::PaintStatusImage(HDC hDC) 27 | { 28 | if (m_sArrowImage.IsEmpty()) 29 | CComboUI::PaintStatusImage(hDC); 30 | else 31 | { 32 | // get index 33 | if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED; 34 | else m_uButtonState &= ~ UISTATE_FOCUSED; 35 | if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED; 36 | else m_uButtonState &= ~ UISTATE_DISABLED; 37 | 38 | int nIndex = 0; 39 | if ((m_uButtonState & UISTATE_DISABLED) != 0) 40 | nIndex = 4; 41 | else if ((m_uButtonState & UISTATE_PUSHED) != 0) 42 | nIndex = 2; 43 | else if ((m_uButtonState & UISTATE_HOT) != 0) 44 | nIndex = 1; 45 | else if ((m_uButtonState & UISTATE_FOCUSED) != 0) 46 | nIndex = 3; 47 | 48 | // make modify string 49 | CDuiString sModify = m_sArrowImage; 50 | 51 | int nPos1 = sModify.Find(_T("source")); 52 | int nPos2 = sModify.Find(_T("'"), nPos1 + 7); 53 | if (nPos2 == -1) return; //first 54 | int nPos3 = sModify.Find(_T("'"), nPos2 + 1); 55 | if (nPos3 == -1) return; //second 56 | 57 | CDuiRect rcBmpPart; 58 | LPTSTR lpszValue = NULL; 59 | rcBmpPart.left = _tcstol(sModify.GetData() + nPos2 + 1, &lpszValue, 10); ASSERT(lpszValue); 60 | rcBmpPart.top = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); 61 | rcBmpPart.right = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); 62 | rcBmpPart.bottom = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue); 63 | 64 | m_nArrowWidth = rcBmpPart.GetWidth() / 5; 65 | rcBmpPart.left += nIndex * m_nArrowWidth; 66 | rcBmpPart.right = rcBmpPart.left + m_nArrowWidth; 67 | 68 | CDuiRect rcDest(0, 0, m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top); 69 | rcDest.Deflate(GetBorderSize(), GetBorderSize()); 70 | rcDest.left = rcDest.right - m_nArrowWidth; 71 | 72 | CDuiString sSource = sModify.Mid(nPos1, nPos3 + 1 - nPos1); 73 | CDuiString sReplace; 74 | sReplace.SmallFormat(_T("source='%d,%d,%d,%d' dest='%d,%d,%d,%d'"), 75 | rcBmpPart.left, rcBmpPart.top, rcBmpPart.right, rcBmpPart.bottom, 76 | rcDest.left, rcDest.top, rcDest.right, rcDest.bottom); 77 | 78 | sModify.Replace(sSource, sReplace); 79 | 80 | // draw image 81 | if (!DrawImage(hDC, m_sArrowImage, sModify)) 82 | m_sNormalImage.Empty(); 83 | } 84 | } 85 | 86 | void CComboBoxUI::PaintText(HDC hDC) 87 | { 88 | RECT rcText = m_rcItem; 89 | rcText.left += m_rcTextPadding.left; 90 | rcText.right -= m_rcTextPadding.right; 91 | rcText.top += m_rcTextPadding.top; 92 | rcText.bottom -= m_rcTextPadding.bottom; 93 | 94 | rcText.right -= m_nArrowWidth; // add this line than CComboUI::PaintText(HDC hDC) 95 | 96 | if( m_iCurSel >= 0 ) { 97 | CControlUI* pControl = static_cast(m_items[m_iCurSel]); 98 | IListItemUI* pElement = static_cast(pControl->GetInterface(_T("ListItem"))); 99 | if( pElement != NULL ) { 100 | pElement->DrawItemText(hDC, rcText); 101 | } 102 | else { 103 | RECT rcOldPos = pControl->GetPos(); 104 | pControl->SetPos(rcText); 105 | pControl->DoPaint(hDC, rcText); 106 | pControl->SetPos(rcOldPos); 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Duilib/Control/UIComboBox.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIComboBox.h -------------------------------------------------------------------------------- /Duilib/Control/UIComboEX.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIComboEX.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIComboEX.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICOMBOEX_H__ 2 | #define __UICOMBOEX_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | ///////////////////////////////////////////////////////////////////////////////////// 8 | // 9 | 10 | class CComboExWnd; 11 | 12 | class UILIB_API CComboExUI : public CContainerUI, public IListOwnerUI 13 | { 14 | friend class CComboExWnd; 15 | public: 16 | CComboExUI(); 17 | 18 | LPCTSTR GetClass() const; 19 | LPVOID GetInterface(LPCTSTR pstrName); 20 | 21 | void DoInit(); 22 | UINT GetControlFlags() const; 23 | 24 | CDuiString GetText() const; 25 | void SetEnabled(bool bEnable = true); 26 | 27 | CDuiString GetDropBoxAttributeList(); 28 | void SetDropBoxAttributeList(LPCTSTR pstrList); 29 | SIZE GetDropBoxSize() const; 30 | void SetDropBoxSize(SIZE szDropBox); 31 | 32 | int GetCurSel() const; 33 | bool SelectItem(int iIndex, bool bTakeFocus = false); 34 | 35 | bool SetItemIndex(CControlUI* pControl, int iIndex); 36 | bool Add(CControlUI* pControl); 37 | bool AddAt(CControlUI* pControl, int iIndex); 38 | bool Remove(CControlUI* pControl); 39 | bool RemoveAt(int iIndex); 40 | void RemoveAll(); 41 | 42 | bool Activate(); 43 | 44 | RECT GetTextPadding() const; 45 | void SetTextPadding(RECT rc); 46 | LPCTSTR GetNormalImage() const; 47 | void SetNormalImage(LPCTSTR pStrImage); 48 | LPCTSTR GetHotImage() const; 49 | void SetHotImage(LPCTSTR pStrImage); 50 | LPCTSTR GetPushedImage() const; 51 | void SetPushedImage(LPCTSTR pStrImage); 52 | LPCTSTR GetFocusedImage() const; 53 | void SetFocusedImage(LPCTSTR pStrImage); 54 | LPCTSTR GetDisabledImage() const; 55 | void SetDisabledImage(LPCTSTR pStrImage); 56 | 57 | TListInfoUI* GetListInfo(); 58 | void SetItemFont(int index); 59 | void SetItemTextStyle(UINT uStyle); 60 | RECT GetItemTextPadding() const; 61 | void SetItemTextPadding(RECT rc); 62 | DWORD GetItemTextColor() const; 63 | void SetItemTextColor(DWORD dwTextColor); 64 | DWORD GetItemBkColor() const; 65 | void SetItemBkColor(DWORD dwBkColor); 66 | LPCTSTR GetItemBkImage() const; 67 | void SetItemBkImage(LPCTSTR pStrImage); 68 | bool IsAlternateBk() const; 69 | void SetAlternateBk(bool bAlternateBk); 70 | DWORD GetSelectedItemTextColor() const; 71 | void SetSelectedItemTextColor(DWORD dwTextColor); 72 | DWORD GetSelectedItemBkColor() const; 73 | void SetSelectedItemBkColor(DWORD dwBkColor); 74 | LPCTSTR GetSelectedItemImage() const; 75 | void SetSelectedItemImage(LPCTSTR pStrImage); 76 | DWORD GetHotItemTextColor() const; 77 | void SetHotItemTextColor(DWORD dwTextColor); 78 | DWORD GetHotItemBkColor() const; 79 | void SetHotItemBkColor(DWORD dwBkColor); 80 | LPCTSTR GetHotItemImage() const; 81 | void SetHotItemImage(LPCTSTR pStrImage); 82 | DWORD GetDisabledItemTextColor() const; 83 | void SetDisabledItemTextColor(DWORD dwTextColor); 84 | DWORD GetDisabledItemBkColor() const; 85 | void SetDisabledItemBkColor(DWORD dwBkColor); 86 | LPCTSTR GetDisabledItemImage() const; 87 | void SetDisabledItemImage(LPCTSTR pStrImage); 88 | DWORD GetItemLineColor() const; 89 | void SetItemLineColor(DWORD dwLineColor); 90 | bool IsItemShowHtml(); 91 | void SetItemShowHtml(bool bShowHtml = true); 92 | 93 | SIZE EstimateSize(SIZE szAvailable); 94 | void SetPos(RECT rc); 95 | void DoEvent(TEventUI& event); 96 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 97 | 98 | void DoPaint(HDC hDC, const RECT& rcPaint); 99 | void PaintText(HDC hDC); 100 | void PaintStatusImage(HDC hDC); 101 | 102 | protected: 103 | CComboExWnd* m_pWindow; 104 | 105 | int m_iCurSel; 106 | RECT m_rcTextPadding; 107 | CDuiString m_sDropBoxAttributes; 108 | SIZE m_szDropBox; 109 | UINT m_uButtonState; 110 | 111 | CDuiString m_sNormalImage; 112 | CDuiString m_sHotImage; 113 | CDuiString m_sPushedImage; 114 | CDuiString m_sFocusedImage; 115 | CDuiString m_sDisabledImage; 116 | 117 | TListInfoUI m_ListInfo; 118 | }; 119 | 120 | } // namespace UiLib 121 | 122 | #endif // __UICOMBO_H__ 123 | -------------------------------------------------------------------------------- /Duilib/Control/UIDateTime.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIDateTime.h" 3 | 4 | namespace DuiLib 5 | { 6 | //CDateTimeUI::m_nDTUpdateFlag 7 | #define DT_NONE 0 8 | #define DT_UPDATE 1 9 | #define DT_DELETE 2 10 | #define DT_KEEP 3 11 | 12 | class CDateTimeWnd : public CWindowWnd 13 | { 14 | public: 15 | CDateTimeWnd(); 16 | 17 | void Init(CDateTimeUI* pOwner); 18 | RECT CalPos(); 19 | 20 | LPCTSTR GetWindowClassName() const; 21 | LPCTSTR GetSuperClassName() const; 22 | void OnFinalMessage(HWND hWnd); 23 | 24 | LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); 25 | protected: 26 | CDateTimeUI* m_pOwner; 27 | HBRUSH m_hBkBrush; 28 | bool m_bInit; 29 | bool m_bDropOpen; 30 | SYSTEMTIME m_oldSysTime; 31 | }; 32 | 33 | CDateTimeWnd::CDateTimeWnd() : m_pOwner(NULL), m_hBkBrush(NULL), m_bInit(false), m_bDropOpen(false) 34 | { 35 | } 36 | 37 | void CDateTimeWnd::Init(CDateTimeUI* pOwner) 38 | { 39 | m_pOwner = pOwner; 40 | m_pOwner->m_nDTUpdateFlag = DT_NONE; 41 | 42 | if (m_hWnd == NULL) 43 | { 44 | RECT rcPos = CalPos(); 45 | UINT uStyle = WS_CHILD; 46 | Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos); 47 | SetWindowFont(m_hWnd, m_pOwner->GetManager()->GetFontInfo(m_pOwner->GetFont())->hFont, TRUE); 48 | } 49 | 50 | if (m_pOwner->GetText().IsEmpty()) { 51 | ::GetLocalTime(&m_pOwner->m_sysTime); 52 | } 53 | memcpy(&m_oldSysTime, &m_pOwner->m_sysTime, sizeof(SYSTEMTIME)); 54 | ::SendMessage(m_hWnd, DTM_SETSYSTEMTIME, 0, (LPARAM)&m_pOwner->m_sysTime); 55 | ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE); 56 | ::SetFocus(m_hWnd); 57 | 58 | m_bInit = true; 59 | } 60 | 61 | RECT CDateTimeWnd::CalPos() 62 | { 63 | CDuiRect rcPos = m_pOwner->GetPos(); 64 | 65 | CControlUI* pParent = m_pOwner; 66 | RECT rcParent; 67 | while( pParent = pParent->GetParent() ) { 68 | if( !pParent->IsVisible() ) { 69 | rcPos.left = rcPos.top = rcPos.right = rcPos.bottom = 0; 70 | break; 71 | } 72 | rcParent = pParent->GetClientPos(); 73 | if( !::IntersectRect(&rcPos, &rcPos, &rcParent) ) { 74 | rcPos.left = rcPos.top = rcPos.right = rcPos.bottom = 0; 75 | break; 76 | } 77 | } 78 | 79 | return rcPos; 80 | } 81 | 82 | LPCTSTR CDateTimeWnd::GetWindowClassName() const 83 | { 84 | return _T("DateTimeWnd"); 85 | } 86 | 87 | LPCTSTR CDateTimeWnd::GetSuperClassName() const 88 | { 89 | return DATETIMEPICK_CLASS; 90 | } 91 | 92 | void CDateTimeWnd::OnFinalMessage(HWND hWnd) 93 | { 94 | if( m_hBkBrush != NULL ) ::DeleteObject(m_hBkBrush); 95 | if( m_pOwner->GetManager()->IsLayered() ) { 96 | m_pOwner->GetManager()->RemovePaintChildWnd(hWnd); 97 | } 98 | m_pOwner->m_pWindow = NULL; 99 | delete this; 100 | } 101 | 102 | LRESULT CDateTimeWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) 103 | { 104 | LRESULT lRes = 0; 105 | BOOL bHandled = TRUE; 106 | if (uMsg == WM_KEYDOWN && wParam == VK_ESCAPE) 107 | { 108 | memcpy(&m_pOwner->m_sysTime, &m_oldSysTime, sizeof(SYSTEMTIME)); 109 | m_pOwner->m_nDTUpdateFlag = DT_UPDATE; 110 | m_pOwner->UpdateText(); 111 | PostMessage(WM_CLOSE); 112 | return lRes; 113 | } 114 | else if(uMsg == OCM_NOTIFY) 115 | { 116 | NMHDR* pHeader=(NMHDR*)lParam; 117 | if(pHeader != NULL && pHeader->hwndFrom == m_hWnd) { 118 | if(pHeader->code == DTN_DATETIMECHANGE) { 119 | LPNMDATETIMECHANGE lpChage=(LPNMDATETIMECHANGE)lParam; 120 | ::SendMessage(m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&m_pOwner->m_sysTime); 121 | m_pOwner->m_nDTUpdateFlag = DT_UPDATE; 122 | m_pOwner->UpdateText(); 123 | } 124 | else if(pHeader->code == DTN_DROPDOWN) { 125 | m_bDropOpen = true; 126 | 127 | } 128 | else if(pHeader->code == DTN_CLOSEUP) { 129 | ::SendMessage(m_hWnd, DTM_GETSYSTEMTIME, 0, (LPARAM)&m_pOwner->m_sysTime); 130 | m_pOwner->m_nDTUpdateFlag = DT_UPDATE; 131 | m_pOwner->UpdateText(); 132 | PostMessage(WM_CLOSE); 133 | m_bDropOpen = false; 134 | } 135 | } 136 | bHandled = FALSE; 137 | } 138 | else if(uMsg == WM_KILLFOCUS) 139 | { 140 | if(!m_bDropOpen) { 141 | PostMessage(WM_CLOSE); 142 | } 143 | bHandled = FALSE; 144 | } 145 | else if( uMsg == WM_PAINT) { 146 | if (m_pOwner->GetManager()->IsLayered()) { 147 | m_pOwner->GetManager()->AddPaintChildWnd(m_hWnd); 148 | } 149 | bHandled = FALSE; 150 | } 151 | else bHandled = FALSE; 152 | if( !bHandled ) return CWindowWnd::HandleMessage(uMsg, wParam, lParam); 153 | return lRes; 154 | } 155 | ////////////////////////////////////////////////////////////////////////// 156 | // 157 | IMPLEMENT_DUICONTROL(CDateTimeUI) 158 | 159 | CDateTimeUI::CDateTimeUI() 160 | { 161 | ::GetLocalTime(&m_sysTime); 162 | m_bReadOnly = false; 163 | m_pWindow = NULL; 164 | m_nDTUpdateFlag=DT_UPDATE; 165 | UpdateText(); 166 | m_nDTUpdateFlag = DT_NONE; 167 | } 168 | 169 | LPCTSTR CDateTimeUI::GetClass() const 170 | { 171 | return _T("DateTimeUI"); 172 | } 173 | 174 | LPVOID CDateTimeUI::GetInterface(LPCTSTR pstrName) 175 | { 176 | if( _tcscmp(pstrName, DUI_CTR_DATETIME) == 0 ) return static_cast(this); 177 | return CLabelUI::GetInterface(pstrName); 178 | } 179 | 180 | SYSTEMTIME& CDateTimeUI::GetTime() 181 | { 182 | return m_sysTime; 183 | } 184 | 185 | void CDateTimeUI::SetTime(SYSTEMTIME* pst) 186 | { 187 | m_sysTime = *pst; 188 | Invalidate(); 189 | m_nDTUpdateFlag = DT_UPDATE; 190 | UpdateText(); 191 | m_nDTUpdateFlag = DT_NONE; 192 | } 193 | 194 | void CDateTimeUI::SetReadOnly(bool bReadOnly) 195 | { 196 | m_bReadOnly = bReadOnly; 197 | Invalidate(); 198 | } 199 | 200 | bool CDateTimeUI::IsReadOnly() const 201 | { 202 | return m_bReadOnly; 203 | } 204 | 205 | void CDateTimeUI::UpdateText() 206 | { 207 | if (m_nDTUpdateFlag == DT_DELETE) { 208 | SetText(_T("")); 209 | } 210 | else if (m_nDTUpdateFlag == DT_UPDATE) { 211 | CDuiString sText; 212 | sText.SmallFormat(_T("%4d-%02d-%02d"), m_sysTime.wYear, m_sysTime.wMonth, m_sysTime.wDay, m_sysTime.wHour, m_sysTime.wMinute); 213 | SetText(sText); 214 | } 215 | } 216 | 217 | void CDateTimeUI::DoEvent(TEventUI& event) 218 | { 219 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { 220 | if( m_pParent != NULL ) m_pParent->DoEvent(event); 221 | else CLabelUI::DoEvent(event); 222 | return; 223 | } 224 | 225 | if( event.Type == UIEVENT_SETCURSOR && IsEnabled() ) 226 | { 227 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_IBEAM))); 228 | return; 229 | } 230 | if( event.Type == UIEVENT_WINDOWSIZE ) 231 | { 232 | if( m_pWindow != NULL ) m_pManager->SetFocusNeeded(this); 233 | } 234 | if( event.Type == UIEVENT_SCROLLWHEEL ) 235 | { 236 | if( m_pWindow != NULL ) return; 237 | } 238 | if( event.Type == UIEVENT_SETFOCUS && IsEnabled() ) 239 | { 240 | if( m_pWindow ) return; 241 | m_pWindow = new CDateTimeWnd(); 242 | ASSERT(m_pWindow); 243 | m_pWindow->Init(this); 244 | m_pWindow->ShowWindow(); 245 | } 246 | if( event.Type == UIEVENT_KILLFOCUS && IsEnabled() ) 247 | { 248 | Invalidate(); 249 | } 250 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK || event.Type == UIEVENT_RBUTTONDOWN) 251 | { 252 | if( IsEnabled() ) { 253 | GetManager()->ReleaseCapture(); 254 | if( IsFocused() && m_pWindow == NULL ) 255 | { 256 | m_pWindow = new CDateTimeWnd(); 257 | ASSERT(m_pWindow); 258 | } 259 | if( m_pWindow != NULL ) 260 | { 261 | m_pWindow->Init(this); 262 | m_pWindow->ShowWindow(); 263 | } 264 | } 265 | return; 266 | } 267 | if( event.Type == UIEVENT_MOUSEMOVE ) 268 | { 269 | return; 270 | } 271 | if( event.Type == UIEVENT_BUTTONUP ) 272 | { 273 | return; 274 | } 275 | if( event.Type == UIEVENT_CONTEXTMENU ) 276 | { 277 | return; 278 | } 279 | if( event.Type == UIEVENT_MOUSEENTER ) 280 | { 281 | return; 282 | } 283 | if( event.Type == UIEVENT_MOUSELEAVE ) 284 | { 285 | return; 286 | } 287 | 288 | CLabelUI::DoEvent(event); 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /Duilib/Control/UIDateTime.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIDateTime.h -------------------------------------------------------------------------------- /Duilib/Control/UIEdit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIEdit.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIEdit.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIEDIT_H__ 2 | #define __UIEDIT_H__ 3 | 4 | #pragma once 5 | #include "UIButton.h" 6 | namespace DuiLib 7 | { 8 | class CEditWnd; 9 | 10 | class UILIB_API CEditUI : public CLabelUI 11 | { 12 | DECLARE_DUICONTROL(CEditUI) 13 | friend class CEditWnd; 14 | public: 15 | CEditUI(); 16 | 17 | LPCTSTR GetClass() const; 18 | LPVOID GetInterface(LPCTSTR pstrName); 19 | UINT GetControlFlags() const; 20 | 21 | void SetEnabled(bool bEnable = true); 22 | void SetText(LPCTSTR pstrText); 23 | void SetMaxChar(UINT uMax); 24 | UINT GetMaxChar(); 25 | void SetReadOnly(bool bReadOnly); 26 | bool IsReadOnly() const; 27 | void SetPasswordMode(bool bPasswordMode); 28 | bool IsPasswordMode() const; 29 | void SetPasswordChar(TCHAR cPasswordChar); 30 | TCHAR GetPasswordChar() const; 31 | void SetNumberOnly(bool bNumberOnly); 32 | bool IsNumberOnly() const; 33 | int GetWindowStyls() const; 34 | 35 | LPCTSTR GetNormalImage(); 36 | void SetNormalImage(LPCTSTR pStrImage); 37 | LPCTSTR GetHotImage(); 38 | void SetHotImage(LPCTSTR pStrImage); 39 | LPCTSTR GetFocusedImage(); 40 | void SetFocusedImage(LPCTSTR pStrImage); 41 | LPCTSTR GetDisabledImage(); 42 | void SetDisabledImage(LPCTSTR pStrImage); 43 | void SetNativeEditBkColor(DWORD dwBkColor); 44 | DWORD GetNativeEditBkColor() const; 45 | void SetNativeEditTextColor( LPCTSTR pStrColor ); 46 | DWORD GetNativeEditTextColor() const; 47 | 48 | void SetSel(long nStartChar, long nEndChar); 49 | void SetSelAll(); 50 | void SetReplaceSel(LPCTSTR lpszReplace); 51 | 52 | void SetTipValue(LPCTSTR pStrTipValue); 53 | LPCTSTR GetTipValue(); 54 | void SetTipValueColor(LPCTSTR pStrColor); 55 | DWORD GetTipValueColor(); 56 | 57 | void SetPos(RECT rc, bool bNeedInvalidate = true); 58 | void Move(SIZE szOffset, bool bNeedInvalidate = true); 59 | void SetVisible(bool bVisible = true); 60 | void SetInternVisible(bool bVisible = true); 61 | SIZE EstimateSize(SIZE szAvailable); 62 | void DoEvent(TEventUI& event); 63 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 64 | 65 | void PaintStatusImage(HDC hDC); 66 | void PaintText(HDC hDC); 67 | 68 | 69 | //--edit 2016/7/7 70 | void SetLogBtnPtr(CButtonUI *pBtn); 71 | BOOL EDITMOUSEENTER; 72 | 73 | protected: 74 | CEditWnd* m_pWindow; 75 | 76 | UINT m_uMaxChar; 77 | bool m_bReadOnly; 78 | bool m_bPasswordMode; 79 | TCHAR m_cPasswordChar; 80 | UINT m_uButtonState; 81 | CDuiString m_sNormalImage; 82 | CDuiString m_sHotImage; 83 | CDuiString m_sFocusedImage; 84 | CDuiString m_sDisabledImage; 85 | CDuiString m_sTipValue; 86 | DWORD m_dwTipValueColor; 87 | DWORD m_dwEditbkColor; 88 | DWORD m_dwEditTextColor; 89 | int m_iWindowStyls; 90 | CButtonUI *m_logBtn; 91 | }; 92 | } 93 | #endif // __UIEDIT_H__ -------------------------------------------------------------------------------- /Duilib/Control/UIFadeButton.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIFadeButton.h" 3 | 4 | namespace DuiLib { 5 | IMPLEMENT_DUICONTROL(CFadeButtonUI) 6 | 7 | CFadeButtonUI::CFadeButtonUI() : CUIAnimation( &(*this) ), m_bMouseHove( FALSE ), m_bMouseLeave( FALSE ) 8 | { 9 | } 10 | 11 | CFadeButtonUI::~CFadeButtonUI() 12 | { 13 | StopAnimation(); 14 | } 15 | 16 | LPCTSTR CFadeButtonUI::GetClass() const 17 | { 18 | return _T("FadeButtonUI"); 19 | } 20 | 21 | LPVOID CFadeButtonUI::GetInterface(LPCTSTR pstrName) 22 | { 23 | if( _tcscmp(pstrName, _T("FadeButton")) == 0 ) 24 | return static_cast(this); 25 | return CButtonUI::GetInterface(pstrName); 26 | } 27 | 28 | void CFadeButtonUI::SetNormalImage(LPCTSTR pStrImage) 29 | { 30 | m_sNormalImage = pStrImage; 31 | m_sLastImage = m_sNormalImage; 32 | } 33 | 34 | void CFadeButtonUI::DoEvent(TEventUI& event) 35 | { 36 | if( event.Type == UIEVENT_MOUSEENTER && !IsAnimationRunning( FADE_IN_ID ) ) 37 | { 38 | m_bFadeAlpha = 0; 39 | m_bMouseHove = TRUE; 40 | StopAnimation( FADE_OUT_ID ); 41 | StartAnimation( FADE_ELLAPSE, FADE_FRAME_COUNT, FADE_IN_ID ); 42 | Invalidate(); 43 | return; 44 | } 45 | if( event.Type == UIEVENT_MOUSELEAVE && !IsAnimationRunning( FADE_OUT_ID ) ) 46 | { 47 | m_bFadeAlpha = 0; 48 | m_bMouseLeave = TRUE; 49 | StopAnimation(FADE_IN_ID); 50 | StartAnimation(FADE_ELLAPSE, FADE_FRAME_COUNT, FADE_OUT_ID); 51 | Invalidate(); 52 | return; 53 | } 54 | if( event.Type == UIEVENT_TIMER ) 55 | { 56 | OnTimer( event.wParam ); 57 | } 58 | CButtonUI::DoEvent( event ); 59 | } 60 | 61 | void CFadeButtonUI::OnTimer( int nTimerID ) 62 | { 63 | OnAnimationElapse( nTimerID ); 64 | } 65 | 66 | void CFadeButtonUI::PaintStatusImage(HDC hDC) 67 | { 68 | if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED; 69 | else m_uButtonState &= ~ UISTATE_FOCUSED; 70 | if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED; 71 | else m_uButtonState &= ~ UISTATE_DISABLED; 72 | 73 | if( (m_uButtonState & UISTATE_DISABLED) != 0 ) { 74 | if( !m_sDisabledImage.IsEmpty() ) { 75 | if( !DrawImage(hDC, (LPCTSTR)m_sDisabledImage) ) m_sDisabledImage.Empty(); 76 | else return; 77 | } 78 | } 79 | else if( (m_uButtonState & UISTATE_PUSHED) != 0 ) { 80 | if( !m_sPushedImage.IsEmpty() ) { 81 | if( !DrawImage(hDC, (LPCTSTR)m_sPushedImage) ) m_sPushedImage.Empty(); 82 | else return; 83 | } 84 | } 85 | else if( (m_uButtonState & UISTATE_FOCUSED) != 0 ) { 86 | if( !m_sFocusedImage.IsEmpty() ) { 87 | if( !DrawImage(hDC, (LPCTSTR)m_sFocusedImage) ) m_sFocusedImage.Empty(); 88 | else return; 89 | } 90 | } 91 | 92 | if( !m_sNormalImage.IsEmpty() ) { 93 | if( IsAnimationRunning(FADE_IN_ID) || IsAnimationRunning(FADE_OUT_ID)) 94 | { 95 | if( m_bMouseHove ) 96 | { 97 | m_bMouseHove = FALSE; 98 | m_sLastImage = m_sHotImage; 99 | if( !DrawImage(hDC, (LPCTSTR)m_sNormalImage) ) 100 | m_sNormalImage.Empty(); 101 | return; 102 | } 103 | 104 | if( m_bMouseLeave ) 105 | { 106 | m_bMouseLeave = FALSE; 107 | m_sLastImage = m_sNormalImage; 108 | if( !DrawImage(hDC, (LPCTSTR)m_sHotImage) ) 109 | m_sHotImage.Empty(); 110 | return; 111 | } 112 | 113 | m_sOldImage = m_sNormalImage; 114 | m_sNewImage = m_sHotImage; 115 | if( IsAnimationRunning(FADE_OUT_ID) ) 116 | { 117 | m_sOldImage = m_sHotImage; 118 | m_sNewImage = m_sNormalImage; 119 | } 120 | CDuiString sFadeOut, sFadeIn; 121 | sFadeOut.Format(_T("fade='%d'"), 255 - m_bFadeAlpha); 122 | sFadeIn.Format(_T("fade='%d'"), m_bFadeAlpha); 123 | if( !DrawImage(hDC, (LPCTSTR)m_sOldImage, sFadeOut) ) m_sOldImage.Empty(); 124 | if( !DrawImage(hDC, (LPCTSTR)m_sNewImage, sFadeIn) ) m_sNewImage.Empty(); 125 | return; 126 | } 127 | else 128 | { 129 | if( !DrawImage(hDC, (LPCTSTR)m_sLastImage) ) m_sLastImage.Empty(); 130 | return; 131 | } 132 | } 133 | } 134 | 135 | void CFadeButtonUI::OnAnimationStep(INT nTotalFrame, INT nCurFrame, INT nAnimationID) 136 | { 137 | m_bFadeAlpha = (BYTE)((nCurFrame / (double)nTotalFrame) * 255); 138 | m_bFadeAlpha = m_bFadeAlpha == 0 ? 10 : m_bFadeAlpha; 139 | Invalidate(); 140 | } 141 | 142 | } // namespace DuiLib -------------------------------------------------------------------------------- /Duilib/Control/UIFadeButton.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIFADEBUTTON_H__ 2 | #define __UIFADEBUTTON_H__ 3 | 4 | #include "UIAnimation.h" 5 | #pragma once 6 | 7 | namespace DuiLib { 8 | 9 | class UILIB_API CFadeButtonUI : public CButtonUI, public CUIAnimation 10 | { 11 | DECLARE_DUICONTROL(CFadeButtonUI) 12 | public: 13 | CFadeButtonUI(); 14 | virtual ~CFadeButtonUI(); 15 | 16 | LPCTSTR GetClass() const; 17 | LPVOID GetInterface(LPCTSTR pstrName); 18 | void SetNormalImage(LPCTSTR pStrImage); 19 | 20 | void DoEvent(TEventUI& event); 21 | void OnTimer( int nTimerID ); 22 | void PaintStatusImage(HDC hDC); 23 | 24 | virtual void OnAnimationStart(INT nAnimationID, BOOL bFirstLoop) {} 25 | virtual void OnAnimationStep(INT nTotalFrame, INT nCurFrame, INT nAnimationID); 26 | virtual void OnAnimationStop(INT nAnimationID) {} 27 | 28 | protected: 29 | CDuiString m_sOldImage; 30 | CDuiString m_sNewImage; 31 | CDuiString m_sLastImage; 32 | BYTE m_bFadeAlpha; 33 | BOOL m_bMouseHove; 34 | BOOL m_bMouseLeave; 35 | enum{ 36 | FADE_IN_ID = 8, 37 | FADE_OUT_ID = 9, 38 | FADE_ELLAPSE = 10, 39 | FADE_FRAME_COUNT = 30, 40 | }; 41 | }; 42 | 43 | } // namespace DuiLib 44 | 45 | #endif // __UIFADEBUTTON_H__ -------------------------------------------------------------------------------- /Duilib/Control/UIFlash.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIFlash.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIFlash.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIFlash.h -------------------------------------------------------------------------------- /Duilib/Control/UIGifAnim.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIGifAnim.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIGifAnim.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIGifAnim.h -------------------------------------------------------------------------------- /Duilib/Control/UIGifAnimEx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIGifAnimEx.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIGifAnimEx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIGifAnimEx.h -------------------------------------------------------------------------------- /Duilib/Control/UIGroupBox.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIGroupBox.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIGroupBox.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIGroupBox.h -------------------------------------------------------------------------------- /Duilib/Control/UIHotKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIHotKey.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIHotKey.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIHOTKEY_H__ 2 | #define __UIHOTKEY_H__ 3 | #pragma once 4 | 5 | namespace DuiLib{ 6 | class CHotKeyUI; 7 | 8 | class UILIB_API CHotKeyWnd : public CWindowWnd 9 | { 10 | public: 11 | CHotKeyWnd(void); 12 | 13 | public: 14 | void Init(CHotKeyUI * pOwner); 15 | RECT CalPos(); 16 | LPCTSTR GetWindowClassName() const; 17 | void OnFinalMessage(HWND hWnd); 18 | LPCTSTR GetSuperClassName() const; 19 | LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); 20 | LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 21 | LRESULT OnEditChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 22 | public: 23 | void SetHotKey(WORD wVirtualKeyCode, WORD wModifiers); 24 | void GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const; 25 | DWORD GetHotKey(void) const; 26 | CDuiString GetHotKeyName(); 27 | void SetRules(WORD wInvalidComb, WORD wModifiers); 28 | CDuiString GetKeyName(UINT vk, BOOL fExtended); 29 | protected: 30 | CHotKeyUI * m_pOwner; 31 | HBRUSH m_hBkBrush; 32 | bool m_bInit; 33 | }; 34 | 35 | class UILIB_API CHotKeyUI : public CLabelUI 36 | { 37 | DECLARE_DUICONTROL(CHotKeyUI) 38 | friend CHotKeyWnd; 39 | public: 40 | CHotKeyUI(); 41 | LPCTSTR GetClass() const; 42 | LPVOID GetInterface(LPCTSTR pstrName); 43 | UINT GetControlFlags() const; 44 | void SetEnabled(bool bEnable = true); 45 | void SetText(LPCTSTR pstrText); 46 | LPCTSTR GetNormalImage(); 47 | void SetNormalImage(LPCTSTR pStrImage); 48 | LPCTSTR GetHotImage(); 49 | void SetHotImage(LPCTSTR pStrImage); 50 | LPCTSTR GetFocusedImage(); 51 | void SetFocusedImage(LPCTSTR pStrImage); 52 | LPCTSTR GetDisabledImage(); 53 | void SetDisabledImage(LPCTSTR pStrImage); 54 | void SetNativeBkColor(DWORD dwBkColor); 55 | DWORD GetNativeBkColor() const; 56 | 57 | void SetPos(RECT rc); 58 | void SetVisible(bool bVisible = true); 59 | void SetInternVisible(bool bVisible = true); 60 | SIZE EstimateSize(SIZE szAvailable); 61 | void DoEvent(TEventUI& event); 62 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 63 | 64 | void PaintStatusImage(HDC hDC); 65 | void PaintText(HDC hDC); 66 | public: 67 | void GetHotKey(WORD &wVirtualKeyCode, WORD &wModifiers) const; 68 | DWORD GetHotKey(void) const; 69 | void SetHotKey(WORD wVirtualKeyCode, WORD wModifiers); 70 | 71 | protected: 72 | CHotKeyWnd * m_pWindow; 73 | UINT m_uButtonState; 74 | CDuiString m_sNormalImage; 75 | CDuiString m_sHotImage; 76 | CDuiString m_sFocusedImage; 77 | CDuiString m_sDisabledImage; 78 | DWORD m_dwHotKeybkColor; 79 | 80 | protected: 81 | WORD m_wVirtualKeyCode; 82 | WORD m_wModifiers; 83 | }; 84 | } 85 | 86 | 87 | #endif -------------------------------------------------------------------------------- /Duilib/Control/UIIPAddress.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIIPAddress.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIIPAddress.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIIPAddress.h -------------------------------------------------------------------------------- /Duilib/Control/UILabel.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UILabel.h" 3 | 4 | #include 5 | namespace DuiLib 6 | { 7 | IMPLEMENT_DUICONTROL(CLabelUI) 8 | 9 | CLabelUI::CLabelUI() : m_uTextStyle(DT_VCENTER | DT_SINGLELINE), m_dwTextColor(0), 10 | m_dwDisabledTextColor(0), 11 | m_iFont(-1), 12 | m_bShowHtml(false), 13 | m_bAutoCalcWidth(false) 14 | { 15 | ::ZeroMemory(&m_rcTextPadding, sizeof(m_rcTextPadding)); 16 | } 17 | 18 | CLabelUI::~CLabelUI() 19 | { 20 | } 21 | 22 | LPCTSTR CLabelUI::GetClass() const 23 | { 24 | return _T("LabelUI"); 25 | } 26 | 27 | LPVOID CLabelUI::GetInterface(LPCTSTR pstrName) 28 | { 29 | if( _tcsicmp(pstrName, _T("Label")) == 0 ) return static_cast(this); 30 | return CControlUI::GetInterface(pstrName); 31 | } 32 | 33 | UINT CLabelUI::GetControlFlags() const 34 | { 35 | return IsEnabled() ? UIFLAG_SETCURSOR : 0; 36 | } 37 | void CLabelUI::SetTextStyle(UINT uStyle) 38 | { 39 | m_uTextStyle = uStyle; 40 | Invalidate(); 41 | } 42 | 43 | UINT CLabelUI::GetTextStyle() const 44 | { 45 | return m_uTextStyle; 46 | } 47 | 48 | void CLabelUI::SetTextColor(DWORD dwTextColor) 49 | { 50 | m_dwTextColor = dwTextColor; 51 | Invalidate(); 52 | } 53 | 54 | DWORD CLabelUI::GetTextColor() const 55 | { 56 | return m_dwTextColor; 57 | } 58 | 59 | void CLabelUI::SetDisabledTextColor(DWORD dwTextColor) 60 | { 61 | m_dwDisabledTextColor = dwTextColor; 62 | Invalidate(); 63 | } 64 | 65 | DWORD CLabelUI::GetDisabledTextColor() const 66 | { 67 | return m_dwDisabledTextColor; 68 | } 69 | 70 | void CLabelUI::SetFont(int index) 71 | { 72 | m_iFont = index; 73 | Invalidate(); 74 | } 75 | 76 | int CLabelUI::GetFont() const 77 | { 78 | return m_iFont; 79 | } 80 | 81 | RECT CLabelUI::GetTextPadding() const 82 | { 83 | return m_rcTextPadding; 84 | } 85 | 86 | void CLabelUI::SetTextPadding(RECT rc) 87 | { 88 | m_rcTextPadding = rc; 89 | Invalidate(); 90 | } 91 | 92 | bool CLabelUI::IsShowHtml() 93 | { 94 | return m_bShowHtml; 95 | } 96 | 97 | void CLabelUI::SetShowHtml(bool bShowHtml) 98 | { 99 | if( m_bShowHtml == bShowHtml ) return; 100 | 101 | m_bShowHtml = bShowHtml; 102 | Invalidate(); 103 | } 104 | 105 | SIZE CLabelUI::EstimateSize(SIZE szAvailable) 106 | { 107 | if (m_bAutoCalcWidth) { 108 | CDuiString sText = GetText(); 109 | 110 | RECT rcText = {0, 0, szAvailable.cx, szAvailable.cy}; 111 | int nLinks = 0; 112 | if( m_bShowHtml ) CRenderEngine::DrawHtmlText(m_pManager->GetPaintDC(), m_pManager, rcText, sText, m_dwTextColor, NULL, NULL, nLinks, DT_CALCRECT | m_uTextStyle); 113 | else CRenderEngine::DrawText(m_pManager->GetPaintDC(), m_pManager, rcText, sText, m_dwTextColor, m_iFont, DT_CALCRECT | m_uTextStyle); 114 | m_cxyFixed.cx = rcText.right - rcText.left + m_rcTextPadding.left + m_rcTextPadding.right; 115 | } 116 | 117 | if( m_cxyFixed.cy == 0 ) return CDuiSize(m_cxyFixed.cx, m_pManager->GetFontInfo(GetFont())->tm.tmHeight + 4); 118 | return CControlUI::EstimateSize(szAvailable); 119 | } 120 | 121 | void CLabelUI::DoEvent(TEventUI& event) 122 | { 123 | if( event.Type == UIEVENT_SETFOCUS ) 124 | { 125 | m_bFocused = true; 126 | return; 127 | } 128 | if( event.Type == UIEVENT_KILLFOCUS ) 129 | { 130 | m_bFocused = false; 131 | return; 132 | } 133 | if( event.Type == UIEVENT_MOUSEENTER ) 134 | { 135 | // return; 136 | } 137 | if( event.Type == UIEVENT_MOUSELEAVE ) 138 | { 139 | // return; 140 | } 141 | CControlUI::DoEvent(event); 142 | } 143 | 144 | void CLabelUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 145 | { 146 | if( _tcsicmp(pstrName, _T("align")) == 0 ) { 147 | if( _tcsstr(pstrValue, _T("left")) != NULL ) { 148 | m_uTextStyle &= ~(DT_CENTER | DT_RIGHT | DT_SINGLELINE); 149 | m_uTextStyle |= DT_LEFT; 150 | } 151 | if( _tcsstr(pstrValue, _T("center")) != NULL ) { 152 | m_uTextStyle &= ~(DT_LEFT | DT_RIGHT ); 153 | m_uTextStyle |= DT_CENTER; 154 | } 155 | if( _tcsstr(pstrValue, _T("right")) != NULL ) { 156 | m_uTextStyle &= ~(DT_LEFT | DT_CENTER | DT_SINGLELINE); 157 | m_uTextStyle |= DT_RIGHT; 158 | } 159 | } 160 | else if( _tcsicmp(pstrName, _T("valign")) == 0 ) { 161 | if( _tcsstr(pstrValue, _T("top")) != NULL ) { 162 | m_uTextStyle &= ~(DT_BOTTOM | DT_VCENTER); 163 | m_uTextStyle |= (DT_TOP | DT_SINGLELINE); 164 | } 165 | if( _tcsstr(pstrValue, _T("vcenter")) != NULL ) { 166 | m_uTextStyle &= ~(DT_TOP | DT_BOTTOM ); 167 | m_uTextStyle |= (DT_VCENTER | DT_SINGLELINE); 168 | } 169 | if( _tcsstr(pstrValue, _T("bottom")) != NULL ) { 170 | m_uTextStyle &= ~(DT_TOP | DT_VCENTER); 171 | m_uTextStyle |= (DT_BOTTOM | DT_SINGLELINE); 172 | } 173 | } 174 | else if( _tcsicmp(pstrName, _T("endellipsis")) == 0 ) { 175 | if( _tcsicmp(pstrValue, _T("true")) == 0 ) m_uTextStyle |= DT_END_ELLIPSIS; 176 | else m_uTextStyle &= ~DT_END_ELLIPSIS; 177 | } 178 | else if( _tcsicmp(pstrName, _T("wordbreak")) == 0 ) { 179 | if( _tcsicmp(pstrValue, _T("true")) == 0 ) { 180 | m_uTextStyle &= ~DT_SINGLELINE; 181 | m_uTextStyle |= DT_WORDBREAK | DT_EDITCONTROL; 182 | } 183 | else { 184 | m_uTextStyle &= ~DT_WORDBREAK & ~DT_EDITCONTROL; 185 | m_uTextStyle |= DT_SINGLELINE; 186 | } 187 | } 188 | else if( _tcsicmp(pstrName, _T("noprefix")) == 0 ) { 189 | if( _tcsicmp(pstrValue, _T("true")) == 0) 190 | { 191 | m_uTextStyle |= DT_NOPREFIX; 192 | } 193 | else 194 | { 195 | m_uTextStyle = m_uTextStyle & ~DT_NOPREFIX; 196 | } 197 | } 198 | else if( _tcsicmp(pstrName, _T("font")) == 0 ) SetFont(_ttoi(pstrValue)); 199 | else if( _tcsicmp(pstrName, _T("textcolor")) == 0 ) { 200 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); 201 | LPTSTR pstr = NULL; 202 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); 203 | SetTextColor(clrColor); 204 | } 205 | else if( _tcsicmp(pstrName, _T("disabledtextcolor")) == 0 ) { 206 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); 207 | LPTSTR pstr = NULL; 208 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); 209 | SetDisabledTextColor(clrColor); 210 | } 211 | else if( _tcsicmp(pstrName, _T("textpadding")) == 0 ) { 212 | RECT rcTextPadding = { 0 }; 213 | LPTSTR pstr = NULL; 214 | rcTextPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 215 | rcTextPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 216 | rcTextPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 217 | rcTextPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 218 | SetTextPadding(rcTextPadding); 219 | } 220 | else if( _tcsicmp(pstrName, _T("showhtml")) == 0 ) SetShowHtml(_tcsicmp(pstrValue, _T("true")) == 0); 221 | else if( _tcsicmp(pstrName, _T("autocalcwidth")) == 0 ) { 222 | SetAutoCalcWidth(_tcsicmp(pstrValue, _T("true")) == 0); 223 | } 224 | else CControlUI::SetAttribute(pstrName, pstrValue); 225 | } 226 | 227 | void CLabelUI::PaintText(HDC hDC) 228 | { 229 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor(); 230 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor(); 231 | 232 | RECT rc = m_rcItem; 233 | rc.left += m_rcTextPadding.left; 234 | rc.right -= m_rcTextPadding.right; 235 | rc.top += m_rcTextPadding.top; 236 | rc.bottom -= m_rcTextPadding.bottom; 237 | 238 | CDuiString sText = GetText(); 239 | if( sText.IsEmpty() ) return; 240 | int nLinks = 0; 241 | if( IsEnabled() ) { 242 | if( m_bShowHtml ) 243 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, sText, m_dwTextColor, \ 244 | NULL, NULL, nLinks, DT_SINGLELINE | m_uTextStyle); 245 | else 246 | CRenderEngine::DrawText(hDC, m_pManager, rc, sText, m_dwTextColor, \ 247 | m_iFont, m_uTextStyle); 248 | } 249 | else { 250 | if( m_bShowHtml ) 251 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, sText, m_dwDisabledTextColor, \ 252 | NULL, NULL, nLinks, DT_SINGLELINE | m_uTextStyle); 253 | else 254 | CRenderEngine::DrawText(hDC, m_pManager, rc, sText, m_dwDisabledTextColor, \ 255 | m_iFont, m_uTextStyle); 256 | } 257 | } 258 | 259 | bool CLabelUI::GetAutoCalcWidth() const 260 | { 261 | return m_bAutoCalcWidth; 262 | } 263 | 264 | void CLabelUI::SetAutoCalcWidth(bool bAutoCalcWidth) 265 | { 266 | m_bAutoCalcWidth = bAutoCalcWidth; 267 | } 268 | 269 | void CLabelUI::SetText( LPCTSTR pstrText ) 270 | { 271 | CControlUI::SetText(pstrText); 272 | if(GetAutoCalcWidth()) { 273 | this->NeedParentUpdate(); 274 | } 275 | } 276 | } -------------------------------------------------------------------------------- /Duilib/Control/UILabel.h: -------------------------------------------------------------------------------- 1 | #ifndef __UILABEL_H__ 2 | #define __UILABEL_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CLabelUI : public CControlUI 9 | { 10 | DECLARE_DUICONTROL(CLabelUI) 11 | public: 12 | CLabelUI(); 13 | ~CLabelUI(); 14 | 15 | LPCTSTR GetClass() const; 16 | LPVOID GetInterface(LPCTSTR pstrName); 17 | UINT GetControlFlags() const; 18 | 19 | void SetTextStyle(UINT uStyle); 20 | UINT GetTextStyle() const; 21 | void SetTextColor(DWORD dwTextColor); 22 | DWORD GetTextColor() const; 23 | void SetDisabledTextColor(DWORD dwTextColor); 24 | DWORD GetDisabledTextColor() const; 25 | void SetFont(int index); 26 | int GetFont() const; 27 | RECT GetTextPadding() const; 28 | void SetTextPadding(RECT rc); 29 | bool IsShowHtml(); 30 | void SetShowHtml(bool bShowHtml = true); 31 | 32 | SIZE EstimateSize(SIZE szAvailable); 33 | void DoEvent(TEventUI& event); 34 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 35 | 36 | void PaintText(HDC hDC); 37 | 38 | virtual bool GetAutoCalcWidth() const; 39 | virtual void SetAutoCalcWidth(bool bAutoCalcWidth); 40 | void SetText(LPCTSTR pstrText); 41 | 42 | protected: 43 | DWORD m_dwTextColor; 44 | DWORD m_dwDisabledTextColor; 45 | int m_iFont; 46 | UINT m_uTextStyle; 47 | RECT m_rcTextPadding; 48 | bool m_bShowHtml; 49 | bool m_bAutoCalcWidth; 50 | }; 51 | } 52 | 53 | #endif // __UILABEL_H__ -------------------------------------------------------------------------------- /Duilib/Control/UIList.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIList.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIList.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIList.h -------------------------------------------------------------------------------- /Duilib/Control/UIListEx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIListEx.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIListEx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIListEx.h -------------------------------------------------------------------------------- /Duilib/Control/UIList_3.0.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIList_3.0.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIList_3.0.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIList_3.0.h -------------------------------------------------------------------------------- /Duilib/Control/UIMenu - 副本.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIMenu - 副本.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIMenu - 副本.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIMenu - 副本.h -------------------------------------------------------------------------------- /Duilib/Control/UIMenu.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIMenu.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIMenu.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIMenu.h -------------------------------------------------------------------------------- /Duilib/Control/UIOption.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIOPTION_H__ 2 | #define __UIOPTION_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API COptionUI : public CButtonUI 9 | { 10 | DECLARE_DUICONTROL(COptionUI) 11 | public: 12 | COptionUI(); 13 | ~COptionUI(); 14 | 15 | LPCTSTR GetClass() const; 16 | LPVOID GetInterface(LPCTSTR pstrName); 17 | 18 | void SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit = true); 19 | 20 | bool Activate(); 21 | void SetEnabled(bool bEnable = true); 22 | 23 | LPCTSTR GetSelectedImage(); 24 | void SetSelectedImage(LPCTSTR pStrImage); 25 | 26 | LPCTSTR GetSelectedHotImage(); 27 | void SetSelectedHotImage(LPCTSTR pStrImage); 28 | 29 | LPCTSTR GetSelectedPushedImage(); 30 | void SetSelectedPushedImage(LPCTSTR pStrImage); 31 | 32 | void SetSelectedTextColor(DWORD dwTextColor); 33 | DWORD GetSelectedTextColor(); 34 | 35 | void SetSelectedBkColor(DWORD dwBkColor); 36 | DWORD GetSelectBkColor(); 37 | 38 | LPCTSTR GetSelectedForedImage(); 39 | void SetSelectedForedImage(LPCTSTR pStrImage); 40 | 41 | LPCTSTR GetGroup() const; 42 | void SetGroup(LPCTSTR pStrGroupName = NULL); 43 | bool IsSelected() const; 44 | virtual void Selected(bool bSelected); 45 | 46 | SIZE EstimateSize(SIZE szAvailable); 47 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 48 | 49 | void PaintStatusImage(HDC hDC); 50 | void PaintText(HDC hDC); 51 | 52 | protected: 53 | bool m_bSelected; 54 | CDuiString m_sGroupName; 55 | 56 | DWORD m_dwSelectedBkColor; 57 | DWORD m_dwSelectedTextColor; 58 | 59 | CDuiString m_sSelectedImage; 60 | CDuiString m_sSelectedHotImage; 61 | CDuiString m_sSelectedPushedImage; 62 | CDuiString m_sSelectedForeImage; 63 | }; 64 | 65 | class UILIB_API CCheckBoxUI : public COptionUI 66 | { 67 | DECLARE_DUICONTROL(CCheckBoxUI) 68 | 69 | public: 70 | virtual LPCTSTR GetClass() const; 71 | virtual LPVOID GetInterface(LPCTSTR pstrName); 72 | 73 | void SetCheck(bool bCheck); 74 | bool GetCheck() const; 75 | protected: 76 | bool m_bAutoCheck; 77 | 78 | public: 79 | CCheckBoxUI(); 80 | virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 81 | void SetAutoCheck(bool bEnable); 82 | virtual void DoEvent(TEventUI& event); 83 | virtual void Selected(bool bSelected); 84 | }; 85 | } // namespace DuiLib 86 | 87 | #endif // __UIOPTION_H__ -------------------------------------------------------------------------------- /Duilib/Control/UIProgress.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIProgress.h" 3 | 4 | namespace DuiLib 5 | { 6 | IMPLEMENT_DUICONTROL(CProgressUI) 7 | 8 | CProgressUI::CProgressUI() : m_bShowText(false), m_bHorizontal(true), m_nMin(0), m_nMax(100), m_nValue(0), m_bStretchForeImage(true) 9 | { 10 | m_uTextStyle = DT_SINGLELINE | DT_CENTER; 11 | SetFixedHeight(12); 12 | } 13 | 14 | LPCTSTR CProgressUI::GetClass() const 15 | { 16 | return _T("ProgressUI"); 17 | } 18 | 19 | LPVOID CProgressUI::GetInterface(LPCTSTR pstrName) 20 | { 21 | if( _tcsicmp(pstrName, DUI_CTR_PROGRESS) == 0 ) return static_cast(this); 22 | return CLabelUI::GetInterface(pstrName); 23 | } 24 | 25 | bool CProgressUI::IsShowText() 26 | { 27 | return m_bShowText; 28 | } 29 | 30 | void CProgressUI::SetShowText(bool bShowText) 31 | { 32 | if( m_bShowText == bShowText ) return; 33 | m_bShowText = bShowText; 34 | if(!m_bShowText) SetText(_T("")); 35 | } 36 | 37 | bool CProgressUI::IsHorizontal() 38 | { 39 | return m_bHorizontal; 40 | } 41 | 42 | void CProgressUI::SetHorizontal(bool bHorizontal) 43 | { 44 | if( m_bHorizontal == bHorizontal ) return; 45 | 46 | m_bHorizontal = bHorizontal; 47 | Invalidate(); 48 | } 49 | 50 | int CProgressUI::GetMinValue() const 51 | { 52 | return m_nMin; 53 | } 54 | 55 | void CProgressUI::SetMinValue(int nMin) 56 | { 57 | m_nMin = nMin; 58 | Invalidate(); 59 | } 60 | 61 | int CProgressUI::GetMaxValue() const 62 | { 63 | return m_nMax; 64 | } 65 | 66 | void CProgressUI::SetMaxValue(int nMax) 67 | { 68 | m_nMax = nMax; 69 | Invalidate(); 70 | } 71 | 72 | int CProgressUI::GetValue() const 73 | { 74 | return m_nValue; 75 | } 76 | 77 | void CProgressUI::SetValue(int nValue) 78 | { 79 | if(nValue == m_nValue || nValue m_nMax) { 80 | return; 81 | } 82 | m_nValue = nValue; 83 | Invalidate(); 84 | UpdateText(); 85 | } 86 | 87 | void CProgressUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 88 | { 89 | if( _tcsicmp(pstrName, _T("hor")) == 0 ) SetHorizontal(_tcsicmp(pstrValue, _T("true")) == 0); 90 | else if( _tcsicmp(pstrName, _T("min")) == 0 ) SetMinValue(_ttoi(pstrValue)); 91 | else if( _tcsicmp(pstrName, _T("max")) == 0 ) SetMaxValue(_ttoi(pstrValue)); 92 | else if( _tcsicmp(pstrName, _T("value")) == 0 ) SetValue(_ttoi(pstrValue)); 93 | else if( _tcsicmp(pstrName, _T("isstretchfore"))==0) SetStretchForeImage(_tcsicmp(pstrValue, _T("true")) == 0? true : false); 94 | else CLabelUI::SetAttribute(pstrName, pstrValue); 95 | } 96 | 97 | void CProgressUI::PaintForeColor(HDC hDC) 98 | { 99 | if(m_dwForeColor == 0) return; 100 | 101 | if( m_nMax <= m_nMin ) m_nMax = m_nMin + 1; 102 | if( m_nValue > m_nMax ) m_nValue = m_nMax; 103 | if( m_nValue < m_nMin ) m_nValue = m_nMin; 104 | 105 | RECT rc = m_rcItem; 106 | if( m_bHorizontal ) { 107 | rc.right = m_rcItem.left + (m_nValue - m_nMin) * (m_rcItem.right - m_rcItem.left) / (m_nMax - m_nMin); 108 | } 109 | else { 110 | rc.bottom = m_rcItem.top + (m_rcItem.bottom - m_rcItem.top) * (m_nMax - m_nValue) / (m_nMax - m_nMin); 111 | 112 | } 113 | 114 | CRenderEngine::DrawColor(hDC, rc, GetAdjustColor(m_dwForeColor)); 115 | } 116 | 117 | void CProgressUI::PaintForeImage(HDC hDC) 118 | { 119 | if( m_nMax <= m_nMin ) m_nMax = m_nMin + 1; 120 | if( m_nValue > m_nMax ) m_nValue = m_nMax; 121 | if( m_nValue < m_nMin ) m_nValue = m_nMin; 122 | 123 | RECT rc = {0}; 124 | if( m_bHorizontal ) { 125 | rc.right = (m_nValue - m_nMin) * (m_rcItem.right - m_rcItem.left) / (m_nMax - m_nMin); 126 | rc.bottom = m_rcItem.bottom - m_rcItem.top; 127 | } 128 | else { 129 | rc.top = (m_rcItem.bottom - m_rcItem.top) * (m_nMax - m_nValue) / (m_nMax - m_nMin); 130 | rc.right = m_rcItem.right - m_rcItem.left; 131 | rc.bottom = m_rcItem.bottom - m_rcItem.top; 132 | } 133 | 134 | if( !m_sForeImage.IsEmpty() ) { 135 | m_sForeImageModify.Empty(); 136 | if (m_bStretchForeImage) 137 | m_sForeImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rc.left, rc.top, rc.right, rc.bottom); 138 | else 139 | m_sForeImageModify.SmallFormat(_T("dest='%d,%d,%d,%d' source='%d,%d,%d,%d'") 140 | , rc.left, rc.top, rc.right, rc.bottom 141 | , rc.left, rc.top, rc.right, rc.bottom); 142 | 143 | if( !DrawImage(hDC, (LPCTSTR)m_sForeImage, (LPCTSTR)m_sForeImageModify) ) m_sForeImage.Empty(); 144 | else return; 145 | } 146 | } 147 | 148 | bool CProgressUI::IsStretchForeImage() 149 | { 150 | return m_bStretchForeImage; 151 | } 152 | 153 | void CProgressUI::SetStretchForeImage( bool bStretchForeImage /*= true*/ ) 154 | { 155 | if (m_bStretchForeImage==bStretchForeImage) return; 156 | m_bStretchForeImage=bStretchForeImage; 157 | Invalidate(); 158 | } 159 | 160 | void CProgressUI::UpdateText() 161 | { 162 | if(m_bShowText) { 163 | CDuiString sText; 164 | sText.Format(_T("%.0f%%"), (m_nValue - m_nMin) * 100.0f / (m_nMax - m_nMin)); 165 | SetText(sText); 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /Duilib/Control/UIProgress.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIPROGRESS_H__ 2 | #define __UIPROGRESS_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CProgressUI : public CLabelUI 9 | { 10 | DECLARE_DUICONTROL(CProgressUI) 11 | public: 12 | CProgressUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | 17 | bool IsShowText(); 18 | void SetShowText(bool bShowText = true); 19 | bool IsHorizontal(); 20 | void SetHorizontal(bool bHorizontal = true); 21 | bool IsStretchForeImage(); 22 | void SetStretchForeImage(bool bStretchForeImage = true); 23 | int GetMinValue() const; 24 | void SetMinValue(int nMin); 25 | int GetMaxValue() const; 26 | void SetMaxValue(int nMax); 27 | int GetValue() const; 28 | void SetValue(int nValue); 29 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 30 | void PaintForeColor(HDC hDC); 31 | void PaintForeImage(HDC hDC); 32 | virtual void UpdateText(); 33 | 34 | protected: 35 | bool m_bShowText; 36 | bool m_bHorizontal; 37 | bool m_bStretchForeImage; 38 | int m_nMax; 39 | int m_nMin; 40 | int m_nValue; 41 | 42 | CDuiString m_sForeImageModify; 43 | }; 44 | 45 | } // namespace DuiLib 46 | 47 | #endif // __UIPROGRESS_H__ 48 | -------------------------------------------------------------------------------- /Duilib/Control/UIRichEdit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIRichEdit.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIRichEdit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIRichEdit.h -------------------------------------------------------------------------------- /Duilib/Control/UIScrollBar.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIScrollBar.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIScrollBar.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIScrollBar.h -------------------------------------------------------------------------------- /Duilib/Control/UISlider.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UISlider.h" 3 | 4 | namespace DuiLib 5 | { 6 | IMPLEMENT_DUICONTROL(CSliderUI) 7 | CSliderUI::CSliderUI() : m_uButtonState(0), m_nStep(1),m_bSendMove(false) 8 | { 9 | m_uTextStyle = DT_SINGLELINE | DT_CENTER; 10 | m_szThumb.cx = m_szThumb.cy = 10; 11 | } 12 | 13 | LPCTSTR CSliderUI::GetClass() const 14 | { 15 | return _T("SliderUI"); 16 | } 17 | 18 | UINT CSliderUI::GetControlFlags() const 19 | { 20 | if( IsEnabled() ) return UIFLAG_SETCURSOR; 21 | else return 0; 22 | } 23 | 24 | LPVOID CSliderUI::GetInterface(LPCTSTR pstrName) 25 | { 26 | if( _tcsicmp(pstrName, DUI_CTR_SLIDER) == 0 ) return static_cast(this); 27 | return CProgressUI::GetInterface(pstrName); 28 | } 29 | 30 | void CSliderUI::SetEnabled(bool bEnable) 31 | { 32 | CControlUI::SetEnabled(bEnable); 33 | if( !IsEnabled() ) { 34 | m_uButtonState = 0; 35 | } 36 | } 37 | 38 | int CSliderUI::GetChangeStep() 39 | { 40 | return m_nStep; 41 | } 42 | 43 | void CSliderUI::SetChangeStep(int step) 44 | { 45 | m_nStep = step; 46 | } 47 | 48 | void CSliderUI::SetThumbSize(SIZE szXY) 49 | { 50 | m_szThumb = szXY; 51 | } 52 | 53 | RECT CSliderUI::GetThumbRect() const 54 | { 55 | if( m_bHorizontal ) { 56 | int left = m_rcItem.left + (m_rcItem.right - m_rcItem.left - m_szThumb.cx) * (m_nValue - m_nMin) / (m_nMax - m_nMin); 57 | int top = (m_rcItem.bottom + m_rcItem.top - m_szThumb.cy) / 2; 58 | return CDuiRect(left, top, left + m_szThumb.cx, top + m_szThumb.cy); 59 | } 60 | else { 61 | int left = (m_rcItem.right + m_rcItem.left - m_szThumb.cx) / 2; 62 | int top = m_rcItem.bottom - m_szThumb.cy - (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy) * (m_nValue - m_nMin) / (m_nMax - m_nMin); 63 | return CDuiRect(left, top, left + m_szThumb.cx, top + m_szThumb.cy); 64 | } 65 | } 66 | 67 | LPCTSTR CSliderUI::GetThumbImage() const 68 | { 69 | return m_sThumbImage; 70 | } 71 | 72 | void CSliderUI::SetThumbImage(LPCTSTR pStrImage) 73 | { 74 | m_sThumbImage = pStrImage; 75 | Invalidate(); 76 | } 77 | 78 | LPCTSTR CSliderUI::GetThumbHotImage() const 79 | { 80 | return m_sThumbHotImage; 81 | } 82 | 83 | void CSliderUI::SetThumbHotImage(LPCTSTR pStrImage) 84 | { 85 | m_sThumbHotImage = pStrImage; 86 | Invalidate(); 87 | } 88 | 89 | LPCTSTR CSliderUI::GetThumbPushedImage() const 90 | { 91 | return m_sThumbPushedImage; 92 | } 93 | 94 | void CSliderUI::SetThumbPushedImage(LPCTSTR pStrImage) 95 | { 96 | m_sThumbPushedImage = pStrImage; 97 | Invalidate(); 98 | } 99 | 100 | void CSliderUI::SetValue(int nValue) 101 | { 102 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) return; 103 | CProgressUI::SetValue(nValue); 104 | } 105 | 106 | void CSliderUI::DoEvent(TEventUI& event) 107 | { 108 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { 109 | if( m_pParent != NULL ) m_pParent->DoEvent(event); 110 | else CProgressUI::DoEvent(event); 111 | return; 112 | } 113 | 114 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) { 115 | if( IsEnabled() ) { 116 | m_uButtonState |= UISTATE_CAPTURED; 117 | 118 | int nValue; 119 | if( m_bHorizontal ) { 120 | if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) nValue = m_nMax; 121 | else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) nValue = m_nMin; 122 | else nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); 123 | } 124 | else { 125 | if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) nValue = m_nMin; 126 | else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) nValue = m_nMax; 127 | else nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); 128 | } 129 | if(m_nValue != nValue && nValue >= m_nMin && nValue <= m_nMax) { 130 | m_nValue = nValue; 131 | Invalidate(); 132 | } 133 | UpdateText(); 134 | } 135 | return; 136 | } 137 | 138 | if( event.Type == UIEVENT_BUTTONUP || event.Type == UIEVENT_RBUTTONUP) { 139 | if( IsEnabled() ) { 140 | int nValue = 0; 141 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { 142 | m_uButtonState &= ~UISTATE_CAPTURED; 143 | } 144 | if( m_bHorizontal ) { 145 | if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) nValue = m_nMax; 146 | else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) nValue = m_nMin; 147 | else nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); 148 | } 149 | else { 150 | if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) nValue = m_nMin; 151 | else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) nValue = m_nMax; 152 | else nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); 153 | } 154 | if(nValue >= m_nMin && nValue <= m_nMax) { 155 | m_nValue =nValue; 156 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); 157 | Invalidate(); 158 | } 159 | UpdateText(); 160 | return; 161 | } 162 | } 163 | if( event.Type == UIEVENT_CONTEXTMENU ) 164 | { 165 | return; 166 | } 167 | if( event.Type == UIEVENT_SCROLLWHEEL ) 168 | { 169 | if( IsEnabled() ) { 170 | switch( LOWORD(event.wParam) ) { 171 | case SB_LINEUP: 172 | SetValue(GetValue() + GetChangeStep()); 173 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); 174 | return; 175 | case SB_LINEDOWN: 176 | SetValue(GetValue() - GetChangeStep()); 177 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); 178 | return; 179 | } 180 | } 181 | } 182 | if( event.Type == UIEVENT_MOUSEMOVE ) { 183 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { 184 | if( m_bHorizontal ) { 185 | if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; 186 | else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; 187 | else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); 188 | } 189 | else { 190 | if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; 191 | else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; 192 | else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); 193 | } 194 | if (m_bSendMove) { 195 | UpdateText(); 196 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED_MOVE); 197 | } 198 | Invalidate(); 199 | } 200 | 201 | POINT pt = event.ptMouse; 202 | RECT rcThumb = GetThumbRect(); 203 | if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) { 204 | m_uButtonState |= UISTATE_HOT; 205 | Invalidate(); 206 | } 207 | else { 208 | m_uButtonState &= ~UISTATE_HOT; 209 | Invalidate(); 210 | } 211 | return; 212 | } 213 | if( event.Type == UIEVENT_SETCURSOR ) 214 | { 215 | RECT rcThumb = GetThumbRect(); 216 | if( IsEnabled()) { 217 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); 218 | return; 219 | } 220 | } 221 | if( event.Type == UIEVENT_MOUSELEAVE ) 222 | { 223 | if( IsEnabled() ) { 224 | m_uButtonState &= ~UISTATE_HOT; 225 | Invalidate(); 226 | } 227 | return; 228 | } 229 | CControlUI::DoEvent(event); 230 | } 231 | 232 | void CSliderUI::SetCanSendMove(bool bCanSend) 233 | { 234 | m_bSendMove = bCanSend; 235 | } 236 | bool CSliderUI::GetCanSendMove() const 237 | { 238 | return m_bSendMove; 239 | } 240 | 241 | void CSliderUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 242 | { 243 | if( _tcsicmp(pstrName, _T("thumbimage")) == 0 ) SetThumbImage(pstrValue); 244 | else if( _tcsicmp(pstrName, _T("thumbhotimage")) == 0 ) SetThumbHotImage(pstrValue); 245 | else if( _tcsicmp(pstrName, _T("thumbpushedimage")) == 0 ) SetThumbPushedImage(pstrValue); 246 | else if( _tcsicmp(pstrName, _T("thumbsize")) == 0 ) { 247 | SIZE szXY = {0}; 248 | LPTSTR pstr = NULL; 249 | szXY.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 250 | szXY.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 251 | SetThumbSize(szXY); 252 | } 253 | else if( _tcsicmp(pstrName, _T("step")) == 0 ) { 254 | SetChangeStep(_ttoi(pstrValue)); 255 | } 256 | else if( _tcsicmp(pstrName, _T("sendmove")) == 0 ) { 257 | SetCanSendMove(_tcsicmp(pstrValue, _T("true")) == 0); 258 | } 259 | else CProgressUI::SetAttribute(pstrName, pstrValue); 260 | } 261 | 262 | void CSliderUI::PaintStatusImage(HDC hDC) 263 | { 264 | CProgressUI::PaintStatusImage(hDC); 265 | 266 | RECT rcThumb = GetThumbRect(); 267 | rcThumb.left -= m_rcItem.left; 268 | rcThumb.top -= m_rcItem.top; 269 | rcThumb.right -= m_rcItem.left; 270 | rcThumb.bottom -= m_rcItem.top; 271 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { 272 | if( !m_sThumbPushedImage.IsEmpty() ) { 273 | m_sImageModify.Empty(); 274 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom); 275 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbPushedImage, (LPCTSTR)m_sImageModify) ) m_sThumbPushedImage.Empty(); 276 | else return; 277 | } 278 | } 279 | else if( (m_uButtonState & UISTATE_HOT) != 0 ) { 280 | if( !m_sThumbHotImage.IsEmpty() ) { 281 | m_sImageModify.Empty(); 282 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom); 283 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbHotImage, (LPCTSTR)m_sImageModify) ) m_sThumbHotImage.Empty(); 284 | else return; 285 | } 286 | } 287 | 288 | if( !m_sThumbImage.IsEmpty() ) { 289 | m_sImageModify.Empty(); 290 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom); 291 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbImage, (LPCTSTR)m_sImageModify) ) m_sThumbImage.Empty(); 292 | else return; 293 | } 294 | } 295 | } 296 | -------------------------------------------------------------------------------- /Duilib/Control/UISlider.h: -------------------------------------------------------------------------------- 1 | #ifndef __UISLIDER_H__ 2 | #define __UISLIDER_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CSliderUI : public CProgressUI 9 | { 10 | DECLARE_DUICONTROL(CSliderUI) 11 | public: 12 | CSliderUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | UINT GetControlFlags() const; 16 | LPVOID GetInterface(LPCTSTR pstrName); 17 | 18 | void SetEnabled(bool bEnable = true); 19 | 20 | int GetChangeStep(); 21 | void SetChangeStep(int step); 22 | void SetThumbSize(SIZE szXY); 23 | RECT GetThumbRect() const; 24 | LPCTSTR GetThumbImage() const; 25 | void SetThumbImage(LPCTSTR pStrImage); 26 | LPCTSTR GetThumbHotImage() const; 27 | void SetThumbHotImage(LPCTSTR pStrImage); 28 | LPCTSTR GetThumbPushedImage() const; 29 | void SetThumbPushedImage(LPCTSTR pStrImage); 30 | 31 | void DoEvent(TEventUI& event); 32 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 33 | void PaintStatusImage(HDC hDC); 34 | 35 | void SetValue(int nValue); 36 | void SetCanSendMove(bool bCanSend); 37 | bool GetCanSendMove() const; 38 | protected: 39 | SIZE m_szThumb; 40 | UINT m_uButtonState; 41 | int m_nStep; 42 | 43 | CDuiString m_sThumbImage; 44 | CDuiString m_sThumbHotImage; 45 | CDuiString m_sThumbPushedImage; 46 | 47 | CDuiString m_sImageModify; 48 | bool m_bSendMove; 49 | }; 50 | } 51 | 52 | #endif // __UISLIDER_H__ -------------------------------------------------------------------------------- /Duilib/Control/UIText.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIText.h" 3 | 4 | namespace DuiLib 5 | { 6 | IMPLEMENT_DUICONTROL(CTextUI) 7 | 8 | CTextUI::CTextUI() : m_nLinks(0), m_nHoverLink(-1) 9 | { 10 | m_uTextStyle = DT_WORDBREAK; 11 | m_rcTextPadding.left = 2; 12 | m_rcTextPadding.right = 2; 13 | ::ZeroMemory(m_rcLinks, sizeof(m_rcLinks)); 14 | } 15 | 16 | CTextUI::~CTextUI() 17 | { 18 | } 19 | 20 | LPCTSTR CTextUI::GetClass() const 21 | { 22 | return _T("TextUI"); 23 | } 24 | 25 | LPVOID CTextUI::GetInterface(LPCTSTR pstrName) 26 | { 27 | if( _tcsicmp(pstrName, DUI_CTR_TEXT) == 0 ) return static_cast(this); 28 | return CLabelUI::GetInterface(pstrName); 29 | } 30 | 31 | UINT CTextUI::GetControlFlags() const 32 | { 33 | if( IsEnabled() && m_nLinks > 0 ) return UIFLAG_SETCURSOR; 34 | else return 0; 35 | } 36 | 37 | CDuiString* CTextUI::GetLinkContent(int iIndex) 38 | { 39 | if( iIndex >= 0 && iIndex < m_nLinks ) return &m_sLinks[iIndex]; 40 | return NULL; 41 | } 42 | 43 | void CTextUI::DoEvent(TEventUI& event) 44 | { 45 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { 46 | if( m_pParent != NULL ) m_pParent->DoEvent(event); 47 | else CLabelUI::DoEvent(event); 48 | return; 49 | } 50 | 51 | if( event.Type == UIEVENT_SETCURSOR ) { 52 | for( int i = 0; i < m_nLinks; i++ ) { 53 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { 54 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); 55 | return; 56 | } 57 | } 58 | } 59 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK && IsEnabled() ) { 60 | for( int i = 0; i < m_nLinks; i++ ) { 61 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { 62 | Invalidate(); 63 | return; 64 | } 65 | } 66 | } 67 | if( event.Type == UIEVENT_BUTTONUP && IsEnabled() ) { 68 | for( int i = 0; i < m_nLinks; i++ ) { 69 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { 70 | m_pManager->SendNotify(this, DUI_MSGTYPE_LINK, i); 71 | return; 72 | } 73 | } 74 | } 75 | if( event.Type == UIEVENT_CONTEXTMENU ) 76 | { 77 | return; 78 | } 79 | // When you move over a link 80 | if( m_nLinks > 0 && event.Type == UIEVENT_MOUSEMOVE && IsEnabled() ) { 81 | int nHoverLink = -1; 82 | for( int i = 0; i < m_nLinks; i++ ) { 83 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { 84 | nHoverLink = i; 85 | break; 86 | } 87 | } 88 | 89 | if(m_nHoverLink != nHoverLink) { 90 | m_nHoverLink = nHoverLink; 91 | Invalidate(); 92 | return; 93 | } 94 | } 95 | if( event.Type == UIEVENT_MOUSELEAVE ) { 96 | if( m_nLinks > 0 && IsEnabled() ) { 97 | if(m_nHoverLink != -1) { 98 | m_nHoverLink = -1; 99 | Invalidate(); 100 | return; 101 | } 102 | } 103 | } 104 | 105 | CLabelUI::DoEvent(event); 106 | } 107 | 108 | SIZE CTextUI::EstimateSize(SIZE szAvailable) 109 | { 110 | CDuiString sText = GetText(); 111 | 112 | RECT rcText = { 0, 0, m_bAutoCalcWidth ? 9999 : m_cxyFixed.cx, 9999 }; 113 | rcText.left += m_rcTextPadding.left; 114 | rcText.right -= m_rcTextPadding.right; 115 | 116 | if( m_bShowHtml ) { 117 | int nLinks = 0; 118 | CRenderEngine::DrawHtmlText(m_pManager->GetPaintDC(), m_pManager, rcText, sText, m_dwTextColor, NULL, NULL, nLinks, DT_CALCRECT | m_uTextStyle); 119 | } 120 | else { 121 | CRenderEngine::DrawText(m_pManager->GetPaintDC(), m_pManager, rcText, sText, m_dwTextColor, m_iFont, DT_CALCRECT | m_uTextStyle); 122 | } 123 | SIZE cXY = {rcText.right - rcText.left + m_rcTextPadding.left + m_rcTextPadding.right, 124 | rcText.bottom - rcText.top + m_rcTextPadding.top + m_rcTextPadding.bottom}; 125 | 126 | if (m_bAutoCalcWidth) 127 | { 128 | m_cxyFixed.cx = cXY.cx; 129 | } 130 | 131 | return CControlUI::EstimateSize(szAvailable); 132 | } 133 | 134 | void CTextUI::PaintText(HDC hDC) 135 | { 136 | CDuiString sText = GetText(); 137 | if( sText.IsEmpty() ) { 138 | m_nLinks = 0; 139 | return; 140 | } 141 | 142 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor(); 143 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor(); 144 | 145 | m_nLinks = lengthof(m_rcLinks); 146 | RECT rc = m_rcItem; 147 | rc.left += m_rcTextPadding.left; 148 | rc.right -= m_rcTextPadding.right; 149 | rc.top += m_rcTextPadding.top; 150 | rc.bottom -= m_rcTextPadding.bottom; 151 | if( IsEnabled() ) { 152 | if( m_bShowHtml ) 153 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, sText, m_dwTextColor, \ 154 | m_rcLinks, m_sLinks, m_nLinks, m_uTextStyle); 155 | else 156 | CRenderEngine::DrawText(hDC, m_pManager, rc, sText, m_dwTextColor, \ 157 | m_iFont, m_uTextStyle); 158 | } 159 | else { 160 | if( m_bShowHtml ) 161 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, sText, m_dwDisabledTextColor, \ 162 | m_rcLinks, m_sLinks, m_nLinks, m_uTextStyle); 163 | else 164 | CRenderEngine::DrawText(hDC, m_pManager, rc, sText, m_dwDisabledTextColor, \ 165 | m_iFont, m_uTextStyle); 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /Duilib/Control/UIText.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITEXT_H__ 2 | #define __UITEXT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTextUI : public CLabelUI 9 | { 10 | DECLARE_DUICONTROL(CTextUI) 11 | public: 12 | CTextUI(); 13 | ~CTextUI(); 14 | 15 | LPCTSTR GetClass() const; 16 | UINT GetControlFlags() const; 17 | LPVOID GetInterface(LPCTSTR pstrName); 18 | 19 | CDuiString* GetLinkContent(int iIndex); 20 | 21 | void DoEvent(TEventUI& event); 22 | SIZE EstimateSize(SIZE szAvailable); 23 | 24 | void PaintText(HDC hDC); 25 | 26 | protected: 27 | enum { MAX_LINK = 8 }; 28 | int m_nLinks; 29 | RECT m_rcLinks[MAX_LINK]; 30 | CDuiString m_sLinks[MAX_LINK]; 31 | int m_nHoverLink; 32 | }; 33 | 34 | } // namespace DuiLib 35 | 36 | #endif //__UITEXT_H__ -------------------------------------------------------------------------------- /Duilib/Control/UITreeView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UITreeView.cpp -------------------------------------------------------------------------------- /Duilib/Control/UITreeView.h: -------------------------------------------------------------------------------- 1 | #ifndef UITreeView_h__ 2 | #define UITreeView_h__ 3 | 4 | #include 5 | using namespace std; 6 | 7 | #pragma once 8 | 9 | namespace DuiLib 10 | { 11 | class CTreeViewUI; 12 | class CCheckBoxUI; 13 | class CLabelUI; 14 | class COptionUI; 15 | 16 | class UILIB_API CTreeNodeUI : public CListContainerElementUI 17 | { 18 | DECLARE_DUICONTROL(CTreeNodeUI) 19 | public: 20 | CTreeNodeUI(CTreeNodeUI* _ParentNode = NULL); 21 | ~CTreeNodeUI(void); 22 | 23 | public: 24 | LPCTSTR GetClass() const; 25 | LPVOID GetInterface(LPCTSTR pstrName); 26 | void DoEvent(TEventUI& event); 27 | void Invalidate(); 28 | bool Select(bool bSelect = TRUE); 29 | 30 | bool Add(CControlUI* _pTreeNodeUI); 31 | bool AddAt(CControlUI* pControl, int iIndex); 32 | bool Remove(CControlUI* pControl); 33 | 34 | void SetVisibleTag(bool _IsVisible); 35 | bool GetVisibleTag(); 36 | void SetItemText(LPCTSTR pstrValue); 37 | CDuiString GetItemText(); 38 | void CheckBoxSelected(bool _Selected); 39 | bool IsCheckBoxSelected() const; 40 | bool IsHasChild() const; 41 | long GetTreeLevel() const; 42 | bool AddChildNode(CTreeNodeUI* _pTreeNodeUI); 43 | bool RemoveAt(CTreeNodeUI* _pTreeNodeUI); 44 | void SetParentNode(CTreeNodeUI* _pParentTreeNode); 45 | CTreeNodeUI* GetParentNode(); 46 | long GetCountChild(); 47 | void SetTreeView(CTreeViewUI* _CTreeViewUI); 48 | CTreeViewUI* GetTreeView(); 49 | CTreeNodeUI* GetChildNode(int _nIndex); 50 | void SetVisibleFolderBtn(bool _IsVisibled); 51 | bool GetVisibleFolderBtn(); 52 | void SetVisibleCheckBtn(bool _IsVisibled); 53 | bool GetVisibleCheckBtn(); 54 | void SetItemTextColor(DWORD _dwItemTextColor); 55 | DWORD GetItemTextColor() const; 56 | void SetItemHotTextColor(DWORD _dwItemHotTextColor); 57 | DWORD GetItemHotTextColor() const; 58 | void SetSelItemTextColor(DWORD _dwSelItemTextColor); 59 | DWORD GetSelItemTextColor() const; 60 | void SetSelItemHotTextColor(DWORD _dwSelHotItemTextColor); 61 | DWORD GetSelItemHotTextColor() const; 62 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 63 | 64 | CStdPtrArray GetTreeNodes(); 65 | int GetTreeIndex(); 66 | int GetNodeIndex(); 67 | 68 | public: 69 | CHorizontalLayoutUI* GetTreeNodeHoriznotal() const {return pHoriz;}; 70 | CCheckBoxUI* GetFolderButton() const {return pFolderButton;}; 71 | CLabelUI* GetDottedLine() const {return pDottedLine;}; 72 | CCheckBoxUI* GetCheckBox() const {return pCheckBox;}; 73 | COptionUI* GetItemButton() const {return pItemButton;}; 74 | 75 | private: 76 | CTreeNodeUI* GetLastNode(); 77 | CTreeNodeUI* CalLocation(CTreeNodeUI* _pTreeNodeUI); 78 | 79 | private: 80 | long m_iTreeLavel; 81 | bool m_bIsVisable; 82 | bool m_bIsCheckBox; 83 | DWORD m_dwItemTextColor; 84 | DWORD m_dwItemHotTextColor; 85 | DWORD m_dwSelItemTextColor; 86 | DWORD m_dwSelItemHotTextColor; 87 | 88 | CTreeViewUI* pTreeView; 89 | CHorizontalLayoutUI* pHoriz; 90 | CCheckBoxUI* pFolderButton; 91 | CLabelUI* pDottedLine; 92 | CCheckBoxUI* pCheckBox; 93 | COptionUI* pItemButton; 94 | CTreeNodeUI* pParentTreeNode; 95 | CStdPtrArray mTreeNodes; 96 | }; 97 | 98 | class UILIB_API CTreeViewUI : public CListUI,public INotifyUI 99 | { 100 | DECLARE_DUICONTROL(CTreeViewUI) 101 | public: 102 | CTreeViewUI(void); 103 | ~CTreeViewUI(void); 104 | 105 | public: 106 | virtual LPCTSTR GetClass() const; 107 | virtual LPVOID GetInterface(LPCTSTR pstrName); 108 | virtual bool Add(CTreeNodeUI* pControl ); 109 | virtual long AddAt(CTreeNodeUI* pControl, int iIndex ); 110 | virtual bool AddAt(CTreeNodeUI* pControl,CTreeNodeUI* _IndexNode); 111 | virtual bool Remove(CTreeNodeUI* pControl); 112 | virtual bool RemoveAt(int iIndex); 113 | virtual void RemoveAll(); 114 | virtual bool OnCheckBoxChanged(void* param); 115 | virtual bool OnFolderChanged(void* param); 116 | virtual bool OnDBClickItem(void* param); 117 | virtual bool SetItemCheckBox(bool _Selected,CTreeNodeUI* _TreeNode = NULL); 118 | virtual void SetItemExpand(bool _Expanded,CTreeNodeUI* _TreeNode = NULL); 119 | virtual void Notify(TNotifyUI& msg); 120 | virtual void SetVisibleFolderBtn(bool _IsVisibled); 121 | virtual bool GetVisibleFolderBtn(); 122 | virtual void SetVisibleCheckBtn(bool _IsVisibled); 123 | virtual bool GetVisibleCheckBtn(); 124 | virtual void SetItemMinWidth(UINT _ItemMinWidth); 125 | virtual UINT GetItemMinWidth(); 126 | virtual void SetItemTextColor(DWORD _dwItemTextColor); 127 | virtual void SetItemHotTextColor(DWORD _dwItemHotTextColor); 128 | virtual void SetSelItemTextColor(DWORD _dwSelItemTextColor); 129 | virtual void SetSelItemHotTextColor(DWORD _dwSelHotItemTextColor); 130 | 131 | virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 132 | private: 133 | UINT m_uItemMinWidth; 134 | bool m_bVisibleFolderBtn; 135 | bool m_bVisibleCheckBtn; 136 | }; 137 | } 138 | 139 | 140 | #endif // UITreeView_h__ 141 | -------------------------------------------------------------------------------- /Duilib/Control/UIWebBrowser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIWebBrowser.cpp -------------------------------------------------------------------------------- /Duilib/Control/UIWebBrowser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Control/UIWebBrowser.h -------------------------------------------------------------------------------- /Duilib/Core/ControlFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "ControlFactory.h" 3 | 4 | namespace DuiLib 5 | { 6 | CControlFactory::CControlFactory() 7 | { 8 | INNER_REGISTER_DUICONTROL(CControlUI); 9 | INNER_REGISTER_DUICONTROL(CContainerUI); 10 | INNER_REGISTER_DUICONTROL(CButtonUI); 11 | INNER_REGISTER_DUICONTROL(CComboUI); 12 | INNER_REGISTER_DUICONTROL(CComboBoxUI); 13 | INNER_REGISTER_DUICONTROL(CDateTimeUI); 14 | INNER_REGISTER_DUICONTROL(CEditUI); 15 | INNER_REGISTER_DUICONTROL(CActiveXUI); 16 | INNER_REGISTER_DUICONTROL(CFlashUI); 17 | INNER_REGISTER_DUICONTROL(CGifAnimUI); 18 | #ifdef USE_XIMAGE_EFFECT 19 | INNER_REGISTER_DUICONTROL(CGifAnimExUI); 20 | #endif 21 | INNER_REGISTER_DUICONTROL(CGroupBoxUI); 22 | INNER_REGISTER_DUICONTROL(CIPAddressUI); 23 | INNER_REGISTER_DUICONTROL(CLabelUI); 24 | INNER_REGISTER_DUICONTROL(CListUI); 25 | INNER_REGISTER_DUICONTROL(CListHeaderUI); 26 | INNER_REGISTER_DUICONTROL(CListHeaderItemUI); 27 | INNER_REGISTER_DUICONTROL(CListLabelElementUI); 28 | INNER_REGISTER_DUICONTROL(CListTextElementUI); 29 | INNER_REGISTER_DUICONTROL(CListContainerElementUI); 30 | INNER_REGISTER_DUICONTROL(CMenuUI); 31 | INNER_REGISTER_DUICONTROL(CMenuElementUI); 32 | INNER_REGISTER_DUICONTROL(COptionUI); 33 | INNER_REGISTER_DUICONTROL(CCheckBoxUI); 34 | INNER_REGISTER_DUICONTROL(CProgressUI); 35 | INNER_REGISTER_DUICONTROL(CRichEditUI); 36 | INNER_REGISTER_DUICONTROL(CScrollBarUI); 37 | INNER_REGISTER_DUICONTROL(CSliderUI); 38 | INNER_REGISTER_DUICONTROL(CTextUI); 39 | INNER_REGISTER_DUICONTROL(CTreeNodeUI); 40 | INNER_REGISTER_DUICONTROL(CTreeViewUI); 41 | INNER_REGISTER_DUICONTROL(CWebBrowserUI); 42 | INNER_REGISTER_DUICONTROL(CAnimationTabLayoutUI); 43 | INNER_REGISTER_DUICONTROL(CChildLayoutUI); 44 | INNER_REGISTER_DUICONTROL(CHorizontalLayoutUI); 45 | INNER_REGISTER_DUICONTROL(CTabLayoutUI); 46 | INNER_REGISTER_DUICONTROL(CTileLayoutUI); 47 | INNER_REGISTER_DUICONTROL(CVerticalLayoutUI); 48 | INNER_REGISTER_DUICONTROL(CRollTextUI); 49 | INNER_REGISTER_DUICONTROL(CColorPaletteUI); 50 | INNER_REGISTER_DUICONTROL(CListExUI); 51 | INNER_REGISTER_DUICONTROL(CListContainerHeaderItemUI); 52 | INNER_REGISTER_DUICONTROL(CListTextExtElementUI); 53 | INNER_REGISTER_DUICONTROL(CHotKeyUI); 54 | INNER_REGISTER_DUICONTROL(CFadeButtonUI); 55 | } 56 | 57 | CControlFactory::~CControlFactory() 58 | { 59 | } 60 | 61 | CControlUI* CControlFactory::CreateControl(CDuiString strClassName) 62 | { 63 | MAP_DUI_CTRATECLASS::iterator iter = m_mapControl.find(strClassName); 64 | if ( iter == m_mapControl.end()) { 65 | return NULL; 66 | } 67 | else { 68 | return (CControlUI*) (iter->second()); 69 | } 70 | } 71 | 72 | void CControlFactory::RegistControl(CDuiString strClassName, CreateClass pFunc) 73 | { 74 | m_mapControl.insert(MAP_DUI_CTRATECLASS::value_type(strClassName, pFunc)); 75 | } 76 | 77 | CControlFactory* CControlFactory::GetInstance() 78 | { 79 | static CControlFactory* pInstance = new CControlFactory; 80 | return pInstance; 81 | } 82 | 83 | void CControlFactory::Release() 84 | { 85 | delete this; 86 | } 87 | } -------------------------------------------------------------------------------- /Duilib/Core/ControlFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | namespace DuiLib 4 | { 5 | typedef CControlUI* (*CreateClass)(); 6 | typedef std::map MAP_DUI_CTRATECLASS; 7 | 8 | class UILIB_API CControlFactory 9 | { 10 | public: 11 | CControlUI* CreateControl(CDuiString strClassName); 12 | void RegistControl(CDuiString strClassName, CreateClass pFunc); 13 | 14 | static CControlFactory* GetInstance(); 15 | void Release(); 16 | 17 | private: 18 | CControlFactory(); 19 | virtual ~CControlFactory(); 20 | 21 | private: 22 | MAP_DUI_CTRATECLASS m_mapControl; 23 | }; 24 | 25 | #define DECLARE_DUICONTROL(class_name)\ 26 | public:\ 27 | static CControlUI* CreateControl(); 28 | 29 | #define IMPLEMENT_DUICONTROL(class_name)\ 30 | CControlUI* class_name::CreateControl()\ 31 | { return new class_name; } 32 | 33 | #define REGIST_DUICONTROL(class_name)\ 34 | CControlFactory::GetInstance()->RegistControl(_T(#class_name), (CreateClass)class_name::CreateControl); 35 | 36 | #define INNER_REGISTER_DUICONTROL(class_name)\ 37 | RegistControl(_T(#class_name), (CreateClass)class_name::CreateControl); 38 | } -------------------------------------------------------------------------------- /Duilib/Core/UIBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIBase.cpp -------------------------------------------------------------------------------- /Duilib/Core/UIBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIBase.h -------------------------------------------------------------------------------- /Duilib/Core/UIContainer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIContainer.cpp -------------------------------------------------------------------------------- /Duilib/Core/UIContainer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIContainer.h -------------------------------------------------------------------------------- /Duilib/Core/UIControl.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIControl.cpp -------------------------------------------------------------------------------- /Duilib/Core/UIControl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIControl.h -------------------------------------------------------------------------------- /Duilib/Core/UIDefine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIDefine.h -------------------------------------------------------------------------------- /Duilib/Core/UIDlgBuilder.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIDlgBuilder.cpp -------------------------------------------------------------------------------- /Duilib/Core/UIDlgBuilder.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIDLGBUILDER_H__ 2 | #define __UIDLGBUILDER_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | 8 | class IDialogBuilderCallback 9 | { 10 | public: 11 | virtual CControlUI* CreateControl(LPCTSTR pstrClass) = 0; 12 | }; 13 | 14 | 15 | class UILIB_API CDialogBuilder 16 | { 17 | public: 18 | CDialogBuilder(); 19 | CControlUI* Create(STRINGorID xml, LPCTSTR type = NULL, IDialogBuilderCallback* pCallback = NULL, 20 | CPaintManagerUI* pManager = NULL, CControlUI* pParent = NULL); 21 | CControlUI* Create(IDialogBuilderCallback* pCallback = NULL, CPaintManagerUI* pManager = NULL, 22 | CControlUI* pParent = NULL); 23 | 24 | CMarkup* GetMarkup(); 25 | 26 | void GetLastErrorMessage(LPTSTR pstrMessage, SIZE_T cchMax) const; 27 | void GetLastErrorLocation(LPTSTR pstrSource, SIZE_T cchMax) const; 28 | void SetInstance(HINSTANCE instance){ m_instance = instance;}; 29 | private: 30 | CControlUI* _Parse(CMarkupNode* parent, CControlUI* pParent = NULL, CPaintManagerUI* pManager = NULL); 31 | 32 | CMarkup m_xml; 33 | IDialogBuilderCallback* m_pCallback; 34 | LPCTSTR m_pstrtype; 35 | HINSTANCE m_instance; 36 | }; 37 | 38 | } // namespace DuiLib 39 | 40 | #endif // __UIDLGBUILDER_H__ 41 | -------------------------------------------------------------------------------- /Duilib/Core/UIManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIManager.cpp -------------------------------------------------------------------------------- /Duilib/Core/UIManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIManager.h -------------------------------------------------------------------------------- /Duilib/Core/UIMarkup.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIMarkup.cpp -------------------------------------------------------------------------------- /Duilib/Core/UIMarkup.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIMARKUP_H__ 2 | #define __UIMARKUP_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | 8 | enum 9 | { 10 | XMLFILE_ENCODING_UTF8 = 0, 11 | XMLFILE_ENCODING_UNICODE = 1, 12 | XMLFILE_ENCODING_ASNI = 2, 13 | }; 14 | 15 | class CMarkup; 16 | class CMarkupNode; 17 | 18 | 19 | class UILIB_API CMarkup 20 | { 21 | friend class CMarkupNode; 22 | public: 23 | CMarkup(LPCTSTR pstrXML = NULL); 24 | ~CMarkup(); 25 | 26 | bool Load(LPCTSTR pstrXML); 27 | bool LoadFromMem(BYTE* pByte, DWORD dwSize, int encoding = XMLFILE_ENCODING_UTF8); 28 | bool LoadFromFile(LPCTSTR pstrFilename, int encoding = XMLFILE_ENCODING_UTF8); 29 | void Release(); 30 | bool IsValid() const; 31 | 32 | void SetPreserveWhitespace(bool bPreserve = true); 33 | void GetLastErrorMessage(LPTSTR pstrMessage, SIZE_T cchMax) const; 34 | void GetLastErrorLocation(LPTSTR pstrSource, SIZE_T cchMax) const; 35 | 36 | CMarkupNode GetRoot(); 37 | 38 | private: 39 | typedef struct tagXMLELEMENT 40 | { 41 | ULONG iStart; 42 | ULONG iChild; 43 | ULONG iNext; 44 | ULONG iParent; 45 | ULONG iData; 46 | } XMLELEMENT; 47 | 48 | LPTSTR m_pstrXML; 49 | XMLELEMENT* m_pElements; 50 | ULONG m_nElements; 51 | ULONG m_nReservedElements; 52 | TCHAR m_szErrorMsg[100]; 53 | TCHAR m_szErrorXML[50]; 54 | bool m_bPreserveWhitespace; 55 | 56 | private: 57 | bool _Parse(); 58 | bool _Parse(LPTSTR& pstrText, ULONG iParent); 59 | XMLELEMENT* _ReserveElement(); 60 | inline void _SkipWhitespace(LPTSTR& pstr) const; 61 | inline void _SkipWhitespace(LPCTSTR& pstr) const; 62 | inline void _SkipIdentifier(LPTSTR& pstr) const; 63 | inline void _SkipIdentifier(LPCTSTR& pstr) const; 64 | bool _ParseData(LPTSTR& pstrText, LPTSTR& pstrData, char cEnd); 65 | void _ParseMetaChar(LPTSTR& pstrText, LPTSTR& pstrDest); 66 | bool _ParseAttributes(LPTSTR& pstrText); 67 | bool _Failed(LPCTSTR pstrError, LPCTSTR pstrLocation = NULL); 68 | }; 69 | 70 | 71 | class UILIB_API CMarkupNode 72 | { 73 | friend class CMarkup; 74 | private: 75 | CMarkupNode(); 76 | CMarkupNode(CMarkup* pOwner, int iPos); 77 | 78 | public: 79 | bool IsValid() const; 80 | 81 | CMarkupNode GetParent(); 82 | CMarkupNode GetSibling(); 83 | CMarkupNode GetChild(); 84 | CMarkupNode GetChild(LPCTSTR pstrName); 85 | 86 | bool HasSiblings() const; 87 | bool HasChildren() const; 88 | LPCTSTR GetName() const; 89 | LPCTSTR GetValue() const; 90 | 91 | bool HasAttributes(); 92 | bool HasAttribute(LPCTSTR pstrName); 93 | int GetAttributeCount(); 94 | LPCTSTR GetAttributeName(int iIndex); 95 | LPCTSTR GetAttributeValue(int iIndex); 96 | LPCTSTR GetAttributeValue(LPCTSTR pstrName); 97 | bool GetAttributeValue(int iIndex, LPTSTR pstrValue, SIZE_T cchMax); 98 | bool GetAttributeValue(LPCTSTR pstrName, LPTSTR pstrValue, SIZE_T cchMax); 99 | 100 | private: 101 | void _MapAttributes(); 102 | 103 | enum { MAX_XML_ATTRIBUTES = 64 }; 104 | 105 | typedef struct 106 | { 107 | ULONG iName; 108 | ULONG iValue; 109 | } XMLATTRIBUTE; 110 | 111 | int m_iPos; 112 | int m_nAttributes; 113 | XMLATTRIBUTE m_aAttributes[MAX_XML_ATTRIBUTES]; 114 | CMarkup* m_pOwner; 115 | }; 116 | 117 | } // namespace DuiLib 118 | 119 | #endif // __UIMARKUP_H__ 120 | -------------------------------------------------------------------------------- /Duilib/Core/UIRender.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIRender.cpp -------------------------------------------------------------------------------- /Duilib/Core/UIRender.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIRender.h -------------------------------------------------------------------------------- /Duilib/Core/UIResourceManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIResourceManager.cpp -------------------------------------------------------------------------------- /Duilib/Core/UIResourceManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Core/UIResourceManager.h -------------------------------------------------------------------------------- /Duilib/DuiLib.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiLib", "DuiLib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | DebugA|Win32 = DebugA|Win32 11 | DebugA|x64 = DebugA|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | ReleaseA|Win32 = ReleaseA|Win32 15 | ReleaseA|x64 = ReleaseA|x64 16 | SDebug|Win32 = SDebug|Win32 17 | SDebug|x64 = SDebug|x64 18 | SDebugA|Win32 = SDebugA|Win32 19 | SDebugA|x64 = SDebugA|x64 20 | SRelease|Win32 = SRelease|Win32 21 | SRelease|x64 = SRelease|x64 22 | SReleaseA|Win32 = SReleaseA|Win32 23 | SReleaseA|x64 = SReleaseA|x64 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.Build.0 = Debug|Win32 28 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.ActiveCfg = Debug|x64 29 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.Build.0 = Debug|x64 30 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.DebugA|Win32.ActiveCfg = DebugA|Win32 31 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.DebugA|Win32.Build.0 = DebugA|Win32 32 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.DebugA|x64.ActiveCfg = DebugA|x64 33 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.DebugA|x64.Build.0 = DebugA|x64 34 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.ActiveCfg = Release|Win32 35 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.Build.0 = Release|Win32 36 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.ActiveCfg = Release|x64 37 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.Build.0 = Release|x64 38 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.ReleaseA|Win32.ActiveCfg = ReleaseA|Win32 39 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.ReleaseA|Win32.Build.0 = ReleaseA|Win32 40 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.ReleaseA|x64.ActiveCfg = ReleaseA|x64 41 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.ReleaseA|x64.Build.0 = ReleaseA|x64 42 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebug|Win32.ActiveCfg = SDebug|Win32 43 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebug|Win32.Build.0 = SDebug|Win32 44 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebug|x64.ActiveCfg = SDebug|x64 45 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebug|x64.Build.0 = SDebug|x64 46 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebugA|Win32.ActiveCfg = SDebugA|Win32 47 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebugA|Win32.Build.0 = SDebugA|Win32 48 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebugA|x64.ActiveCfg = SDebugA|x64 49 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebugA|x64.Build.0 = SDebugA|x64 50 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SRelease|Win32.ActiveCfg = SRelease|Win32 51 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SRelease|Win32.Build.0 = SRelease|Win32 52 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SRelease|x64.ActiveCfg = SRelease|x64 53 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SRelease|x64.Build.0 = SRelease|x64 54 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SReleaseA|Win32.ActiveCfg = SReleaseA|Win32 55 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SReleaseA|Win32.Build.0 = SReleaseA|Win32 56 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SReleaseA|x64.ActiveCfg = SReleaseA|x64 57 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SReleaseA|x64.Build.0 = SReleaseA|x64 58 | EndGlobalSection 59 | GlobalSection(SolutionProperties) = preSolution 60 | HideSolutionNode = FALSE 61 | EndGlobalSection 62 | EndGlobal 63 | -------------------------------------------------------------------------------- /Duilib/DuiLib.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/DuiLib.v11.suo -------------------------------------------------------------------------------- /Duilib/DuiLib.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /Duilib/Layout/UIAnimationTabLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIAnimationTabLayout.h" 3 | 4 | namespace DuiLib { 5 | IMPLEMENT_DUICONTROL(CAnimationTabLayoutUI) 6 | 7 | CAnimationTabLayoutUI::CAnimationTabLayoutUI() : 8 | CUIAnimation( this ), 9 | m_bIsVerticalDirection( false ), 10 | m_nPositiveDirection( 1 ), 11 | m_pCurrentControl( NULL ), 12 | m_bControlVisibleFlag( false ) 13 | { 14 | } 15 | 16 | LPCTSTR CAnimationTabLayoutUI::GetClass() const 17 | { 18 | return _T("AnimationTabLayoutUI"); 19 | } 20 | 21 | LPVOID CAnimationTabLayoutUI::GetInterface(LPCTSTR pstrName) 22 | { 23 | if( _tcsicmp(pstrName, _T("AnimationTabLayout")) == 0 ) 24 | return static_cast(this); 25 | return CTabLayoutUI::GetInterface(pstrName); 26 | } 27 | 28 | bool CAnimationTabLayoutUI::SelectItem( int iIndex ) 29 | { 30 | if( iIndex < 0 || iIndex >= m_items.GetSize() ) return false; 31 | if( iIndex == m_iCurSel ) return true; 32 | if( iIndex > m_iCurSel ) m_nPositiveDirection = -1; 33 | if( iIndex < m_iCurSel ) m_nPositiveDirection = 1; 34 | 35 | int iOldSel = m_iCurSel; 36 | m_iCurSel = iIndex; 37 | for( int it = 0; it < m_items.GetSize(); it++ ) { 38 | if( it == iIndex ) { 39 | GetItemAt(it)->SetVisible(true); 40 | GetItemAt(it)->SetFocus(); 41 | m_bControlVisibleFlag = false; 42 | m_pCurrentControl = static_cast(m_items[it]); 43 | 44 | } 45 | else GetItemAt(it)->SetVisible(false); 46 | } 47 | 48 | NeedParentUpdate(); 49 | if( NULL != m_pCurrentControl ) m_pCurrentControl->SetVisible( false ); 50 | AnimationSwitch(); 51 | 52 | if( m_pManager != NULL ) { 53 | m_pManager->SetNextTabControl(); 54 | m_pManager->SendNotify(this, _T("tabselect"), m_iCurSel, iOldSel); 55 | } 56 | return true; 57 | } 58 | 59 | void CAnimationTabLayoutUI::AnimationSwitch() 60 | { 61 | m_rcItemOld = m_rcItem; 62 | if( !m_bIsVerticalDirection ) 63 | { 64 | m_rcCurPos.top = m_rcItem.top; 65 | m_rcCurPos.bottom = m_rcItem.bottom; 66 | m_rcCurPos.left = m_rcItem.left - ( m_rcItem.right - m_rcItem.left ) * m_nPositiveDirection + 52 * m_nPositiveDirection; 67 | m_rcCurPos.right = m_rcItem.right - ( m_rcItem.right - m_rcItem.left ) * m_nPositiveDirection+ 52 * m_nPositiveDirection; 68 | } 69 | else 70 | { 71 | m_rcCurPos.left = m_rcItem.left; 72 | m_rcCurPos.right = m_rcItem.right; 73 | m_rcCurPos.top = m_rcItem.top - ( m_rcItem.bottom - m_rcItem.top ) * m_nPositiveDirection; 74 | m_rcCurPos.bottom = m_rcItem.bottom - ( m_rcItem.bottom - m_rcItem.top ) * m_nPositiveDirection; 75 | } 76 | 77 | StopAnimation( TAB_ANIMATION_ID ); 78 | StartAnimation( TAB_ANIMATION_ELLAPSE, TAB_ANIMATION_FRAME_COUNT, TAB_ANIMATION_ID ); 79 | } 80 | 81 | void CAnimationTabLayoutUI::DoEvent(TEventUI& event) 82 | { 83 | if( event.Type == UIEVENT_TIMER ) 84 | { 85 | OnTimer( event.wParam ); 86 | } 87 | __super::DoEvent( event ); 88 | } 89 | 90 | void CAnimationTabLayoutUI::OnTimer( int nTimerID ) 91 | { 92 | OnAnimationElapse( nTimerID ); 93 | } 94 | 95 | void CAnimationTabLayoutUI::OnAnimationStep(INT nTotalFrame, INT nCurFrame, INT nAnimationID) 96 | { 97 | if( !m_bControlVisibleFlag ) { 98 | m_bControlVisibleFlag = true; 99 | m_pCurrentControl->SetVisible( true ); 100 | } 101 | 102 | int iStepLen = 0; 103 | if( !m_bIsVerticalDirection ) 104 | { 105 | iStepLen = ( m_rcItemOld.right - m_rcItemOld.left ) * m_nPositiveDirection / nTotalFrame; 106 | if( nCurFrame != nTotalFrame ) 107 | { 108 | m_rcCurPos.left = m_rcCurPos.left + iStepLen; 109 | m_rcCurPos.right = m_rcCurPos.right +iStepLen; 110 | } 111 | else 112 | { 113 | m_rcItem = m_rcCurPos = m_rcItemOld; 114 | } 115 | } 116 | else 117 | { 118 | iStepLen = ( m_rcItemOld.bottom - m_rcItemOld.top ) * m_nPositiveDirection / nTotalFrame; 119 | if( nCurFrame != nTotalFrame ) 120 | { 121 | m_rcCurPos.top = m_rcCurPos.top + iStepLen; 122 | m_rcCurPos.bottom = m_rcCurPos.bottom +iStepLen; 123 | } 124 | else 125 | { 126 | m_rcItem = m_rcCurPos = m_rcItemOld; 127 | } 128 | } 129 | SetPos(m_rcCurPos); 130 | } 131 | 132 | void CAnimationTabLayoutUI::OnAnimationStop(INT nAnimationID) 133 | { 134 | SetPos(m_rcItemOld); 135 | NeedParentUpdate(); 136 | } 137 | 138 | void CAnimationTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 139 | { 140 | if( _tcsicmp(pstrName, _T("animation_direction")) == 0 && _tcsicmp( pstrValue, _T("vertical")) == 0 ) m_bIsVerticalDirection = true; // pstrValue = "vertical" or "horizontal" 141 | return CTabLayoutUI::SetAttribute(pstrName, pstrValue); 142 | } 143 | } // namespace DuiLib -------------------------------------------------------------------------------- /Duilib/Layout/UIAnimationTabLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIANIMATIONTABLAYOUT_H__ 2 | #define __UIANIMATIONTABLAYOUT_H__ 3 | 4 | namespace DuiLib 5 | { 6 | class UILIB_API CAnimationTabLayoutUI : public CTabLayoutUI, public CUIAnimation 7 | { 8 | DECLARE_DUICONTROL(CAnimationTabLayoutUI) 9 | public: 10 | CAnimationTabLayoutUI(); 11 | 12 | LPCTSTR GetClass() const; 13 | LPVOID GetInterface(LPCTSTR pstrName); 14 | 15 | bool SelectItem( int iIndex ); 16 | void AnimationSwitch(); 17 | void DoEvent(TEventUI& event); 18 | void OnTimer( int nTimerID ); 19 | 20 | virtual void OnAnimationStart(INT nAnimationID, BOOL bFirstLoop) {} 21 | virtual void OnAnimationStep(INT nTotalFrame, INT nCurFrame, INT nAnimationID); 22 | virtual void OnAnimationStop(INT nAnimationID); 23 | 24 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 25 | 26 | protected: 27 | bool m_bIsVerticalDirection; 28 | int m_nPositiveDirection; 29 | RECT m_rcCurPos; 30 | RECT m_rcItemOld; 31 | CControlUI* m_pCurrentControl; 32 | bool m_bControlVisibleFlag; 33 | enum 34 | { 35 | TAB_ANIMATION_ID = 1, 36 | 37 | TAB_ANIMATION_ELLAPSE = 10, 38 | TAB_ANIMATION_FRAME_COUNT = 15, 39 | }; 40 | }; 41 | } 42 | #endif // __UIANIMATIONTABLAYOUT_H__ -------------------------------------------------------------------------------- /Duilib/Layout/UIChildLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UIChildLayout.h" 3 | 4 | namespace DuiLib 5 | { 6 | IMPLEMENT_DUICONTROL(CChildLayoutUI) 7 | 8 | CChildLayoutUI::CChildLayoutUI() 9 | { 10 | 11 | } 12 | 13 | void CChildLayoutUI::Init() 14 | { 15 | if (!m_pstrXMLFile.IsEmpty()) 16 | { 17 | CDialogBuilder builder; 18 | CContainerUI* pChildWindow = static_cast(builder.Create(m_pstrXMLFile.GetData(), (UINT)0, NULL, m_pManager)); 19 | if (pChildWindow) 20 | { 21 | this->Add(pChildWindow); 22 | } 23 | else 24 | { 25 | this->RemoveAll(); 26 | } 27 | } 28 | } 29 | 30 | void CChildLayoutUI::SetAttribute( LPCTSTR pstrName, LPCTSTR pstrValue ) 31 | { 32 | if( _tcsicmp(pstrName, _T("xmlfile")) == 0 ) 33 | SetChildLayoutXML(pstrValue); 34 | else 35 | CContainerUI::SetAttribute(pstrName,pstrValue); 36 | } 37 | 38 | void CChildLayoutUI::SetChildLayoutXML( DuiLib::CDuiString pXML ) 39 | { 40 | m_pstrXMLFile=pXML; 41 | } 42 | 43 | DuiLib::CDuiString CChildLayoutUI::GetChildLayoutXML() 44 | { 45 | return m_pstrXMLFile; 46 | } 47 | 48 | LPVOID CChildLayoutUI::GetInterface( LPCTSTR pstrName ) 49 | { 50 | if( _tcsicmp(pstrName, DUI_CTR_CHILDLAYOUT) == 0 ) return static_cast(this); 51 | return CControlUI::GetInterface(pstrName); 52 | } 53 | 54 | LPCTSTR CChildLayoutUI::GetClass() const 55 | { 56 | return _T("ChildLayoutUI"); 57 | } 58 | } // namespace DuiLib 59 | -------------------------------------------------------------------------------- /Duilib/Layout/UIChildLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UICHILDLAYOUT_H__ 2 | #define __UICHILDLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CChildLayoutUI : public CContainerUI 9 | { 10 | DECLARE_DUICONTROL(CChildLayoutUI) 11 | public: 12 | CChildLayoutUI(); 13 | 14 | void Init(); 15 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 16 | void SetChildLayoutXML(CDuiString pXML); 17 | CDuiString GetChildLayoutXML(); 18 | virtual LPVOID GetInterface(LPCTSTR pstrName); 19 | virtual LPCTSTR GetClass() const; 20 | 21 | private: 22 | CDuiString m_pstrXMLFile; 23 | }; 24 | } // namespace DuiLib 25 | #endif // __UICHILDLAYOUT_H__ 26 | -------------------------------------------------------------------------------- /Duilib/Layout/UIHorizontalLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIHORIZONTALLAYOUT_H__ 2 | #define __UIHORIZONTALLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CHorizontalLayoutUI : public CContainerUI 9 | { 10 | DECLARE_DUICONTROL(CHorizontalLayoutUI) 11 | public: 12 | CHorizontalLayoutUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | UINT GetControlFlags() const; 17 | 18 | void SetSepWidth(int iWidth); 19 | int GetSepWidth() const; 20 | void SetSepImmMode(bool bImmediately); 21 | bool IsSepImmMode() const; 22 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 23 | void DoEvent(TEventUI& event); 24 | 25 | void SetPos(RECT rc, bool bNeedInvalidate = true); 26 | void DoPostPaint(HDC hDC, const RECT& rcPaint); 27 | 28 | RECT GetThumbRect(bool bUseNew = false) const; 29 | 30 | protected: 31 | int m_iSepWidth; 32 | UINT m_uButtonState; 33 | POINT ptLastMouse; 34 | RECT m_rcNewPos; 35 | bool m_bImmMode; 36 | }; 37 | } 38 | #endif // __UIHORIZONTALLAYOUT_H__ 39 | -------------------------------------------------------------------------------- /Duilib/Layout/UITabLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UITabLayout.h" 3 | 4 | namespace DuiLib 5 | { 6 | IMPLEMENT_DUICONTROL(CTabLayoutUI) 7 | CTabLayoutUI::CTabLayoutUI() : m_iCurSel(-1) 8 | { 9 | } 10 | 11 | LPCTSTR CTabLayoutUI::GetClass() const 12 | { 13 | return _T("TabLayoutUI"); 14 | } 15 | 16 | LPVOID CTabLayoutUI::GetInterface(LPCTSTR pstrName) 17 | { 18 | if( _tcsicmp(pstrName, DUI_CTR_TABLAYOUT) == 0 ) return static_cast(this); 19 | return CContainerUI::GetInterface(pstrName); 20 | } 21 | 22 | bool CTabLayoutUI::Add(CControlUI* pControl) 23 | { 24 | bool ret = CContainerUI::Add(pControl); 25 | if( !ret ) return ret; 26 | 27 | if(m_iCurSel == -1 && pControl->IsVisible()) 28 | { 29 | m_iCurSel = GetItemIndex(pControl); 30 | } 31 | else 32 | { 33 | pControl->SetVisible(false); 34 | } 35 | 36 | return ret; 37 | } 38 | 39 | bool CTabLayoutUI::AddAt(CControlUI* pControl, int iIndex) 40 | { 41 | bool ret = CContainerUI::AddAt(pControl, iIndex); 42 | if( !ret ) return ret; 43 | 44 | if(m_iCurSel == -1 && pControl->IsVisible()) 45 | { 46 | m_iCurSel = GetItemIndex(pControl); 47 | } 48 | else if( m_iCurSel != -1 && iIndex <= m_iCurSel ) 49 | { 50 | m_iCurSel += 1; 51 | } 52 | else 53 | { 54 | pControl->SetVisible(false); 55 | } 56 | 57 | return ret; 58 | } 59 | 60 | bool CTabLayoutUI::Remove(CControlUI* pControl) 61 | { 62 | if( pControl == NULL) return false; 63 | 64 | int index = GetItemIndex(pControl); 65 | bool ret = CContainerUI::Remove(pControl); 66 | if( !ret ) return false; 67 | 68 | if( m_iCurSel == index) 69 | { 70 | if( GetCount() > 0 ) 71 | { 72 | m_iCurSel=0; 73 | GetItemAt(m_iCurSel)->SetVisible(true); 74 | } 75 | else 76 | m_iCurSel=-1; 77 | NeedParentUpdate(); 78 | } 79 | else if( m_iCurSel > index ) 80 | { 81 | m_iCurSel -= 1; 82 | } 83 | 84 | return ret; 85 | } 86 | 87 | void CTabLayoutUI::RemoveAll() 88 | { 89 | m_iCurSel = -1; 90 | CContainerUI::RemoveAll(); 91 | NeedParentUpdate(); 92 | } 93 | 94 | int CTabLayoutUI::GetCurSel() const 95 | { 96 | return m_iCurSel; 97 | } 98 | 99 | bool CTabLayoutUI::SelectItem(int iIndex) 100 | { 101 | if( iIndex < 0 || iIndex >= m_items.GetSize() ) return false; 102 | if( iIndex == m_iCurSel ) return true; 103 | 104 | int iOldSel = m_iCurSel; 105 | m_iCurSel = iIndex; 106 | for( int it = 0; it < m_items.GetSize(); it++ ) 107 | { 108 | if( it == iIndex ) { 109 | GetItemAt(it)->SetVisible(true); 110 | GetItemAt(it)->SetFocus(); 111 | SetPos(m_rcItem); 112 | } 113 | else GetItemAt(it)->SetVisible(false); 114 | } 115 | NeedParentUpdate(); 116 | 117 | if( m_pManager != NULL ) { 118 | m_pManager->SetNextTabControl(); 119 | m_pManager->SendNotify(this, DUI_MSGTYPE_TABSELECT, m_iCurSel, iOldSel); 120 | } 121 | return true; 122 | } 123 | 124 | bool CTabLayoutUI::SelectItem( CControlUI* pControl ) 125 | { 126 | int iIndex=GetItemIndex(pControl); 127 | if (iIndex==-1) 128 | return false; 129 | else 130 | return SelectItem(iIndex); 131 | } 132 | 133 | void CTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 134 | { 135 | if( _tcsicmp(pstrName, _T("selectedid")) == 0 ) SelectItem(_ttoi(pstrValue)); 136 | return CContainerUI::SetAttribute(pstrName, pstrValue); 137 | } 138 | 139 | void CTabLayoutUI::SetPos(RECT rc, bool bNeedInvalidate) 140 | { 141 | CControlUI::SetPos(rc, bNeedInvalidate); 142 | rc = m_rcItem; 143 | 144 | // Adjust for inset 145 | rc.left += m_rcInset.left; 146 | rc.top += m_rcInset.top; 147 | rc.right -= m_rcInset.right; 148 | rc.bottom -= m_rcInset.bottom; 149 | 150 | for( int it = 0; it < m_items.GetSize(); it++ ) { 151 | CControlUI* pControl = static_cast(m_items[it]); 152 | if( !pControl->IsVisible() ) continue; 153 | if( pControl->IsFloat() ) { 154 | SetFloatPos(it); 155 | continue; 156 | } 157 | 158 | if( it != m_iCurSel ) continue; 159 | 160 | RECT rcPadding = pControl->GetPadding(); 161 | rc.left += rcPadding.left; 162 | rc.top += rcPadding.top; 163 | rc.right -= rcPadding.right; 164 | rc.bottom -= rcPadding.bottom; 165 | 166 | SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top }; 167 | 168 | SIZE sz = pControl->EstimateSize(szAvailable); 169 | if( sz.cx == 0 ) { 170 | sz.cx = MAX(0, szAvailable.cx); 171 | } 172 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth(); 173 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth(); 174 | 175 | if(sz.cy == 0) { 176 | sz.cy = MAX(0, szAvailable.cy); 177 | } 178 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight(); 179 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight(); 180 | 181 | RECT rcCtrl = { rc.left, rc.top, rc.left + sz.cx, rc.top + sz.cy}; 182 | pControl->SetPos(rcCtrl); 183 | } 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /Duilib/Layout/UITabLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITABLAYOUT_H__ 2 | #define __UITABLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTabLayoutUI : public CContainerUI 9 | { 10 | DECLARE_DUICONTROL(CTabLayoutUI) 11 | public: 12 | CTabLayoutUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | 17 | bool Add(CControlUI* pControl); 18 | bool AddAt(CControlUI* pControl, int iIndex); 19 | bool Remove(CControlUI* pControl); 20 | void RemoveAll(); 21 | int GetCurSel() const; 22 | virtual bool SelectItem(int iIndex); 23 | virtual bool SelectItem(CControlUI* pControl); 24 | 25 | void SetPos(RECT rc, bool bNeedInvalidate = true); 26 | 27 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 28 | 29 | protected: 30 | int m_iCurSel; 31 | }; 32 | } 33 | #endif // __UITABLAYOUT_H__ 34 | -------------------------------------------------------------------------------- /Duilib/Layout/UITileLayout.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "UITileLayout.h" 3 | 4 | namespace DuiLib 5 | { 6 | IMPLEMENT_DUICONTROL(CTileLayoutUI) 7 | CTileLayoutUI::CTileLayoutUI() : m_nColumns(1) 8 | { 9 | m_szItem.cx = m_szItem.cy = 0; 10 | } 11 | 12 | LPCTSTR CTileLayoutUI::GetClass() const 13 | { 14 | return _T("TileLayoutUI"); 15 | } 16 | 17 | LPVOID CTileLayoutUI::GetInterface(LPCTSTR pstrName) 18 | { 19 | if( _tcsicmp(pstrName, DUI_CTR_TILELAYOUT) == 0 ) return static_cast(this); 20 | return CContainerUI::GetInterface(pstrName); 21 | } 22 | 23 | SIZE CTileLayoutUI::GetItemSize() const 24 | { 25 | return m_szItem; 26 | } 27 | 28 | void CTileLayoutUI::SetItemSize(SIZE szItem) 29 | { 30 | if( m_szItem.cx != szItem.cx || m_szItem.cy != szItem.cy ) { 31 | m_szItem = szItem; 32 | NeedUpdate(); 33 | } 34 | } 35 | 36 | int CTileLayoutUI::GetColumns() const 37 | { 38 | return m_nColumns; 39 | } 40 | 41 | void CTileLayoutUI::SetColumns(int nCols) 42 | { 43 | if( nCols <= 0 ) return; 44 | m_nColumns = nCols; 45 | NeedUpdate(); 46 | } 47 | 48 | void CTileLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) 49 | { 50 | if( _tcsicmp(pstrName, _T("itemsize")) == 0 ) { 51 | SIZE szItem = { 0 }; 52 | LPTSTR pstr = NULL; 53 | szItem.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); 54 | szItem.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); 55 | SetItemSize(szItem); 56 | } 57 | else if( _tcsicmp(pstrName, _T("columns")) == 0 ) SetColumns(_ttoi(pstrValue)); 58 | else CContainerUI::SetAttribute(pstrName, pstrValue); 59 | } 60 | 61 | void CTileLayoutUI::SetPos(RECT rc, bool bNeedInvalidate) 62 | { 63 | CControlUI::SetPos(rc, bNeedInvalidate); 64 | rc = m_rcItem; 65 | 66 | // Adjust for inset 67 | rc.left += m_rcInset.left; 68 | rc.top += m_rcInset.top; 69 | rc.right -= m_rcInset.right; 70 | rc.bottom -= m_rcInset.bottom; 71 | 72 | if( m_items.GetSize() == 0) { 73 | ProcessScrollBar(rc, 0, 0); 74 | return; 75 | } 76 | 77 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) rc.right -= m_pVerticalScrollBar->GetFixedWidth(); 78 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight(); 79 | 80 | // Position the elements 81 | if( m_szItem.cx > 0 ) m_nColumns = (rc.right - rc.left) / m_szItem.cx; 82 | if( m_nColumns == 0 ) m_nColumns = 1; 83 | 84 | int cyNeeded = 0; 85 | int cxWidth = (rc.right - rc.left) / m_nColumns; 86 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) 87 | cxWidth = (rc.right - rc.left + m_pHorizontalScrollBar->GetScrollRange() ) / m_nColumns; ; 88 | 89 | int cyHeight = 0; 90 | int iCount = 0; 91 | POINT ptTile = { rc.left, rc.top }; 92 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) { 93 | ptTile.y -= m_pVerticalScrollBar->GetScrollPos(); 94 | } 95 | int iPosX = rc.left; 96 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) { 97 | iPosX -= m_pHorizontalScrollBar->GetScrollPos(); 98 | ptTile.x = iPosX; 99 | } 100 | for( int it1 = 0; it1 < m_items.GetSize(); it1++ ) { 101 | CControlUI* pControl = static_cast(m_items[it1]); 102 | if( !pControl->IsVisible() ) continue; 103 | if( pControl->IsFloat() ) { 104 | SetFloatPos(it1); 105 | continue; 106 | } 107 | 108 | // Determine size 109 | RECT rcTile = { ptTile.x, ptTile.y, ptTile.x + cxWidth, ptTile.y }; 110 | if( (iCount % m_nColumns) == 0 ) 111 | { 112 | int iIndex = iCount; 113 | for( int it2 = it1; it2 < m_items.GetSize(); it2++ ) { 114 | CControlUI* pLineControl = static_cast(m_items[it2]); 115 | if( !pLineControl->IsVisible() ) continue; 116 | if( pLineControl->IsFloat() ) continue; 117 | 118 | RECT rcPadding = pLineControl->GetPadding(); 119 | SIZE szAvailable = { rcTile.right - rcTile.left - rcPadding.left - rcPadding.right, 9999 }; 120 | if( iIndex == iCount || (iIndex + 1) % m_nColumns == 0 ) { 121 | szAvailable.cx -= m_iChildPadding / 2; 122 | } 123 | else { 124 | szAvailable.cx -= m_iChildPadding; 125 | } 126 | 127 | if( szAvailable.cx < pControl->GetMinWidth() ) szAvailable.cx = pControl->GetMinWidth(); 128 | if( szAvailable.cx > pControl->GetMaxWidth() ) szAvailable.cx = pControl->GetMaxWidth(); 129 | 130 | SIZE szTile = pLineControl->EstimateSize(szAvailable); 131 | if( szTile.cx < pControl->GetMinWidth() ) szTile.cx = pControl->GetMinWidth(); 132 | if( szTile.cx > pControl->GetMaxWidth() ) szTile.cx = pControl->GetMaxWidth(); 133 | if( szTile.cy < pControl->GetMinHeight() ) szTile.cy = pControl->GetMinHeight(); 134 | if( szTile.cy > pControl->GetMaxHeight() ) szTile.cy = pControl->GetMaxHeight(); 135 | 136 | cyHeight = MAX(cyHeight, szTile.cy + rcPadding.top + rcPadding.bottom); 137 | if( (++iIndex % m_nColumns) == 0) break; 138 | } 139 | } 140 | 141 | RECT rcPadding = pControl->GetPadding(); 142 | 143 | rcTile.left += rcPadding.left + m_iChildPadding / 2; 144 | rcTile.right -= rcPadding.right + m_iChildPadding / 2; 145 | if( (iCount % m_nColumns) == 0 ) { 146 | rcTile.left -= m_iChildPadding / 2; 147 | } 148 | 149 | if( ( (iCount + 1) % m_nColumns) == 0 ) { 150 | rcTile.right += m_iChildPadding / 2; 151 | } 152 | 153 | // Set position 154 | rcTile.top = ptTile.y + rcPadding.top; 155 | rcTile.bottom = ptTile.y + cyHeight; 156 | 157 | SIZE szAvailable = { rcTile.right - rcTile.left, rcTile.bottom - rcTile.top }; 158 | SIZE szTile = pControl->EstimateSize(szAvailable); 159 | if( szTile.cx == 0 ) szTile.cx = szAvailable.cx; 160 | if( szTile.cy == 0 ) szTile.cy = szAvailable.cy; 161 | if( szTile.cx < pControl->GetMinWidth() ) szTile.cx = pControl->GetMinWidth(); 162 | if( szTile.cx > pControl->GetMaxWidth() ) szTile.cx = pControl->GetMaxWidth(); 163 | if( szTile.cy < pControl->GetMinHeight() ) szTile.cy = pControl->GetMinHeight(); 164 | if( szTile.cy > pControl->GetMaxHeight() ) szTile.cy = pControl->GetMaxHeight(); 165 | RECT rcPos = {(rcTile.left + rcTile.right - szTile.cx) / 2, (rcTile.top + rcTile.bottom - szTile.cy) / 2, 166 | (rcTile.left + rcTile.right - szTile.cx) / 2 + szTile.cx, (rcTile.top + rcTile.bottom - szTile.cy) / 2 + szTile.cy}; 167 | pControl->SetPos(rcPos); 168 | 169 | if( (++iCount % m_nColumns) == 0 ) { 170 | ptTile.x = iPosX; 171 | ptTile.y += cyHeight + m_iChildPadding; 172 | cyHeight = 0; 173 | } 174 | else { 175 | ptTile.x += cxWidth; 176 | } 177 | cyNeeded = rcTile.bottom - rc.top; 178 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) cyNeeded += m_pVerticalScrollBar->GetScrollPos(); 179 | } 180 | 181 | // Process the scrollbar 182 | ProcessScrollBar(rc, 0, cyNeeded); 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /Duilib/Layout/UITileLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITILELAYOUT_H__ 2 | #define __UITILELAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CTileLayoutUI : public CContainerUI 9 | { 10 | DECLARE_DUICONTROL(CTileLayoutUI) 11 | public: 12 | CTileLayoutUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | 17 | void SetPos(RECT rc, bool bNeedInvalidate = true); 18 | 19 | SIZE GetItemSize() const; 20 | void SetItemSize(SIZE szItem); 21 | int GetColumns() const; 22 | void SetColumns(int nCols); 23 | 24 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 25 | 26 | protected: 27 | SIZE m_szItem; 28 | int m_nColumns; 29 | }; 30 | } 31 | #endif // __UITILELAYOUT_H__ 32 | -------------------------------------------------------------------------------- /Duilib/Layout/UIVerticalLayout.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIVERTICALLAYOUT_H__ 2 | #define __UIVERTICALLAYOUT_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib 7 | { 8 | class UILIB_API CVerticalLayoutUI : public CContainerUI 9 | { 10 | DECLARE_DUICONTROL(CVerticalLayoutUI) 11 | public: 12 | CVerticalLayoutUI(); 13 | 14 | LPCTSTR GetClass() const; 15 | LPVOID GetInterface(LPCTSTR pstrName); 16 | UINT GetControlFlags() const; 17 | 18 | void SetSepHeight(int iHeight); 19 | int GetSepHeight() const; 20 | void SetSepImmMode(bool bImmediately); 21 | bool IsSepImmMode() const; 22 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); 23 | void DoEvent(TEventUI& event); 24 | 25 | void SetPos(RECT rc, bool bNeedInvalidate = true); 26 | void DoPostPaint(HDC hDC, const RECT& rcPaint); 27 | 28 | RECT GetThumbRect(bool bUseNew = false) const; 29 | 30 | protected: 31 | int m_iSepHeight; 32 | UINT m_uButtonState; 33 | POINT ptLastMouse; 34 | RECT m_rcNewPos; 35 | bool m_bImmMode; 36 | }; 37 | } 38 | #endif // __UIVERTICALLAYOUT_H__ 39 | -------------------------------------------------------------------------------- /Duilib/Lib/DuiLib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Lib/DuiLib.lib -------------------------------------------------------------------------------- /Duilib/Lib/DuiLib_d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Lib/DuiLib_d.lib -------------------------------------------------------------------------------- /Duilib/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // UIlib.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "StdAfx.h" 6 | 7 | #pragma comment( lib, "winmm.lib" ) 8 | #pragma comment( lib, "comctl32.lib" ) -------------------------------------------------------------------------------- /Duilib/StdAfx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/StdAfx.h -------------------------------------------------------------------------------- /Duilib/UILib.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010-2011, duilib develop team(www.duilib.com). 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or 5 | // without modification, are permitted provided that the 6 | // following conditions are met. 7 | // 8 | // Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // 11 | // Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following 13 | // disclaimer in the documentation and/or other materials 14 | // provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 17 | // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 18 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 | // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // 31 | // DirectUI - UI Library 32 | // 33 | // Written by Bjarke Viksoe (bjarke@viksoe.dk) 34 | // Copyright (c) 2006-2007 Bjarke Viksoe. 35 | // 36 | // This code may be used in compiled form in any way you desire. These 37 | // source files may be redistributed by any means PROVIDING it is 38 | // not sold for profit without the authors written consent, and 39 | // providing that this notice and the authors name is included. 40 | // 41 | // This file is provided "as is" with no expressed or implied warranty. 42 | // The author accepts no liability if it causes any damage to you or your 43 | // computer whatsoever. It's free, so don't hassle me about it. 44 | // 45 | // Beware of bugs. 46 | // 47 | // 48 | 49 | 50 | #include "StdAfx.h" 51 | #include "UIlib.h" 52 | 53 | 54 | BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID /*lpReserved*/) 55 | { 56 | switch( dwReason ) { 57 | case DLL_PROCESS_ATTACH: 58 | case DLL_THREAD_ATTACH: 59 | case DLL_THREAD_DETACH: 60 | case DLL_PROCESS_DETACH: 61 | ::DisableThreadLibraryCalls((HMODULE)hModule); 62 | break; 63 | } 64 | return TRUE; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /Duilib/UIlib.h: -------------------------------------------------------------------------------- 1 | #ifdef UILIB_STATIC 2 | #define UILIB_API 3 | #else 4 | #if defined(UILIB_EXPORTS) 5 | # if defined(_MSC_VER) 6 | # define UILIB_API __declspec(dllexport) 7 | # else 8 | # define UILIB_API 9 | # endif 10 | #else 11 | # if defined(_MSC_VER) 12 | # define UILIB_API __declspec(dllimport) 13 | # else 14 | # define UILIB_API 15 | # endif 16 | #endif 17 | #endif 18 | #define UILIB_COMDAT __declspec(selectany) 19 | 20 | #pragma warning(disable:4251) 21 | 22 | #if defined _M_IX86 23 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 24 | #elif defined _M_IA64 25 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") 26 | #elif defined _M_X64 27 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 28 | #else 29 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 30 | #endif 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include "Utils/Utils.h" 45 | #include "Core/UIMarkup.h" 46 | //#include "Utils/observer_impl_base.h" 47 | #include "Utils/UIShadow.h" 48 | 49 | #include "Utils/DuiTrayIcon.h" 50 | #include "Core/UITimer.h" 51 | 52 | #include "Utils/UIDelegate.h" 53 | #include "Utils/DragDropImpl.h" 54 | #include "Utils/TrayIcon.h" 55 | 56 | #include "Core/UIDefine.h" 57 | #include "Core/UIResourceManager.h" 58 | #include "Core/UIManager.h" 59 | #include "Core/UIBase.h" 60 | #include "Core/ControlFactory.h" 61 | #include "Core/UIControl.h" 62 | #include "Core/UIContainer.h" 63 | 64 | #include "Core/UIDlgBuilder.h" 65 | #include "Core/UIRender.h" 66 | #include "Utils/WinImplBase.h" 67 | 68 | #include "Layout/UIVerticalLayout.h" 69 | #include "Layout/UIHorizontalLayout.h" 70 | #include "Layout/UITileLayout.h" 71 | #include "Layout/UITabLayout.h" 72 | #include "Layout/UIChildLayout.h" 73 | 74 | #include "Control/UIList.h" 75 | #include "Control/UICombo.h" 76 | #include "Control/UIScrollBar.h" 77 | #include "Control/UITreeView.h" 78 | 79 | #include "Control/UILabel.h" 80 | #include "Control/UIText.h" 81 | #include "Control/UIEdit.h" 82 | #include "Control/UIGifAnim.h" 83 | #include "Control/UIGifAnimEx.h" 84 | 85 | #include "Control/UIAnimation.h" 86 | #include "Layout/UIAnimationTabLayout.h" 87 | #include "Control/UIButton.h" 88 | #include "Control/UIOption.h" 89 | 90 | #include "Control/UIProgress.h" 91 | #include "Control/UISlider.h" 92 | 93 | #include "Control/UIComboBox.h" 94 | #include "Control/UIRichEdit.h" 95 | #include "Control/UIDateTime.h" 96 | #include "Control/UIIPAddress.h" 97 | 98 | #include "Control/UIActiveX.h" 99 | #include "Control/UIWebBrowser.h" 100 | #include "Control/UIFlash.h" 101 | 102 | #include "Control/UIMenu.h" 103 | #include "Control/UIGroupBox.h" 104 | #include "Control/RollTextUI.h" 105 | #include "Control/UIColorPalette.h" 106 | #include "Control/UIListEx.h" 107 | #include "Control/UIHotKey.h" 108 | #include "Control/UIFadeButton.h" 109 | 110 | #pragma comment( lib, "comctl32.lib" ) 111 | #pragma comment( lib, "GdiPlus.lib" ) 112 | #pragma comment( lib, "Imm32.lib" ) -------------------------------------------------------------------------------- /Duilib/Utils/DragDropImpl.h: -------------------------------------------------------------------------------- 1 | // IDataObjectImpl.h: interface for the CIDataObjectImpl class. 2 | /************************************************************************** 3 | THIS CODE AND INFORMATION IS PROVIDED 'AS IS' WITHOUT WARRANTY OF 4 | ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 5 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 6 | PARTICULAR PURPOSE. 7 | Author: Leon Finker 1/2001 8 | **************************************************************************/ 9 | #ifndef __DRAGDROPIMPL_H__ 10 | #define __DRAGDROPIMPL_H__ 11 | #include 12 | #include 13 | 14 | namespace DuiLib { 15 | typedef std::vector FormatEtcArray; 16 | typedef std::vector PFormatEtcArray; 17 | typedef std::vector PStgMediumArray; 18 | 19 | /////////////////////////////////////////////////////////////////////////////////////////////// 20 | class UILIB_API CEnumFormatEtc : public IEnumFORMATETC 21 | { 22 | private: 23 | ULONG m_cRefCount; 24 | FormatEtcArray m_pFmtEtc; 25 | int m_iCur; 26 | 27 | public: 28 | CEnumFormatEtc(const FormatEtcArray& ArrFE); 29 | CEnumFormatEtc(const PFormatEtcArray& ArrFE); 30 | //IUnknown members 31 | STDMETHOD(QueryInterface)(REFIID, void FAR* FAR*); 32 | STDMETHOD_(ULONG, AddRef)(void); 33 | STDMETHOD_(ULONG, Release)(void); 34 | 35 | //IEnumFORMATETC members 36 | STDMETHOD(Next)(ULONG, LPFORMATETC, ULONG FAR *); 37 | STDMETHOD(Skip)(ULONG); 38 | STDMETHOD(Reset)(void); 39 | STDMETHOD(Clone)(IEnumFORMATETC FAR * FAR*); 40 | }; 41 | 42 | /////////////////////////////////////////////////////////////////////////////////////////////// 43 | class UILIB_API CIDropSource : public IDropSource 44 | { 45 | long m_cRefCount; 46 | public: 47 | bool m_bDropped; 48 | 49 | CIDropSource::CIDropSource():m_cRefCount(0),m_bDropped(false) {} 50 | //IUnknown 51 | virtual HRESULT STDMETHODCALLTYPE QueryInterface( 52 | /* [in] */ REFIID riid, 53 | /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 54 | virtual ULONG STDMETHODCALLTYPE AddRef( void); 55 | virtual ULONG STDMETHODCALLTYPE Release( void); 56 | //IDropSource 57 | virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag( 58 | /* [in] */ BOOL fEscapePressed, 59 | /* [in] */ DWORD grfKeyState); 60 | 61 | virtual HRESULT STDMETHODCALLTYPE GiveFeedback( 62 | /* [in] */ DWORD dwEffect); 63 | }; 64 | 65 | /////////////////////////////////////////////////////////////////////////////////////////////// 66 | class UILIB_API CIDataObject : public IDataObject//,public IAsyncOperation 67 | { 68 | CIDropSource* m_pDropSource; 69 | long m_cRefCount; 70 | PFormatEtcArray m_ArrFormatEtc; 71 | PStgMediumArray m_StgMedium; 72 | 73 | public: 74 | CIDataObject(CIDropSource* pDropSource); 75 | ~CIDataObject(); 76 | void CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc); 77 | //IUnknown 78 | virtual HRESULT STDMETHODCALLTYPE QueryInterface( 79 | /* [in] */ REFIID riid, 80 | /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 81 | virtual ULONG STDMETHODCALLTYPE AddRef( void); 82 | virtual ULONG STDMETHODCALLTYPE Release( void); 83 | 84 | //IDataObject 85 | virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetData( 86 | /* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn, 87 | /* [out] */ STGMEDIUM __RPC_FAR *pmedium); 88 | 89 | virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetDataHere( 90 | /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc, 91 | /* [out][in] */ STGMEDIUM __RPC_FAR *pmedium); 92 | 93 | virtual HRESULT STDMETHODCALLTYPE QueryGetData( 94 | /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc); 95 | 96 | virtual HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc( 97 | /* [unique][in] */ FORMATETC __RPC_FAR *pformatectIn, 98 | /* [out] */ FORMATETC __RPC_FAR *pformatetcOut); 99 | 100 | virtual /* [local] */ HRESULT STDMETHODCALLTYPE SetData( 101 | /* [unique][in] */ FORMATETC __RPC_FAR *pformatetc, 102 | /* [unique][in] */ STGMEDIUM __RPC_FAR *pmedium, 103 | /* [in] */ BOOL fRelease); 104 | 105 | virtual HRESULT STDMETHODCALLTYPE EnumFormatEtc( 106 | /* [in] */ DWORD dwDirection, 107 | /* [out] */ IEnumFORMATETC __RPC_FAR *__RPC_FAR *ppenumFormatEtc); 108 | 109 | virtual HRESULT STDMETHODCALLTYPE DAdvise( 110 | /* [in] */ FORMATETC __RPC_FAR *pformatetc, 111 | /* [in] */ DWORD advf, 112 | /* [unique][in] */ IAdviseSink __RPC_FAR *pAdvSink, 113 | /* [out] */ DWORD __RPC_FAR *pdwConnection); 114 | 115 | virtual HRESULT STDMETHODCALLTYPE DUnadvise( 116 | /* [in] */ DWORD dwConnection); 117 | 118 | virtual HRESULT STDMETHODCALLTYPE EnumDAdvise( 119 | /* [out] */ IEnumSTATDATA __RPC_FAR *__RPC_FAR *ppenumAdvise); 120 | 121 | //IAsyncOperation 122 | //virtual HRESULT STDMETHODCALLTYPE SetAsyncMode( 123 | // /* [in] */ BOOL fDoOpAsync) 124 | //{ 125 | // return E_NOTIMPL; 126 | //} 127 | // 128 | //virtual HRESULT STDMETHODCALLTYPE GetAsyncMode( 129 | // /* [out] */ BOOL __RPC_FAR *pfIsOpAsync) 130 | //{ 131 | // return E_NOTIMPL; 132 | //} 133 | // 134 | //virtual HRESULT STDMETHODCALLTYPE StartOperation( 135 | // /* [optional][unique][in] */ IBindCtx __RPC_FAR *pbcReserved) 136 | //{ 137 | // return E_NOTIMPL; 138 | //} 139 | // 140 | //virtual HRESULT STDMETHODCALLTYPE InOperation( 141 | // /* [out] */ BOOL __RPC_FAR *pfInAsyncOp) 142 | //{ 143 | // return E_NOTIMPL; 144 | //} 145 | // 146 | //virtual HRESULT STDMETHODCALLTYPE EndOperation( 147 | // /* [in] */ HRESULT hResult, 148 | // /* [unique][in] */ IBindCtx __RPC_FAR *pbcReserved, 149 | // /* [in] */ DWORD dwEffects) 150 | //{ 151 | // return E_NOTIMPL; 152 | //} 153 | }; 154 | 155 | /////////////////////////////////////////////////////////////////////////////////////////////// 156 | class UILIB_API CIDropTarget : public IDropTarget 157 | { 158 | DWORD m_cRefCount; 159 | bool m_bAllowDrop; 160 | struct IDropTargetHelper *m_pDropTargetHelper; 161 | FormatEtcArray m_formatetc; 162 | FORMATETC* m_pSupportedFrmt; 163 | protected: 164 | HWND m_hTargetWnd; 165 | public: 166 | 167 | CIDropTarget(HWND m_hTargetWnd = NULL); 168 | virtual ~CIDropTarget(); 169 | void AddSuportedFormat(FORMATETC& ftetc) { m_formatetc.push_back(ftetc); } 170 | void SetTargetWnd(HWND hWnd) { m_hTargetWnd = hWnd; } 171 | 172 | //return values: true - release the medium. false - don't release the medium 173 | virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium,DWORD *pdwEffect) = 0; 174 | 175 | virtual HRESULT STDMETHODCALLTYPE QueryInterface( 176 | /* [in] */ REFIID riid, 177 | /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 178 | virtual ULONG STDMETHODCALLTYPE AddRef( void) { return ++m_cRefCount; } 179 | virtual ULONG STDMETHODCALLTYPE Release( void); 180 | 181 | bool QueryDrop(DWORD grfKeyState, LPDWORD pdwEffect); 182 | virtual HRESULT STDMETHODCALLTYPE DragEnter( 183 | /* [unique][in] */ IDataObject __RPC_FAR *pDataObj, 184 | /* [in] */ DWORD grfKeyState, 185 | /* [in] */ POINTL pt, 186 | /* [out][in] */ DWORD __RPC_FAR *pdwEffect); 187 | virtual HRESULT STDMETHODCALLTYPE DragOver( 188 | /* [in] */ DWORD grfKeyState, 189 | /* [in] */ POINTL pt, 190 | /* [out][in] */ DWORD __RPC_FAR *pdwEffect); 191 | virtual HRESULT STDMETHODCALLTYPE DragLeave( void); 192 | virtual HRESULT STDMETHODCALLTYPE Drop( 193 | /* [unique][in] */ IDataObject __RPC_FAR *pDataObj, 194 | /* [in] */ DWORD grfKeyState, 195 | /* [in] */ POINTL pt, 196 | /* [out][in] */ DWORD __RPC_FAR *pdwEffect); 197 | }; 198 | 199 | class UILIB_API CDragSourceHelper 200 | { 201 | IDragSourceHelper* pDragSourceHelper; 202 | public: 203 | CDragSourceHelper() 204 | { 205 | if(FAILED(CoCreateInstance(CLSID_DragDropHelper, 206 | NULL, 207 | CLSCTX_INPROC_SERVER, 208 | IID_IDragSourceHelper, 209 | (void**)&pDragSourceHelper))) 210 | pDragSourceHelper = NULL; 211 | } 212 | virtual ~CDragSourceHelper() 213 | { 214 | if( pDragSourceHelper!= NULL ) 215 | { 216 | pDragSourceHelper->Release(); 217 | pDragSourceHelper=NULL; 218 | } 219 | } 220 | 221 | // IDragSourceHelper 222 | HRESULT InitializeFromBitmap(HBITMAP hBitmap, 223 | POINT& pt, // cursor position in client coords of the window 224 | RECT& rc, // selected item's bounding rect 225 | IDataObject* pDataObject, 226 | COLORREF crColorKey=GetSysColor(COLOR_WINDOW)// color of the window used for transparent effect. 227 | ) 228 | { 229 | if(pDragSourceHelper == NULL) 230 | return E_FAIL; 231 | 232 | SHDRAGIMAGE di; 233 | BITMAP bm; 234 | GetObject(hBitmap, sizeof(bm), &bm); 235 | di.sizeDragImage.cx = bm.bmWidth; 236 | di.sizeDragImage.cy = bm.bmHeight; 237 | di.hbmpDragImage = hBitmap; 238 | di.crColorKey = crColorKey; 239 | di.ptOffset.x = pt.x - rc.left; 240 | di.ptOffset.y = pt.y - rc.top; 241 | return pDragSourceHelper->InitializeFromBitmap(&di, pDataObject); 242 | } 243 | HRESULT InitializeFromWindow(HWND hwnd, POINT& pt,IDataObject* pDataObject) 244 | { 245 | if(pDragSourceHelper == NULL) 246 | return E_FAIL; 247 | return pDragSourceHelper->InitializeFromWindow(hwnd, &pt, pDataObject); 248 | } 249 | }; 250 | } 251 | #endif //__DRAGDROPIMPL_H__ -------------------------------------------------------------------------------- /Duilib/Utils/DuiTrayIcon.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "DuiTrayIcon.h" 3 | 4 | 5 | 6 | namespace DuiLib 7 | { 8 | 9 | CDuiTrayIcon::CDuiTrayIcon(void) 10 | { 11 | memset(&m_trayData, 0, sizeof(m_trayData)); 12 | m_bEnabled = false; 13 | m_bVisible = false; 14 | m_bTwinkling = false; 15 | m_hWnd = NULL; 16 | pIDuiTimer = NULL; 17 | m_uMessage = UIEVENT_TRAYICON; 18 | } 19 | 20 | 21 | CDuiTrayIcon::~CDuiTrayIcon(void) 22 | { 23 | DeleteTrayIcon(); 24 | } 25 | 26 | void CDuiTrayIcon::CreateTrayIcon( HWND _RecvHwnd,UINT _IconIDResource,LPCTSTR _ToolTipText /*= NULL*/,UINT _Message /*= UIEVENT_TRAYICON*/) 27 | { 28 | if(_Message == NULL) 29 | _Message = UIEVENT_TRAYICON; 30 | 31 | if(!_RecvHwnd || _IconIDResource <= 0 || _Message < 0) 32 | return; 33 | 34 | m_hIcon = LoadIcon(CPaintManagerUI::GetInstance(),MAKEINTRESOURCE(_IconIDResource)); 35 | 36 | m_trayData.cbSize = sizeof(NOTIFYICONDATA); 37 | m_trayData.hWnd = _RecvHwnd; 38 | m_trayData.uID = _IconIDResource; 39 | m_trayData.hIcon = m_hIcon; 40 | m_trayData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; 41 | m_trayData.uCallbackMessage = _Message; 42 | if(_ToolTipText) 43 | strcpy((char *)m_trayData.szTip,(const char *)_ToolTipText); 44 | 45 | Shell_NotifyIcon(NIM_ADD,&m_trayData); 46 | m_bEnabled = true; 47 | } 48 | 49 | void CDuiTrayIcon::DeleteTrayIcon() 50 | { 51 | if(pIDuiTimer) 52 | StopTwinkling(); 53 | 54 | Shell_NotifyIcon(NIM_DELETE,&m_trayData); 55 | m_bEnabled = false; 56 | m_bVisible = false; 57 | m_bTwinkling = false; 58 | m_hWnd = NULL; 59 | m_uMessage = UIEVENT_TRAYICON; 60 | } 61 | 62 | bool CDuiTrayIcon::SetTooltipText( LPCTSTR _ToolTipText ) 63 | { 64 | if(_ToolTipText) 65 | strcpy((char *)m_trayData.szTip,(const char *)_ToolTipText); 66 | 67 | if (!m_bEnabled) return FALSE; 68 | m_trayData.uFlags = NIF_TIP; 69 | return Shell_NotifyIcon(NIM_MODIFY, &m_trayData) == TRUE; 70 | } 71 | 72 | bool CDuiTrayIcon::SetTooltipText( UINT _IDResource ) 73 | { 74 | wchar_t mbuf[64]; 75 | LoadString(CPaintManagerUI::GetInstance(),_IDResource,(LPWSTR)mbuf,64); 76 | 77 | return SetTooltipText((LPCTSTR)mbuf); 78 | } 79 | 80 | DuiLib::CDuiString CDuiTrayIcon::GetTooltipText() const 81 | { 82 | return m_trayData.szTip; 83 | } 84 | 85 | bool CDuiTrayIcon::SetIcon( HICON _Hicon ) 86 | { 87 | if(_Hicon) 88 | m_hIcon = _Hicon; 89 | 90 | m_trayData.uFlags = NIF_ICON; 91 | m_trayData.hIcon = _Hicon; 92 | 93 | if (!m_bEnabled) return FALSE; 94 | return Shell_NotifyIcon(NIM_MODIFY, &m_trayData) == TRUE; 95 | 96 | return false; 97 | } 98 | 99 | bool CDuiTrayIcon::SetIcon( LPCTSTR _IconFile ) 100 | { 101 | HICON hIcon = LoadIcon(CPaintManagerUI::GetInstance(),_IconFile); 102 | return SetIcon(hIcon); 103 | } 104 | 105 | bool CDuiTrayIcon::SetIcon( UINT _IDResource ) 106 | { 107 | HICON hIcon = LoadIcon(CPaintManagerUI::GetInstance(),MAKEINTRESOURCE(_IDResource)); 108 | return SetIcon(hIcon); 109 | } 110 | 111 | HICON CDuiTrayIcon::GetIcon() const 112 | { 113 | HICON hIcon = NULL; 114 | hIcon = m_trayData.hIcon; 115 | return hIcon; 116 | } 117 | 118 | void CDuiTrayIcon::SetHideIcon() 119 | { 120 | if (IsVisible()) { 121 | SetIcon((HICON)NULL); 122 | m_bVisible = TRUE; 123 | } 124 | } 125 | 126 | void CDuiTrayIcon::SetShowIcon() 127 | { 128 | if (!IsVisible()) { 129 | SetIcon(m_hIcon); 130 | m_bVisible = FALSE; 131 | } 132 | } 133 | 134 | void CDuiTrayIcon::RemoveIcon() 135 | { 136 | m_trayData.uFlags = 0; 137 | Shell_NotifyIcon(NIM_DELETE, &m_trayData); 138 | m_bEnabled = FALSE; 139 | } 140 | 141 | bool CDuiTrayIcon::StartTwinkling() 142 | { 143 | if(m_bTwinkling || !m_bEnabled || pIDuiTimer) 144 | return false; 145 | 146 | pIDuiTimer = MakeDuiTimer(this,&CDuiTrayIcon::OnTimer,400); 147 | pIDuiTimer->SetDuiTimer(); 148 | m_bTwinkling = true; 149 | return true; 150 | } 151 | 152 | void CDuiTrayIcon::StopTwinkling() 153 | { 154 | if(pIDuiTimer){ 155 | pIDuiTimer->KillDuiTimer(); 156 | delete pIDuiTimer; 157 | pIDuiTimer = NULL; 158 | } 159 | m_bTwinkling = false; 160 | SetShowIcon(); 161 | } 162 | 163 | void CDuiTrayIcon::OnTimer( IDuiTimer* pTimer ) 164 | { 165 | IsVisible()?SetHideIcon():SetShowIcon(); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /Duilib/Utils/DuiTrayIcon.h: -------------------------------------------------------------------------------- 1 | #ifndef DuiTrayIcon_h__ 2 | #define DuiTrayIcon_h__ 3 | 4 | #pragma once 5 | #include 6 | 7 | namespace DuiLib 8 | { 9 | class IDuiTimer; 10 | class UILIB_API CDuiTrayIcon 11 | { 12 | public: 13 | CDuiTrayIcon(void); 14 | ~CDuiTrayIcon(void); 15 | 16 | public: 17 | void CreateTrayIcon( HWND _RecvHwnd,UINT _IconIDResource,LPCTSTR _ToolTipText = NULL,UINT _Message = NULL/*(UIEVENT_TRAYICON)*/); 18 | void DeleteTrayIcon(); 19 | bool SetTooltipText(LPCTSTR _ToolTipText); 20 | bool SetTooltipText(UINT _IDResource); 21 | CDuiString GetTooltipText() const; 22 | 23 | bool SetIcon(HICON _Hicon); 24 | bool SetIcon(LPCTSTR _IconFile); 25 | bool SetIcon(UINT _IDResource); 26 | HICON GetIcon() const; 27 | void SetHideIcon(); 28 | void SetShowIcon(); 29 | void RemoveIcon(); 30 | bool StartTwinkling(); 31 | void StopTwinkling(); 32 | 33 | bool Enabled(){return m_bEnabled;}; 34 | bool IsVisible(){return !m_bVisible;}; 35 | bool IsTwinkling(){return m_bTwinkling;}; 36 | 37 | void OnTimer(IDuiTimer* pTimer); 38 | private: 39 | bool m_bEnabled; 40 | bool m_bVisible; 41 | bool m_bTwinkling; 42 | HWND m_hWnd; 43 | UINT m_uMessage; 44 | HICON m_hIcon; 45 | IDuiTimer* pIDuiTimer; 46 | NOTIFYICONDATA m_trayData; 47 | }; 48 | } 49 | #endif // DuiTrayIcon_h__ 50 | 51 | -------------------------------------------------------------------------------- /Duilib/Utils/Flash11.tlb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Utils/Flash11.tlb -------------------------------------------------------------------------------- /Duilib/Utils/FlashEventHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Utils/FlashEventHandler.h -------------------------------------------------------------------------------- /Duilib/Utils/TrayIcon.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "TrayIcon.h" 3 | 4 | namespace DuiLib 5 | { 6 | CTrayIcon::CTrayIcon(void) 7 | { 8 | memset(&m_trayData, 0, sizeof(m_trayData)); 9 | m_bEnabled = false; 10 | m_bVisible = false; 11 | m_hWnd = NULL; 12 | m_uMessage = UIMSG_TRAYICON; 13 | } 14 | 15 | CTrayIcon::~CTrayIcon(void) 16 | { 17 | DeleteTrayIcon(); 18 | } 19 | 20 | void CTrayIcon::CreateTrayIcon( HWND _RecvHwnd, UINT _IconIDResource, LPCTSTR _ToolTipText, UINT _Message) 21 | { 22 | if(!_RecvHwnd || _IconIDResource <= 0 ){ 23 | return; 24 | } 25 | if(_Message != 0) m_uMessage = _Message; 26 | m_hIcon = LoadIcon(CPaintManagerUI::GetInstance(), MAKEINTRESOURCE(_IconIDResource)); 27 | m_trayData.cbSize = sizeof(NOTIFYICONDATA); 28 | m_trayData.hWnd = _RecvHwnd; 29 | m_trayData.uID = _IconIDResource; 30 | m_trayData.hIcon = m_hIcon; 31 | m_trayData.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; 32 | m_trayData.uCallbackMessage = m_uMessage; 33 | if(_ToolTipText) _tcscpy(m_trayData.szTip, _ToolTipText); 34 | Shell_NotifyIcon(NIM_ADD, &m_trayData); 35 | m_bEnabled = true; 36 | } 37 | 38 | void CTrayIcon::DeleteTrayIcon() 39 | { 40 | Shell_NotifyIcon(NIM_DELETE, &m_trayData); 41 | m_bEnabled = false; 42 | m_bVisible = false; 43 | m_hWnd = NULL; 44 | m_uMessage = UIMSG_TRAYICON; 45 | } 46 | 47 | bool CTrayIcon::SetTooltipText( LPCTSTR _ToolTipText ) 48 | { 49 | if(_ToolTipText) _tcscpy(m_trayData.szTip,_ToolTipText); 50 | if (!m_bEnabled) return FALSE; 51 | m_trayData.uFlags = NIF_TIP; 52 | return Shell_NotifyIcon(NIM_MODIFY, &m_trayData) == TRUE; 53 | } 54 | 55 | bool CTrayIcon::SetTooltipText( UINT _IDResource ) 56 | { 57 | TCHAR mbuf[256] = {0}; 58 | LoadString(CPaintManagerUI::GetInstance(), _IDResource,mbuf, 256); 59 | return SetTooltipText(mbuf); 60 | } 61 | 62 | DuiLib::CDuiString CTrayIcon::GetTooltipText() const 63 | { 64 | return m_trayData.szTip; 65 | } 66 | 67 | bool CTrayIcon::SetIcon( HICON _Hicon ) 68 | { 69 | if(_Hicon) m_hIcon = _Hicon; 70 | m_trayData.uFlags = NIF_ICON; 71 | m_trayData.hIcon = _Hicon; 72 | 73 | if (!m_bEnabled) return FALSE; 74 | return Shell_NotifyIcon(NIM_MODIFY, &m_trayData) == TRUE; 75 | 76 | return false; 77 | } 78 | 79 | bool CTrayIcon::SetIcon( LPCTSTR _IconFile ) 80 | { 81 | HICON hIcon = LoadIcon(CPaintManagerUI::GetInstance(),_IconFile); 82 | return SetIcon(hIcon); 83 | } 84 | 85 | bool CTrayIcon::SetIcon( UINT _IDResource ) 86 | { 87 | HICON hIcon = LoadIcon(CPaintManagerUI::GetInstance(), MAKEINTRESOURCE(_IDResource)); 88 | return SetIcon(hIcon); 89 | } 90 | 91 | HICON CTrayIcon::GetIcon() const 92 | { 93 | HICON hIcon = NULL; 94 | hIcon = m_trayData.hIcon; 95 | return hIcon; 96 | } 97 | 98 | void CTrayIcon::SetHideIcon() 99 | { 100 | if (IsVisible()) { 101 | SetIcon((HICON)NULL); 102 | m_bVisible = TRUE; 103 | } 104 | } 105 | 106 | void CTrayIcon::SetShowIcon() 107 | { 108 | if (!IsVisible()) { 109 | SetIcon(m_hIcon); 110 | m_bVisible = FALSE; 111 | } 112 | } 113 | 114 | void CTrayIcon::RemoveIcon() 115 | { 116 | m_trayData.uFlags = 0; 117 | Shell_NotifyIcon(NIM_DELETE, &m_trayData); 118 | m_bEnabled = FALSE; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /Duilib/Utils/TrayIcon.h: -------------------------------------------------------------------------------- 1 | #ifndef __UITRAICON_H__ 2 | #define __UITRAICON_H__ 3 | 4 | #pragma once 5 | #include 6 | 7 | namespace DuiLib 8 | { 9 | class UILIB_API CTrayIcon 10 | { 11 | public: 12 | CTrayIcon(void); 13 | ~CTrayIcon(void); 14 | 15 | public: 16 | void CreateTrayIcon( HWND _RecvHwnd, UINT _IconIDResource, LPCTSTR _ToolTipText = NULL, UINT _Message = NULL); 17 | void DeleteTrayIcon(); 18 | bool SetTooltipText(LPCTSTR _ToolTipText); 19 | bool SetTooltipText(UINT _IDResource); 20 | CDuiString GetTooltipText() const; 21 | 22 | bool SetIcon(HICON _Hicon); 23 | bool SetIcon(LPCTSTR _IconFile); 24 | bool SetIcon(UINT _IDResource); 25 | HICON GetIcon() const; 26 | void SetHideIcon(); 27 | void SetShowIcon(); 28 | void RemoveIcon(); 29 | bool Enabled(){return m_bEnabled;}; 30 | bool IsVisible(){return !m_bVisible;}; 31 | 32 | private: 33 | bool m_bEnabled; 34 | bool m_bVisible; 35 | HWND m_hWnd; 36 | UINT m_uMessage; 37 | HICON m_hIcon; 38 | NOTIFYICONDATA m_trayData; 39 | }; 40 | } 41 | #endif // 42 | 43 | -------------------------------------------------------------------------------- /Duilib/Utils/UIDelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | 3 | namespace DuiLib { 4 | 5 | CDelegateBase::CDelegateBase(void* pObject, void* pFn) 6 | { 7 | m_pObject = pObject; 8 | m_pFn = pFn; 9 | } 10 | 11 | CDelegateBase::CDelegateBase(const CDelegateBase& rhs) 12 | { 13 | m_pObject = rhs.m_pObject; 14 | m_pFn = rhs.m_pFn; 15 | } 16 | 17 | CDelegateBase::~CDelegateBase() 18 | { 19 | 20 | } 21 | 22 | bool CDelegateBase::Equals(const CDelegateBase& rhs) const 23 | { 24 | return m_pObject == rhs.m_pObject && m_pFn == rhs.m_pFn; 25 | } 26 | 27 | bool CDelegateBase::operator() (void* param) 28 | { 29 | return Invoke(param); 30 | } 31 | 32 | void* CDelegateBase::GetFn() 33 | { 34 | return m_pFn; 35 | } 36 | 37 | void* CDelegateBase::GetObject() 38 | { 39 | return m_pObject; 40 | } 41 | 42 | CEventSource::~CEventSource() 43 | { 44 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 45 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 46 | if( pObject) delete pObject; 47 | } 48 | } 49 | 50 | CEventSource::operator bool() 51 | { 52 | return m_aDelegates.GetSize() > 0; 53 | } 54 | 55 | void CEventSource::operator+= (const CDelegateBase& d) 56 | { 57 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 58 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 59 | if( pObject && pObject->Equals(d) ) return; 60 | } 61 | 62 | m_aDelegates.Add(d.Copy()); 63 | } 64 | 65 | void CEventSource::operator+= (FnType pFn) 66 | { 67 | (*this) += MakeDelegate(pFn); 68 | } 69 | 70 | void CEventSource::operator-= (const CDelegateBase& d) 71 | { 72 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 73 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 74 | if( pObject && pObject->Equals(d) ) { 75 | delete pObject; 76 | m_aDelegates.Remove(i); 77 | return; 78 | } 79 | } 80 | } 81 | void CEventSource::operator-= (FnType pFn) 82 | { 83 | (*this) -= MakeDelegate(pFn); 84 | } 85 | 86 | bool CEventSource::operator() (void* param) 87 | { 88 | for( int i = 0; i < m_aDelegates.GetSize(); i++ ) { 89 | CDelegateBase* pObject = static_cast(m_aDelegates[i]); 90 | if( pObject && !(*pObject)(param) ) return false; 91 | } 92 | return true; 93 | } 94 | 95 | } // namespace DuiLib 96 | -------------------------------------------------------------------------------- /Duilib/Utils/UIDelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef __UIDELEGATE_H__ 2 | #define __UIDELEGATE_H__ 3 | 4 | #pragma once 5 | 6 | namespace DuiLib { 7 | 8 | class UILIB_API CDelegateBase 9 | { 10 | public: 11 | CDelegateBase(void* pObject, void* pFn); 12 | CDelegateBase(const CDelegateBase& rhs); 13 | virtual ~CDelegateBase(); 14 | bool Equals(const CDelegateBase& rhs) const; 15 | bool operator() (void* param); 16 | virtual CDelegateBase* Copy() const = 0; // add const for gcc 17 | 18 | protected: 19 | void* GetFn(); 20 | void* GetObject(); 21 | virtual bool Invoke(void* param) = 0; 22 | 23 | private: 24 | void* m_pObject; 25 | void* m_pFn; 26 | }; 27 | 28 | class CDelegateStatic: public CDelegateBase 29 | { 30 | typedef bool (*Fn)(void*); 31 | public: 32 | CDelegateStatic(Fn pFn) : CDelegateBase(NULL, pFn) { } 33 | CDelegateStatic(const CDelegateStatic& rhs) : CDelegateBase(rhs) { } 34 | virtual CDelegateBase* Copy() const { return new CDelegateStatic(*this); } 35 | 36 | protected: 37 | virtual bool Invoke(void* param) 38 | { 39 | Fn pFn = (Fn)GetFn(); 40 | return (*pFn)(param); 41 | } 42 | }; 43 | 44 | template 45 | class CDelegate : public CDelegateBase 46 | { 47 | typedef bool (T::* Fn)(void*); 48 | public: 49 | CDelegate(O* pObj, Fn pFn) : CDelegateBase(pObj, &pFn), m_pFn(pFn) { } 50 | CDelegate(const CDelegate& rhs) : CDelegateBase(rhs) { m_pFn = rhs.m_pFn; } 51 | virtual CDelegateBase* Copy() const { return new CDelegate(*this); } 52 | 53 | protected: 54 | virtual bool Invoke(void* param) 55 | { 56 | O* pObject = (O*) GetObject(); 57 | return (pObject->*m_pFn)(param); 58 | } 59 | 60 | private: 61 | Fn m_pFn; 62 | }; 63 | 64 | template 65 | CDelegate MakeDelegate(O* pObject, bool (T::* pFn)(void*)) 66 | { 67 | return CDelegate(pObject, pFn); 68 | } 69 | 70 | inline CDelegateStatic MakeDelegate(bool (*pFn)(void*)) 71 | { 72 | return CDelegateStatic(pFn); 73 | } 74 | 75 | class UILIB_API CEventSource 76 | { 77 | typedef bool (*FnType)(void*); 78 | public: 79 | ~CEventSource(); 80 | operator bool(); 81 | void operator+= (const CDelegateBase& d); // add const for gcc 82 | void operator+= (FnType pFn); 83 | void operator-= (const CDelegateBase& d); 84 | void operator-= (FnType pFn); 85 | bool operator() (void* param); 86 | 87 | protected: 88 | CStdPtrArray m_aDelegates; 89 | }; 90 | 91 | } // namespace DuiLib 92 | 93 | #endif // __UIDELEGATE_H__ -------------------------------------------------------------------------------- /Duilib/Utils/UIShadow.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Utils/UIShadow.h -------------------------------------------------------------------------------- /Duilib/Utils/Utils.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Utils/Utils.cpp -------------------------------------------------------------------------------- /Duilib/Utils/Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __UTILS_H__ 2 | #define __UTILS_H__ 3 | 4 | #pragma once 5 | #include "OAIdl.h" 6 | #include 7 | 8 | namespace DuiLib 9 | { 10 | ///////////////////////////////////////////////////////////////////////////////////// 11 | // 12 | 13 | class UILIB_API STRINGorID 14 | { 15 | public: 16 | STRINGorID(LPCTSTR lpString) : m_lpstr(lpString) 17 | { } 18 | STRINGorID(UINT nID) : m_lpstr(MAKEINTRESOURCE(nID)) 19 | { } 20 | LPCTSTR m_lpstr; 21 | }; 22 | 23 | ///////////////////////////////////////////////////////////////////////////////////// 24 | // 25 | 26 | class UILIB_API CDuiPoint : public tagPOINT 27 | { 28 | public: 29 | CDuiPoint(); 30 | CDuiPoint(const POINT& src); 31 | CDuiPoint(int x, int y); 32 | CDuiPoint(LPARAM lParam); 33 | }; 34 | 35 | 36 | ///////////////////////////////////////////////////////////////////////////////////// 37 | // 38 | 39 | class UILIB_API CDuiSize : public tagSIZE 40 | { 41 | public: 42 | CDuiSize(); 43 | CDuiSize(const SIZE& src); 44 | CDuiSize(const RECT rc); 45 | CDuiSize(int cx, int cy); 46 | }; 47 | 48 | 49 | ///////////////////////////////////////////////////////////////////////////////////// 50 | // 51 | 52 | class UILIB_API CDuiRect : public tagRECT 53 | { 54 | public: 55 | CDuiRect(); 56 | CDuiRect(const RECT& src); 57 | CDuiRect(int iLeft, int iTop, int iRight, int iBottom); 58 | 59 | int GetWidth() const; 60 | int GetHeight() const; 61 | void Empty(); 62 | bool IsNull() const; 63 | void Join(const RECT& rc); 64 | void ResetOffset(); 65 | void Normalize(); 66 | void Offset(int cx, int cy); 67 | void Inflate(int cx, int cy); 68 | void Deflate(int cx, int cy); 69 | void Union(CDuiRect& rc); 70 | }; 71 | 72 | ///////////////////////////////////////////////////////////////////////////////////// 73 | // 74 | 75 | class UILIB_API CStdPtrArray 76 | { 77 | public: 78 | CStdPtrArray(int iPreallocSize = 0); 79 | CStdPtrArray(const CStdPtrArray& src); 80 | ~CStdPtrArray(); 81 | 82 | void Empty(); 83 | void Resize(int iSize); 84 | bool IsEmpty() const; 85 | int Find(LPVOID iIndex) const; 86 | bool Add(LPVOID pData); 87 | bool SetAt(int iIndex, LPVOID pData); 88 | bool InsertAt(int iIndex, LPVOID pData); 89 | bool Remove(int iIndex); 90 | int GetSize() const; 91 | LPVOID* GetData(); 92 | 93 | LPVOID GetAt(int iIndex) const; 94 | LPVOID operator[] (int nIndex) const; 95 | 96 | protected: 97 | LPVOID* m_ppVoid; 98 | int m_nCount; 99 | int m_nAllocated; 100 | }; 101 | 102 | 103 | ///////////////////////////////////////////////////////////////////////////////////// 104 | // 105 | 106 | class UILIB_API CStdValArray 107 | { 108 | public: 109 | CStdValArray(int iElementSize, int iPreallocSize = 0); 110 | ~CStdValArray(); 111 | 112 | void Empty(); 113 | bool IsEmpty() const; 114 | bool Add(LPCVOID pData); 115 | bool Remove(int iIndex); 116 | int GetSize() const; 117 | LPVOID GetData(); 118 | 119 | LPVOID GetAt(int iIndex) const; 120 | LPVOID operator[] (int nIndex) const; 121 | 122 | protected: 123 | LPBYTE m_pVoid; 124 | int m_iElementSize; 125 | int m_nCount; 126 | int m_nAllocated; 127 | }; 128 | 129 | 130 | ///////////////////////////////////////////////////////////////////////////////////// 131 | // 132 | 133 | class UILIB_API CDuiString 134 | { 135 | public: 136 | enum { MAX_LOCAL_STRING_LEN = 63 }; 137 | 138 | CDuiString(); 139 | CDuiString(const TCHAR ch); 140 | CDuiString(const CDuiString& src); 141 | CDuiString(LPCTSTR lpsz, int nLen = -1); 142 | ~CDuiString(); 143 | 144 | void Empty(); 145 | int GetLength() const; 146 | bool IsEmpty() const; 147 | TCHAR GetAt(int nIndex) const; 148 | void Append(LPCTSTR pstr); 149 | void Assign(LPCTSTR pstr, int nLength = -1); 150 | LPCTSTR GetData() const; 151 | 152 | void SetAt(int nIndex, TCHAR ch); 153 | operator LPCTSTR() const; 154 | 155 | TCHAR operator[] (int nIndex) const; 156 | const CDuiString& operator=(const CDuiString& src); 157 | const CDuiString& operator=(const TCHAR ch); 158 | const CDuiString& operator=(LPCTSTR pstr); 159 | #ifdef _UNICODE 160 | const CDuiString& CDuiString::operator=(LPCSTR lpStr); 161 | const CDuiString& CDuiString::operator+=(LPCSTR lpStr); 162 | #else 163 | const CDuiString& CDuiString::operator=(LPCWSTR lpwStr); 164 | const CDuiString& CDuiString::operator+=(LPCWSTR lpwStr); 165 | #endif 166 | CDuiString operator+(const CDuiString& src) const; 167 | CDuiString operator+(LPCTSTR pstr) const; 168 | const CDuiString& operator+=(const CDuiString& src); 169 | const CDuiString& operator+=(LPCTSTR pstr); 170 | const CDuiString& operator+=(const TCHAR ch); 171 | 172 | bool operator == (LPCTSTR str) const; 173 | bool operator != (LPCTSTR str) const; 174 | bool operator <= (LPCTSTR str) const; 175 | bool operator < (LPCTSTR str) const; 176 | bool operator >= (LPCTSTR str) const; 177 | bool operator > (LPCTSTR str) const; 178 | 179 | int Compare(LPCTSTR pstr) const; 180 | int CompareNoCase(LPCTSTR pstr) const; 181 | 182 | void MakeUpper(); 183 | void MakeLower(); 184 | 185 | CDuiString Left(int nLength) const; 186 | CDuiString Mid(int iPos, int nLength = -1) const; 187 | CDuiString Right(int nLength) const; 188 | 189 | int Find(TCHAR ch, int iPos = 0) const; 190 | int Find(LPCTSTR pstr, int iPos = 0) const; 191 | int ReverseFind(TCHAR ch) const; 192 | int Replace(LPCTSTR pstrFrom, LPCTSTR pstrTo); 193 | 194 | int __cdecl Format(LPCTSTR pstrFormat, ...); 195 | int __cdecl SmallFormat(LPCTSTR pstrFormat, ...); 196 | 197 | protected: 198 | int __cdecl InnerFormat(LPCTSTR pstrFormat, va_list Args); 199 | 200 | protected: 201 | LPTSTR m_pstr; 202 | TCHAR m_szBuffer[MAX_LOCAL_STRING_LEN + 1]; 203 | }; 204 | 205 | static std::vector StrSplit(CDuiString text, CDuiString sp) 206 | { 207 | std::vector vResults; 208 | int pos = text.Find(sp, 0); 209 | while (pos >= 0) 210 | { 211 | CDuiString t = text.Left(pos); 212 | vResults.push_back(t); 213 | text = text.Right(text.GetLength() - pos - sp.GetLength()); 214 | pos = text.Find(sp); 215 | } 216 | vResults.push_back(text); 217 | return vResults; 218 | } 219 | ///////////////////////////////////////////////////////////////////////////////////// 220 | // 221 | 222 | struct TITEM 223 | { 224 | CDuiString Key; 225 | LPVOID Data; 226 | struct TITEM* pPrev; 227 | struct TITEM* pNext; 228 | }; 229 | 230 | class UILIB_API CStdStringPtrMap 231 | { 232 | public: 233 | CStdStringPtrMap(int nSize = 83); 234 | ~CStdStringPtrMap(); 235 | 236 | void Resize(int nSize = 83); 237 | LPVOID Find(LPCTSTR key, bool optimize = true) const; 238 | bool Insert(LPCTSTR key, LPVOID pData); 239 | LPVOID Set(LPCTSTR key, LPVOID pData); 240 | bool Remove(LPCTSTR key); 241 | void RemoveAll(); 242 | int GetSize() const; 243 | LPCTSTR GetAt(int iIndex) const; 244 | LPCTSTR operator[] (int nIndex) const; 245 | 246 | protected: 247 | TITEM** m_aT; 248 | int m_nBuckets; 249 | int m_nCount; 250 | }; 251 | 252 | ///////////////////////////////////////////////////////////////////////////////////// 253 | // 254 | 255 | class UILIB_API CWaitCursor 256 | { 257 | public: 258 | CWaitCursor(); 259 | ~CWaitCursor(); 260 | 261 | protected: 262 | HCURSOR m_hOrigCursor; 263 | }; 264 | 265 | ///////////////////////////////////////////////////////////////////////////////////// 266 | // 267 | 268 | class CDuiVariant : public VARIANT 269 | { 270 | public: 271 | CDuiVariant() 272 | { 273 | VariantInit(this); 274 | } 275 | CDuiVariant(int i) 276 | { 277 | VariantInit(this); 278 | this->vt = VT_I4; 279 | this->intVal = i; 280 | } 281 | CDuiVariant(float f) 282 | { 283 | VariantInit(this); 284 | this->vt = VT_R4; 285 | this->fltVal = f; 286 | } 287 | CDuiVariant(LPOLESTR s) 288 | { 289 | VariantInit(this); 290 | this->vt = VT_BSTR; 291 | this->bstrVal = s; 292 | } 293 | CDuiVariant(IDispatch *disp) 294 | { 295 | VariantInit(this); 296 | this->vt = VT_DISPATCH; 297 | this->pdispVal = disp; 298 | } 299 | 300 | ~CDuiVariant() 301 | { 302 | VariantClear(this); 303 | } 304 | }; 305 | 306 | }// namespace DuiLib 307 | 308 | #endif // __UTILS_H__ -------------------------------------------------------------------------------- /Duilib/Utils/WebBrowserEventHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Utils/WebBrowserEventHandler.h -------------------------------------------------------------------------------- /Duilib/Utils/WinImplBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Utils/WinImplBase.cpp -------------------------------------------------------------------------------- /Duilib/Utils/WinImplBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Duilib/Utils/WinImplBase.h -------------------------------------------------------------------------------- /Duilib/Utils/WndShadow.h: -------------------------------------------------------------------------------- 1 | // WndShadow.h : header file 2 | // 3 | // Version 0.1 4 | // 5 | // Copyright (c) 2006 Perry Zhu, All Rights Reserved. 6 | // 7 | // mailto:perry@live.com 8 | // 9 | // 10 | // This source file may be redistributed unmodified by any means PROVIDING 11 | // it is NOT sold for profit without the authors expressed written 12 | // consent, and providing that this notice and the author's name and all 13 | // copyright notices remain intact. This software is by no means to be 14 | // included as part of any third party components library, or as part any 15 | // development solution that offers MFC extensions that are sold for profit. 16 | // 17 | // If the source code is used in any commercial applications then a statement 18 | // along the lines of: 19 | // 20 | // "Portions Copyright (c) 2006 Perry Zhu" must be included in the "Startup 21 | // Banner", "About Box" or "Printed Documentation". This software is provided 22 | // "as is" without express or implied warranty. Use it at your own risk! The 23 | // author accepts no liability for any damage/loss of business that this 24 | // product may cause. 25 | // 26 | ///////////////////////////////////////////////////////////////////////////// 27 | //**************************************************************************** 28 | 29 | 30 | #pragma once 31 | 32 | #include "map" 33 | 34 | 35 | class CWndShadow 36 | { 37 | public: 38 | CWndShadow(void); 39 | public: 40 | virtual ~CWndShadow(void); 41 | 42 | protected: 43 | 44 | // Instance handle, used to register window class and create window 45 | static HINSTANCE s_hInstance; 46 | 47 | // Parent HWND and CWndShadow object pares, in order to find CWndShadow in ParentProc() 48 | static std::map s_Shadowmap; 49 | 50 | // 51 | typedef BOOL (WINAPI *pfnUpdateLayeredWindow)(HWND hWnd, HDC hdcDst, POINT *pptDst, 52 | SIZE *psize, HDC hdcSrc, POINT *pptSrc, COLORREF crKey, 53 | BLENDFUNCTION *pblend, DWORD dwFlags); 54 | static pfnUpdateLayeredWindow s_UpdateLayeredWindow; 55 | 56 | HWND m_hWnd; 57 | 58 | LONG m_OriParentProc; // Original WndProc of parent window 59 | 60 | enum ShadowStatus 61 | { 62 | SS_ENABLED = 1, // Shadow is enabled, if not, the following one is always false 63 | SS_VISABLE = 1 << 1, // Shadow window is visible 64 | SS_PARENTVISIBLE = 1<< 2 // Parent window is visible, if not, the above one is always false 65 | }; 66 | BYTE m_Status; 67 | 68 | unsigned char m_nDarkness; // Darkness, transparency of blurred area 69 | unsigned char m_nSharpness; // Sharpness, width of blurred border of shadow window 70 | signed char m_nSize; // Shadow window size, relative to parent window size 71 | 72 | // The X and Y offsets of shadow window, 73 | // relative to the parent window, at center of both windows (not top-left corner), signed 74 | signed char m_nxOffset; 75 | signed char m_nyOffset; 76 | 77 | // Restore last parent window size, used to determine the update strategy when parent window is resized 78 | LPARAM m_WndSize; 79 | 80 | // Set this to true if the shadow should not be update until next WM_PAINT is received 81 | bool m_bUpdate; 82 | 83 | COLORREF m_Color; // Color of shadow 84 | 85 | public: 86 | static bool Initialize(HINSTANCE hInstance); 87 | void Create(HWND hParentWnd, bool IsWS_CAPTION = false); 88 | 89 | bool SetSize(int NewSize = 0); 90 | bool SetSharpness(unsigned int NewSharpness = 5); 91 | bool SetDarkness(unsigned int NewDarkness = 200); 92 | bool SetPosition(int NewXOffset = 5, int NewYOffset = 5); 93 | bool SetColor(COLORREF NewColor = 0); 94 | 95 | protected: 96 | //static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 97 | static LRESULT CALLBACK ParentProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 98 | 99 | // Redraw, resize and move the shadow 100 | // called when window resized or shadow properties changed, but not only moved without resizing 101 | void Update(HWND hParent); 102 | 103 | // Fill in the shadow window alpha blend bitmap with shadow image pixels 104 | void MakeShadow(UINT32 *pShadBits, HWND hParent, RECT *rcParent); 105 | 106 | // Helper to calculate the alpha-premultiled value for a pixel 107 | inline DWORD PreMultiply(COLORREF cl, unsigned char nAlpha) 108 | { 109 | // It's strange that the byte order of RGB in 32b BMP is reverse to in COLORREF 110 | return (GetRValue(cl) * (DWORD)nAlpha / 255) << 16 | 111 | (GetGValue(cl) * (DWORD)nAlpha / 255) << 8 | 112 | (GetBValue(cl) * (DWORD)nAlpha / 255); 113 | } 114 | }; 115 | -------------------------------------------------------------------------------- /Duilib/Utils/downloadmgr.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma warning( disable: 4049 ) /* more than 64k source lines */ 3 | 4 | /* this ALWAYS GENERATED file contains the definitions for the interfaces */ 5 | 6 | 7 | /* File created by MIDL compiler version 5.03.0279 */ 8 | /* at Mon Jul 23 17:42:46 2001 9 | */ 10 | /* Compiler settings for downloadmgr.idl: 11 | Oicf (OptLev=i2), W1, Zp8, env=Win32 (32b run), ms_ext, c_ext 12 | error checks: allocation ref bounds_check enum stub_data 13 | VC __declspec() decoration level: 14 | __declspec(uuid()), __declspec(selectany), __declspec(novtable) 15 | DECLSPEC_UUID(), MIDL_INTERFACE() 16 | */ 17 | //@@MIDL_FILE_HEADING( ) 18 | 19 | 20 | /* verify that the version is high enough to compile this file*/ 21 | #ifndef __REQUIRED_RPCNDR_H_VERSION__ 22 | #define __REQUIRED_RPCNDR_H_VERSION__ 440 23 | #endif 24 | 25 | #include "rpc.h" 26 | #include "rpcndr.h" 27 | 28 | #ifndef __RPCNDR_H_VERSION__ 29 | #error this stub requires an updated version of 30 | #endif // __RPCNDR_H_VERSION__ 31 | 32 | #ifndef COM_NO_WINDOWS_H 33 | #include "windows.h" 34 | #include "ole2.h" 35 | #endif /*COM_NO_WINDOWS_H*/ 36 | 37 | #ifndef __downloadmgr_h__ 38 | #define __downloadmgr_h__ 39 | 40 | /* Forward Declarations */ 41 | 42 | #ifndef __IDownloadManager_FWD_DEFINED__ 43 | #define __IDownloadManager_FWD_DEFINED__ 44 | typedef interface IDownloadManager IDownloadManager; 45 | #endif /* __IDownloadManager_FWD_DEFINED__ */ 46 | 47 | 48 | /* header files for imported files */ 49 | #include "unknwn.h" 50 | #include "ocidl.h" 51 | 52 | #ifdef __cplusplus 53 | extern "C"{ 54 | #endif 55 | 56 | void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); 57 | void __RPC_USER MIDL_user_free( void __RPC_FAR * ); 58 | 59 | /* interface __MIDL_itf_downloadmgr_0000 */ 60 | /* [local] */ 61 | 62 | //=--------------------------------------------------------------------------= 63 | // downloadmgr.h 64 | //=--------------------------------------------------------------------------= 65 | // (C) Copyright 2000 Microsoft Corporation. All Rights Reserved. 66 | // 67 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 68 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 69 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 70 | // PARTICULAR PURPOSE. 71 | //=--------------------------------------------------------------------------= 72 | 73 | #pragma comment(lib,"uuid.lib") 74 | 75 | //---------------------------------------------------------------------------= 76 | // Internet Explorer Download Manager Interfaces 77 | 78 | // -------------------------------------------------------------------------------- 79 | // GUIDS 80 | // -------------------------------------------------------------------------------- 81 | // {988934A4-064B-11D3-BB80-00104B35E7F9} 82 | DEFINE_GUID(IID_IDownloadManager, 0x988934a4, 0x064b, 0x11d3, 0xbb, 0x80, 0x0, 0x10, 0x4b, 0x35, 0xe7, 0xf9); 83 | #define SID_SDownloadManager IID_IDownloadManager 84 | 85 | 86 | 87 | extern RPC_IF_HANDLE __MIDL_itf_downloadmgr_0000_v0_0_c_ifspec; 88 | extern RPC_IF_HANDLE __MIDL_itf_downloadmgr_0000_v0_0_s_ifspec; 89 | 90 | #ifndef __IDownloadManager_INTERFACE_DEFINED__ 91 | #define __IDownloadManager_INTERFACE_DEFINED__ 92 | 93 | /* interface IDownloadManager */ 94 | /* [local][unique][uuid][object][helpstring] */ 95 | 96 | 97 | EXTERN_C const IID IID_IDownloadManager; 98 | 99 | #if defined(__cplusplus) && !defined(CINTERFACE) 100 | 101 | MIDL_INTERFACE("988934A4-064B-11D3-BB80-00104B35E7F9") 102 | IDownloadManager : public IUnknown 103 | { 104 | public: 105 | virtual HRESULT STDMETHODCALLTYPE Download( 106 | /* [in] */ IMoniker __RPC_FAR *pmk, 107 | /* [in] */ IBindCtx __RPC_FAR *pbc, 108 | /* [in] */ DWORD dwBindVerb, 109 | /* [in] */ LONG grfBINDF, 110 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo, 111 | /* [in] */ LPCOLESTR pszHeaders, 112 | /* [in] */ LPCOLESTR pszRedir, 113 | /* [in] */ UINT uiCP) = 0; 114 | 115 | }; 116 | 117 | #else /* C style interface */ 118 | 119 | typedef struct IDownloadManagerVtbl 120 | { 121 | BEGIN_INTERFACE 122 | 123 | HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( 124 | IDownloadManager __RPC_FAR * This, 125 | /* [in] */ REFIID riid, 126 | /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); 127 | 128 | ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( 129 | IDownloadManager __RPC_FAR * This); 130 | 131 | ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( 132 | IDownloadManager __RPC_FAR * This); 133 | 134 | HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Download )( 135 | IDownloadManager __RPC_FAR * This, 136 | /* [in] */ IMoniker __RPC_FAR *pmk, 137 | /* [in] */ IBindCtx __RPC_FAR *pbc, 138 | /* [in] */ DWORD dwBindVerb, 139 | /* [in] */ LONG grfBINDF, 140 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo, 141 | /* [in] */ LPCOLESTR pszHeaders, 142 | /* [in] */ LPCOLESTR pszRedir, 143 | /* [in] */ UINT uiCP); 144 | 145 | END_INTERFACE 146 | } IDownloadManagerVtbl; 147 | 148 | interface IDownloadManager 149 | { 150 | CONST_VTBL struct IDownloadManagerVtbl __RPC_FAR *lpVtbl; 151 | }; 152 | 153 | 154 | 155 | #ifdef COBJMACROS 156 | 157 | 158 | #define IDownloadManager_QueryInterface(This,riid,ppvObject) \ 159 | (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) 160 | 161 | #define IDownloadManager_AddRef(This) \ 162 | (This)->lpVtbl -> AddRef(This) 163 | 164 | #define IDownloadManager_Release(This) \ 165 | (This)->lpVtbl -> Release(This) 166 | 167 | 168 | #define IDownloadManager_Download(This,pmk,pbc,dwBindVerb,grfBINDF,pBindInfo,pszHeaders,pszRedir,uiCP) \ 169 | (This)->lpVtbl -> Download(This,pmk,pbc,dwBindVerb,grfBINDF,pBindInfo,pszHeaders,pszRedir,uiCP) 170 | 171 | #endif /* COBJMACROS */ 172 | 173 | 174 | #endif /* C style interface */ 175 | 176 | 177 | 178 | HRESULT STDMETHODCALLTYPE IDownloadManager_Download_Proxy( 179 | IDownloadManager __RPC_FAR * This, 180 | /* [in] */ IMoniker __RPC_FAR *pmk, 181 | /* [in] */ IBindCtx __RPC_FAR *pbc, 182 | /* [in] */ DWORD dwBindVerb, 183 | /* [in] */ LONG grfBINDF, 184 | /* [in] */ BINDINFO __RPC_FAR *pBindInfo, 185 | /* [in] */ LPCOLESTR pszHeaders, 186 | /* [in] */ LPCOLESTR pszRedir, 187 | /* [in] */ UINT uiCP); 188 | 189 | 190 | void __RPC_STUB IDownloadManager_Download_Stub( 191 | IRpcStubBuffer *This, 192 | IRpcChannelBuffer *_pRpcChannelBuffer, 193 | PRPC_MESSAGE _pRpcMessage, 194 | DWORD *_pdwStubPhase); 195 | 196 | 197 | 198 | #endif /* __IDownloadManager_INTERFACE_DEFINED__ */ 199 | 200 | 201 | /* Additional Prototypes for ALL interfaces */ 202 | 203 | /* end of Additional Prototypes */ 204 | 205 | #ifdef __cplusplus 206 | } 207 | #endif 208 | 209 | #endif 210 | 211 | 212 | -------------------------------------------------------------------------------- /Duilib/Utils/observer_impl_base.h: -------------------------------------------------------------------------------- 1 | #ifndef OBSERVER_IMPL_BASE_HPP 2 | #define OBSERVER_IMPL_BASE_HPP 3 | 4 | #include 5 | #include 6 | 7 | 8 | /* 9 | template 10 | class ReceiverImplBase; 11 | 12 | template 13 | class ObserverImplBase 14 | { 15 | public: 16 | virtual void AddReceiver(ReceiverImplBase* receiver) = 0; 17 | virtual void RemoveReceiver(ReceiverImplBase* receiver) = 0; 18 | virtual ReturnT Broadcast(ParamT param) = 0; 19 | virtual ReturnT Notify(ParamT param) = 0; 20 | }; 21 | 22 | template 23 | class ReceiverImplBase 24 | { 25 | public: 26 | virtual void AddObserver(ObserverImplBase* observer) = 0; 27 | virtual void RemoveObserver() = 0; 28 | virtual ReturnT Receive(ParamT param) = 0; 29 | virtual ReturnT Respond(ParamT param, ObserverImplBase* observer) = 0; 30 | }; 31 | 32 | template 33 | class ReceiverImpl; 34 | 35 | template 36 | class ObserverImpl : public ObserverImplBase 37 | { 38 | public: 39 | ObserverImpl() 40 | : count_(0) 41 | {} 42 | 43 | virtual ~ObserverImpl() {} 44 | 45 | virtual void AddReceiver(ReceiverImplBase* receiver) 46 | { 47 | if (receiver == NULL) 48 | return; 49 | 50 | receivers_[count_] = receiver; 51 | receiver->AddObserver(this); 52 | count_++; 53 | } 54 | 55 | virtual void RemoveReceiver(ReceiverImplBase* receiver) 56 | { 57 | if (receiver == NULL) 58 | return; 59 | 60 | ReceiversMap::iterator it = receivers_.begin(); 61 | for (; it != receivers_.end(); ++it) 62 | { 63 | if (it->second == receiver) 64 | { 65 | receivers_.erase(it); 66 | break; 67 | } 68 | } 69 | } 70 | 71 | virtual ReturnT Broadcast(ParamT param) 72 | { 73 | ReceiversMap::iterator it = receivers_.begin(); 74 | for (; it != receivers_.end(); ++it) 75 | { 76 | it->second->Receive(param); 77 | } 78 | 79 | return ReturnT(); 80 | } 81 | 82 | virtual ReturnT Notify(ParamT param) 83 | { 84 | ReceiversMap::iterator it = receivers_.begin(); 85 | for (; it != receivers_.end(); ++it) 86 | { 87 | it->second->Respond(param, this); 88 | } 89 | 90 | return ReturnT(); 91 | } 92 | 93 | protected: 94 | typedef std::map*> ReceiversMap; 95 | ReceiversMap receivers_; 96 | int count_; 97 | }; 98 | 99 | 100 | template 101 | class ReceiverImpl : public ReceiverImplBase 102 | { 103 | public: 104 | ReceiverImpl() 105 | : count_(0) 106 | {} 107 | 108 | virtual ~ReceiverImpl() {} 109 | 110 | virtual void AddObserver(ObserverImplBase* observer) 111 | { 112 | observers_[count_] = observer; 113 | count_++; 114 | } 115 | 116 | virtual void RemoveObserver() 117 | { 118 | ObserversMap::iterator it = observers_.begin(); 119 | for (; it != observers_.end(); ++it) 120 | { 121 | it->second->RemoveReceiver(this); 122 | } 123 | } 124 | 125 | virtual ReturnT Receive(ParamT param) 126 | { 127 | return ReturnT(); 128 | } 129 | 130 | virtual ReturnT Respond(ParamT param, ObserverImplBase* observer) 131 | { 132 | return ReturnT(); 133 | } 134 | 135 | protected: 136 | typedef std::map*> ObserversMap; 137 | ObserversMap observers_; 138 | int count_; 139 | }; 140 | */ 141 | #endif // OBSERVER_IMPL_BASE_HPP -------------------------------------------------------------------------------- /DuilibPreview.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27004.2009 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuilibPreview", "DuilibPreview\DuilibPreview.vcxproj", "{B1B1B73B-612A-408F-A074-33FB0D333D32}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiLib", "Duilib\DuiLib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Win32 = Debug|Win32 13 | Debug|x64 = Debug|x64 14 | DebugA|Win32 = DebugA|Win32 15 | DebugA|x64 = DebugA|x64 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | ReleaseA|Win32 = ReleaseA|Win32 19 | ReleaseA|x64 = ReleaseA|x64 20 | SDebug|Win32 = SDebug|Win32 21 | SDebug|x64 = SDebug|x64 22 | SDebugA|Win32 = SDebugA|Win32 23 | SDebugA|x64 = SDebugA|x64 24 | SRelease|Win32 = SRelease|Win32 25 | SRelease|x64 = SRelease|x64 26 | SReleaseA|Win32 = SReleaseA|Win32 27 | SReleaseA|x64 = SReleaseA|x64 28 | UnicodeRelease|Win32 = UnicodeRelease|Win32 29 | UnicodeRelease|x64 = UnicodeRelease|x64 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.Debug|Win32.ActiveCfg = Release|Win32 33 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.Debug|Win32.Build.0 = Release|Win32 34 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.Debug|x64.ActiveCfg = Release|Win32 35 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.Debug|x64.Build.0 = Release|Win32 36 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.DebugA|Win32.ActiveCfg = Release|Win32 37 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.DebugA|Win32.Build.0 = Release|Win32 38 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.DebugA|x64.ActiveCfg = Release|Win32 39 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.DebugA|x64.Build.0 = Release|Win32 40 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.Release|Win32.ActiveCfg = Release|Win32 41 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.Release|Win32.Build.0 = Release|Win32 42 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.Release|x64.ActiveCfg = Release|Win32 43 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.ReleaseA|Win32.ActiveCfg = Release|Win32 44 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.ReleaseA|Win32.Build.0 = Release|Win32 45 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.ReleaseA|x64.ActiveCfg = Release|Win32 46 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.ReleaseA|x64.Build.0 = Release|Win32 47 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SDebug|Win32.ActiveCfg = Release|Win32 48 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SDebug|Win32.Build.0 = Release|Win32 49 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SDebug|x64.ActiveCfg = Release|Win32 50 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SDebug|x64.Build.0 = Release|Win32 51 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SDebugA|Win32.ActiveCfg = Release|Win32 52 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SDebugA|Win32.Build.0 = Release|Win32 53 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SDebugA|x64.ActiveCfg = Release|Win32 54 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SDebugA|x64.Build.0 = Release|Win32 55 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SRelease|Win32.ActiveCfg = Release|Win32 56 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SRelease|Win32.Build.0 = Release|Win32 57 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SRelease|x64.ActiveCfg = Release|Win32 58 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SRelease|x64.Build.0 = Release|Win32 59 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SReleaseA|Win32.ActiveCfg = Release|Win32 60 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SReleaseA|Win32.Build.0 = Release|Win32 61 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SReleaseA|x64.ActiveCfg = Release|Win32 62 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.SReleaseA|x64.Build.0 = Release|Win32 63 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.UnicodeRelease|Win32.ActiveCfg = Release|Win32 64 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.UnicodeRelease|Win32.Build.0 = Release|Win32 65 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.UnicodeRelease|x64.ActiveCfg = Release|Win32 66 | {B1B1B73B-612A-408F-A074-33FB0D333D32}.UnicodeRelease|x64.Build.0 = Release|Win32 67 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.ActiveCfg = Debug|Win32 68 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.Build.0 = Debug|Win32 69 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.ActiveCfg = Debug|x64 70 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|x64.Build.0 = Debug|x64 71 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.DebugA|Win32.ActiveCfg = DebugA|Win32 72 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.DebugA|Win32.Build.0 = DebugA|Win32 73 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.DebugA|x64.ActiveCfg = DebugA|x64 74 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.DebugA|x64.Build.0 = DebugA|x64 75 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.ActiveCfg = Release|Win32 76 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.Build.0 = Release|Win32 77 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.ActiveCfg = Release|x64 78 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|x64.Build.0 = Release|x64 79 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.ReleaseA|Win32.ActiveCfg = ReleaseA|Win32 80 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.ReleaseA|Win32.Build.0 = ReleaseA|Win32 81 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.ReleaseA|x64.ActiveCfg = ReleaseA|x64 82 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.ReleaseA|x64.Build.0 = ReleaseA|x64 83 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebug|Win32.ActiveCfg = SDebug|Win32 84 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebug|Win32.Build.0 = SDebug|Win32 85 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebug|x64.ActiveCfg = SDebug|x64 86 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebug|x64.Build.0 = SDebug|x64 87 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebugA|Win32.ActiveCfg = SDebugA|Win32 88 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebugA|Win32.Build.0 = SDebugA|Win32 89 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebugA|x64.ActiveCfg = SDebugA|x64 90 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SDebugA|x64.Build.0 = SDebugA|x64 91 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SRelease|Win32.ActiveCfg = SRelease|Win32 92 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SRelease|Win32.Build.0 = SRelease|Win32 93 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SRelease|x64.ActiveCfg = SRelease|x64 94 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SRelease|x64.Build.0 = SRelease|x64 95 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SReleaseA|Win32.ActiveCfg = SReleaseA|Win32 96 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SReleaseA|Win32.Build.0 = SReleaseA|Win32 97 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SReleaseA|x64.ActiveCfg = SReleaseA|x64 98 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.SReleaseA|x64.Build.0 = SReleaseA|x64 99 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|Win32.ActiveCfg = Release|Win32 100 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|Win32.Build.0 = Release|Win32 101 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|x64.ActiveCfg = Release|x64 102 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|x64.Build.0 = Release|x64 103 | EndGlobalSection 104 | GlobalSection(SolutionProperties) = preSolution 105 | HideSolutionNode = FALSE 106 | EndGlobalSection 107 | GlobalSection(ExtensibilityGlobals) = postSolution 108 | SolutionGuid = {7A3FF7CA-409B-47E8-89A2-9F2D2244C2DB} 109 | EndGlobalSection 110 | EndGlobal 111 | -------------------------------------------------------------------------------- /DuilibPreview/App.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/App.cpp -------------------------------------------------------------------------------- /DuilibPreview/App.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/App.h -------------------------------------------------------------------------------- /DuilibPreview/DuiLib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/DuiLib.dll -------------------------------------------------------------------------------- /DuilibPreview/DuiLib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/DuiLib.lib -------------------------------------------------------------------------------- /DuilibPreview/DuiLib_u.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/DuiLib_u.dll -------------------------------------------------------------------------------- /DuilibPreview/DuilibPreview.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/DuilibPreview.vcproj -------------------------------------------------------------------------------- /DuilibPreview/DuilibPreview.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Release 6 | Win32 7 | 8 | 9 | 10 | {B1B1B73B-612A-408F-A074-33FB0D333D32} 11 | DuilibPreview 12 | Win32Proj 13 | 14 | 15 | 16 | Application 17 | v141 18 | Unicode 19 | true 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | <_ProjectFileVersion>15.0.26919.1 30 | 31 | 32 | $(SolutionDir)$(Configuration)\ 33 | $(Configuration)\ 34 | false 35 | $(SolutionDir)Duilib;$(VC_IncludePath);$(WindowsSDK_IncludePath) 36 | $(SolutionDir)Duilib\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 37 | 38 | 39 | 40 | Disabled 41 | true 42 | WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 43 | MultiThreaded 44 | true 45 | NotUsing 46 | Level3 47 | ProgramDatabase 48 | 49 | 50 | 51 | 52 | $(OutDir)$(TargetName)$(TargetExt) 53 | true 54 | true 55 | Windows 56 | true 57 | true 58 | MachineX86 59 | DuiLib.dll 60 | 61 | 62 | DuiLib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | {e106acd7-4e53-4aee-942b-d0dd426db34e} 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /DuilibPreview/DuilibPreview.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 源文件 23 | 24 | 25 | 源文件 26 | 27 | 28 | 源文件 29 | 30 | 31 | 源文件 32 | 33 | 34 | 源文件 35 | 36 | 37 | 38 | 39 | 头文件 40 | 41 | 42 | 头文件 43 | 44 | 45 | 头文件 46 | 47 | 48 | 头文件 49 | 50 | 51 | 头文件 52 | 53 | 54 | 头文件 55 | 56 | 57 | 头文件 58 | 59 | 60 | 头文件 61 | 62 | 63 | -------------------------------------------------------------------------------- /DuilibPreview/DuilibPreview.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /DuilibPreview/MainWnd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/MainWnd.cpp -------------------------------------------------------------------------------- /DuilibPreview/MainWnd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stdafx.h" 3 | 4 | class CMainWnd : public WindowImplBase 5 | { 6 | public: 7 | CMainWnd(); 8 | ~CMainWnd(); 9 | 10 | void Notify(TNotifyUI& msg); 11 | void InitWindow(); 12 | 13 | LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 14 | LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 15 | 16 | LPCTSTR GetWindowClassName() const; 17 | CDuiString GetSkinFile(); 18 | 19 | LPCTSTR getXmlPath() const; 20 | void previewXmlLayout(/*LPSTR lpCmdLine*/); 21 | void tcharToChar(const TCHAR* sourTchar, char* destChar); 22 | 23 | private: 24 | CButtonUI* m_closeBtn; 25 | CButtonUI* m_minBtn; 26 | CButtonUI* m_maxBtn; 27 | CButtonUI* m_restoreBtn; 28 | CButtonUI* m_previewBtn; 29 | CRichEditUI* m_xmlPathEdit; 30 | }; 31 | -------------------------------------------------------------------------------- /DuilibPreview/PreviewWnd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/PreviewWnd.cpp -------------------------------------------------------------------------------- /DuilibPreview/PreviewWnd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CPreviewWnd : public WindowImplBase 4 | { 5 | public: 6 | CPreviewWnd() { }; 7 | ~CPreviewWnd() { }; 8 | 9 | virtual CDuiString GetSkinFile(); 10 | virtual CDuiString GetSkinFolder(); 11 | virtual LPCTSTR GetWindowClassName(void) const; 12 | virtual void Notify(TNotifyUI &msg ); 13 | virtual LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); 14 | virtual void OnFinalMessage(HWND); 15 | virtual LRESULT OnKeyDown(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled); 16 | virtual LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 17 | virtual void SetSkinFile(CDuiString); 18 | virtual void SetSkinFolder(CDuiString); 19 | 20 | private: 21 | CDuiString m_skinFolder; 22 | CDuiString m_skinFile; 23 | CDuiString m_strXMLPath; 24 | }; -------------------------------------------------------------------------------- /DuilibPreview/PreviewXml.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/PreviewXml.cpp -------------------------------------------------------------------------------- /DuilibPreview/PreviewXml.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stdafx.h" 3 | 4 | class CPreviewXml : public CWindowWnd, public INotifyUI 5 | { 6 | public: 7 | CPreviewXml(LPCTSTR pszXMLPath); 8 | ~CPreviewXml(); 9 | 10 | LPCTSTR GetWindowClassName() const; 11 | UINT GetClassStyle() const; 12 | void OnFinalMessage(HWND /*hWnd*/); 13 | 14 | void Init(); 15 | void Notify(TNotifyUI& msg); 16 | 17 | void SetSkinFile(CDuiString); 18 | void SetSkinFolder(CDuiString); 19 | 20 | void SetBkColor(DWORD dwBackColor); 21 | DWORD GetBkColor() const; 22 | void SetBkImage(CDuiString strBkImage); 23 | LPCTSTR GetBkImage(); 24 | 25 | LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 26 | LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 27 | LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 28 | LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 29 | LRESULT OnNcActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 30 | LRESULT OnNcCalcSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 31 | LRESULT OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 32 | LRESULT OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 33 | LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 34 | LRESULT OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 35 | LRESULT OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 36 | LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); 37 | 38 | protected: 39 | CDuiString m_strXMLPath; 40 | CPaintManagerUI m_pm; 41 | }; 42 | -------------------------------------------------------------------------------- /DuilibPreview/StringTools.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/StringTools.cpp -------------------------------------------------------------------------------- /DuilibPreview/StringTools.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/StringTools.h -------------------------------------------------------------------------------- /DuilibPreview/WinImplBase.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/WinImplBase.hpp -------------------------------------------------------------------------------- /DuilibPreview/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/resource.h -------------------------------------------------------------------------------- /DuilibPreview/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/stdafx.cpp -------------------------------------------------------------------------------- /DuilibPreview/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/stdafx.h -------------------------------------------------------------------------------- /DuilibPreview/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/DuilibPreview/targetver.h -------------------------------------------------------------------------------- /Lib/DuiLib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Lib/DuiLib.lib -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warren-lei/DuilibPreview/9fe6b5299e08e80888cfa50feffade2e8aa2c579/Readme.md -------------------------------------------------------------------------------- /Release/skin/MainDlg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |