├── Update
├── HttpPost.cpp
├── HttpPost.h
├── Global.h
├── Thread.h
├── skin.zip
├── BaseWnd.h
├── Global.cpp
├── Thread.cpp
├── Update.aps
├── Update.cpp
├── Update.rc
├── resource.h
├── unzip.cpp
├── update.ico
├── BaseWnd.cpp
├── UpdateInfo.h
├── UpdateWnd.cpp
├── UpdateWnd.h
├── update__.ico
├── UpadteInfo.cpp
├── XmlDocument.cpp
├── Update.vcxproj.user
├── XmlDocument.h
├── Update.vcxproj.filters
├── Update.vcxproj
└── unzip.h
├── Update.suo
├── DuiLib
├── StdAfx.h
├── Core
│ ├── UIBase.h
│ ├── UIBase.cpp
│ ├── UIDefine.h
│ ├── UIRender.h
│ ├── UIContainer.h
│ ├── UIControl.cpp
│ ├── UIControl.h
│ ├── UIManager.h
│ ├── UIMarkup.cpp
│ ├── UIRender.cpp
│ ├── UIContainer.cpp
│ ├── UIDlgBuilder.cpp
│ ├── UIDlgBuilder.h
│ └── UIMarkup.h
├── Utils
│ ├── Utils.cpp
│ ├── Flash11.tlb
│ ├── WinImplBase.h
│ ├── WinImplBase.cpp
│ ├── FlashEventHandler.h
│ ├── WebBrowserEventHandler.h
│ ├── GifHandler.h
│ ├── GifHandler.cpp
│ ├── UIDelegate.cpp
│ ├── UIDelegate.h
│ ├── downloadmgr.h
│ └── Utils.h
├── Control
│ ├── UIFlash.h
│ ├── UIList.cpp
│ ├── UIList.h
│ ├── UICheckBox.h
│ ├── UICombo.cpp
│ ├── UIComboBox.h
│ ├── UIDateTime.h
│ ├── UIFlash.cpp
│ ├── UIRichEdit.h
│ ├── UIActiveX.cpp
│ ├── UIDateTime.cpp
│ ├── UIRichEdit.cpp
│ ├── UITreeView.cpp
│ ├── UIWebBrowser.h
│ ├── UIWebBrowser.cpp
│ ├── UICheckBox.cpp
│ ├── UIText.h
│ ├── UIProgress.h
│ ├── UISlider.h
│ ├── UIOption.h
│ ├── UIButton.h
│ ├── UIActiveX.h
│ ├── UIEdit.h
│ ├── UILabel.h
│ ├── UIComboBox.cpp
│ ├── UIProgress.cpp
│ ├── UICombo.h
│ ├── UIScrollBar.h
│ ├── UITreeView.h
│ ├── UIText.cpp
│ ├── UISlider.cpp
│ ├── UIOption.cpp
│ ├── UIButton.cpp
│ └── UIEdit.cpp
├── DuiLib.vcxproj.user
├── StdAfx.cpp
├── Layout
│ ├── UIChildLayout.h
│ ├── UITileLayout.h
│ ├── UITabLayout.h
│ ├── UIVerticalLayout.h
│ ├── UIHorizontalLayout.h
│ ├── UIChildLayout.cpp
│ ├── UITabLayout.cpp
│ ├── UITileLayout.cpp
│ ├── UIHorizontalLayout.cpp
│ └── UIVerticalLayout.cpp
├── CMakeLists.txt
├── UIlib.cpp
├── UIlib.h
└── DuiLib.vcxproj.filters
├── HtttpDownload
├── HttpDownload.def
├── stdafx.h
├── Download.h
├── dllmain.cpp
├── stdafx.cpp
├── targetver.h
├── Download.cpp
├── HtttpDownload.cpp
├── HtttpDownload.vcxproj.user
├── ReadMe.txt
├── HtttpDownload.vcxproj.filters
└── HtttpDownload.vcxproj
├── Preview
├── 1.png
├── 2.png
├── 3.png
├── 4.png
├── 5.png
├── 6.png
├── 7.png
└── 更新时候背景图片自动切换显示日志,需在服务器设置.png
├── README.md
├── .gitignore
└── Update.sln
/Update/HttpPost.cpp:
--------------------------------------------------------------------------------
1 | #include "HttpPost.h"
--------------------------------------------------------------------------------
/Update/HttpPost.h:
--------------------------------------------------------------------------------
1 | #include "Global.h"
2 |
3 | void SendHttpRequest()
--------------------------------------------------------------------------------
/Update.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update.suo
--------------------------------------------------------------------------------
/DuiLib/StdAfx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/StdAfx.h
--------------------------------------------------------------------------------
/HtttpDownload/HttpDownload.def:
--------------------------------------------------------------------------------
1 | EXPORTS
2 | http_downloadfile
3 | http_downloadtobuf
--------------------------------------------------------------------------------
/Preview/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Preview/1.png
--------------------------------------------------------------------------------
/Preview/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Preview/2.png
--------------------------------------------------------------------------------
/Preview/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Preview/3.png
--------------------------------------------------------------------------------
/Preview/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Preview/4.png
--------------------------------------------------------------------------------
/Preview/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Preview/5.png
--------------------------------------------------------------------------------
/Preview/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Preview/6.png
--------------------------------------------------------------------------------
/Preview/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Preview/7.png
--------------------------------------------------------------------------------
/Update/Global.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/Global.h
--------------------------------------------------------------------------------
/Update/Thread.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/Thread.h
--------------------------------------------------------------------------------
/Update/skin.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/skin.zip
--------------------------------------------------------------------------------
/Update/BaseWnd.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/BaseWnd.h
--------------------------------------------------------------------------------
/Update/Global.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/Global.cpp
--------------------------------------------------------------------------------
/Update/Thread.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/Thread.cpp
--------------------------------------------------------------------------------
/Update/Update.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/Update.aps
--------------------------------------------------------------------------------
/Update/Update.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/Update.cpp
--------------------------------------------------------------------------------
/Update/Update.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/Update.rc
--------------------------------------------------------------------------------
/Update/resource.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/resource.h
--------------------------------------------------------------------------------
/Update/unzip.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/unzip.cpp
--------------------------------------------------------------------------------
/Update/update.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/update.ico
--------------------------------------------------------------------------------
/DuiLib/Core/UIBase.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIBase.h
--------------------------------------------------------------------------------
/Update/BaseWnd.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/BaseWnd.cpp
--------------------------------------------------------------------------------
/Update/UpdateInfo.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/UpdateInfo.h
--------------------------------------------------------------------------------
/Update/UpdateWnd.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/UpdateWnd.cpp
--------------------------------------------------------------------------------
/Update/UpdateWnd.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/UpdateWnd.h
--------------------------------------------------------------------------------
/Update/update__.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/update__.ico
--------------------------------------------------------------------------------
/DuiLib/Core/UIBase.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIBase.cpp
--------------------------------------------------------------------------------
/DuiLib/Core/UIDefine.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIDefine.h
--------------------------------------------------------------------------------
/DuiLib/Core/UIRender.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIRender.h
--------------------------------------------------------------------------------
/DuiLib/Utils/Utils.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Utils/Utils.cpp
--------------------------------------------------------------------------------
/HtttpDownload/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/HtttpDownload/stdafx.h
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | UpdateClient
2 | ============
3 | Auto updateclient , can update acroos versions.
4 |
--------------------------------------------------------------------------------
/Update/UpadteInfo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/UpadteInfo.cpp
--------------------------------------------------------------------------------
/Update/XmlDocument.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Update/XmlDocument.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIFlash.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIFlash.h
--------------------------------------------------------------------------------
/DuiLib/Control/UIList.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIList.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIList.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIList.h
--------------------------------------------------------------------------------
/DuiLib/Core/UIContainer.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIContainer.h
--------------------------------------------------------------------------------
/DuiLib/Core/UIControl.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIControl.cpp
--------------------------------------------------------------------------------
/DuiLib/Core/UIControl.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIControl.h
--------------------------------------------------------------------------------
/DuiLib/Core/UIManager.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIManager.h
--------------------------------------------------------------------------------
/DuiLib/Core/UIMarkup.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIMarkup.cpp
--------------------------------------------------------------------------------
/DuiLib/Core/UIRender.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIRender.cpp
--------------------------------------------------------------------------------
/DuiLib/Utils/Flash11.tlb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Utils/Flash11.tlb
--------------------------------------------------------------------------------
/HtttpDownload/Download.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/HtttpDownload/Download.h
--------------------------------------------------------------------------------
/HtttpDownload/dllmain.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/HtttpDownload/dllmain.cpp
--------------------------------------------------------------------------------
/HtttpDownload/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/HtttpDownload/stdafx.cpp
--------------------------------------------------------------------------------
/HtttpDownload/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/HtttpDownload/targetver.h
--------------------------------------------------------------------------------
/DuiLib/Control/UICheckBox.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UICheckBox.h
--------------------------------------------------------------------------------
/DuiLib/Control/UICombo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UICombo.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIComboBox.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIComboBox.h
--------------------------------------------------------------------------------
/DuiLib/Control/UIDateTime.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIDateTime.h
--------------------------------------------------------------------------------
/DuiLib/Control/UIFlash.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIFlash.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIRichEdit.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIRichEdit.h
--------------------------------------------------------------------------------
/DuiLib/Core/UIContainer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIContainer.cpp
--------------------------------------------------------------------------------
/DuiLib/Utils/WinImplBase.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Utils/WinImplBase.h
--------------------------------------------------------------------------------
/HtttpDownload/Download.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/HtttpDownload/Download.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIActiveX.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIActiveX.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIDateTime.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIDateTime.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIRichEdit.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIRichEdit.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UITreeView.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UITreeView.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIWebBrowser.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIWebBrowser.h
--------------------------------------------------------------------------------
/DuiLib/Core/UIDlgBuilder.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Core/UIDlgBuilder.cpp
--------------------------------------------------------------------------------
/DuiLib/Utils/WinImplBase.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Utils/WinImplBase.cpp
--------------------------------------------------------------------------------
/DuiLib/Control/UIWebBrowser.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Control/UIWebBrowser.cpp
--------------------------------------------------------------------------------
/DuiLib/Utils/FlashEventHandler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Utils/FlashEventHandler.h
--------------------------------------------------------------------------------
/HtttpDownload/HtttpDownload.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/HtttpDownload/HtttpDownload.cpp
--------------------------------------------------------------------------------
/DuiLib/Utils/WebBrowserEventHandler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/DuiLib/Utils/WebBrowserEventHandler.h
--------------------------------------------------------------------------------
/Preview/更新时候背景图片自动切换显示日志,需在服务器设置.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xlet/UpdateClient/HEAD/Preview/更新时候背景图片自动切换显示日志,需在服务器设置.png
--------------------------------------------------------------------------------
/DuiLib/DuiLib.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/HtttpDownload/HtttpDownload.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.exe
2 | *.dll
3 | /Debug
4 | /Release
5 | *.sdf
6 | /lib
7 | /DuiLib/Build
8 | /HtttpDownload/Debug
9 | /HtttpDownload/Release
10 | /Update/Debug
11 | /Update/Release
12 |
13 |
--------------------------------------------------------------------------------
/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 |
8 | #pragma comment( lib, "winmm.lib" )
9 | #pragma comment( lib, "comctl32.lib" )
10 |
--------------------------------------------------------------------------------
/DuiLib/Control/UICheckBox.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UICheckBox.h"
3 |
4 | namespace DuiLib
5 | {
6 | LPCTSTR CCheckBoxUI::GetClass() const
7 | {
8 | return _T("CheckBoxUI");
9 | }
10 |
11 | void CCheckBoxUI::SetCheck(bool bCheck)
12 | {
13 | Selected(bCheck);
14 | }
15 |
16 | bool CCheckBoxUI::GetCheck() const
17 | {
18 | return IsSelected();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/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 | public:
11 | CChildLayoutUI();
12 |
13 | void Init();
14 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
15 | void SetChildLayoutXML(CDuiString pXML);
16 | DuiLib::CDuiString GetChildLayoutXML();
17 | virtual LPVOID GetInterface(LPCTSTR pstrName);
18 | virtual LPCTSTR GetClass() const;
19 |
20 | private:
21 | DuiLib::CDuiString m_pstrXMLFile;
22 | };
23 | } // namespace DuiLib
24 | #endif // __UICHILDLAYOUT_H__
25 |
--------------------------------------------------------------------------------
/DuiLib/Utils/GifHandler.h:
--------------------------------------------------------------------------------
1 | #ifndef __GIFHANDLER_H__
2 | #define __GIFHANDLER_H__
3 |
4 | #pragma once
5 |
6 |
7 |
8 | namespace DuiLib
9 | {
10 |
11 |
12 | class UILIB_API CGifHandler
13 | {
14 | public:
15 | CGifHandler();
16 |
17 | virtual ~CGifHandler();
18 |
19 | int GetFrameCount();
20 |
21 | void AddFrameInfo(GifTFontInfo* pFrameInfo);
22 |
23 | GifTFontInfo* GetNextFrameInfo();
24 |
25 | GifTFontInfo* GetCurrentFrameInfo();
26 |
27 | GifTFontInfo* GetFrameInfoAt(int index);
28 |
29 | private:
30 | CStdPtrArray ImageInfos;
31 | int nCurrentFrame;
32 | int nFrameCount;
33 | bool isDeleting;
34 |
35 | };
36 | }
37 |
38 | #endif
--------------------------------------------------------------------------------
/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 | public:
11 | CTileLayoutUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 |
16 | void SetPos(RECT rc);
17 |
18 | SIZE GetItemSize() const;
19 | void SetItemSize(SIZE szItem);
20 | int GetColumns() const;
21 | void SetColumns(int nCols);
22 |
23 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
24 |
25 | protected:
26 | SIZE m_szItem;
27 | int m_nColumns;
28 | };
29 | }
30 | #endif // __UITILELAYOUT_H__
31 |
--------------------------------------------------------------------------------
/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 | public:
11 | CTextUI();
12 | ~CTextUI();
13 |
14 | LPCTSTR GetClass() const;
15 | UINT GetControlFlags() const;
16 | LPVOID GetInterface(LPCTSTR pstrName);
17 |
18 | CDuiString* GetLinkContent(int iIndex);
19 |
20 | void DoEvent(TEventUI& event);
21 | SIZE EstimateSize(SIZE szAvailable);
22 |
23 | void PaintText(HDC hDC);
24 |
25 | protected:
26 | enum { MAX_LINK = 8 };
27 | int m_nLinks;
28 | RECT m_rcLinks[MAX_LINK];
29 | CDuiString m_sLinks[MAX_LINK];
30 | int m_nHoverLink;
31 | };
32 |
33 | } // namespace DuiLib
34 |
35 | #endif //__UITEXT_H__
--------------------------------------------------------------------------------
/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 | public:
11 | CTabLayoutUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 |
16 | bool Add(CControlUI* pControl);
17 | bool AddAt(CControlUI* pControl, int iIndex);
18 | bool Remove(CControlUI* pControl);
19 | void RemoveAll();
20 | int GetCurSel() const;
21 | bool SelectItem(int iIndex);
22 | bool SelectItem(CControlUI* pControl);
23 |
24 | void SetPos(RECT rc);
25 |
26 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
27 |
28 | protected:
29 | int m_iCurSel;
30 | };
31 | }
32 | #endif // __UITABLAYOUT_H__
33 |
--------------------------------------------------------------------------------
/Update/Update.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | http://update.myhouse.w.cn/api/v1/version.xml?product=househelper&version=1.0.3
5 | WindowsLocalDebugger
6 |
7 |
8 | http://update.myhouse.w.cn/api/v1/version.xml?product=househelper&version=1.0.3
9 | WindowsLocalDebugger
10 |
11 |
--------------------------------------------------------------------------------
/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 | public:
11 | CVerticalLayoutUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 | UINT GetControlFlags() const;
16 |
17 | void SetSepHeight(int iHeight);
18 | int GetSepHeight() const;
19 | void SetSepImmMode(bool bImmediately);
20 | bool IsSepImmMode() const;
21 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
22 | void DoEvent(TEventUI& event);
23 |
24 | void SetPos(RECT rc);
25 | void DoPostPaint(HDC hDC, const RECT& rcPaint);
26 |
27 | RECT GetThumbRect(bool bUseNew = false) const;
28 |
29 | protected:
30 | int m_iSepHeight;
31 | UINT m_uButtonState;
32 | POINT ptLastMouse;
33 | RECT m_rcNewPos;
34 | bool m_bImmMode;
35 | };
36 | }
37 | #endif // __UIVERTICALLAYOUT_H__
38 |
--------------------------------------------------------------------------------
/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 | public:
11 | CHorizontalLayoutUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 | UINT GetControlFlags() const;
16 |
17 | void SetSepWidth(int iWidth);
18 | int GetSepWidth() const;
19 | void SetSepImmMode(bool bImmediately);
20 | bool IsSepImmMode() const;
21 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
22 | void DoEvent(TEventUI& event);
23 |
24 | void SetPos(RECT rc);
25 | void DoPostPaint(HDC hDC, const RECT& rcPaint);
26 |
27 | RECT GetThumbRect(bool bUseNew = false) const;
28 |
29 | protected:
30 | int m_iSepWidth;
31 | UINT m_uButtonState;
32 | POINT ptLastMouse;
33 | RECT m_rcNewPos;
34 | bool m_bImmMode;
35 | };
36 | }
37 | #endif // __UIHORIZONTALLAYOUT_H__
38 |
--------------------------------------------------------------------------------
/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 | public:
11 | CProgressUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 |
16 | bool IsHorizontal();
17 | void SetHorizontal(bool bHorizontal = true);
18 | bool IsStretchForeImage();
19 | void SetStretchForeImage(bool bStretchForeImage = true);
20 | int GetMinValue() const;
21 | void SetMinValue(int nMin);
22 | int GetMaxValue() const;
23 | void SetMaxValue(int nMax);
24 | int GetValue() const;
25 | void SetValue(int nValue);
26 | LPCTSTR GetForeImage() const;
27 | void SetForeImage(LPCTSTR pStrImage);
28 |
29 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
30 | void PaintStatusImage(HDC hDC);
31 |
32 | protected:
33 | bool m_bHorizontal;
34 | bool m_bStretchForeImage;
35 | int m_nMax;
36 | int m_nMin;
37 | int m_nValue;
38 |
39 | CDuiString m_sForeImage;
40 | CDuiString m_sForeImageModify;
41 | };
42 |
43 | } // namespace DuiLib
44 |
45 | #endif // __UIPROGRESS_H__
46 |
--------------------------------------------------------------------------------
/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 | private:
29 | CControlUI* _Parse(CMarkupNode* parent, CControlUI* pParent = NULL, CPaintManagerUI* pManager = NULL);
30 |
31 | CMarkup m_xml;
32 | IDialogBuilderCallback* m_pCallback;
33 | LPCTSTR m_pstrtype;
34 | };
35 |
36 | } // namespace DuiLib
37 |
38 | #endif // __UIDLGBUILDER_H__
39 |
--------------------------------------------------------------------------------
/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 | public:
11 | CSliderUI();
12 |
13 | LPCTSTR GetClass() const;
14 | UINT GetControlFlags() const;
15 | LPVOID GetInterface(LPCTSTR pstrName);
16 |
17 | void SetEnabled(bool bEnable = true);
18 |
19 | int GetChangeStep();
20 | void SetChangeStep(int step);
21 | void SetThumbSize(SIZE szXY);
22 | RECT GetThumbRect() const;
23 | LPCTSTR GetThumbImage() const;
24 | void SetThumbImage(LPCTSTR pStrImage);
25 | LPCTSTR GetThumbHotImage() const;
26 | void SetThumbHotImage(LPCTSTR pStrImage);
27 | LPCTSTR GetThumbPushedImage() const;
28 | void SetThumbPushedImage(LPCTSTR pStrImage);
29 |
30 | void DoEvent(TEventUI& event);
31 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
32 | void PaintStatusImage(HDC hDC);
33 |
34 | protected:
35 | SIZE m_szThumb;
36 | UINT m_uButtonState;
37 | int m_nStep;
38 |
39 | CDuiString m_sThumbImage;
40 | CDuiString m_sThumbHotImage;
41 | CDuiString m_sThumbPushedImage;
42 |
43 | CDuiString m_sImageModify;
44 | };
45 | }
46 |
47 | #endif // __UISLIDER_H__
--------------------------------------------------------------------------------
/DuiLib/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # cmake file for duilib
2 | #Author Qi Gao(monkgau@gmail.com)
3 | #Created: 2012/09/16
4 |
5 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} Root_src)
6 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Control Control_src)
7 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Core Core_src)
8 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Layout Layout_src)
9 | aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/Utils Utils_src)
10 |
11 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
12 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Control)
13 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core)
14 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Layout)
15 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Utils)
16 |
17 | set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
18 | add_library(duilib SHARED ${Control_src} ${Core_src} ${Layout_src} ${Utils_src} ${Root_src})
19 |
20 | add_definitions(-DUILIB_EXPORTS)
21 | target_link_libraries(duilib riched20 comctl32)
22 | set_target_properties(duilib PROPERTIES OUTPUT_NAME "duilib")
23 | add_custom_command(TARGET duilib POST_BUILD
24 | COMMAND ${CMAKE_COMMAND} -E copy_if_different
25 | ${PROJECT_BINARY_DIR}/lib/duilib.dll ${PROJECT_SOURCE_DIR}/bin/duilib.dll)
26 |
--------------------------------------------------------------------------------
/HtttpDownload/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | 动态链接库:HtttpDownload 项目概述
3 | ========================================================================
4 |
5 | 应用程序向导已为您创建了此 HtttpDownload DLL。
6 |
7 | 本文件概要介绍组成 HtttpDownload 应用程序的每个文件的内容。
8 |
9 |
10 | HtttpDownload.vcxproj
11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,
12 | 其中包含生成该文件的 Visual C++
13 | 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
14 |
15 | HtttpDownload.vcxproj.filters
16 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。
17 | 它包含有关项目文件与筛选器之间的关联信息。 在 IDE
18 | 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。
19 | 例如,“.cpp”文件与“源文件”筛选器关联。
20 |
21 | HtttpDownload.cpp
22 | 这是主 DLL 源文件。
23 |
24 | 此 DLL 在创建时不导出任何符号。 因此,在生成此 DLL 时
25 | 生成时不会产生 .lib 文件。 如果希望此项目
26 | 成为其他某个项目的项目依赖项,则需要
27 | 添加代码以从 DLL 导出某些符号,
28 | 以便产生一个导出库,或者,也可以在项目“属性页”对话框中的
29 | “链接器”文件夹中,将“常规”属性页上的
30 | “忽略输入库”属性设置为“是”。
31 |
32 | /////////////////////////////////////////////////////////////////////////////
33 | 其他标准文件:
34 |
35 | StdAfx.h,StdAfx.cpp
36 | 这些文件用于生成名为 HtttpDownload.pch 的预编译头 (PCH) 文件和
37 | 名为 StdAfx.obj 的预编译类型文件。
38 |
39 | /////////////////////////////////////////////////////////////////////////////
40 | 其他注释:
41 |
42 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
43 |
44 | /////////////////////////////////////////////////////////////////////////////
45 |
--------------------------------------------------------------------------------
/DuiLib/Layout/UIChildLayout.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIChildLayout.h"
3 |
4 | namespace DuiLib
5 | {
6 | CChildLayoutUI::CChildLayoutUI()
7 | {
8 |
9 | }
10 |
11 | void CChildLayoutUI::Init()
12 | {
13 | if (!m_pstrXMLFile.IsEmpty())
14 | {
15 | CDialogBuilder builder;
16 | CContainerUI* pChildWindow = static_cast(builder.Create(m_pstrXMLFile.GetData(), (UINT)0, NULL, m_pManager));
17 | if (pChildWindow)
18 | {
19 | this->Add(pChildWindow);
20 | }
21 | else
22 | {
23 | this->RemoveAll();
24 | }
25 | }
26 | }
27 |
28 | void CChildLayoutUI::SetAttribute( LPCTSTR pstrName, LPCTSTR pstrValue )
29 | {
30 | if( _tcscmp(pstrName, _T("xmlfile")) == 0 )
31 | SetChildLayoutXML(pstrValue);
32 | else
33 | CContainerUI::SetAttribute(pstrName,pstrValue);
34 | }
35 |
36 | void CChildLayoutUI::SetChildLayoutXML( DuiLib::CDuiString pXML )
37 | {
38 | m_pstrXMLFile=pXML;
39 | }
40 |
41 | DuiLib::CDuiString CChildLayoutUI::GetChildLayoutXML()
42 | {
43 | return m_pstrXMLFile;
44 | }
45 |
46 | LPVOID CChildLayoutUI::GetInterface( LPCTSTR pstrName )
47 | {
48 | if( _tcscmp(pstrName, DUI_CTR_CHILDLAYOUT) == 0 ) return static_cast(this);
49 | return CControlUI::GetInterface(pstrName);
50 | }
51 |
52 | LPCTSTR CChildLayoutUI::GetClass() const
53 | {
54 | return _T("ChildLayoutUI");
55 | }
56 | } // namespace DuiLib
57 |
--------------------------------------------------------------------------------
/DuiLib/Utils/GifHandler.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 |
3 | #include "GifHandler.h"
4 |
5 | namespace DuiLib
6 | {
7 | CGifHandler::CGifHandler():
8 | nCurrentFrame(0),
9 | isDeleting(false)
10 | {
11 | }
12 |
13 | CGifHandler::~CGifHandler()
14 | {
15 | isDeleting = true;
16 | for(int i = 0; i < ImageInfos.GetSize(); i++)
17 | {
18 | CRenderEngine::FreeImage((GifTFontInfo *)ImageInfos.GetAt(i));
19 | }
20 | }
21 |
22 | int CGifHandler::GetFrameCount()
23 | {
24 | return ImageInfos.GetSize();
25 | }
26 |
27 | void CGifHandler::AddFrameInfo(GifTFontInfo* pFrameInfo)
28 | {
29 | if (pFrameInfo)
30 | {
31 | ImageInfos.Add(pFrameInfo);
32 | }
33 | }
34 |
35 | GifTFontInfo* CGifHandler::GetNextFrameInfo()
36 | {
37 | if(isDeleting == false)
38 | {
39 | int n = nCurrentFrame++;
40 | if (nCurrentFrame >= ImageInfos.GetSize())
41 | {
42 | nCurrentFrame = 0;
43 | }
44 |
45 | return (GifTFontInfo *)ImageInfos.GetAt(n);
46 | }
47 |
48 | return NULL;
49 | }
50 |
51 | GifTFontInfo* CGifHandler::GetCurrentFrameInfo()
52 | {
53 | if(isDeleting == false)
54 | {
55 | return (GifTFontInfo *)ImageInfos.GetAt(nCurrentFrame);
56 | }
57 |
58 | return NULL;
59 | }
60 |
61 | GifTFontInfo* CGifHandler::GetFrameInfoAt(int index)
62 | {
63 | if(isDeleting == false)
64 | {
65 | return (GifTFontInfo *)ImageInfos.GetAt(index);
66 | }
67 |
68 | return NULL;
69 | }
70 | }
--------------------------------------------------------------------------------
/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 | public:
11 | COptionUI();
12 | ~COptionUI();
13 |
14 | LPCTSTR GetClass() const;
15 | LPVOID GetInterface(LPCTSTR pstrName);
16 |
17 | void SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit = true);
18 |
19 | bool Activate();
20 | void SetEnabled(bool bEnable = true);
21 |
22 | LPCTSTR GetSelectedImage();
23 | void SetSelectedImage(LPCTSTR pStrImage);
24 |
25 | LPCTSTR GetSelectedHotImage();
26 | void SetSelectedHotImage(LPCTSTR pStrImage);
27 |
28 | void SetSelectedTextColor(DWORD dwTextColor);
29 | DWORD GetSelectedTextColor();
30 |
31 | void SetSelectedBkColor(DWORD dwBkColor);
32 | DWORD GetSelectBkColor();
33 |
34 | LPCTSTR GetForeImage();
35 | void SetForeImage(LPCTSTR pStrImage);
36 |
37 | LPCTSTR GetGroup() const;
38 | void SetGroup(LPCTSTR pStrGroupName = NULL);
39 | bool IsSelected() const;
40 | virtual void Selected(bool bSelected);
41 |
42 | SIZE EstimateSize(SIZE szAvailable);
43 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
44 |
45 | void PaintStatusImage(HDC hDC);
46 | void PaintText(HDC hDC);
47 |
48 | protected:
49 | bool m_bSelected;
50 | CDuiString m_sGroupName;
51 |
52 | DWORD m_dwSelectedBkColor;
53 | DWORD m_dwSelectedTextColor;
54 |
55 | CDuiString m_sSelectedImage;
56 | CDuiString m_sSelectedHotImage;
57 | CDuiString m_sForeImage;
58 | };
59 |
60 | } // namespace DuiLib
61 |
62 | #endif // __UIOPTION_H__
--------------------------------------------------------------------------------
/HtttpDownload/HtttpDownload.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;mfcribbon-ms
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 |
--------------------------------------------------------------------------------
/Update/XmlDocument.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | #import "msxml3.dll"
6 | #include
7 | #include
8 |
9 | #if defined(UNICODE) || defined(_UNICODE)
10 | // typedef std::wstring tString;
11 | // #else
12 | // typedef std::string tString;
13 | #endif
14 |
15 | class CXmlNodeList;
16 |
17 | class CXmlNode
18 | {
19 | public:
20 | CXmlNode(void);
21 | ~CXmlNode(void);
22 |
23 | public:
24 | BOOL SelectSingleNode(LPCTSTR pNodeName, CXmlNode& objXmlNode);
25 | BOOL SelectNodes(LPCTSTR pNodeName, CXmlNodeList& objXmlNodeList);
26 | BOOL GetFirstChildNode(LPCTSTR pNodeName, CXmlNode& objXmlNode);
27 | BOOL GetNextSiblingNode(LPCTSTR pNodeName, CXmlNode& objXmlNode);
28 | BOOL GetFirstChildNode(CXmlNode& objXmlNode);
29 | BOOL GetNextSiblingNode(CXmlNode& objXmlNode);
30 | std::wstring GetNodeName();
31 | std::wstring GetText();
32 | int GetTextInt();
33 | std::wstring GetAttribute(LPCTSTR lpAttributeName);
34 | int GetAttributeInt(LPCTSTR lpAttributeName);
35 | void Release();
36 | void Attach(IXMLDOMNode * pXMLNode);
37 | IXMLDOMNode * Detach();
38 |
39 | private:
40 | IXMLDOMNode * m_pXMLNode;
41 | };
42 |
43 | class CXmlNodeList
44 | {
45 | public:
46 | CXmlNodeList(void);
47 | ~CXmlNodeList(void);
48 |
49 | public:
50 | int GetLength();
51 | BOOL GetItem(int nIndex, CXmlNode& objXmlNode);
52 | void Release();
53 | void Attach(IXMLDOMNodeList* pXMLNodeList);
54 | IXMLDOMNodeList * Detach();
55 |
56 | private:
57 | IXMLDOMNodeList* m_pXMLNodeList;
58 | };
59 |
60 | class CXmlDocument
61 | {
62 | public:
63 | CXmlDocument(void);
64 | ~CXmlDocument(void);
65 |
66 | public:
67 | BOOL Load(LPCTSTR pPath);
68 | BOOL LoadXml(LPCTSTR pXml);
69 | BOOL SelectSingleNode(LPCTSTR pNodeName, CXmlNode& objXmlNode);
70 | BOOL SelectNodes(LPCTSTR pNodeName, CXmlNodeList& objXmlNodeList);
71 | void Release();
72 |
73 | private:
74 | IXMLDOMDocument2 * m_pXMLDoc;
75 | };
76 |
--------------------------------------------------------------------------------
/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 | public:
11 | CButtonUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 | UINT GetControlFlags() const;
16 |
17 | bool Activate();
18 | void SetEnabled(bool bEnable = true);
19 | void DoEvent(TEventUI& event);
20 |
21 | LPCTSTR GetNormalImage();
22 | void SetNormalImage(LPCTSTR pStrImage);
23 | LPCTSTR GetHotImage();
24 | void SetHotImage(LPCTSTR pStrImage);
25 | LPCTSTR GetPushedImage();
26 | void SetPushedImage(LPCTSTR pStrImage);
27 | LPCTSTR GetFocusedImage();
28 | void SetFocusedImage(LPCTSTR pStrImage);
29 | LPCTSTR GetDisabledImage();
30 | void SetDisabledImage(LPCTSTR pStrImage);
31 | LPCTSTR GetForeImage();
32 | void SetForeImage(LPCTSTR pStrImage);
33 | LPCTSTR GetHotForeImage();
34 | void SetHotForeImage(LPCTSTR pStrImage);
35 |
36 | void SetHotBkColor(DWORD dwColor);
37 | DWORD GetHotBkColor() const;
38 | void SetHotTextColor(DWORD dwColor);
39 | DWORD GetHotTextColor() const;
40 | void SetPushedTextColor(DWORD dwColor);
41 | DWORD GetPushedTextColor() const;
42 | void SetFocusedTextColor(DWORD dwColor);
43 | DWORD GetFocusedTextColor() const;
44 | SIZE EstimateSize(SIZE szAvailable);
45 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
46 |
47 | void PaintText(HDC hDC);
48 | void PaintStatusImage(HDC hDC);
49 |
50 | protected:
51 | UINT m_uButtonState;
52 |
53 | DWORD m_dwHotBkColor;
54 | DWORD m_dwHotTextColor;
55 | DWORD m_dwPushedTextColor;
56 | DWORD m_dwFocusedTextColor;
57 |
58 | CDuiString m_sNormalImage;
59 | CDuiString m_sHotImage;
60 | CDuiString m_sHotForeImage;
61 | CDuiString m_sPushedImage;
62 | CDuiString m_sPushedForeImage;
63 | CDuiString m_sFocusedImage;
64 | CDuiString m_sDisabledImage;
65 | };
66 |
67 | } // namespace DuiLib
68 |
69 | #endif // __UIBUTTON_H__
--------------------------------------------------------------------------------
/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 | friend class CActiveXCtrl;
31 | public:
32 | CActiveXUI();
33 | virtual ~CActiveXUI();
34 |
35 | LPCTSTR GetClass() const;
36 | LPVOID GetInterface(LPCTSTR pstrName);
37 |
38 | HWND GetHostWindow() const;
39 |
40 | bool IsDelayCreate() const;
41 | void SetDelayCreate(bool bDelayCreate = true);
42 |
43 | bool CreateControl(const CLSID clsid);
44 | bool CreateControl(LPCTSTR pstrCLSID);
45 | HRESULT GetControl(const IID iid, LPVOID* ppRet);
46 | CLSID GetClisd() const;
47 | CDuiString GetModuleName() const;
48 | void SetModuleName(LPCTSTR pstrText);
49 |
50 | void SetVisible(bool bVisible = true);
51 | void SetInternVisible(bool bVisible = true);
52 | void SetPos(RECT rc);
53 | void DoPaint(HDC hDC, const RECT& rcPaint);
54 |
55 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
56 |
57 | LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
58 |
59 | protected:
60 | virtual void ReleaseControl();
61 | virtual bool DoCreateControl();
62 |
63 | protected:
64 | CLSID m_clsid;
65 | CDuiString m_sModuleName;
66 | bool m_bCreated;
67 | bool m_bDelayCreate;
68 | IOleObject* m_pUnk;
69 | CActiveXCtrl* m_pControl;
70 | HWND m_hwndHost;
71 | };
72 |
73 | } // namespace DuiLib
74 |
75 | #endif // __UIACTIVEX_H__
76 |
--------------------------------------------------------------------------------
/DuiLib/Control/UIEdit.h:
--------------------------------------------------------------------------------
1 | #ifndef __UIEDIT_H__
2 | #define __UIEDIT_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class CEditWnd;
9 |
10 | class UILIB_API CEditUI : public CLabelUI
11 | {
12 | friend class CEditWnd;
13 | public:
14 | CEditUI();
15 |
16 | LPCTSTR GetClass() const;
17 | LPVOID GetInterface(LPCTSTR pstrName);
18 | UINT GetControlFlags() const;
19 |
20 | void SetEnabled(bool bEnable = true);
21 | void SetText(LPCTSTR pstrText);
22 | void SetMaxChar(UINT uMax);
23 | UINT GetMaxChar();
24 | void SetReadOnly(bool bReadOnly);
25 | bool IsReadOnly() const;
26 | void SetPasswordMode(bool bPasswordMode);
27 | bool IsPasswordMode() const;
28 | void SetPasswordChar(TCHAR cPasswordChar);
29 | TCHAR GetPasswordChar() const;
30 | void SetNumberOnly(bool bNumberOnly);
31 | bool IsNumberOnly() const;
32 | int GetWindowStyls() const;
33 |
34 | LPCTSTR GetNormalImage();
35 | void SetNormalImage(LPCTSTR pStrImage);
36 | LPCTSTR GetHotImage();
37 | void SetHotImage(LPCTSTR pStrImage);
38 | LPCTSTR GetFocusedImage();
39 | void SetFocusedImage(LPCTSTR pStrImage);
40 | LPCTSTR GetDisabledImage();
41 | void SetDisabledImage(LPCTSTR pStrImage);
42 | void SetNativeEditBkColor(DWORD dwBkColor);
43 | DWORD GetNativeEditBkColor() const;
44 |
45 | void SetSel(long nStartChar, long nEndChar);
46 | void SetSelAll();
47 | void SetReplaceSel(LPCTSTR lpszReplace);
48 |
49 | void SetPos(RECT rc);
50 | void SetVisible(bool bVisible = true);
51 | void SetInternVisible(bool bVisible = true);
52 | SIZE EstimateSize(SIZE szAvailable);
53 | void DoEvent(TEventUI& event);
54 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
55 |
56 | void PaintStatusImage(HDC hDC);
57 | void PaintText(HDC hDC);
58 |
59 | protected:
60 | CEditWnd* m_pWindow;
61 |
62 | UINT m_uMaxChar;
63 | bool m_bReadOnly;
64 | bool m_bPasswordMode;
65 | TCHAR m_cPasswordChar;
66 | UINT m_uButtonState;
67 | CDuiString m_sNormalImage;
68 | CDuiString m_sHotImage;
69 | CDuiString m_sFocusedImage;
70 | CDuiString m_sDisabledImage;
71 | DWORD m_dwEditbkColor;
72 | int m_iWindowStyls;
73 | };
74 | }
75 | #endif // __UIEDIT_H__
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/Update/Update.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
6 | h;hpp;hxx;hm;inl;inc;xsd
7 |
8 |
9 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
10 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
11 |
12 |
13 | {86523fe0-20d7-403e-a79a-3a1213362f0b}
14 |
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 |
64 |
65 | 源文件
66 |
67 |
68 |
69 |
70 | 资源文件
71 |
72 |
73 |
74 |
75 |
76 | 资源文件
77 |
78 |
79 | 资源文件
80 |
81 |
82 | 资源文件
83 |
84 |
85 |
--------------------------------------------------------------------------------
/Update.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Update", "Update\Update.vcxproj", "{875C0529-82C5-4685-A59A-6F822225A29A}"
5 | ProjectSection(ProjectDependencies) = postProject
6 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}
7 | {B65D4BD8-A59B-496C-8779-41968858255D} = {B65D4BD8-A59B-496C-8779-41968858255D}
8 | EndProjectSection
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HtttpDownload", "HtttpDownload\HtttpDownload.vcxproj", "{B65D4BD8-A59B-496C-8779-41968858255D}"
11 | EndProject
12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DuiLib", "DuiLib\DuiLib.vcxproj", "{E106ACD7-4E53-4AEE-942B-D0DD426DB34E}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Win32 = Debug|Win32
17 | Release|Win32 = Release|Win32
18 | UnicodeDebug|Win32 = UnicodeDebug|Win32
19 | UnicodeRelease|Win32 = UnicodeRelease|Win32
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {875C0529-82C5-4685-A59A-6F822225A29A}.Debug|Win32.ActiveCfg = Debug|Win32
23 | {875C0529-82C5-4685-A59A-6F822225A29A}.Debug|Win32.Build.0 = Debug|Win32
24 | {875C0529-82C5-4685-A59A-6F822225A29A}.Release|Win32.ActiveCfg = Release|Win32
25 | {875C0529-82C5-4685-A59A-6F822225A29A}.Release|Win32.Build.0 = Release|Win32
26 | {875C0529-82C5-4685-A59A-6F822225A29A}.UnicodeDebug|Win32.ActiveCfg = Debug|Win32
27 | {875C0529-82C5-4685-A59A-6F822225A29A}.UnicodeDebug|Win32.Build.0 = Debug|Win32
28 | {875C0529-82C5-4685-A59A-6F822225A29A}.UnicodeRelease|Win32.ActiveCfg = Release|Win32
29 | {875C0529-82C5-4685-A59A-6F822225A29A}.UnicodeRelease|Win32.Build.0 = Release|Win32
30 | {B65D4BD8-A59B-496C-8779-41968858255D}.Debug|Win32.ActiveCfg = Debug|Win32
31 | {B65D4BD8-A59B-496C-8779-41968858255D}.Debug|Win32.Build.0 = Debug|Win32
32 | {B65D4BD8-A59B-496C-8779-41968858255D}.Release|Win32.ActiveCfg = Release|Win32
33 | {B65D4BD8-A59B-496C-8779-41968858255D}.Release|Win32.Build.0 = Release|Win32
34 | {B65D4BD8-A59B-496C-8779-41968858255D}.UnicodeDebug|Win32.ActiveCfg = Debug|Win32
35 | {B65D4BD8-A59B-496C-8779-41968858255D}.UnicodeDebug|Win32.Build.0 = Debug|Win32
36 | {B65D4BD8-A59B-496C-8779-41968858255D}.UnicodeRelease|Win32.ActiveCfg = Release|Win32
37 | {B65D4BD8-A59B-496C-8779-41968858255D}.UnicodeRelease|Win32.Build.0 = Release|Win32
38 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.ActiveCfg = UnicodeDebug|Win32
39 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Debug|Win32.Build.0 = UnicodeDebug|Win32
40 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.ActiveCfg = UnicodeRelease|Win32
41 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.Release|Win32.Build.0 = UnicodeRelease|Win32
42 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|Win32.ActiveCfg = UnicodeDebug|Win32
43 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeDebug|Win32.Build.0 = UnicodeDebug|Win32
44 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|Win32.ActiveCfg = UnicodeRelease|Win32
45 | {E106ACD7-4E53-4AEE-942B-D0DD426DB34E}.UnicodeRelease|Win32.Build.0 = UnicodeRelease|Win32
46 | EndGlobalSection
47 | GlobalSection(SolutionProperties) = preSolution
48 | HideSolutionNode = FALSE
49 | EndGlobalSection
50 | EndGlobal
51 |
--------------------------------------------------------------------------------
/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/Control/UILabel.h:
--------------------------------------------------------------------------------
1 | #ifndef __UILABEL_H__
2 | #define __UILABEL_H__
3 |
4 | #pragma once
5 |
6 | #include
7 | #pragma comment( lib, "GdiPlus.lib" )
8 | using namespace Gdiplus;
9 | class UILIB_API Gdiplus::RectF;
10 | struct UILIB_API Gdiplus::GdiplusStartupInput;
11 |
12 | namespace DuiLib
13 | {
14 | class UILIB_API CLabelUI : public CControlUI
15 | {
16 | public:
17 | CLabelUI();
18 | ~CLabelUI();
19 |
20 | LPCTSTR GetClass() const;
21 | LPVOID GetInterface(LPCTSTR pstrName);
22 |
23 | void SetTextStyle(UINT uStyle);
24 | UINT GetTextStyle() const;
25 | void SetTextColor(DWORD dwTextColor);
26 | DWORD GetTextColor() const;
27 | void SetDisabledTextColor(DWORD dwTextColor);
28 | DWORD GetDisabledTextColor() const;
29 | void SetFont(int index);
30 | int GetFont() const;
31 | RECT GetTextPadding() const;
32 | void SetTextPadding(RECT rc);
33 | bool IsShowHtml();
34 | void SetShowHtml(bool bShowHtml = true);
35 |
36 | SIZE EstimateSize(SIZE szAvailable);
37 | void DoEvent(TEventUI& event);
38 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
39 |
40 | void PaintText(HDC hDC);
41 |
42 | void SetEnabledEffect(bool _EnabledEffect);
43 | bool GetEnabledEffect();
44 | void SetText(LPCTSTR pstrText);
45 | CDuiString GetText() const;
46 | void SetTransShadow(int _TransShadow);
47 | int GetTransShadow();
48 | void SetTransShadow1(int _TransShadow);
49 | int GetTransShadow1();
50 | void SetTransText(int _TransText);
51 | int GetTransText();
52 | void SetTransText1(int _TransText);
53 | int GetTransText1();
54 | void SetTransStroke(int _TransStroke);
55 | int GetTransStroke();
56 | void SetGradientLength(int _GradientLength);
57 | int GetGradientLength();
58 | void SetTextRenderingHintAntiAlias(int _TextRenderingHintAntiAlias);
59 | int GetTextRenderingHintAntiAlias();
60 | void SetShadowOffset(int _offset,int _angle);
61 | RectF GetShadowOffset();
62 | void SetTextColor1(DWORD _TextColor1);
63 | DWORD GetTextColor1();
64 | void SetTextShadowColorA(DWORD _TextShadowColorA);
65 | DWORD GetTextShadowColorA();
66 | void SetTextShadowColorB(DWORD _TextShadowColorB);
67 | DWORD GetTextShadowColorB();
68 | void SetStrokeColor(DWORD _StrokeColor);
69 | DWORD GetStrokeColor();
70 | void SetGradientAngle(int _SetGradientAngle);
71 | int GetGradientAngle();
72 | void SetEnabledStroke(bool _EnabledStroke);
73 | bool GetEnabledStroke();
74 | void SetEnabledShadow(bool _EnabledShadowe);
75 | bool GetEnabledShadow();
76 |
77 | protected:
78 | DWORD m_dwTextColor;
79 | DWORD m_dwDisabledTextColor;
80 | int m_iFont;
81 | UINT m_uTextStyle;
82 | RECT m_rcTextPadding;
83 | bool m_bShowHtml;
84 |
85 | int m_hAlign;
86 | int m_vAlign;
87 | int m_TransShadow;
88 | int m_TransShadow1;
89 | int m_TransText;
90 | int m_TransText1;
91 | int m_TransStroke;
92 | int m_GradientLength;
93 | int m_GradientAngle;
94 | bool m_EnableEffect;
95 | bool m_EnabledStroke;
96 | bool m_EnabledShadow;
97 | DWORD m_dwTextColor1;
98 | DWORD m_dwTextShadowColorA;
99 | DWORD m_dwTextShadowColorB;
100 | DWORD m_dwStrokeColor;
101 | RectF m_ShadowOffset;
102 | CDuiString m_TextValue;
103 | ULONG_PTR m_gdiplusToken;
104 | GdiplusStartupInput m_gdiplusStartupInput;
105 | TextRenderingHint m_TextRenderingHintAntiAlias;
106 | };
107 | }
108 |
109 | #endif // __UILABEL_H__
--------------------------------------------------------------------------------
/DuiLib/Control/UIComboBox.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIComboBox.h"
3 |
4 | namespace DuiLib
5 | {
6 | CComboBoxUI::CComboBoxUI()
7 | {
8 | m_nArrowWidth = 0;
9 | }
10 |
11 | LPCTSTR CComboBoxUI::GetClass() const
12 | {
13 | return _T("ComboBoxUI");
14 | }
15 |
16 | void CComboBoxUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
17 | {
18 | if (_tcscmp(pstrName, _T("arrowimage")) == 0)
19 | m_sArrowImage = pstrValue;
20 | else
21 | CComboUI::SetAttribute(pstrName, pstrValue);
22 | }
23 |
24 | void CComboBoxUI::PaintStatusImage(HDC hDC)
25 | {
26 | if (m_sArrowImage.IsEmpty())
27 | CComboUI::PaintStatusImage(hDC);
28 | else
29 | {
30 | // get index
31 | if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED;
32 | else m_uButtonState &= ~ UISTATE_FOCUSED;
33 | if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED;
34 | else m_uButtonState &= ~ UISTATE_DISABLED;
35 |
36 | int nIndex = 0;
37 | if ((m_uButtonState & UISTATE_DISABLED) != 0)
38 | nIndex = 4;
39 | else if ((m_uButtonState & UISTATE_PUSHED) != 0)
40 | nIndex = 2;
41 | else if ((m_uButtonState & UISTATE_HOT) != 0)
42 | nIndex = 1;
43 | else if ((m_uButtonState & UISTATE_FOCUSED) != 0)
44 | nIndex = 3;
45 |
46 | // make modify string
47 | CDuiString sModify = m_sArrowImage;
48 |
49 | int nPos1 = sModify.Find(_T("source"));
50 | int nPos2 = sModify.Find(_T("'"), nPos1 + 7);
51 | if (nPos2 == -1) return; //first
52 | int nPos3 = sModify.Find(_T("'"), nPos2 + 1);
53 | if (nPos3 == -1) return; //second
54 |
55 | CDuiRect rcBmpPart;
56 | LPTSTR lpszValue = NULL;
57 | rcBmpPart.left = _tcstol(sModify.GetData() + nPos2 + 1, &lpszValue, 10); ASSERT(lpszValue);
58 | rcBmpPart.top = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue);
59 | rcBmpPart.right = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue);
60 | rcBmpPart.bottom = _tcstol(lpszValue + 1, &lpszValue, 10); ASSERT(lpszValue);
61 |
62 | m_nArrowWidth = rcBmpPart.GetWidth() / 5;
63 | rcBmpPart.left += nIndex * m_nArrowWidth;
64 | rcBmpPart.right = rcBmpPart.left + m_nArrowWidth;
65 |
66 | CDuiRect rcDest(0, 0, m_rcItem.right - m_rcItem.left, m_rcItem.bottom - m_rcItem.top);
67 | rcDest.Deflate(GetBorderSize(), GetBorderSize());
68 | rcDest.left = rcDest.right - m_nArrowWidth;
69 |
70 | CDuiString sSource = sModify.Mid(nPos1, nPos3 + 1 - nPos1);
71 | CDuiString sReplace;
72 | sReplace.SmallFormat(_T("source='%d,%d,%d,%d' dest='%d,%d,%d,%d'"),
73 | rcBmpPart.left, rcBmpPart.top, rcBmpPart.right, rcBmpPart.bottom,
74 | rcDest.left, rcDest.top, rcDest.right, rcDest.bottom);
75 |
76 | sModify.Replace(sSource, sReplace);
77 |
78 | // draw image
79 | if (!DrawImage(hDC, m_sArrowImage, sModify))
80 | m_sNormalImage.Empty();
81 | }
82 | }
83 |
84 | void CComboBoxUI::PaintText(HDC hDC)
85 | {
86 | RECT rcText = m_rcItem;
87 | rcText.left += m_rcTextPadding.left;
88 | rcText.right -= m_rcTextPadding.right;
89 | rcText.top += m_rcTextPadding.top;
90 | rcText.bottom -= m_rcTextPadding.bottom;
91 |
92 | rcText.right -= m_nArrowWidth; // add this line than CComboUI::PaintText(HDC hDC)
93 |
94 | if( m_iCurSel >= 0 ) {
95 | CControlUI* pControl = static_cast(m_items[m_iCurSel]);
96 | IListItemUI* pElement = static_cast(pControl->GetInterface(_T("ListItem")));
97 | if( pElement != NULL ) {
98 | pElement->DrawItemText(hDC, rcText);
99 | }
100 | else {
101 | RECT rcOldPos = pControl->GetPos();
102 | pControl->SetPos(rcText);
103 | pControl->DoPaint(hDC, rcText);
104 | pControl->SetPos(rcOldPos);
105 | }
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/DuiLib/Control/UIProgress.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIProgress.h"
3 |
4 | namespace DuiLib
5 | {
6 | CProgressUI::CProgressUI() : m_bHorizontal(true), m_nMin(0), m_nMax(100), m_nValue(0), m_bStretchForeImage(true)
7 | {
8 | m_uTextStyle = DT_SINGLELINE | DT_CENTER;
9 | SetFixedHeight(12);
10 | }
11 |
12 | LPCTSTR CProgressUI::GetClass() const
13 | {
14 | return _T("ProgressUI");
15 | }
16 |
17 | LPVOID CProgressUI::GetInterface(LPCTSTR pstrName)
18 | {
19 | if( _tcscmp(pstrName, DUI_CTR_PROGRESS) == 0 ) return static_cast(this);
20 | return CLabelUI::GetInterface(pstrName);
21 | }
22 |
23 | bool CProgressUI::IsHorizontal()
24 | {
25 | return m_bHorizontal;
26 | }
27 |
28 | void CProgressUI::SetHorizontal(bool bHorizontal)
29 | {
30 | if( m_bHorizontal == bHorizontal ) return;
31 |
32 | m_bHorizontal = bHorizontal;
33 | Invalidate();
34 | }
35 |
36 | int CProgressUI::GetMinValue() const
37 | {
38 | return m_nMin;
39 | }
40 |
41 | void CProgressUI::SetMinValue(int nMin)
42 | {
43 | m_nMin = nMin;
44 | Invalidate();
45 | }
46 |
47 | int CProgressUI::GetMaxValue() const
48 | {
49 | return m_nMax;
50 | }
51 |
52 | void CProgressUI::SetMaxValue(int nMax)
53 | {
54 | m_nMax = nMax;
55 | Invalidate();
56 | }
57 |
58 | int CProgressUI::GetValue() const
59 | {
60 | return m_nValue;
61 | }
62 |
63 | void CProgressUI::SetValue(int nValue)
64 | {
65 | if(nValue == m_nValue || nValue m_nMax)
66 | {
67 | return;
68 | }
69 | m_nValue = nValue;
70 | Invalidate();
71 | }
72 |
73 | LPCTSTR CProgressUI::GetForeImage() const
74 | {
75 | return m_sForeImage;
76 | }
77 |
78 | void CProgressUI::SetForeImage(LPCTSTR pStrImage)
79 | {
80 | if( m_sForeImage == pStrImage ) return;
81 |
82 | m_sForeImage = pStrImage;
83 | Invalidate();
84 | }
85 |
86 | void CProgressUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
87 | {
88 | if( _tcscmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue);
89 | else if( _tcscmp(pstrName, _T("hor")) == 0 ) SetHorizontal(_tcscmp(pstrValue, _T("true")) == 0);
90 | else if( _tcscmp(pstrName, _T("min")) == 0 ) SetMinValue(_ttoi(pstrValue));
91 | else if( _tcscmp(pstrName, _T("max")) == 0 ) SetMaxValue(_ttoi(pstrValue));
92 | else if( _tcscmp(pstrName, _T("value")) == 0 ) SetValue(_ttoi(pstrValue));
93 | else if( _tcscmp(pstrName, _T("isstretchfore"))==0) SetStretchForeImage(_tcscmp(pstrValue, _T("true")) == 0? true : false);
94 | else CLabelUI::SetAttribute(pstrName, pstrValue);
95 | }
96 |
97 | void CProgressUI::PaintStatusImage(HDC hDC)
98 | {
99 | if( m_nMax <= m_nMin ) m_nMax = m_nMin + 1;
100 | if( m_nValue > m_nMax ) m_nValue = m_nMax;
101 | if( m_nValue < m_nMin ) m_nValue = m_nMin;
102 |
103 | RECT rc = {0};
104 | if( m_bHorizontal ) {
105 | rc.right = (m_nValue - m_nMin) * (m_rcItem.right - m_rcItem.left) / (m_nMax - m_nMin);
106 | rc.bottom = m_rcItem.bottom - m_rcItem.top;
107 | }
108 | else {
109 | rc.top = (m_rcItem.bottom - m_rcItem.top) * (m_nMax - m_nValue) / (m_nMax - m_nMin);
110 | rc.right = m_rcItem.right - m_rcItem.left;
111 | rc.bottom = m_rcItem.bottom - m_rcItem.top;
112 | }
113 |
114 | if( !m_sForeImage.IsEmpty() ) {
115 | m_sForeImageModify.Empty();
116 | if (m_bStretchForeImage)
117 | m_sForeImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rc.left, rc.top, rc.right, rc.bottom);
118 | else
119 | m_sForeImageModify.SmallFormat(_T("dest='%d,%d,%d,%d' source='%d,%d,%d,%d'")
120 | , rc.left, rc.top, rc.right, rc.bottom
121 | , rc.left, rc.top, rc.right, rc.bottom);
122 |
123 | if( !DrawImage(hDC, (LPCTSTR)m_sForeImage, (LPCTSTR)m_sForeImageModify) ) m_sForeImage.Empty();
124 | else return;
125 | }
126 | }
127 |
128 | bool CProgressUI::IsStretchForeImage()
129 | {
130 | return m_bStretchForeImage;
131 | }
132 |
133 | void CProgressUI::SetStretchForeImage( bool bStretchForeImage /*= true*/ )
134 | {
135 | if (m_bStretchForeImage==bStretchForeImage) return;
136 | m_bStretchForeImage=bStretchForeImage;
137 | Invalidate();
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/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 | friend class CComboWnd;
15 | public:
16 | CComboUI();
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 | CComboWnd* 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 DuiLib
121 |
122 | #endif // __UICOMBO_H__
123 |
--------------------------------------------------------------------------------
/DuiLib/UIlib.h:
--------------------------------------------------------------------------------
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 | // #if defined(UILIB_EXPORTS)
31 | // #if defined(_MSC_VER)
32 | // #define UILIB_API __declspec(dllexport)
33 | // #else
34 | // #define UILIB_API
35 | // #endif
36 | // #else
37 | // #if defined(_MSC_VER)
38 | // #define UILIB_API __declspec(dllimport)
39 | // #else
40 | // #define UILIB_API
41 | // #endif
42 | // #endif
43 | #define UILIB_API
44 | #define UILIB_COMDAT __declspec(selectany)
45 |
46 | #if defined _M_IX86
47 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
48 | #elif defined _M_IA64
49 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
50 | #elif defined _M_X64
51 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
52 | #else
53 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
54 | #endif
55 |
56 | #include
57 | #include
58 | #include
59 | #include
60 | #include
61 | #include
62 | #include
63 | #include
64 | #include
65 |
66 | #include "Utils/Utils.h"
67 | #include "Utils/UIDelegate.h"
68 | #include "Core/UIDefine.h"
69 | #include "Core/UIManager.h"
70 | #include "Core/UIBase.h"
71 | #include "Core/UIControl.h"
72 | #include "Core/UIContainer.h"
73 | #include "Core/UIMarkup.h"
74 | #include "Core/UIDlgBuilder.h"
75 | #include "Core/UIRender.h"
76 | #include "Utils/WinImplBase.h"
77 |
78 | #include "Layout/UIVerticalLayout.h"
79 | #include "Layout/UIHorizontalLayout.h"
80 | #include "Layout/UITileLayout.h"
81 | #include "Layout/UITabLayout.h"
82 | #include "Layout/UIChildLayout.h"
83 |
84 | #include "Control/UIList.h"
85 | #include "Control/UICombo.h"
86 | #include "Control/UIScrollBar.h"
87 | #include "Control/UITreeView.h"
88 |
89 | #include "Control/UILabel.h"
90 | #include "Control/UIText.h"
91 | #include "Control/UIEdit.h"
92 |
93 | #include "Control/UIButton.h"
94 | #include "Control/UIOption.h"
95 | #include "Control/UICheckBox.h"
96 |
97 | #include "Control/UIProgress.h"
98 | #include "Control/UISlider.h"
99 |
100 | #include "Control/UIComboBox.h"
101 | #include "Control/UIRichEdit.h"
102 | #include "Control/UIDateTime.h"
103 |
104 | #include "Control/UIActiveX.h"
105 | #include "Control/UIWebBrowser.h"
106 | #include "Control/UIFlash.h"
107 |
108 | #pragma comment(lib,"oledlg.lib")
109 | #pragma comment(lib,"winmm.lib")
110 | #pragma comment(lib,"comctl32.lib")
111 | #pragma comment(lib,"Riched20.lib")
--------------------------------------------------------------------------------
/DuiLib/Control/UIScrollBar.h:
--------------------------------------------------------------------------------
1 | #ifndef __UISCROLLBAR_H__
2 | #define __UISCROLLBAR_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | class UILIB_API CScrollBarUI : public CControlUI
9 | {
10 | public:
11 | CScrollBarUI();
12 |
13 | LPCTSTR GetClass() const;
14 | LPVOID GetInterface(LPCTSTR pstrName);
15 |
16 | CContainerUI* GetOwner() const;
17 | void SetOwner(CContainerUI* pOwner);
18 |
19 | void SetVisible(bool bVisible = true);
20 | void SetEnabled(bool bEnable = true);
21 | void SetFocus();
22 |
23 | bool IsHorizontal();
24 | void SetHorizontal(bool bHorizontal = true);
25 | int GetScrollRange() const;
26 | void SetScrollRange(int nRange);
27 | int GetScrollPos() const;
28 | void SetScrollPos(int nPos);
29 | int GetLineSize() const;
30 | void SetLineSize(int nSize);
31 |
32 | bool GetShowButton1();
33 | void SetShowButton1(bool bShow);
34 | LPCTSTR GetButton1NormalImage();
35 | void SetButton1NormalImage(LPCTSTR pStrImage);
36 | LPCTSTR GetButton1HotImage();
37 | void SetButton1HotImage(LPCTSTR pStrImage);
38 | LPCTSTR GetButton1PushedImage();
39 | void SetButton1PushedImage(LPCTSTR pStrImage);
40 | LPCTSTR GetButton1DisabledImage();
41 | void SetButton1DisabledImage(LPCTSTR pStrImage);
42 |
43 | bool GetShowButton2();
44 | void SetShowButton2(bool bShow);
45 | LPCTSTR GetButton2NormalImage();
46 | void SetButton2NormalImage(LPCTSTR pStrImage);
47 | LPCTSTR GetButton2HotImage();
48 | void SetButton2HotImage(LPCTSTR pStrImage);
49 | LPCTSTR GetButton2PushedImage();
50 | void SetButton2PushedImage(LPCTSTR pStrImage);
51 | LPCTSTR GetButton2DisabledImage();
52 | void SetButton2DisabledImage(LPCTSTR pStrImage);
53 |
54 | LPCTSTR GetThumbNormalImage();
55 | void SetThumbNormalImage(LPCTSTR pStrImage);
56 | LPCTSTR GetThumbHotImage();
57 | void SetThumbHotImage(LPCTSTR pStrImage);
58 | LPCTSTR GetThumbPushedImage();
59 | void SetThumbPushedImage(LPCTSTR pStrImage);
60 | LPCTSTR GetThumbDisabledImage();
61 | void SetThumbDisabledImage(LPCTSTR pStrImage);
62 |
63 | LPCTSTR GetRailNormalImage();
64 | void SetRailNormalImage(LPCTSTR pStrImage);
65 | LPCTSTR GetRailHotImage();
66 | void SetRailHotImage(LPCTSTR pStrImage);
67 | LPCTSTR GetRailPushedImage();
68 | void SetRailPushedImage(LPCTSTR pStrImage);
69 | LPCTSTR GetRailDisabledImage();
70 | void SetRailDisabledImage(LPCTSTR pStrImage);
71 |
72 | LPCTSTR GetBkNormalImage();
73 | void SetBkNormalImage(LPCTSTR pStrImage);
74 | LPCTSTR GetBkHotImage();
75 | void SetBkHotImage(LPCTSTR pStrImage);
76 | LPCTSTR GetBkPushedImage();
77 | void SetBkPushedImage(LPCTSTR pStrImage);
78 | LPCTSTR GetBkDisabledImage();
79 | void SetBkDisabledImage(LPCTSTR pStrImage);
80 |
81 | void SetPos(RECT rc);
82 | void DoEvent(TEventUI& event);
83 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
84 |
85 | void DoPaint(HDC hDC, const RECT& rcPaint);
86 |
87 | void PaintBk(HDC hDC);
88 | void PaintButton1(HDC hDC);
89 | void PaintButton2(HDC hDC);
90 | void PaintThumb(HDC hDC);
91 | void PaintRail(HDC hDC);
92 |
93 | protected:
94 |
95 | enum
96 | {
97 | DEFAULT_SCROLLBAR_SIZE = 16,
98 | DEFAULT_TIMERID = 10,
99 | };
100 |
101 | bool m_bHorizontal;
102 | int m_nRange;
103 | int m_nScrollPos;
104 | int m_nLineSize;
105 | CContainerUI* m_pOwner;
106 | POINT ptLastMouse;
107 | int m_nLastScrollPos;
108 | int m_nLastScrollOffset;
109 | int m_nScrollRepeatDelay;
110 |
111 | CDuiString m_sBkNormalImage;
112 | CDuiString m_sBkHotImage;
113 | CDuiString m_sBkPushedImage;
114 | CDuiString m_sBkDisabledImage;
115 |
116 | bool m_bShowButton1;
117 | RECT m_rcButton1;
118 | UINT m_uButton1State;
119 | CDuiString m_sButton1NormalImage;
120 | CDuiString m_sButton1HotImage;
121 | CDuiString m_sButton1PushedImage;
122 | CDuiString m_sButton1DisabledImage;
123 |
124 | bool m_bShowButton2;
125 | RECT m_rcButton2;
126 | UINT m_uButton2State;
127 | CDuiString m_sButton2NormalImage;
128 | CDuiString m_sButton2HotImage;
129 | CDuiString m_sButton2PushedImage;
130 | CDuiString m_sButton2DisabledImage;
131 |
132 | RECT m_rcThumb;
133 | UINT m_uThumbState;
134 | CDuiString m_sThumbNormalImage;
135 | CDuiString m_sThumbHotImage;
136 | CDuiString m_sThumbPushedImage;
137 | CDuiString m_sThumbDisabledImage;
138 |
139 | CDuiString m_sRailNormalImage;
140 | CDuiString m_sRailHotImage;
141 | CDuiString m_sRailPushedImage;
142 | CDuiString m_sRailDisabledImage;
143 |
144 | CDuiString m_sImageModify;
145 | };
146 | }
147 |
148 | #endif // __UISCROLLBAR_H__
--------------------------------------------------------------------------------
/DuiLib/Layout/UITabLayout.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UITabLayout.h"
3 |
4 | namespace DuiLib
5 | {
6 | CTabLayoutUI::CTabLayoutUI() : m_iCurSel(-1)
7 | {
8 | }
9 |
10 | LPCTSTR CTabLayoutUI::GetClass() const
11 | {
12 | return _T("TabLayoutUI");
13 | }
14 |
15 | LPVOID CTabLayoutUI::GetInterface(LPCTSTR pstrName)
16 | {
17 | if( _tcscmp(pstrName, DUI_CTR_TABLAYOUT) == 0 ) return static_cast(this);
18 | return CContainerUI::GetInterface(pstrName);
19 | }
20 |
21 | bool CTabLayoutUI::Add(CControlUI* pControl)
22 | {
23 | bool ret = CContainerUI::Add(pControl);
24 | if( !ret ) return ret;
25 |
26 | if(m_iCurSel == -1 && pControl->IsVisible())
27 | {
28 | m_iCurSel = GetItemIndex(pControl);
29 | }
30 | else
31 | {
32 | pControl->SetVisible(false);
33 | }
34 |
35 | return ret;
36 | }
37 |
38 | bool CTabLayoutUI::AddAt(CControlUI* pControl, int iIndex)
39 | {
40 | bool ret = CContainerUI::AddAt(pControl, iIndex);
41 | if( !ret ) return ret;
42 |
43 | if(m_iCurSel == -1 && pControl->IsVisible())
44 | {
45 | m_iCurSel = GetItemIndex(pControl);
46 | }
47 | else if( m_iCurSel != -1 && iIndex <= m_iCurSel )
48 | {
49 | m_iCurSel += 1;
50 | }
51 | else
52 | {
53 | pControl->SetVisible(false);
54 | }
55 |
56 | return ret;
57 | }
58 |
59 | bool CTabLayoutUI::Remove(CControlUI* pControl)
60 | {
61 | if( pControl == NULL) return false;
62 |
63 | int index = GetItemIndex(pControl);
64 | bool ret = CContainerUI::Remove(pControl);
65 | if( !ret ) return false;
66 |
67 | if( m_iCurSel == index)
68 | {
69 | if( GetCount() > 0 )
70 | {
71 | m_iCurSel=0;
72 | GetItemAt(m_iCurSel)->SetVisible(true);
73 | }
74 | else
75 | m_iCurSel=-1;
76 | NeedParentUpdate();
77 | }
78 | else if( m_iCurSel > index )
79 | {
80 | m_iCurSel -= 1;
81 | }
82 |
83 | return ret;
84 | }
85 |
86 | void CTabLayoutUI::RemoveAll()
87 | {
88 | m_iCurSel = -1;
89 | CContainerUI::RemoveAll();
90 | NeedParentUpdate();
91 | }
92 |
93 | int CTabLayoutUI::GetCurSel() const
94 | {
95 | return m_iCurSel;
96 | }
97 |
98 | bool CTabLayoutUI::SelectItem(int iIndex)
99 | {
100 | if( iIndex < 0 || iIndex >= m_items.GetSize() ) return false;
101 | if( iIndex == m_iCurSel ) return true;
102 |
103 | int iOldSel = m_iCurSel;
104 | m_iCurSel = iIndex;
105 | for( int it = 0; it < m_items.GetSize(); it++ )
106 | {
107 | if( it == iIndex ) {
108 | GetItemAt(it)->SetVisible(true);
109 | GetItemAt(it)->SetFocus();
110 | SetPos(m_rcItem);
111 | }
112 | else GetItemAt(it)->SetVisible(false);
113 | }
114 | NeedParentUpdate();
115 |
116 | if( m_pManager != NULL ) {
117 | m_pManager->SetNextTabControl();
118 | m_pManager->SendNotify(this, DUI_MSGTYPE_TABSELECT, m_iCurSel, iOldSel);
119 | }
120 | return true;
121 | }
122 |
123 | bool CTabLayoutUI::SelectItem( CControlUI* pControl )
124 | {
125 | int iIndex=GetItemIndex(pControl);
126 | if (iIndex==-1)
127 | return false;
128 | else
129 | return SelectItem(iIndex);
130 | }
131 |
132 | void CTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
133 | {
134 | if( _tcscmp(pstrName, _T("selectedid")) == 0 ) SelectItem(_ttoi(pstrValue));
135 | return CContainerUI::SetAttribute(pstrName, pstrValue);
136 | }
137 |
138 | void CTabLayoutUI::SetPos(RECT rc)
139 | {
140 | CControlUI::SetPos(rc);
141 | rc = m_rcItem;
142 |
143 | // Adjust for inset
144 | rc.left += m_rcInset.left;
145 | rc.top += m_rcInset.top;
146 | rc.right -= m_rcInset.right;
147 | rc.bottom -= m_rcInset.bottom;
148 |
149 | for( int it = 0; it < m_items.GetSize(); it++ ) {
150 | CControlUI* pControl = static_cast(m_items[it]);
151 | if( !pControl->IsVisible() ) continue;
152 | if( pControl->IsFloat() ) {
153 | SetFloatPos(it);
154 | continue;
155 | }
156 |
157 | if( it != m_iCurSel ) continue;
158 |
159 | RECT rcPadding = pControl->GetPadding();
160 | rc.left += rcPadding.left;
161 | rc.top += rcPadding.top;
162 | rc.right -= rcPadding.right;
163 | rc.bottom -= rcPadding.bottom;
164 |
165 | SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top };
166 |
167 | SIZE sz = pControl->EstimateSize(szAvailable);
168 | if( sz.cx == 0 ) {
169 | sz.cx = MAX(0, szAvailable.cx);
170 | }
171 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth();
172 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth();
173 |
174 | if(sz.cy == 0) {
175 | sz.cy = MAX(0, szAvailable.cy);
176 | }
177 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight();
178 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
179 |
180 | RECT rcCtrl = { rc.left, rc.top, rc.left + sz.cx, rc.top + sz.cy};
181 | pControl->SetPos(rcCtrl);
182 | }
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/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 | public:
19 | CTreeNodeUI(CTreeNodeUI* _ParentNode = NULL);
20 | ~CTreeNodeUI(void);
21 |
22 | public:
23 | LPCTSTR GetClass() const;
24 | LPVOID GetInterface(LPCTSTR pstrName);
25 | void DoEvent(TEventUI& event);
26 | void Invalidate();
27 | bool Select(bool bSelect = true);
28 |
29 | bool Add(CControlUI* _pTreeNodeUI);
30 | bool AddAt(CControlUI* pControl, int iIndex);
31 | bool Remove(CControlUI* pControl);
32 |
33 | void SetVisibleTag(bool _IsVisible);
34 | bool GetVisibleTag();
35 | void SetItemText(LPCTSTR pstrValue);
36 | CDuiString GetItemText();
37 | void CheckBoxSelected(bool _Selected);
38 | bool IsCheckBoxSelected() const;
39 | bool IsHasChild() const;
40 | long GetTreeLevel() const;
41 | bool AddChildNode(CTreeNodeUI* _pTreeNodeUI);
42 | bool RemoveAt(CTreeNodeUI* _pTreeNodeUI);
43 | void SetParentNode(CTreeNodeUI* _pParentTreeNode);
44 | CTreeNodeUI* GetParentNode();
45 | long GetCountChild();
46 | void SetTreeView(CTreeViewUI* _CTreeViewUI);
47 | CTreeViewUI* GetTreeView();
48 | CTreeNodeUI* GetChildNode(int _nIndex);
49 | void SetVisibleFolderBtn(bool _IsVisibled);
50 | bool GetVisibleFolderBtn();
51 | void SetVisibleCheckBtn(bool _IsVisibled);
52 | bool GetVisibleCheckBtn();
53 | void SetItemTextColor(DWORD _dwItemTextColor);
54 | DWORD GetItemTextColor() const;
55 | void SetItemHotTextColor(DWORD _dwItemHotTextColor);
56 | DWORD GetItemHotTextColor() const;
57 | void SetSelItemTextColor(DWORD _dwSelItemTextColor);
58 | DWORD GetSelItemTextColor() const;
59 | void SetSelItemHotTextColor(DWORD _dwSelHotItemTextColor);
60 | DWORD GetSelItemHotTextColor() const;
61 |
62 | void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
63 |
64 | CStdPtrArray GetTreeNodes();
65 |
66 | int GetTreeIndex();
67 | int GetNodeIndex();
68 |
69 | private:
70 | CTreeNodeUI* GetLastNode();
71 | CTreeNodeUI* CalLocation(CTreeNodeUI* _pTreeNodeUI);
72 | public:
73 | CHorizontalLayoutUI* GetTreeNodeHoriznotal() const {return pHoriz;};
74 | CCheckBoxUI* GetFolderButton() const {return pFolderButton;};
75 | CLabelUI* GetDottedLine() const {return pDottedLine;};
76 | CCheckBoxUI* GetCheckBox() const {return pCheckBox;};
77 | COptionUI* GetItemButton() const {return pItemButton;};
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 |
95 | CTreeNodeUI* pParentTreeNode;
96 |
97 | CStdPtrArray mTreeNodes;
98 | };
99 |
100 | class UILIB_API CTreeViewUI : public CListUI,public INotifyUI
101 | {
102 | public:
103 | CTreeViewUI(void);
104 | ~CTreeViewUI(void);
105 |
106 | public:
107 | virtual LPCTSTR GetClass() const;
108 | virtual LPVOID GetInterface(LPCTSTR pstrName);
109 | virtual bool Add(CTreeNodeUI* pControl );
110 | virtual long AddAt(CTreeNodeUI* pControl, int iIndex );
111 | virtual bool AddAt(CTreeNodeUI* pControl,CTreeNodeUI* _IndexNode);
112 | virtual bool Remove(CTreeNodeUI* pControl);
113 | virtual bool RemoveAt(int iIndex);
114 | virtual void RemoveAll();
115 | virtual bool OnCheckBoxChanged(void* param);
116 | virtual bool OnFolderChanged(void* param);
117 | virtual bool OnDBClickItem(void* param);
118 | virtual bool SetItemCheckBox(bool _Selected,CTreeNodeUI* _TreeNode = NULL);
119 | virtual void SetItemExpand(bool _Expanded,CTreeNodeUI* _TreeNode = NULL);
120 | virtual void Notify(TNotifyUI& msg);
121 | virtual void SetVisibleFolderBtn(bool _IsVisibled);
122 | virtual bool GetVisibleFolderBtn();
123 | virtual void SetVisibleCheckBtn(bool _IsVisibled);
124 | virtual bool GetVisibleCheckBtn();
125 | virtual void SetItemMinWidth(UINT _ItemMinWidth);
126 | virtual UINT GetItemMinWidth();
127 | virtual void SetItemTextColor(DWORD _dwItemTextColor);
128 | virtual void SetItemHotTextColor(DWORD _dwItemHotTextColor);
129 | virtual void SetSelItemTextColor(DWORD _dwSelItemTextColor);
130 | virtual void SetSelItemHotTextColor(DWORD _dwSelHotItemTextColor);
131 |
132 | virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
133 | private:
134 | UINT m_uItemMinWidth;
135 | bool m_bVisibleFolderBtn;
136 | bool m_bVisibleCheckBtn;
137 | };
138 | }
139 |
140 |
141 | #endif // UITreeView_h__
142 |
--------------------------------------------------------------------------------
/DuiLib/Control/UIText.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 | #include "UIText.h"
3 |
4 | namespace DuiLib
5 | {
6 | CTextUI::CTextUI() : m_nLinks(0), m_nHoverLink(-1)
7 | {
8 | m_uTextStyle = DT_WORDBREAK;
9 | m_rcTextPadding.left = 2;
10 | m_rcTextPadding.right = 2;
11 | ::ZeroMemory(m_rcLinks, sizeof(m_rcLinks));
12 | }
13 |
14 | CTextUI::~CTextUI()
15 | {
16 | }
17 |
18 | LPCTSTR CTextUI::GetClass() const
19 | {
20 | return _T("TextUI");
21 | }
22 |
23 | LPVOID CTextUI::GetInterface(LPCTSTR pstrName)
24 | {
25 | if( _tcscmp(pstrName, DUI_CTR_TEXT) == 0 ) return static_cast(this);
26 | return CLabelUI::GetInterface(pstrName);
27 | }
28 |
29 | UINT CTextUI::GetControlFlags() const
30 | {
31 | if( IsEnabled() && m_nLinks > 0 ) return UIFLAG_SETCURSOR;
32 | else return 0;
33 | }
34 |
35 | CDuiString* CTextUI::GetLinkContent(int iIndex)
36 | {
37 | if( iIndex >= 0 && iIndex < m_nLinks ) return &m_sLinks[iIndex];
38 | return NULL;
39 | }
40 |
41 | void CTextUI::DoEvent(TEventUI& event)
42 | {
43 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) {
44 | if( m_pParent != NULL ) m_pParent->DoEvent(event);
45 | else CLabelUI::DoEvent(event);
46 | return;
47 | }
48 |
49 | if( event.Type == UIEVENT_SETCURSOR ) {
50 | for( int i = 0; i < m_nLinks; i++ ) {
51 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) {
52 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
53 | return;
54 | }
55 | }
56 | }
57 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK && IsEnabled() ) {
58 | for( int i = 0; i < m_nLinks; i++ ) {
59 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) {
60 | Invalidate();
61 | return;
62 | }
63 | }
64 | }
65 | if( event.Type == UIEVENT_BUTTONUP && IsEnabled() ) {
66 | for( int i = 0; i < m_nLinks; i++ ) {
67 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) {
68 | m_pManager->SendNotify(this, DUI_MSGTYPE_LINK, i);
69 | return;
70 | }
71 | }
72 | }
73 | if( event.Type == UIEVENT_CONTEXTMENU )
74 | {
75 | return;
76 | }
77 | // When you move over a link
78 | if( m_nLinks > 0 && event.Type == UIEVENT_MOUSEMOVE && IsEnabled() ) {
79 | int nHoverLink = -1;
80 | for( int i = 0; i < m_nLinks; i++ ) {
81 | if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) {
82 | nHoverLink = i;
83 | break;
84 | }
85 | }
86 |
87 | if(m_nHoverLink != nHoverLink) {
88 | m_nHoverLink = nHoverLink;
89 | Invalidate();
90 | return;
91 | }
92 | }
93 | if( event.Type == UIEVENT_MOUSELEAVE ) {
94 | if( m_nLinks > 0 && IsEnabled() ) {
95 | if(m_nHoverLink != -1) {
96 | m_nHoverLink = -1;
97 | Invalidate();
98 | return;
99 | }
100 | }
101 | }
102 |
103 | CLabelUI::DoEvent(event);
104 | }
105 |
106 | SIZE CTextUI::EstimateSize(SIZE szAvailable)
107 | {
108 | RECT rcText = { 0, 0, MAX(szAvailable.cx, m_cxyFixed.cx), 9999 };
109 | rcText.left += m_rcTextPadding.left;
110 | rcText.right -= m_rcTextPadding.right;
111 | if( m_bShowHtml ) {
112 | int nLinks = 0;
113 | CRenderEngine::DrawHtmlText(m_pManager->GetPaintDC(), m_pManager, rcText, m_sText, m_dwTextColor, NULL, NULL, nLinks, DT_CALCRECT | m_uTextStyle);
114 | }
115 | else {
116 | CRenderEngine::DrawText(m_pManager->GetPaintDC(), m_pManager, rcText, m_sText, m_dwTextColor, m_iFont, DT_CALCRECT | m_uTextStyle);
117 | }
118 | SIZE cXY = {rcText.right - rcText.left + m_rcTextPadding.left + m_rcTextPadding.right,
119 | rcText.bottom - rcText.top + m_rcTextPadding.top + m_rcTextPadding.bottom};
120 |
121 | if( m_cxyFixed.cy != 0 ) cXY.cy = m_cxyFixed.cy;
122 | return cXY;
123 | }
124 |
125 | void CTextUI::PaintText(HDC hDC)
126 | {
127 | if( m_sText.IsEmpty() ) {
128 | m_nLinks = 0;
129 | return;
130 | }
131 |
132 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor();
133 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor();
134 |
135 | if( m_sText.IsEmpty() ) return;
136 |
137 | m_nLinks = lengthof(m_rcLinks);
138 | RECT rc = m_rcItem;
139 | rc.left += m_rcTextPadding.left;
140 | rc.right -= m_rcTextPadding.right;
141 | rc.top += m_rcTextPadding.top;
142 | rc.bottom -= m_rcTextPadding.bottom;
143 | if( IsEnabled() ) {
144 | if( m_bShowHtml )
145 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, m_dwTextColor, \
146 | m_rcLinks, m_sLinks, m_nLinks, m_uTextStyle);
147 | else
148 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, m_dwTextColor, \
149 | m_iFont, m_uTextStyle);
150 | }
151 | else {
152 | if( m_bShowHtml )
153 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, m_dwDisabledTextColor, \
154 | m_rcLinks, m_sLinks, m_nLinks, m_uTextStyle);
155 | else
156 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, m_dwDisabledTextColor, \
157 | m_iFont, m_uTextStyle);
158 | }
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/Update/Update.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {875C0529-82C5-4685-A59A-6F822225A29A}
15 | Win32Proj
16 | Update
17 |
18 |
19 |
20 | Application
21 | true
22 | Unicode
23 |
24 |
25 | Application
26 | false
27 | true
28 | Unicode
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | true
42 | ..\lib;$(LibraryPath)
43 | ..\Duilib;$(IncludePath)
44 | $(SolutionDir)$(Configuration)\
45 |
46 |
47 | false
48 | ..\lib;..\bin;$(LibraryPath)
49 | ..\DuiLib;$(IncludePath)
50 |
51 |
52 |
53 |
54 |
55 | Level3
56 | Disabled
57 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
58 | MultiThreadedDebug
59 |
60 |
61 | Windows
62 | true
63 |
64 |
65 |
66 |
67 | Level3
68 |
69 |
70 | MaxSpeed
71 | true
72 | true
73 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
74 | MultiThreaded
75 |
76 |
77 | Windows
78 | true
79 | true
80 | true
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | NotUsing
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/HtttpDownload/HtttpDownload.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {B65D4BD8-A59B-496C-8779-41968858255D}
15 | Win32Proj
16 | HtttpDownload
17 |
18 |
19 |
20 | StaticLibrary
21 | true
22 | MultiByte
23 |
24 |
25 | StaticLibrary
26 | false
27 | true
28 | MultiByte
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | true
42 | $(ProjectName)_d
43 | ../lib
44 |
45 |
46 | false
47 | ../lib
48 | .lib
49 |
50 |
51 |
52 | Use
53 | Level3
54 | Disabled
55 | WIN32;_DEBUG;_WINDOWS;_USRDLL;HTTTPDOWNLOAD_EXPORTS;%(PreprocessorDefinitions)
56 | MultiThreadedDebug
57 |
58 |
59 | Windows
60 | true
61 | HttpDownload.def
62 | D:\imClient\ImClient\Debug\ImClient\HttpDownload_d.dll
63 |
64 |
65 |
66 |
67 | Level3
68 | Use
69 | MaxSpeed
70 | true
71 | true
72 | WIN32;NDEBUG;_WINDOWS;_USRDLL;HTTTPDOWNLOAD_EXPORTS;%(PreprocessorDefinitions)
73 | MultiThreaded
74 |
75 |
76 | Windows
77 | true
78 | true
79 | true
80 | HttpDownload.def
81 | D:\imClient\ImClient\Release\ImClient\HttpDownload.dll
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | false
96 |
97 |
98 | false
99 |
100 |
101 |
102 |
103 |
104 |
105 | Create
106 | Create
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/DuiLib/Layout/UITileLayout.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UITileLayout.h"
3 |
4 | namespace DuiLib
5 | {
6 | CTileLayoutUI::CTileLayoutUI() : m_nColumns(1)
7 | {
8 | m_szItem.cx = m_szItem.cy = 0;
9 | }
10 |
11 | LPCTSTR CTileLayoutUI::GetClass() const
12 | {
13 | return _T("TileLayoutUI");
14 | }
15 |
16 | LPVOID CTileLayoutUI::GetInterface(LPCTSTR pstrName)
17 | {
18 | if( _tcscmp(pstrName, DUI_CTR_TILELAYOUT) == 0 ) return static_cast(this);
19 | return CContainerUI::GetInterface(pstrName);
20 | }
21 |
22 | SIZE CTileLayoutUI::GetItemSize() const
23 | {
24 | return m_szItem;
25 | }
26 |
27 | void CTileLayoutUI::SetItemSize(SIZE szItem)
28 | {
29 | if( m_szItem.cx != szItem.cx || m_szItem.cy != szItem.cy ) {
30 | m_szItem = szItem;
31 | NeedUpdate();
32 | }
33 | }
34 |
35 | int CTileLayoutUI::GetColumns() const
36 | {
37 | return m_nColumns;
38 | }
39 |
40 | void CTileLayoutUI::SetColumns(int nCols)
41 | {
42 | if( nCols <= 0 ) return;
43 | m_nColumns = nCols;
44 | NeedUpdate();
45 | }
46 |
47 | void CTileLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
48 | {
49 | if( _tcscmp(pstrName, _T("itemsize")) == 0 ) {
50 | SIZE szItem = { 0 };
51 | LPTSTR pstr = NULL;
52 | szItem.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr);
53 | szItem.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);
54 | SetItemSize(szItem);
55 | }
56 | else if( _tcscmp(pstrName, _T("columns")) == 0 ) SetColumns(_ttoi(pstrValue));
57 | else CContainerUI::SetAttribute(pstrName, pstrValue);
58 | }
59 |
60 | void CTileLayoutUI::SetPos(RECT rc)
61 | {
62 | CControlUI::SetPos(rc);
63 | rc = m_rcItem;
64 |
65 | // Adjust for inset
66 | rc.left += m_rcInset.left;
67 | rc.top += m_rcInset.top;
68 | rc.right -= m_rcInset.right;
69 | rc.bottom -= m_rcInset.bottom;
70 |
71 | if( m_items.GetSize() == 0) {
72 | ProcessScrollBar(rc, 0, 0);
73 | return;
74 | }
75 |
76 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) rc.right -= m_pVerticalScrollBar->GetFixedWidth();
77 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight();
78 |
79 | // Position the elements
80 | if( m_szItem.cx > 0 ) m_nColumns = (rc.right - rc.left) / m_szItem.cx;
81 | if( m_nColumns == 0 ) m_nColumns = 1;
82 |
83 | int cyNeeded = 0;
84 | int cxWidth = (rc.right - rc.left) / m_nColumns;
85 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() )
86 | cxWidth = (rc.right - rc.left + m_pHorizontalScrollBar->GetScrollRange() ) / m_nColumns; ;
87 |
88 | int cyHeight = 0;
89 | int iCount = 0;
90 | POINT ptTile = { rc.left, rc.top };
91 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) {
92 | ptTile.y -= m_pVerticalScrollBar->GetScrollPos();
93 | }
94 | int iPosX = rc.left;
95 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) {
96 | iPosX -= m_pHorizontalScrollBar->GetScrollPos();
97 | ptTile.x = iPosX;
98 | }
99 | for( int it1 = 0; it1 < m_items.GetSize(); it1++ ) {
100 | CControlUI* pControl = static_cast(m_items[it1]);
101 | if( !pControl->IsVisible() ) continue;
102 | if( pControl->IsFloat() ) {
103 | SetFloatPos(it1);
104 | continue;
105 | }
106 |
107 | // Determine size
108 | RECT rcTile = { ptTile.x, ptTile.y, ptTile.x + cxWidth, ptTile.y };
109 | if( (iCount % m_nColumns) == 0 )
110 | {
111 | int iIndex = iCount;
112 | for( int it2 = it1; it2 < m_items.GetSize(); it2++ ) {
113 | CControlUI* pLineControl = static_cast(m_items[it2]);
114 | if( !pLineControl->IsVisible() ) continue;
115 | if( pLineControl->IsFloat() ) continue;
116 |
117 | RECT rcPadding = pLineControl->GetPadding();
118 | SIZE szAvailable = { rcTile.right - rcTile.left - rcPadding.left - rcPadding.right, 9999 };
119 | if( iIndex == iCount || (iIndex + 1) % m_nColumns == 0 ) {
120 | szAvailable.cx -= m_iChildPadding / 2;
121 | }
122 | else {
123 | szAvailable.cx -= m_iChildPadding;
124 | }
125 |
126 | if( szAvailable.cx < pControl->GetMinWidth() ) szAvailable.cx = pControl->GetMinWidth();
127 | if( szAvailable.cx > pControl->GetMaxWidth() ) szAvailable.cx = pControl->GetMaxWidth();
128 |
129 | SIZE szTile = pLineControl->EstimateSize(szAvailable);
130 | if( szTile.cx < pControl->GetMinWidth() ) szTile.cx = pControl->GetMinWidth();
131 | if( szTile.cx > pControl->GetMaxWidth() ) szTile.cx = pControl->GetMaxWidth();
132 | if( szTile.cy < pControl->GetMinHeight() ) szTile.cy = pControl->GetMinHeight();
133 | if( szTile.cy > pControl->GetMaxHeight() ) szTile.cy = pControl->GetMaxHeight();
134 |
135 | cyHeight = MAX(cyHeight, szTile.cy + rcPadding.top + rcPadding.bottom);
136 | if( (++iIndex % m_nColumns) == 0) break;
137 | }
138 | }
139 |
140 | RECT rcPadding = pControl->GetPadding();
141 |
142 | rcTile.left += rcPadding.left + m_iChildPadding / 2;
143 | rcTile.right -= rcPadding.right + m_iChildPadding / 2;
144 | if( (iCount % m_nColumns) == 0 ) {
145 | rcTile.left -= m_iChildPadding / 2;
146 | }
147 |
148 | if( ( (iCount + 1) % m_nColumns) == 0 ) {
149 | rcTile.right += m_iChildPadding / 2;
150 | }
151 |
152 | // Set position
153 | rcTile.top = ptTile.y + rcPadding.top;
154 | rcTile.bottom = ptTile.y + cyHeight;
155 |
156 | SIZE szAvailable = { rcTile.right - rcTile.left, rcTile.bottom - rcTile.top };
157 | SIZE szTile = pControl->EstimateSize(szAvailable);
158 | if( szTile.cx == 0 ) szTile.cx = szAvailable.cx;
159 | if( szTile.cy == 0 ) szTile.cy = szAvailable.cy;
160 | if( szTile.cx < pControl->GetMinWidth() ) szTile.cx = pControl->GetMinWidth();
161 | if( szTile.cx > pControl->GetMaxWidth() ) szTile.cx = pControl->GetMaxWidth();
162 | if( szTile.cy < pControl->GetMinHeight() ) szTile.cy = pControl->GetMinHeight();
163 | if( szTile.cy > pControl->GetMaxHeight() ) szTile.cy = pControl->GetMaxHeight();
164 | RECT rcPos = {(rcTile.left + rcTile.right - szTile.cx) / 2, (rcTile.top + rcTile.bottom - szTile.cy) / 2,
165 | (rcTile.left + rcTile.right - szTile.cx) / 2 + szTile.cx, (rcTile.top + rcTile.bottom - szTile.cy) / 2 + szTile.cy};
166 | pControl->SetPos(rcPos);
167 |
168 | if( (++iCount % m_nColumns) == 0 ) {
169 | ptTile.x = iPosX;
170 | ptTile.y += cyHeight + m_iChildPadding;
171 | cyHeight = 0;
172 | }
173 | else {
174 | ptTile.x += cxWidth;
175 | }
176 | cyNeeded = rcTile.bottom - rc.top;
177 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) cyNeeded += m_pVerticalScrollBar->GetScrollPos();
178 | }
179 |
180 | // Process the scrollbar
181 | ProcessScrollBar(rc, 0, cyNeeded);
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/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/Utils.h:
--------------------------------------------------------------------------------
1 | #ifndef __UTILS_H__
2 | #define __UTILS_H__
3 |
4 | #pragma once
5 |
6 | namespace DuiLib
7 | {
8 | /////////////////////////////////////////////////////////////////////////////////////
9 | //
10 |
11 | class STRINGorID
12 | {
13 | public:
14 | STRINGorID(LPCTSTR lpString) : m_lpstr(lpString)
15 | { }
16 | STRINGorID(UINT nID) : m_lpstr(MAKEINTRESOURCE(nID))
17 | { }
18 | LPCTSTR m_lpstr;
19 | };
20 |
21 | /////////////////////////////////////////////////////////////////////////////////////
22 | //
23 |
24 | class UILIB_API CPoint : public tagPOINT
25 | {
26 | public:
27 | CPoint();
28 | CPoint(const POINT& src);
29 | CPoint(int x, int y);
30 | CPoint(LPARAM lParam);
31 | };
32 |
33 |
34 | /////////////////////////////////////////////////////////////////////////////////////
35 | //
36 |
37 | class UILIB_API CSize : public tagSIZE
38 | {
39 | public:
40 | CSize();
41 | CSize(const SIZE& src);
42 | CSize(const RECT rc);
43 | CSize(int cx, int cy);
44 | };
45 |
46 |
47 | /////////////////////////////////////////////////////////////////////////////////////
48 | //
49 |
50 | class UILIB_API CDuiRect : public tagRECT
51 | {
52 | public:
53 | CDuiRect();
54 | CDuiRect(const RECT& src);
55 | CDuiRect(int iLeft, int iTop, int iRight, int iBottom);
56 |
57 | int GetWidth() const;
58 | int GetHeight() const;
59 | void Empty();
60 | bool IsNull() const;
61 | void Join(const RECT& rc);
62 | void ResetOffset();
63 | void Normalize();
64 | void Offset(int cx, int cy);
65 | void Inflate(int cx, int cy);
66 | void Deflate(int cx, int cy);
67 | void Union(CDuiRect& rc);
68 | };
69 |
70 | /////////////////////////////////////////////////////////////////////////////////////
71 | //
72 |
73 | class UILIB_API CStdPtrArray
74 | {
75 | public:
76 | CStdPtrArray(int iPreallocSize = 0);
77 | CStdPtrArray(const CStdPtrArray& src);
78 | ~CStdPtrArray();
79 |
80 | void Empty();
81 | void Resize(int iSize);
82 | bool IsEmpty() const;
83 | int Find(LPVOID iIndex) const;
84 | bool Add(LPVOID pData);
85 | bool SetAt(int iIndex, LPVOID pData);
86 | bool InsertAt(int iIndex, LPVOID pData);
87 | bool Remove(int iIndex);
88 | int GetSize() const;
89 | LPVOID* GetData();
90 |
91 | LPVOID GetAt(int iIndex) const;
92 | LPVOID operator[] (int nIndex) const;
93 |
94 | protected:
95 | LPVOID* m_ppVoid;
96 | int m_nCount;
97 | int m_nAllocated;
98 | };
99 |
100 |
101 | /////////////////////////////////////////////////////////////////////////////////////
102 | //
103 |
104 | class UILIB_API CStdValArray
105 | {
106 | public:
107 | CStdValArray(int iElementSize, int iPreallocSize = 0);
108 | ~CStdValArray();
109 |
110 | void Empty();
111 | bool IsEmpty() const;
112 | bool Add(LPCVOID pData);
113 | bool Remove(int iIndex);
114 | int GetSize() const;
115 | LPVOID GetData();
116 |
117 | LPVOID GetAt(int iIndex) const;
118 | LPVOID operator[] (int nIndex) const;
119 |
120 | protected:
121 | LPBYTE m_pVoid;
122 | int m_iElementSize;
123 | int m_nCount;
124 | int m_nAllocated;
125 | };
126 |
127 |
128 | /////////////////////////////////////////////////////////////////////////////////////
129 | //
130 |
131 | class UILIB_API CDuiString
132 | {
133 | public:
134 | enum { MAX_LOCAL_STRING_LEN = 63 };
135 |
136 | CDuiString();
137 | CDuiString(const TCHAR ch);
138 | CDuiString(const CDuiString& src);
139 | CDuiString(LPCTSTR lpsz, int nLen = -1);
140 | ~CDuiString();
141 |
142 | void Empty();
143 | int GetLength() const;
144 | bool IsEmpty() const;
145 | TCHAR GetAt(int nIndex) const;
146 | void Append(LPCTSTR pstr);
147 | void Assign(LPCTSTR pstr, int nLength = -1);
148 | LPCTSTR GetData() const;
149 |
150 | void SetAt(int nIndex, TCHAR ch);
151 | operator LPCTSTR() const;
152 |
153 | TCHAR operator[] (int nIndex) const;
154 | const CDuiString& operator=(const CDuiString& src);
155 | const CDuiString& operator=(const TCHAR ch);
156 | const CDuiString& operator=(LPCTSTR pstr);
157 | #ifdef _UNICODE
158 | const CDuiString& CDuiString::operator=(LPCSTR lpStr);
159 | const CDuiString& CDuiString::operator+=(LPCSTR lpStr);
160 | #else
161 | const CDuiString& CDuiString::operator=(LPCWSTR lpwStr);
162 | const CDuiString& CDuiString::operator+=(LPCWSTR lpwStr);
163 | #endif
164 | CDuiString operator+(const CDuiString& src) const;
165 | CDuiString operator+(LPCTSTR pstr) const;
166 | const CDuiString& operator+=(const CDuiString& src);
167 | const CDuiString& operator+=(LPCTSTR pstr);
168 | const CDuiString& operator+=(const TCHAR ch);
169 |
170 | bool operator == (LPCTSTR str) const;
171 | bool operator != (LPCTSTR str) const;
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 |
177 | int Compare(LPCTSTR pstr) const;
178 | int CompareNoCase(LPCTSTR pstr) const;
179 |
180 | void MakeUpper();
181 | void MakeLower();
182 |
183 | CDuiString Left(int nLength) const;
184 | CDuiString Mid(int iPos, int nLength = -1) const;
185 | CDuiString Right(int nLength) const;
186 |
187 | int Find(TCHAR ch, int iPos = 0) const;
188 | int Find(LPCTSTR pstr, int iPos = 0) const;
189 | int ReverseFind(TCHAR ch) const;
190 | int Replace(LPCTSTR pstrFrom, LPCTSTR pstrTo);
191 |
192 | int __cdecl Format(LPCTSTR pstrFormat, ...);
193 | int __cdecl Format(LPCTSTR pstrFormat, va_list Args);
194 | int __cdecl SmallFormat(LPCTSTR pstrFormat, ...);
195 |
196 | protected:
197 | LPTSTR m_pstr;
198 | TCHAR m_szBuffer[MAX_LOCAL_STRING_LEN + 1];
199 | };
200 |
201 |
202 | /////////////////////////////////////////////////////////////////////////////////////
203 | //
204 |
205 | struct TITEM
206 | {
207 | CDuiString Key;
208 | LPVOID Data;
209 | struct TITEM* pPrev;
210 | struct TITEM* pNext;
211 | };
212 |
213 | class UILIB_API CStdStringPtrMap
214 | {
215 | public:
216 | CStdStringPtrMap(int nSize = 83);
217 | ~CStdStringPtrMap();
218 |
219 | void Resize(int nSize = 83);
220 | LPVOID Find(LPCTSTR key, bool optimize = true) const;
221 | bool Insert(LPCTSTR key, LPVOID pData);
222 | LPVOID Set(LPCTSTR key, LPVOID pData);
223 | bool Remove(LPCTSTR key);
224 | void RemoveAll();
225 | int GetSize() const;
226 | LPCTSTR GetAt(int iIndex) const;
227 | LPCTSTR operator[] (int nIndex) const;
228 |
229 | protected:
230 | TITEM** m_aT;
231 | int m_nBuckets;
232 | int m_nCount;
233 | };
234 |
235 | /////////////////////////////////////////////////////////////////////////////////////
236 | //
237 |
238 | class UILIB_API CWaitCursor
239 | {
240 | public:
241 | CWaitCursor();
242 | ~CWaitCursor();
243 |
244 | protected:
245 | HCURSOR m_hOrigCursor;
246 | };
247 |
248 | /////////////////////////////////////////////////////////////////////////////////////
249 | //
250 |
251 | class CVariant : public VARIANT
252 | {
253 | public:
254 | CVariant()
255 | {
256 | VariantInit(this);
257 | }
258 | CVariant(int i)
259 | {
260 | VariantInit(this);
261 | this->vt = VT_I4;
262 | this->intVal = i;
263 | }
264 | CVariant(float f)
265 | {
266 | VariantInit(this);
267 | this->vt = VT_R4;
268 | this->fltVal = f;
269 | }
270 | CVariant(LPOLESTR s)
271 | {
272 | VariantInit(this);
273 | this->vt = VT_BSTR;
274 | this->bstrVal = s;
275 | }
276 | CVariant(IDispatch *disp)
277 | {
278 | VariantInit(this);
279 | this->vt = VT_DISPATCH;
280 | this->pdispVal = disp;
281 | }
282 |
283 | ~CVariant()
284 | {
285 | VariantClear(this);
286 | }
287 | };
288 |
289 | }// namespace DuiLib
290 |
291 | #endif // __UTILS_H__
--------------------------------------------------------------------------------
/DuiLib/Control/UISlider.cpp:
--------------------------------------------------------------------------------
1 | #include "StdAfx.h"
2 | #include "UISlider.h"
3 |
4 | namespace DuiLib
5 | {
6 | CSliderUI::CSliderUI() : m_uButtonState(0), m_nStep(1)
7 | {
8 | m_uTextStyle = DT_SINGLELINE | DT_CENTER;
9 | m_szThumb.cx = m_szThumb.cy = 10;
10 | }
11 |
12 | LPCTSTR CSliderUI::GetClass() const
13 | {
14 | return _T("SliderUI");
15 | }
16 |
17 | UINT CSliderUI::GetControlFlags() const
18 | {
19 | if( IsEnabled() ) return UIFLAG_SETCURSOR;
20 | else return 0;
21 | }
22 |
23 | LPVOID CSliderUI::GetInterface(LPCTSTR pstrName)
24 | {
25 | if( _tcscmp(pstrName, DUI_CTR_SLIDER) == 0 ) return static_cast(this);
26 | return CProgressUI::GetInterface(pstrName);
27 | }
28 |
29 | void CSliderUI::SetEnabled(bool bEnable)
30 | {
31 | CControlUI::SetEnabled(bEnable);
32 | if( !IsEnabled() ) {
33 | m_uButtonState = 0;
34 | }
35 | }
36 |
37 | int CSliderUI::GetChangeStep()
38 | {
39 | return m_nStep;
40 | }
41 |
42 | void CSliderUI::SetChangeStep(int step)
43 | {
44 | m_nStep = step;
45 | }
46 |
47 | void CSliderUI::SetThumbSize(SIZE szXY)
48 | {
49 | m_szThumb = szXY;
50 | }
51 |
52 | RECT CSliderUI::GetThumbRect() const
53 | {
54 | if( m_bHorizontal ) {
55 | int left = m_rcItem.left + (m_rcItem.right - m_rcItem.left - m_szThumb.cx) * (m_nValue - m_nMin) / (m_nMax - m_nMin);
56 | int top = (m_rcItem.bottom + m_rcItem.top - m_szThumb.cy) / 2;
57 | return CDuiRect(left, top, left + m_szThumb.cx, top + m_szThumb.cy);
58 | }
59 | else {
60 | int left = (m_rcItem.right + m_rcItem.left - m_szThumb.cx) / 2;
61 | 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);
62 | return CDuiRect(left, top, left + m_szThumb.cx, top + m_szThumb.cy);
63 | }
64 | }
65 |
66 | LPCTSTR CSliderUI::GetThumbImage() const
67 | {
68 | return m_sThumbImage;
69 | }
70 |
71 | void CSliderUI::SetThumbImage(LPCTSTR pStrImage)
72 | {
73 | m_sThumbImage = pStrImage;
74 | Invalidate();
75 | }
76 |
77 | LPCTSTR CSliderUI::GetThumbHotImage() const
78 | {
79 | return m_sThumbHotImage;
80 | }
81 |
82 | void CSliderUI::SetThumbHotImage(LPCTSTR pStrImage)
83 | {
84 | m_sThumbHotImage = pStrImage;
85 | Invalidate();
86 | }
87 |
88 | LPCTSTR CSliderUI::GetThumbPushedImage() const
89 | {
90 | return m_sThumbPushedImage;
91 | }
92 |
93 | void CSliderUI::SetThumbPushedImage(LPCTSTR pStrImage)
94 | {
95 | m_sThumbPushedImage = pStrImage;
96 | Invalidate();
97 | }
98 |
99 | void CSliderUI::DoEvent(TEventUI& event)
100 | {
101 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) {
102 | if( m_pParent != NULL ) m_pParent->DoEvent(event);
103 | else CProgressUI::DoEvent(event);
104 | return;
105 | }
106 |
107 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK )
108 | {
109 | if( IsEnabled() ) {
110 | RECT rcThumb = GetThumbRect();
111 | if( ::PtInRect(&rcThumb, event.ptMouse) ) {
112 | m_uButtonState |= UISTATE_CAPTURED;
113 | }
114 | }
115 | return;
116 | }
117 | if( event.Type == UIEVENT_BUTTONUP )
118 | {
119 | int nValue;
120 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
121 | m_uButtonState &= ~UISTATE_CAPTURED;
122 | }
123 | if( m_bHorizontal ) {
124 | if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) nValue = m_nMax;
125 | else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) nValue = m_nMin;
126 | 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);
127 | }
128 | else {
129 | if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) nValue = m_nMin;
130 | else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) nValue = m_nMax;
131 | 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);
132 | }
133 | if(m_nValue !=nValue && nValue>=m_nMin && nValue<=m_nMax)
134 | {
135 | m_nValue =nValue;
136 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED);
137 | Invalidate();
138 | }
139 | return;
140 | }
141 | if( event.Type == UIEVENT_CONTEXTMENU )
142 | {
143 | return;
144 | }
145 | if( event.Type == UIEVENT_SCROLLWHEEL )
146 | {
147 | switch( LOWORD(event.wParam) ) {
148 | case SB_LINEUP:
149 | SetValue(GetValue() + GetChangeStep());
150 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED);
151 | return;
152 | case SB_LINEDOWN:
153 | SetValue(GetValue() - GetChangeStep());
154 | m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED);
155 | return;
156 | }
157 | }
158 | if( event.Type == UIEVENT_MOUSEMOVE )
159 | {
160 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
161 | if( m_bHorizontal ) {
162 | if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax;
163 | else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin;
164 | 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);
165 | }
166 | else {
167 | if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin;
168 | else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax;
169 | 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);
170 | }
171 | Invalidate();
172 | }
173 | return;
174 | }
175 | if( event.Type == UIEVENT_SETCURSOR )
176 | {
177 | RECT rcThumb = GetThumbRect();
178 | if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) {
179 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
180 | return;
181 | }
182 | }
183 | if( event.Type == UIEVENT_MOUSEENTER )
184 | {
185 | if( IsEnabled() ) {
186 | m_uButtonState |= UISTATE_HOT;
187 | Invalidate();
188 | }
189 | return;
190 | }
191 | if( event.Type == UIEVENT_MOUSELEAVE )
192 | {
193 | if( IsEnabled() ) {
194 | m_uButtonState &= ~UISTATE_HOT;
195 | Invalidate();
196 | }
197 | return;
198 | }
199 | CControlUI::DoEvent(event);
200 | }
201 |
202 |
203 | void CSliderUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
204 | {
205 | if( _tcscmp(pstrName, _T("thumbimage")) == 0 ) SetThumbImage(pstrValue);
206 | else if( _tcscmp(pstrName, _T("thumbhotimage")) == 0 ) SetThumbHotImage(pstrValue);
207 | else if( _tcscmp(pstrName, _T("thumbpushedimage")) == 0 ) SetThumbPushedImage(pstrValue);
208 | else if( _tcscmp(pstrName, _T("thumbsize")) == 0 ) {
209 | SIZE szXY = {0};
210 | LPTSTR pstr = NULL;
211 | szXY.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr);
212 | szXY.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);
213 | SetThumbSize(szXY);
214 | }
215 | else if( _tcscmp(pstrName, _T("step")) == 0 ) {
216 | SetChangeStep(_ttoi(pstrValue));
217 | }
218 | else CProgressUI::SetAttribute(pstrName, pstrValue);
219 | }
220 |
221 | void CSliderUI::PaintStatusImage(HDC hDC)
222 | {
223 | CProgressUI::PaintStatusImage(hDC);
224 |
225 | RECT rcThumb = GetThumbRect();
226 | rcThumb.left -= m_rcItem.left;
227 | rcThumb.top -= m_rcItem.top;
228 | rcThumb.right -= m_rcItem.left;
229 | rcThumb.bottom -= m_rcItem.top;
230 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
231 | if( !m_sThumbPushedImage.IsEmpty() ) {
232 | m_sImageModify.Empty();
233 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom);
234 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbPushedImage, (LPCTSTR)m_sImageModify) ) m_sThumbPushedImage.Empty();
235 | else return;
236 | }
237 | }
238 | else if( (m_uButtonState & UISTATE_HOT) != 0 ) {
239 | if( !m_sThumbHotImage.IsEmpty() ) {
240 | m_sImageModify.Empty();
241 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom);
242 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbHotImage, (LPCTSTR)m_sImageModify) ) m_sThumbHotImage.Empty();
243 | else return;
244 | }
245 | }
246 |
247 | if( !m_sThumbImage.IsEmpty() ) {
248 | m_sImageModify.Empty();
249 | m_sImageModify.SmallFormat(_T("dest='%d,%d,%d,%d'"), rcThumb.left, rcThumb.top, rcThumb.right, rcThumb.bottom);
250 | if( !DrawImage(hDC, (LPCTSTR)m_sThumbImage, (LPCTSTR)m_sImageModify) ) m_sThumbImage.Empty();
251 | else return;
252 | }
253 | }
254 | }
255 |
--------------------------------------------------------------------------------
/DuiLib/Control/UIOption.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIOption.h"
3 |
4 | namespace DuiLib
5 | {
6 | COptionUI::COptionUI() : m_bSelected(false), m_dwSelectedTextColor(0)
7 | {
8 | }
9 |
10 | COptionUI::~COptionUI()
11 | {
12 | if( !m_sGroupName.IsEmpty() && m_pManager ) m_pManager->RemoveOptionGroup(m_sGroupName, this);
13 | }
14 |
15 | LPCTSTR COptionUI::GetClass() const
16 | {
17 | return _T("OptionUI");
18 | }
19 |
20 | LPVOID COptionUI::GetInterface(LPCTSTR pstrName)
21 | {
22 | if( _tcscmp(pstrName, DUI_CTR_OPTION) == 0 ) return static_cast(this);
23 | return CButtonUI::GetInterface(pstrName);
24 | }
25 |
26 | void COptionUI::SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit)
27 | {
28 | CControlUI::SetManager(pManager, pParent, bInit);
29 | if( bInit && !m_sGroupName.IsEmpty() ) {
30 | if (m_pManager) m_pManager->AddOptionGroup(m_sGroupName, this);
31 | }
32 | }
33 |
34 | LPCTSTR COptionUI::GetGroup() const
35 | {
36 | return m_sGroupName;
37 | }
38 |
39 | void COptionUI::SetGroup(LPCTSTR pStrGroupName)
40 | {
41 | if( pStrGroupName == NULL ) {
42 | if( m_sGroupName.IsEmpty() ) return;
43 | m_sGroupName.Empty();
44 | }
45 | else {
46 | if( m_sGroupName == pStrGroupName ) return;
47 | if (!m_sGroupName.IsEmpty() && m_pManager) m_pManager->RemoveOptionGroup(m_sGroupName, this);
48 | m_sGroupName = pStrGroupName;
49 | }
50 |
51 | if( !m_sGroupName.IsEmpty() ) {
52 | if (m_pManager) m_pManager->AddOptionGroup(m_sGroupName, this);
53 | }
54 | else {
55 | if (m_pManager) m_pManager->RemoveOptionGroup(m_sGroupName, this);
56 | }
57 |
58 | Selected(m_bSelected);
59 | }
60 |
61 | bool COptionUI::IsSelected() const
62 | {
63 | return m_bSelected;
64 | }
65 |
66 | void COptionUI::Selected(bool bSelected)
67 | {
68 | if( m_bSelected == bSelected ) return;
69 | m_bSelected = bSelected;
70 | if( m_bSelected ) m_uButtonState |= UISTATE_SELECTED;
71 | else m_uButtonState &= ~UISTATE_SELECTED;
72 |
73 | if( m_pManager != NULL ) {
74 | if( !m_sGroupName.IsEmpty() ) {
75 | if( m_bSelected ) {
76 | CStdPtrArray* aOptionGroup = m_pManager->GetOptionGroup(m_sGroupName);
77 | for( int i = 0; i < aOptionGroup->GetSize(); i++ ) {
78 | COptionUI* pControl = static_cast(aOptionGroup->GetAt(i));
79 | if( pControl != this ) {
80 | pControl->Selected(false);
81 | }
82 | }
83 | m_pManager->SendNotify(this, DUI_MSGTYPE_SELECTCHANGED);
84 | }
85 | }
86 | else {
87 | m_pManager->SendNotify(this, DUI_MSGTYPE_SELECTCHANGED);
88 | }
89 | }
90 |
91 | Invalidate();
92 | }
93 |
94 | bool COptionUI::Activate()
95 | {
96 | if( !CButtonUI::Activate() ) return false;
97 | if( !m_sGroupName.IsEmpty() ) Selected(true);
98 | else Selected(!m_bSelected);
99 |
100 | return true;
101 | }
102 |
103 | void COptionUI::SetEnabled(bool bEnable)
104 | {
105 | CControlUI::SetEnabled(bEnable);
106 | if( !IsEnabled() ) {
107 | if( m_bSelected ) m_uButtonState = UISTATE_SELECTED;
108 | else m_uButtonState = 0;
109 | }
110 | }
111 |
112 | LPCTSTR COptionUI::GetSelectedImage()
113 | {
114 | return m_sSelectedImage;
115 | }
116 |
117 | void COptionUI::SetSelectedImage(LPCTSTR pStrImage)
118 | {
119 | m_sSelectedImage = pStrImage;
120 | Invalidate();
121 | }
122 |
123 | //************************************
124 | // Method: GetSelectedHotImage
125 | // FullName: COptionUI::GetSelectedHotImage
126 | // Access: public
127 | // Returns: LPCTSTR
128 | // Qualifier:
129 | // Node:
130 | //************************************
131 | LPCTSTR COptionUI::GetSelectedHotImage()
132 | {
133 | return m_sSelectedHotImage;
134 | }
135 | //************************************
136 | // Method: SetSelectedHotImage
137 | // FullName: COptionUI::SetSelectedHotImage
138 | // Access: public
139 | // Returns: void
140 | // Qualifier:
141 | // Parameter: LPCTSTR pStrImage
142 | // Node:
143 | //************************************
144 | void COptionUI::SetSelectedHotImage( LPCTSTR pStrImage )
145 | {
146 | m_sSelectedHotImage = pStrImage;
147 | Invalidate();
148 | }
149 |
150 | void COptionUI::SetSelectedTextColor(DWORD dwTextColor)
151 | {
152 | m_dwSelectedTextColor = dwTextColor;
153 | }
154 |
155 | DWORD COptionUI::GetSelectedTextColor()
156 | {
157 | if (m_dwSelectedTextColor == 0) m_dwSelectedTextColor = m_pManager->GetDefaultFontColor();
158 | return m_dwSelectedTextColor;
159 | }
160 |
161 | //************************************
162 | // Method: SetSelectedBkColor
163 | // FullName: COptionUI::SetSelectedBkColor
164 | // Access: public
165 | // Returns: void
166 | // Qualifier:
167 | // Parameter: DWORD dwBkColor
168 | // Note:
169 | //************************************
170 | void COptionUI::SetSelectedBkColor( DWORD dwBkColor )
171 | {
172 | m_dwSelectedBkColor = dwBkColor;
173 | }
174 |
175 | //************************************
176 | // Method: GetSelectBkColor
177 | // FullName: COptionUI::GetSelectBkColor
178 | // Access: public
179 | // Returns: DWORD
180 | // Qualifier:
181 | // Note:
182 | //************************************
183 | DWORD COptionUI::GetSelectBkColor()
184 | {
185 | return m_dwSelectedBkColor;
186 | }
187 |
188 | LPCTSTR COptionUI::GetForeImage()
189 | {
190 | return m_sForeImage;
191 | }
192 |
193 | void COptionUI::SetForeImage(LPCTSTR pStrImage)
194 | {
195 | m_sForeImage = pStrImage;
196 | Invalidate();
197 | }
198 |
199 | SIZE COptionUI::EstimateSize(SIZE szAvailable)
200 | {
201 | if( m_cxyFixed.cy == 0 ) return CSize(m_cxyFixed.cx, m_pManager->GetFontInfo(GetFont())->tm.tmHeight + 8);
202 | return CControlUI::EstimateSize(szAvailable);
203 | }
204 |
205 | void COptionUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
206 | {
207 | if( _tcscmp(pstrName, _T("group")) == 0 ) SetGroup(pstrValue);
208 | else if( _tcscmp(pstrName, _T("selected")) == 0 ) Selected(_tcscmp(pstrValue, _T("true")) == 0);
209 | else if( _tcscmp(pstrName, _T("selectedimage")) == 0 ) SetSelectedImage(pstrValue);
210 | else if( _tcscmp(pstrName, _T("selectedhotimage")) == 0 ) SetSelectedHotImage(pstrValue);
211 | else if( _tcscmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue);
212 | else if( _tcscmp(pstrName, _T("selectedbkcolor")) == 0 ) {
213 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
214 | LPTSTR pstr = NULL;
215 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
216 | SetSelectedBkColor(clrColor);
217 | }
218 | else if( _tcscmp(pstrName, _T("selectedtextcolor")) == 0 ) {
219 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
220 | LPTSTR pstr = NULL;
221 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
222 | SetSelectedTextColor(clrColor);
223 | }
224 | else CButtonUI::SetAttribute(pstrName, pstrValue);
225 | }
226 |
227 | void COptionUI::PaintStatusImage(HDC hDC)
228 | {
229 | m_uButtonState &= ~UISTATE_PUSHED;
230 |
231 | if( (m_uButtonState & UISTATE_HOT) != 0 && IsSelected() && !m_sSelectedHotImage.IsEmpty()) {
232 | if( !DrawImage(hDC, (LPCTSTR)m_sSelectedHotImage) )
233 | m_sSelectedHotImage.Empty();
234 | else goto Label_ForeImage;
235 | }
236 | else if( (m_uButtonState & UISTATE_SELECTED) != 0 ) {
237 | if( !m_sSelectedImage.IsEmpty() ) {
238 | if( !DrawImage(hDC, (LPCTSTR)m_sSelectedImage) ) m_sSelectedImage.Empty();
239 | else goto Label_ForeImage;
240 | }
241 | else if(m_dwSelectedBkColor != 0) {
242 | CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwSelectedBkColor));
243 | return;
244 | }
245 | }
246 |
247 | CButtonUI::PaintStatusImage(hDC);
248 |
249 | Label_ForeImage:
250 | if( !m_sForeImage.IsEmpty() ) {
251 | if( !DrawImage(hDC, (LPCTSTR)m_sForeImage) ) m_sForeImage.Empty();
252 | }
253 | }
254 |
255 | void COptionUI::PaintText(HDC hDC)
256 | {
257 | if( (m_uButtonState & UISTATE_SELECTED) != 0 )
258 | {
259 | DWORD oldTextColor = m_dwTextColor;
260 | if( m_dwSelectedTextColor != 0 ) m_dwTextColor = m_dwSelectedTextColor;
261 |
262 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor();
263 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor();
264 |
265 | if( m_sText.IsEmpty() ) return;
266 | int nLinks = 0;
267 | RECT rc = m_rcItem;
268 | rc.left += m_rcTextPadding.left;
269 | rc.right -= m_rcTextPadding.right;
270 | rc.top += m_rcTextPadding.top;
271 | rc.bottom -= m_rcTextPadding.bottom;
272 |
273 | if( m_bShowHtml )
274 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, IsEnabled()?m_dwTextColor:m_dwDisabledTextColor, \
275 | NULL, NULL, nLinks, m_uTextStyle);
276 | else
277 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, IsEnabled()?m_dwTextColor:m_dwDisabledTextColor, \
278 | m_iFont, m_uTextStyle);
279 |
280 | m_dwTextColor = oldTextColor;
281 | }
282 | else
283 | CButtonUI::PaintText(hDC);
284 | }
285 | }
--------------------------------------------------------------------------------
/DuiLib/Layout/UIHorizontalLayout.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIHorizontalLayout.h"
3 |
4 | namespace DuiLib
5 | {
6 | CHorizontalLayoutUI::CHorizontalLayoutUI() : m_iSepWidth(0), m_uButtonState(0), m_bImmMode(false)
7 | {
8 | ptLastMouse.x = ptLastMouse.y = 0;
9 | ::ZeroMemory(&m_rcNewPos, sizeof(m_rcNewPos));
10 | }
11 |
12 | LPCTSTR CHorizontalLayoutUI::GetClass() const
13 | {
14 | return _T("HorizontalLayoutUI");
15 | }
16 |
17 | LPVOID CHorizontalLayoutUI::GetInterface(LPCTSTR pstrName)
18 | {
19 | if( _tcscmp(pstrName, DUI_CTR_HORIZONTALLAYOUT) == 0 ) return static_cast(this);
20 | return CContainerUI::GetInterface(pstrName);
21 | }
22 |
23 | UINT CHorizontalLayoutUI::GetControlFlags() const
24 | {
25 | if( IsEnabled() && m_iSepWidth != 0 ) return UIFLAG_SETCURSOR;
26 | else return 0;
27 | }
28 |
29 | void CHorizontalLayoutUI::SetPos(RECT rc)
30 | {
31 | CControlUI::SetPos(rc);
32 | rc = m_rcItem;
33 |
34 | // Adjust for inset
35 | rc.left += m_rcInset.left;
36 | rc.top += m_rcInset.top;
37 | rc.right -= m_rcInset.right;
38 | rc.bottom -= m_rcInset.bottom;
39 |
40 | if( m_items.GetSize() == 0) {
41 | ProcessScrollBar(rc, 0, 0);
42 | return;
43 | }
44 |
45 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) rc.right -= m_pVerticalScrollBar->GetFixedWidth();
46 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight();
47 |
48 | // Determine the width of elements that are sizeable
49 | SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top };
50 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() )
51 | szAvailable.cx += m_pHorizontalScrollBar->GetScrollRange();
52 |
53 | int nAdjustables = 0;
54 | int cxFixed = 0;
55 | int nEstimateNum = 0;
56 | for( int it1 = 0; it1 < m_items.GetSize(); it1++ ) {
57 | CControlUI* pControl = static_cast(m_items[it1]);
58 | if( !pControl->IsVisible() ) continue;
59 | if( pControl->IsFloat() ) continue;
60 | SIZE sz = pControl->EstimateSize(szAvailable);
61 | if( sz.cx == 0 ) {
62 | nAdjustables++;
63 | }
64 | else {
65 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth();
66 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth();
67 | }
68 | cxFixed += sz.cx + pControl->GetPadding().left + pControl->GetPadding().right;
69 | nEstimateNum++;
70 | }
71 | cxFixed += (nEstimateNum - 1) * m_iChildPadding;
72 |
73 | int cxExpand = 0;
74 | int cxNeeded = 0;
75 | if( nAdjustables > 0 ) cxExpand = MAX(0, (szAvailable.cx - cxFixed) / nAdjustables);
76 | // Position the elements
77 | SIZE szRemaining = szAvailable;
78 | int iPosX = rc.left;
79 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) {
80 | iPosX -= m_pHorizontalScrollBar->GetScrollPos();
81 | }
82 | int iAdjustable = 0;
83 | int cxFixedRemaining = cxFixed;
84 | for( int it2 = 0; it2 < m_items.GetSize(); it2++ ) {
85 | CControlUI* pControl = static_cast(m_items[it2]);
86 | if( !pControl->IsVisible() ) continue;
87 | if( pControl->IsFloat() ) {
88 | SetFloatPos(it2);
89 | continue;
90 | }
91 | RECT rcPadding = pControl->GetPadding();
92 | szRemaining.cx -= rcPadding.left;
93 | SIZE sz = pControl->EstimateSize(szRemaining);
94 | if( sz.cx == 0 ) {
95 | iAdjustable++;
96 | sz.cx = cxExpand;
97 | // Distribute remaining to last element (usually round-off left-overs)
98 | if( iAdjustable == nAdjustables ) {
99 | sz.cx = MAX(0, szRemaining.cx - rcPadding.right - cxFixedRemaining);
100 | }
101 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth();
102 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth();
103 | }
104 | else {
105 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth();
106 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth();
107 |
108 | cxFixedRemaining -= sz.cx;
109 | }
110 |
111 | sz.cy = pControl->GetFixedHeight();
112 | if( sz.cy == 0 ) sz.cy = rc.bottom - rc.top - rcPadding.top - rcPadding.bottom;
113 | if( sz.cy < 0 ) sz.cy = 0;
114 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight();
115 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
116 |
117 | RECT rcCtrl = { iPosX + rcPadding.left, rc.top + rcPadding.top, iPosX + sz.cx + rcPadding.left + rcPadding.right, rc.top + rcPadding.top + sz.cy};
118 | pControl->SetPos(rcCtrl);
119 | iPosX += sz.cx + m_iChildPadding + rcPadding.left + rcPadding.right;
120 | cxNeeded += sz.cx + rcPadding.left + rcPadding.right;
121 | szRemaining.cx -= sz.cx + m_iChildPadding + rcPadding.right;
122 | }
123 | cxNeeded += (nEstimateNum - 1) * m_iChildPadding;
124 |
125 | // Process the scrollbar
126 | ProcessScrollBar(rc, cxNeeded, 0);
127 | }
128 |
129 | void CHorizontalLayoutUI::DoPostPaint(HDC hDC, const RECT& rcPaint)
130 | {
131 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && !m_bImmMode ) {
132 | RECT rcSeparator = GetThumbRect(true);
133 | CRenderEngine::DrawColor(hDC, rcSeparator, 0xAA000000);
134 | }
135 | }
136 |
137 | void CHorizontalLayoutUI::SetSepWidth(int iWidth)
138 | {
139 | m_iSepWidth = iWidth;
140 | }
141 |
142 | int CHorizontalLayoutUI::GetSepWidth() const
143 | {
144 | return m_iSepWidth;
145 | }
146 |
147 | void CHorizontalLayoutUI::SetSepImmMode(bool bImmediately)
148 | {
149 | if( m_bImmMode == bImmediately ) return;
150 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && !m_bImmMode && m_pManager != NULL ) {
151 | m_pManager->RemovePostPaint(this);
152 | }
153 |
154 | m_bImmMode = bImmediately;
155 | }
156 |
157 | bool CHorizontalLayoutUI::IsSepImmMode() const
158 | {
159 | return m_bImmMode;
160 | }
161 |
162 | void CHorizontalLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
163 | {
164 | if( _tcscmp(pstrName, _T("sepwidth")) == 0 ) SetSepWidth(_ttoi(pstrValue));
165 | else if( _tcscmp(pstrName, _T("sepimm")) == 0 ) SetSepImmMode(_tcscmp(pstrValue, _T("true")) == 0);
166 | else CContainerUI::SetAttribute(pstrName, pstrValue);
167 | }
168 |
169 | void CHorizontalLayoutUI::DoEvent(TEventUI& event)
170 | {
171 | if( m_iSepWidth != 0 ) {
172 | if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() )
173 | {
174 | RECT rcSeparator = GetThumbRect(false);
175 | if( ::PtInRect(&rcSeparator, event.ptMouse) ) {
176 | m_uButtonState |= UISTATE_CAPTURED;
177 | ptLastMouse = event.ptMouse;
178 | m_rcNewPos = m_rcItem;
179 | if( !m_bImmMode && m_pManager ) m_pManager->AddPostPaint(this);
180 | return;
181 | }
182 | }
183 | if( event.Type == UIEVENT_BUTTONUP )
184 | {
185 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
186 | m_uButtonState &= ~UISTATE_CAPTURED;
187 | m_rcItem = m_rcNewPos;
188 | if( !m_bImmMode && m_pManager ) m_pManager->RemovePostPaint(this);
189 | NeedParentUpdate();
190 | return;
191 | }
192 | }
193 | if( event.Type == UIEVENT_MOUSEMOVE )
194 | {
195 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
196 | LONG cx = event.ptMouse.x - ptLastMouse.x;
197 | ptLastMouse = event.ptMouse;
198 | RECT rc = m_rcNewPos;
199 | if( m_iSepWidth >= 0 ) {
200 | if( cx > 0 && event.ptMouse.x < m_rcNewPos.right - m_iSepWidth ) return;
201 | if( cx < 0 && event.ptMouse.x > m_rcNewPos.right ) return;
202 | rc.right += cx;
203 | if( rc.right - rc.left <= GetMinWidth() ) {
204 | if( m_rcNewPos.right - m_rcNewPos.left <= GetMinWidth() ) return;
205 | rc.right = rc.left + GetMinWidth();
206 | }
207 | if( rc.right - rc.left >= GetMaxWidth() ) {
208 | if( m_rcNewPos.right - m_rcNewPos.left >= GetMaxWidth() ) return;
209 | rc.right = rc.left + GetMaxWidth();
210 | }
211 | }
212 | else {
213 | if( cx > 0 && event.ptMouse.x < m_rcNewPos.left ) return;
214 | if( cx < 0 && event.ptMouse.x > m_rcNewPos.left - m_iSepWidth ) return;
215 | rc.left += cx;
216 | if( rc.right - rc.left <= GetMinWidth() ) {
217 | if( m_rcNewPos.right - m_rcNewPos.left <= GetMinWidth() ) return;
218 | rc.left = rc.right - GetMinWidth();
219 | }
220 | if( rc.right - rc.left >= GetMaxWidth() ) {
221 | if( m_rcNewPos.right - m_rcNewPos.left >= GetMaxWidth() ) return;
222 | rc.left = rc.right - GetMaxWidth();
223 | }
224 | }
225 |
226 | CDuiRect rcInvalidate = GetThumbRect(true);
227 | m_rcNewPos = rc;
228 | m_cxyFixed.cx = m_rcNewPos.right - m_rcNewPos.left;
229 |
230 | if( m_bImmMode ) {
231 | m_rcItem = m_rcNewPos;
232 | NeedParentUpdate();
233 | }
234 | else {
235 | rcInvalidate.Join(GetThumbRect(true));
236 | rcInvalidate.Join(GetThumbRect(false));
237 | if( m_pManager ) m_pManager->Invalidate(rcInvalidate);
238 | }
239 | return;
240 | }
241 | }
242 | if( event.Type == UIEVENT_SETCURSOR )
243 | {
244 | RECT rcSeparator = GetThumbRect(false);
245 | if( IsEnabled() && ::PtInRect(&rcSeparator, event.ptMouse) ) {
246 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE)));
247 | return;
248 | }
249 | }
250 | }
251 | CContainerUI::DoEvent(event);
252 | }
253 |
254 | RECT CHorizontalLayoutUI::GetThumbRect(bool bUseNew) const
255 | {
256 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && bUseNew) {
257 | if( m_iSepWidth >= 0 ) return CDuiRect(m_rcNewPos.right - m_iSepWidth, m_rcNewPos.top, m_rcNewPos.right, m_rcNewPos.bottom);
258 | else return CDuiRect(m_rcNewPos.left, m_rcNewPos.top, m_rcNewPos.left - m_iSepWidth, m_rcNewPos.bottom);
259 | }
260 | else {
261 | if( m_iSepWidth >= 0 ) return CDuiRect(m_rcItem.right - m_iSepWidth, m_rcItem.top, m_rcItem.right, m_rcItem.bottom);
262 | else return CDuiRect(m_rcItem.left, m_rcItem.top, m_rcItem.left - m_iSepWidth, m_rcItem.bottom);
263 | }
264 | }
265 | }
266 |
--------------------------------------------------------------------------------
/Update/unzip.h:
--------------------------------------------------------------------------------
1 | #ifndef _unzip_H
2 | #define _unzip_H
3 |
4 | // UNZIPPING functions -- for unzipping.
5 | // This file is a repackaged form of extracts from the zlib code available
6 | // at www.gzip.org/zlib, by Jean-Loup Gailly and Mark Adler. The original
7 | // copyright notice may be found in unzip.cpp. The repackaging was done
8 | // by Lucian Wischik to simplify and extend its use in Windows/C++. Also
9 | // encryption and unicode filenames have been added.
10 |
11 | namespace Unzip
12 | {
13 |
14 | #ifndef _zip_H
15 | DECLARE_HANDLE(HZIP);
16 | #endif
17 | // An HZIP identifies a zip file that has been opened
18 |
19 | typedef DWORD ZRESULT;
20 | // return codes from any of the zip functions. Listed later.
21 |
22 | typedef struct
23 | { int index; // index of this file within the zip
24 | TCHAR name[MAX_PATH]; // filename within the zip
25 | DWORD attr; // attributes, as in GetFileAttributes.
26 | FILETIME atime,ctime,mtime;// access, create, modify filetimes
27 | long comp_size; // sizes of item, compressed and uncompressed. These
28 | long unc_size; // may be -1 if not yet known (e.g. being streamed in)
29 | } ZIPENTRY;
30 |
31 |
32 | HZIP OpenZip(const TCHAR *fn, const char *password);
33 | HZIP OpenZip(void *z,unsigned int len, const char *password);
34 | HZIP OpenZipHandle(HANDLE h, const char *password);
35 | // OpenZip - opens a zip file and returns a handle with which you can
36 | // subsequently examine its contents. You can open a zip file from:
37 | // from a pipe: OpenZipHandle(hpipe_read,0);
38 | // from a file (by handle): OpenZipHandle(hfile,0);
39 | // from a file (by name): OpenZip("c:\\test.zip","password");
40 | // from a memory block: OpenZip(bufstart, buflen,0);
41 | // If the file is opened through a pipe, then items may only be
42 | // accessed in increasing order, and an item may only be unzipped once,
43 | // although GetZipItem can be called immediately before and after unzipping
44 | // it. If it's opened in any other way, then full random access is possible.
45 | // Note: pipe input is not yet implemented.
46 | // Note: zip passwords are ascii, not unicode.
47 | // Note: for windows-ce, you cannot close the handle until after CloseZip.
48 | // but for real windows, the zip makes its own copy of your handle, so you
49 | // can close yours anytime.
50 |
51 | ZRESULT GetZipItem(HZIP hz, int index, ZIPENTRY *ze);
52 | // GetZipItem - call this to get information about an item in the zip.
53 | // If index is -1 and the file wasn't opened through a pipe,
54 | // then it returns information about the whole zipfile
55 | // (and in particular ze.index returns the number of index items).
56 | // Note: the item might be a directory (ze.attr & FILE_ATTRIBUTE_DIRECTORY)
57 | // See below for notes on what happens when you unzip such an item.
58 | // Note: if you are opening the zip through a pipe, then random access
59 | // is not possible and GetZipItem(-1) fails and you can't discover the number
60 | // of items except by calling GetZipItem on each one of them in turn,
61 | // starting at 0, until eventually the call fails. Also, in the event that
62 | // you are opening through a pipe and the zip was itself created into a pipe,
63 | // then then comp_size and sometimes unc_size as well may not be known until
64 | // after the item has been unzipped.
65 |
66 | ZRESULT FindZipItem(HZIP hz, const TCHAR *name, bool ic, int *index, ZIPENTRY *ze);
67 | // FindZipItem - finds an item by name. ic means 'insensitive to case'.
68 | // It returns the index of the item, and returns information about it.
69 | // If nothing was found, then index is set to -1 and the function returns
70 | // an error code.
71 |
72 | ZRESULT UnzipItem(HZIP hz, int index, const TCHAR *fn);
73 | ZRESULT UnzipItem(HZIP hz, int index, void *z,unsigned int len);
74 | ZRESULT UnzipItemHandle(HZIP hz, int index, HANDLE h);
75 | // UnzipItem - given an index to an item, unzips it. You can unzip to:
76 | // to a pipe: UnzipItemHandle(hz,i, hpipe_write);
77 | // to a file (by handle): UnzipItemHandle(hz,i, hfile);
78 | // to a file (by name): UnzipItem(hz,i, ze.name);
79 | // to a memory block: UnzipItem(hz,i, buf,buflen);
80 | // In the final case, if the buffer isn't large enough to hold it all,
81 | // then the return code indicates that more is yet to come. If it was
82 | // large enough, and you want to know precisely how big, GetZipItem.
83 | // Note: zip files are normally stored with relative pathnames. If you
84 | // unzip with ZIP_FILENAME a relative pathname then the item gets created
85 | // relative to the current directory - it first ensures that all necessary
86 | // subdirectories have been created. Also, the item may itself be a directory.
87 | // If you unzip a directory with ZIP_FILENAME, then the directory gets created.
88 | // If you unzip it to a handle or a memory block, then nothing gets created
89 | // and it emits 0 bytes.
90 | ZRESULT SetUnzipBaseDir(HZIP hz, const TCHAR *dir);
91 | // if unzipping to a filename, and it's a relative filename, then it will be relative to here.
92 | // (defaults to current-directory).
93 |
94 |
95 | ZRESULT CloseZip(HZIP hz);
96 | // CloseZip - the zip handle must be closed with this function.
97 |
98 | unsigned int FormatZipMessage(ZRESULT code, TCHAR *buf,unsigned int len);
99 | // FormatZipMessage - given an error code, formats it as a string.
100 | // It returns the length of the error message. If buf/len points
101 | // to a real buffer, then it also writes as much as possible into there.
102 |
103 |
104 | // These are the result codes:
105 | #define ZR_OK 0x00000000 // nb. the pseudo-code zr-recent is never returned,
106 | #define ZR_RECENT 0x00000001 // but can be passed to FormatZipMessage.
107 | // The following come from general system stuff (e.g. files not openable)
108 | #define ZR_GENMASK 0x0000FF00
109 | #define ZR_NODUPH 0x00000100 // couldn't duplicate the handle
110 | #define ZR_NOFILE 0x00000200 // couldn't create/open the file
111 | #define ZR_NOALLOC 0x00000300 // failed to allocate some resource
112 | #define ZR_WRITE 0x00000400 // a general error writing to the file
113 | #define ZR_NOTFOUND 0x00000500 // couldn't find that file in the zip
114 | #define ZR_MORE 0x00000600 // there's still more data to be unzipped
115 | #define ZR_CORRUPT 0x00000700 // the zipfile is corrupt or not a zipfile
116 | #define ZR_READ 0x00000800 // a general error reading the file
117 | #define ZR_PASSWORD 0x00001000 // we didn't get the right password to unzip the file
118 | // The following come from mistakes on the part of the caller
119 | #define ZR_CALLERMASK 0x00FF0000
120 | #define ZR_ARGS 0x00010000 // general mistake with the arguments
121 | #define ZR_NOTMMAP 0x00020000 // tried to ZipGetMemory, but that only works on mmap zipfiles, which yours wasn't
122 | #define ZR_MEMSIZE 0x00030000 // the memory size is too small
123 | #define ZR_FAILED 0x00040000 // the thing was already failed when you called this function
124 | #define ZR_ENDED 0x00050000 // the zip creation has already been closed
125 | #define ZR_MISSIZE 0x00060000 // the indicated input file size turned out mistaken
126 | #define ZR_PARTIALUNZ 0x00070000 // the file had already been partially unzipped
127 | #define ZR_ZMODE 0x00080000 // tried to mix creating/opening a zip
128 | // The following come from bugs within the zip library itself
129 | #define ZR_BUGMASK 0xFF000000
130 | #define ZR_NOTINITED 0x01000000 // initialisation didn't work
131 | #define ZR_SEEK 0x02000000 // trying to seek in an unseekable file
132 | #define ZR_NOCHANGE 0x04000000 // changed its mind on storage, but not allowed
133 | #define ZR_FLATE 0x05000000 // an internal error in the de/inflation code
134 |
135 |
136 |
137 |
138 |
139 | // e.g.
140 | //
141 | // SetCurrentDirectory("c:\\docs\\stuff");
142 | // HZIP hz = OpenZip("c:\\stuff.zip",0);
143 | // ZIPENTRY ze; GetZipItem(hz,-1,&ze); int numitems=ze.index;
144 | // for (int i=0; i(this);
20 | return CContainerUI::GetInterface(pstrName);
21 | }
22 |
23 | UINT CVerticalLayoutUI::GetControlFlags() const
24 | {
25 | if( IsEnabled() && m_iSepHeight != 0 ) return UIFLAG_SETCURSOR;
26 | else return 0;
27 | }
28 |
29 | void CVerticalLayoutUI::SetPos(RECT rc)
30 | {
31 | CControlUI::SetPos(rc);
32 | rc = m_rcItem;
33 |
34 | // Adjust for inset
35 | rc.left += m_rcInset.left;
36 | rc.top += m_rcInset.top;
37 | rc.right -= m_rcInset.right;
38 | rc.bottom -= m_rcInset.bottom;
39 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) rc.right -= m_pVerticalScrollBar->GetFixedWidth();
40 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight();
41 |
42 | if( m_items.GetSize() == 0) {
43 | ProcessScrollBar(rc, 0, 0);
44 | return;
45 | }
46 |
47 | // Determine the minimum size
48 | SIZE szAvailable = { rc.right - rc.left, rc.bottom - rc.top };
49 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() )
50 | szAvailable.cx += m_pHorizontalScrollBar->GetScrollRange();
51 |
52 | int nAdjustables = 0;
53 | int cyFixed = 0;
54 | int nEstimateNum = 0;
55 | for( int it1 = 0; it1 < m_items.GetSize(); it1++ ) {
56 | CControlUI* pControl = static_cast(m_items[it1]);
57 | if( !pControl->IsVisible() ) continue;
58 | if( pControl->IsFloat() ) continue;
59 | SIZE sz = pControl->EstimateSize(szAvailable);
60 | if( sz.cy == 0 ) {
61 | nAdjustables++;
62 | }
63 | else {
64 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight();
65 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
66 | }
67 | cyFixed += sz.cy + pControl->GetPadding().top + pControl->GetPadding().bottom;
68 | nEstimateNum++;
69 | }
70 | cyFixed += (nEstimateNum - 1) * m_iChildPadding;
71 |
72 | // Place elements
73 | int cyNeeded = 0;
74 | int cyExpand = 0;
75 | if( nAdjustables > 0 ) cyExpand = MAX(0, (szAvailable.cy - cyFixed) / nAdjustables);
76 | // Position the elements
77 | SIZE szRemaining = szAvailable;
78 | int iPosY = rc.top;
79 | if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) {
80 | iPosY -= m_pVerticalScrollBar->GetScrollPos();
81 | }
82 | int iPosX = rc.left;
83 | if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) {
84 | iPosX -= m_pHorizontalScrollBar->GetScrollPos();
85 | }
86 | int iAdjustable = 0;
87 | int cyFixedRemaining = cyFixed;
88 | for( int it2 = 0; it2 < m_items.GetSize(); it2++ ) {
89 | CControlUI* pControl = static_cast(m_items[it2]);
90 | if( !pControl->IsVisible() ) continue;
91 | if( pControl->IsFloat() ) {
92 | SetFloatPos(it2);
93 | continue;
94 | }
95 |
96 | RECT rcPadding = pControl->GetPadding();
97 | szRemaining.cy -= rcPadding.top;
98 | SIZE sz = pControl->EstimateSize(szRemaining);
99 | if( sz.cy == 0 ) {
100 | iAdjustable++;
101 | sz.cy = cyExpand;
102 | // Distribute remaining to last element (usually round-off left-overs)
103 | if( iAdjustable == nAdjustables ) {
104 | //////////////////////////////////////////////////////////////////////////
105 | ///corrected by gechunping on 2014_3_27
106 | ///deleted origin /// sz.cy = MAX(0, szRemaining.cy - rcPadding.bottom - cyFixedRemaining);
107 | ///corrected by gechunping on 2014_3_27
108 | //////////////////////////////////////////////////////////////////////////
109 | }
110 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight();
111 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
112 | }
113 | else {
114 | if( sz.cy < pControl->GetMinHeight() ) sz.cy = pControl->GetMinHeight();
115 | if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
116 | cyFixedRemaining -= sz.cy;
117 | }
118 |
119 | sz.cx = pControl->GetFixedWidth();
120 | if( sz.cx == 0 ) sz.cx = szAvailable.cx - rcPadding.left - rcPadding.right;
121 | if( sz.cx < 0 ) sz.cx = 0;
122 | if( sz.cx < pControl->GetMinWidth() ) sz.cx = pControl->GetMinWidth();
123 | if( sz.cx > pControl->GetMaxWidth() ) sz.cx = pControl->GetMaxWidth();
124 |
125 |
126 | //////////////////////////////////////////////////////////////////////////
127 | ///corrected by gechunping on 2014_3_27
128 | ///origin/// RECT rcCtrl = { iPosX + rcPadding.left, iPosY + rcPadding.top, iPosX + rcPadding.left + sz.cx, iPosY + sz.cy + rcPadding.top + rcPadding.bottom };
129 | RECT rcCtrl = { iPosX + rcPadding.left, iPosY + rcPadding.top, iPosX + rcPadding.left + sz.cx, iPosY + sz.cy + rcPadding.bottom };
130 | ///corrected by gechunping on 2014_3_27
131 | //////////////////////////////////////////////////////////////////////////
132 | pControl->SetPos(rcCtrl);
133 |
134 | iPosY += sz.cy + m_iChildPadding + rcPadding.top + rcPadding.bottom;
135 | cyNeeded += sz.cy + rcPadding.top + rcPadding.bottom;
136 | szRemaining.cy -= sz.cy + m_iChildPadding + rcPadding.bottom;
137 | }
138 | cyNeeded += (nEstimateNum - 1) * m_iChildPadding;
139 |
140 | // Process the scrollbar
141 | ProcessScrollBar(rc, 0, cyNeeded);
142 | }
143 |
144 | void CVerticalLayoutUI::DoPostPaint(HDC hDC, const RECT& rcPaint)
145 | {
146 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && !m_bImmMode ) {
147 | RECT rcSeparator = GetThumbRect(true);
148 | CRenderEngine::DrawColor(hDC, rcSeparator, 0xAA000000);
149 | }
150 | }
151 |
152 | void CVerticalLayoutUI::SetSepHeight(int iHeight)
153 | {
154 | m_iSepHeight = iHeight;
155 | }
156 |
157 | int CVerticalLayoutUI::GetSepHeight() const
158 | {
159 | return m_iSepHeight;
160 | }
161 |
162 | void CVerticalLayoutUI::SetSepImmMode(bool bImmediately)
163 | {
164 | if( m_bImmMode == bImmediately ) return;
165 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && !m_bImmMode && m_pManager != NULL ) {
166 | m_pManager->RemovePostPaint(this);
167 | }
168 |
169 | m_bImmMode = bImmediately;
170 | }
171 |
172 | bool CVerticalLayoutUI::IsSepImmMode() const
173 | {
174 | return m_bImmMode;
175 | }
176 |
177 | void CVerticalLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
178 | {
179 | if( _tcscmp(pstrName, _T("sepheight")) == 0 ) SetSepHeight(_ttoi(pstrValue));
180 | else if( _tcscmp(pstrName, _T("sepimm")) == 0 ) SetSepImmMode(_tcscmp(pstrValue, _T("true")) == 0);
181 | else CContainerUI::SetAttribute(pstrName, pstrValue);
182 | }
183 |
184 | void CVerticalLayoutUI::DoEvent(TEventUI& event)
185 | {
186 | if( m_iSepHeight != 0 ) {
187 | if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() )
188 | {
189 | RECT rcSeparator = GetThumbRect(false);
190 | if( ::PtInRect(&rcSeparator, event.ptMouse) ) {
191 | m_uButtonState |= UISTATE_CAPTURED;
192 | ptLastMouse = event.ptMouse;
193 | m_rcNewPos = m_rcItem;
194 | if( !m_bImmMode && m_pManager ) m_pManager->AddPostPaint(this);
195 | return;
196 | }
197 | }
198 | if( event.Type == UIEVENT_BUTTONUP )
199 | {
200 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
201 | m_uButtonState &= ~UISTATE_CAPTURED;
202 | m_rcItem = m_rcNewPos;
203 | if( !m_bImmMode && m_pManager ) m_pManager->RemovePostPaint(this);
204 | NeedParentUpdate();
205 | return;
206 | }
207 | }
208 | if( event.Type == UIEVENT_MOUSEMOVE )
209 | {
210 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
211 | LONG cy = event.ptMouse.y - ptLastMouse.y;
212 | ptLastMouse = event.ptMouse;
213 | RECT rc = m_rcNewPos;
214 | if( m_iSepHeight >= 0 ) {
215 | if( cy > 0 && event.ptMouse.y < m_rcNewPos.bottom + m_iSepHeight ) return;
216 | if( cy < 0 && event.ptMouse.y > m_rcNewPos.bottom ) return;
217 | rc.bottom += cy;
218 | if( rc.bottom - rc.top <= GetMinHeight() ) {
219 | if( m_rcNewPos.bottom - m_rcNewPos.top <= GetMinHeight() ) return;
220 | rc.bottom = rc.top + GetMinHeight();
221 | }
222 | if( rc.bottom - rc.top >= GetMaxHeight() ) {
223 | if( m_rcNewPos.bottom - m_rcNewPos.top >= GetMaxHeight() ) return;
224 | rc.bottom = rc.top + GetMaxHeight();
225 | }
226 | }
227 | else {
228 | if( cy > 0 && event.ptMouse.y < m_rcNewPos.top ) return;
229 | if( cy < 0 && event.ptMouse.y > m_rcNewPos.top + m_iSepHeight ) return;
230 | rc.top += cy;
231 | if( rc.bottom - rc.top <= GetMinHeight() ) {
232 | if( m_rcNewPos.bottom - m_rcNewPos.top <= GetMinHeight() ) return;
233 | rc.top = rc.bottom - GetMinHeight();
234 | }
235 | if( rc.bottom - rc.top >= GetMaxHeight() ) {
236 | if( m_rcNewPos.bottom - m_rcNewPos.top >= GetMaxHeight() ) return;
237 | rc.top = rc.bottom - GetMaxHeight();
238 | }
239 | }
240 |
241 | CDuiRect rcInvalidate = GetThumbRect(true);
242 | m_rcNewPos = rc;
243 | m_cxyFixed.cy = m_rcNewPos.bottom - m_rcNewPos.top;
244 |
245 | if( m_bImmMode ) {
246 | m_rcItem = m_rcNewPos;
247 | NeedParentUpdate();
248 | }
249 | else {
250 | rcInvalidate.Join(GetThumbRect(true));
251 | rcInvalidate.Join(GetThumbRect(false));
252 | if( m_pManager ) m_pManager->Invalidate(rcInvalidate);
253 | }
254 | return;
255 | }
256 | }
257 | if( event.Type == UIEVENT_SETCURSOR )
258 | {
259 | RECT rcSeparator = GetThumbRect(false);
260 | if( IsEnabled() && ::PtInRect(&rcSeparator, event.ptMouse) ) {
261 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS)));
262 | return;
263 | }
264 | }
265 | }
266 | CContainerUI::DoEvent(event);
267 | }
268 |
269 | RECT CVerticalLayoutUI::GetThumbRect(bool bUseNew) const
270 | {
271 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 && bUseNew) {
272 | if( m_iSepHeight >= 0 )
273 | return CDuiRect(m_rcNewPos.left, MAX(m_rcNewPos.bottom - m_iSepHeight, m_rcNewPos.top),
274 | m_rcNewPos.right, m_rcNewPos.bottom);
275 | else
276 | return CDuiRect(m_rcNewPos.left, m_rcNewPos.top, m_rcNewPos.right,
277 | MIN(m_rcNewPos.top - m_iSepHeight, m_rcNewPos.bottom));
278 | }
279 | else {
280 | if( m_iSepHeight >= 0 )
281 | return CDuiRect(m_rcItem.left, MAX(m_rcItem.bottom - m_iSepHeight, m_rcItem.top), m_rcItem.right,
282 | m_rcItem.bottom);
283 | else
284 | return CDuiRect(m_rcItem.left, m_rcItem.top, m_rcItem.right,
285 | MIN(m_rcItem.top - m_iSepHeight, m_rcItem.bottom));
286 |
287 | }
288 | }
289 | }
290 |
--------------------------------------------------------------------------------
/DuiLib/DuiLib.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {0beade84-9bdb-47d6-8646-22f810f44478}
6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat
7 |
8 |
9 | {0937fcf2-c781-435f-8f11-23e1b232cdb0}
10 |
11 |
12 | {8df57117-d8ab-411e-a70c-419488576987}
13 |
14 |
15 | {7442fddb-1a86-4036-ab51-f64e29438eb1}
16 |
17 |
18 | {c16bee10-6b61-4c5a-a7cb-63d23f55caa0}
19 |
20 |
21 | {eff9c2cd-9938-4b6a-ae5e-a4e1c929339e}
22 | h;hpp;hxx;hm;inl
23 |
24 |
25 | {b11ac541-8a66-492d-9a07-b2111efeb8ed}
26 |
27 |
28 | {19b6b007-2c36-43c8-879e-df3899788b45}
29 |
30 |
31 | {a0457c55-9312-43af-9f97-8c6edbbef0ab}
32 |
33 |
34 | {6e1ecb2c-f2e2-4bb3-baa1-b500975b70c0}
35 |
36 |
37 | {91048e31-3afa-4093-9d58-fbed506f840c}
38 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe
39 |
40 |
41 |
42 |
43 | Source Files
44 |
45 |
46 | Source Files
47 |
48 |
49 | Source Files
50 |
51 |
52 | Source Files\Utils
53 |
54 |
55 | Source Files\Utils
56 |
57 |
58 | Source Files\Utils
59 |
60 |
61 | Source Files\Utils
62 |
63 |
64 | Source Files\Core
65 |
66 |
67 | Source Files\Core
68 |
69 |
70 | Source Files\Core
71 |
72 |
73 | Source Files\Core
74 |
75 |
76 | Source Files\Core
77 |
78 |
79 | Source Files\Core
80 |
81 |
82 | Source Files\Core
83 |
84 |
85 | Source Files\Layout
86 |
87 |
88 | Source Files\Layout
89 |
90 |
91 | Source Files\Layout
92 |
93 |
94 | Source Files\Layout
95 |
96 |
97 | Source Files\Layout
98 |
99 |
100 | Source Files\Control
101 |
102 |
103 | Source Files\Control
104 |
105 |
106 | Source Files\Control
107 |
108 |
109 | Source Files\Control
110 |
111 |
112 | Source Files\Control
113 |
114 |
115 | Source Files\Control
116 |
117 |
118 | Source Files\Control
119 |
120 |
121 | Source Files\Control
122 |
123 |
124 | Source Files\Control
125 |
126 |
127 | Source Files\Control
128 |
129 |
130 | Source Files\Control
131 |
132 |
133 | Source Files\Control
134 |
135 |
136 | Source Files\Control
137 |
138 |
139 | Source Files\Control
140 |
141 |
142 | Source Files\Control
143 |
144 |
145 | Source Files\Control
146 |
147 |
148 | Source Files\Control
149 |
150 |
151 | Source Files\Control
152 |
153 |
154 | Source Files\Utils
155 |
156 |
157 |
158 |
159 | Header Files
160 |
161 |
162 | Header Files
163 |
164 |
165 | Header Files\Utils
166 |
167 |
168 | Header Files\Utils
169 |
170 |
171 | Header Files\Utils
172 |
173 |
174 | Header Files\Utils
175 |
176 |
177 | Header Files\Utils
178 |
179 |
180 | Header Files\Utils
181 |
182 |
183 | Header Files\Core
184 |
185 |
186 | Header Files\Core
187 |
188 |
189 | Header Files\Core
190 |
191 |
192 | Header Files\Core
193 |
194 |
195 | Header Files\Core
196 |
197 |
198 | Header Files\Core
199 |
200 |
201 | Header Files\Core
202 |
203 |
204 | Header Files\Core
205 |
206 |
207 | Header Files\Layout
208 |
209 |
210 | Header Files\Layout
211 |
212 |
213 | Header Files\Layout
214 |
215 |
216 | Header Files\Layout
217 |
218 |
219 | Header Files\Layout
220 |
221 |
222 | Header Files\Control
223 |
224 |
225 | Header Files\Control
226 |
227 |
228 | Header Files\Control
229 |
230 |
231 | Header Files\Control
232 |
233 |
234 | Header Files\Control
235 |
236 |
237 | Header Files\Control
238 |
239 |
240 | Header Files\Control
241 |
242 |
243 | Header Files\Control
244 |
245 |
246 | Header Files\Control
247 |
248 |
249 | Header Files\Control
250 |
251 |
252 | Header Files\Control
253 |
254 |
255 | Header Files\Control
256 |
257 |
258 | Header Files\Control
259 |
260 |
261 | Header Files\Control
262 |
263 |
264 | Header Files\Control
265 |
266 |
267 | Header Files\Control
268 |
269 |
270 | Header Files\Control
271 |
272 |
273 | Header Files\Control
274 |
275 |
276 | Header Files\Utils
277 |
278 |
279 |
--------------------------------------------------------------------------------
/DuiLib/Control/UIButton.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIButton.h"
3 |
4 | namespace DuiLib
5 | {
6 | CButtonUI::CButtonUI()
7 | : m_uButtonState(0)
8 | , m_dwHotTextColor(0)
9 | , m_dwPushedTextColor(0)
10 | , m_dwFocusedTextColor(0)
11 | ,m_dwHotBkColor(0)
12 | {
13 | m_uTextStyle = DT_SINGLELINE | DT_VCENTER | DT_CENTER;
14 | }
15 |
16 | LPCTSTR CButtonUI::GetClass() const
17 | {
18 | return _T("ButtonUI");
19 | }
20 |
21 | LPVOID CButtonUI::GetInterface(LPCTSTR pstrName)
22 | {
23 | if( _tcscmp(pstrName, DUI_CTR_BUTTON) == 0 ) return static_cast(this);
24 | return CLabelUI::GetInterface(pstrName);
25 | }
26 |
27 | UINT CButtonUI::GetControlFlags() const
28 | {
29 | return (IsKeyboardEnabled() ? UIFLAG_TABSTOP : 0) | (IsEnabled() ? UIFLAG_SETCURSOR : 0);
30 | }
31 |
32 | void CButtonUI::DoEvent(TEventUI& event)
33 | {
34 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) {
35 | if( m_pParent != NULL ) m_pParent->DoEvent(event);
36 | else CLabelUI::DoEvent(event);
37 | return;
38 | }
39 |
40 | if( event.Type == UIEVENT_SETFOCUS )
41 | {
42 | Invalidate();
43 | }
44 | if( event.Type == UIEVENT_KILLFOCUS )
45 | {
46 | Invalidate();
47 | }
48 | if( event.Type == UIEVENT_KEYDOWN )
49 | {
50 | if (IsKeyboardEnabled()) {
51 | if( event.chKey == VK_SPACE || event.chKey == VK_RETURN ) {
52 | Activate();
53 | return;
54 | }
55 | }
56 | }
57 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK )
58 | {
59 | if( ::PtInRect(&m_rcItem, event.ptMouse) && IsEnabled() ) {
60 | m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED;
61 | Invalidate();
62 | }
63 | return;
64 | }
65 | if( event.Type == UIEVENT_MOUSEMOVE )
66 | {
67 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
68 | if( ::PtInRect(&m_rcItem, event.ptMouse) ) m_uButtonState |= UISTATE_PUSHED;
69 | else m_uButtonState &= ~UISTATE_PUSHED;
70 | Invalidate();
71 | }
72 | return;
73 | }
74 | if( event.Type == UIEVENT_BUTTONUP )
75 | {
76 | if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
77 | if( ::PtInRect(&m_rcItem, event.ptMouse) ) Activate();
78 | m_uButtonState &= ~(UISTATE_PUSHED | UISTATE_CAPTURED);
79 | Invalidate();
80 | }
81 | return;
82 | }
83 | if( event.Type == UIEVENT_CONTEXTMENU )
84 | {
85 | if( IsContextMenuUsed() ) {
86 | m_pManager->SendNotify(this, DUI_MSGTYPE_MENU, event.wParam, event.lParam);
87 | }
88 | return;
89 | }
90 | if( event.Type == UIEVENT_MOUSEENTER )
91 | {
92 | if( IsEnabled() ) {
93 | m_uButtonState |= UISTATE_HOT;
94 | Invalidate();
95 | }
96 | // return;
97 | }
98 | if( event.Type == UIEVENT_MOUSELEAVE )
99 | {
100 | if( IsEnabled() ) {
101 | m_uButtonState &= ~UISTATE_HOT;
102 | Invalidate();
103 | }
104 | // return;
105 | }
106 | if( event.Type == UIEVENT_SETCURSOR ) {
107 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
108 | return;
109 | }
110 | CLabelUI::DoEvent(event);
111 | }
112 |
113 | bool CButtonUI::Activate()
114 | {
115 | if( !CControlUI::Activate() ) return false;
116 | if( m_pManager != NULL ) m_pManager->SendNotify(this, DUI_MSGTYPE_CLICK);
117 | return true;
118 | }
119 |
120 | void CButtonUI::SetEnabled(bool bEnable)
121 | {
122 | CControlUI::SetEnabled(bEnable);
123 | if( !IsEnabled() ) {
124 | m_uButtonState = 0;
125 | }
126 | }
127 |
128 | //************************************
129 | // Method: SetHotBkColor
130 | // FullName: CButtonUI::SetHotBkColor
131 | // Access: public
132 | // Returns: void
133 | // Qualifier:
134 | // Parameter: DWORD dwColor
135 | // Note:
136 | //************************************
137 | void CButtonUI::SetHotBkColor( DWORD dwColor )
138 | {
139 | m_dwHotBkColor = dwColor;
140 | }
141 |
142 | //************************************
143 | // Method: GetHotBkColor
144 | // FullName: CButtonUI::GetHotBkColor
145 | // Access: public
146 | // Returns: DWORD
147 | // Qualifier: const
148 | // Note:
149 | //************************************
150 | DWORD CButtonUI::GetHotBkColor() const
151 | {
152 | return m_dwHotBkColor;
153 | }
154 |
155 | void CButtonUI::SetHotTextColor(DWORD dwColor)
156 | {
157 | m_dwHotTextColor = dwColor;
158 | }
159 |
160 | DWORD CButtonUI::GetHotTextColor() const
161 | {
162 | return m_dwHotTextColor;
163 | }
164 |
165 | void CButtonUI::SetPushedTextColor(DWORD dwColor)
166 | {
167 | m_dwPushedTextColor = dwColor;
168 | }
169 |
170 | DWORD CButtonUI::GetPushedTextColor() const
171 | {
172 | return m_dwPushedTextColor;
173 | }
174 |
175 | void CButtonUI::SetFocusedTextColor(DWORD dwColor)
176 | {
177 | m_dwFocusedTextColor = dwColor;
178 | }
179 |
180 | DWORD CButtonUI::GetFocusedTextColor() const
181 | {
182 | return m_dwFocusedTextColor;
183 | }
184 |
185 | LPCTSTR CButtonUI::GetNormalImage()
186 | {
187 | return m_sNormalImage;
188 | }
189 |
190 | void CButtonUI::SetNormalImage(LPCTSTR pStrImage)
191 | {
192 | m_sNormalImage = pStrImage;
193 | Invalidate();
194 | }
195 |
196 | LPCTSTR CButtonUI::GetHotImage()
197 | {
198 | return m_sHotImage;
199 | }
200 |
201 | void CButtonUI::SetHotImage(LPCTSTR pStrImage)
202 | {
203 | m_sHotImage = pStrImage;
204 | Invalidate();
205 | }
206 |
207 | LPCTSTR CButtonUI::GetPushedImage()
208 | {
209 | return m_sPushedImage;
210 | }
211 |
212 | void CButtonUI::SetPushedImage(LPCTSTR pStrImage)
213 | {
214 | m_sPushedImage = pStrImage;
215 | Invalidate();
216 | }
217 |
218 | LPCTSTR CButtonUI::GetFocusedImage()
219 | {
220 | return m_sFocusedImage;
221 | }
222 |
223 | void CButtonUI::SetFocusedImage(LPCTSTR pStrImage)
224 | {
225 | m_sFocusedImage = pStrImage;
226 | Invalidate();
227 | }
228 |
229 | LPCTSTR CButtonUI::GetDisabledImage()
230 | {
231 | return m_sDisabledImage;
232 | }
233 |
234 | void CButtonUI::SetDisabledImage(LPCTSTR pStrImage)
235 | {
236 | m_sDisabledImage = pStrImage;
237 | Invalidate();
238 | }
239 |
240 | //************************************
241 | // Method: GetForeImage
242 | // FullName: CButtonUI::GetForeImage
243 | // Access: public
244 | // Returns: LPCTSTR
245 | // Qualifier:
246 | // Note:
247 | //************************************
248 | LPCTSTR CButtonUI::GetForeImage()
249 | {
250 | return m_sForeImage;
251 | }
252 |
253 | //************************************
254 | // Method: SetForeImage
255 | // FullName: CButtonUI::SetForeImage
256 | // Access: public
257 | // Returns: void
258 | // Qualifier:
259 | // Parameter: LPCTSTR pStrImage
260 | // Note:
261 | //************************************
262 | void CButtonUI::SetForeImage( LPCTSTR pStrImage )
263 | {
264 | m_sForeImage = pStrImage;
265 | Invalidate();
266 | }
267 |
268 | //************************************
269 | // Method: GetHotForeImage
270 | // FullName: CButtonUI::GetHotForeImage
271 | // Access: public
272 | // Returns: LPCTSTR
273 | // Qualifier:
274 | // Note:
275 | //************************************
276 | LPCTSTR CButtonUI::GetHotForeImage()
277 | {
278 | return m_sHotForeImage;
279 | }
280 |
281 | //************************************
282 | // Method: SetHotForeImage
283 | // FullName: CButtonUI::SetHotForeImage
284 | // Access: public
285 | // Returns: void
286 | // Qualifier:
287 | // Parameter: LPCTSTR pStrImage
288 | // Note:
289 | //************************************
290 | void CButtonUI::SetHotForeImage( LPCTSTR pStrImage )
291 | {
292 | m_sHotForeImage = pStrImage;
293 | Invalidate();
294 | }
295 |
296 | SIZE CButtonUI::EstimateSize(SIZE szAvailable)
297 | {
298 | if( m_cxyFixed.cy == 0 ) return CSize(m_cxyFixed.cx, m_pManager->GetFontInfo(GetFont())->tm.tmHeight + 8);
299 | return CControlUI::EstimateSize(szAvailable);
300 | }
301 |
302 | void CButtonUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
303 | {
304 | if( _tcscmp(pstrName, _T("normalimage")) == 0 ) SetNormalImage(pstrValue);
305 | else if( _tcscmp(pstrName, _T("hotimage")) == 0 ) SetHotImage(pstrValue);
306 | else if( _tcscmp(pstrName, _T("pushedimage")) == 0 ) SetPushedImage(pstrValue);
307 | else if( _tcscmp(pstrName, _T("focusedimage")) == 0 ) SetFocusedImage(pstrValue);
308 | else if( _tcscmp(pstrName, _T("disabledimage")) == 0 ) SetDisabledImage(pstrValue);
309 | else if( _tcscmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue);
310 | else if( _tcscmp(pstrName, _T("hotforeimage")) == 0 ) SetHotForeImage(pstrValue);
311 | else if( _tcscmp(pstrName, _T("hotbkcolor")) == 0 )
312 | {
313 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
314 | LPTSTR pstr = NULL;
315 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
316 | SetHotBkColor(clrColor);
317 | }
318 | else if( _tcscmp(pstrName, _T("hottextcolor")) == 0 )
319 | {
320 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
321 | LPTSTR pstr = NULL;
322 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
323 | SetHotTextColor(clrColor);
324 | }
325 | else if( _tcscmp(pstrName, _T("pushedtextcolor")) == 0 )
326 | {
327 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
328 | LPTSTR pstr = NULL;
329 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
330 | SetPushedTextColor(clrColor);
331 | }
332 | else if( _tcscmp(pstrName, _T("focusedtextcolor")) == 0 )
333 | {
334 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
335 | LPTSTR pstr = NULL;
336 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
337 | SetFocusedTextColor(clrColor);
338 | }
339 | else CLabelUI::SetAttribute(pstrName, pstrValue);
340 | }
341 |
342 | void CButtonUI::PaintText(HDC hDC)
343 | {
344 | if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED;
345 | else m_uButtonState &= ~ UISTATE_FOCUSED;
346 | if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED;
347 | else m_uButtonState &= ~ UISTATE_DISABLED;
348 |
349 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor();
350 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor();
351 |
352 | if( m_sText.IsEmpty() ) return;
353 | int nLinks = 0;
354 | RECT rc = m_rcItem;
355 | rc.left += m_rcTextPadding.left;
356 | rc.right -= m_rcTextPadding.right;
357 | rc.top += m_rcTextPadding.top;
358 | rc.bottom -= m_rcTextPadding.bottom;
359 |
360 | DWORD clrColor = IsEnabled()?m_dwTextColor:m_dwDisabledTextColor;
361 |
362 | if( ((m_uButtonState & UISTATE_PUSHED) != 0) && (GetPushedTextColor() != 0) )
363 | clrColor = GetPushedTextColor();
364 | else if( ((m_uButtonState & UISTATE_HOT) != 0) && (GetHotTextColor() != 0) )
365 | clrColor = GetHotTextColor();
366 | else if( ((m_uButtonState & UISTATE_FOCUSED) != 0) && (GetFocusedTextColor() != 0) )
367 | clrColor = GetFocusedTextColor();
368 |
369 | if( m_bShowHtml )
370 | CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, clrColor, \
371 | NULL, NULL, nLinks, m_uTextStyle);
372 | else
373 | CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, clrColor, \
374 | m_iFont, m_uTextStyle);
375 | }
376 |
377 | void CButtonUI::PaintStatusImage(HDC hDC)
378 | {
379 | if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED;
380 | else m_uButtonState &= ~ UISTATE_FOCUSED;
381 | if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED;
382 | else m_uButtonState &= ~ UISTATE_DISABLED;
383 |
384 | if( (m_uButtonState & UISTATE_DISABLED) != 0 ) {
385 | if( !m_sDisabledImage.IsEmpty() )
386 | {
387 | if( !DrawImage(hDC, (LPCTSTR)m_sDisabledImage) ) m_sDisabledImage.Empty();
388 | else goto Label_ForeImage;
389 | }
390 | }
391 | else if( (m_uButtonState & UISTATE_PUSHED) != 0 ) {
392 | if( !m_sPushedImage.IsEmpty() ) {
393 | if( !DrawImage(hDC, (LPCTSTR)m_sPushedImage) ){
394 | m_sPushedImage.Empty();
395 | }
396 | if( !m_sPushedForeImage.IsEmpty() )
397 | {
398 | if( !DrawImage(hDC, (LPCTSTR)m_sPushedForeImage) )
399 | m_sPushedForeImage.Empty();
400 | return;
401 | }
402 | else goto Label_ForeImage;
403 | }
404 | }
405 | else if( (m_uButtonState & UISTATE_HOT) != 0 ) {
406 | if( !m_sHotImage.IsEmpty() ) {
407 | if( !DrawImage(hDC, (LPCTSTR)m_sHotImage) ){
408 | m_sHotImage.Empty();
409 | }
410 | if( !m_sHotForeImage.IsEmpty() ) {
411 | if( !DrawImage(hDC, (LPCTSTR)m_sHotForeImage) )
412 | m_sHotForeImage.Empty();
413 | return;
414 | }
415 | else goto Label_ForeImage;
416 | }
417 | else if(m_dwHotBkColor != 0) {
418 | CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwHotBkColor));
419 | return;
420 | }
421 | }
422 | else if( (m_uButtonState & UISTATE_FOCUSED) != 0 ) {
423 | if( !m_sFocusedImage.IsEmpty() ) {
424 | if( !DrawImage(hDC, (LPCTSTR)m_sFocusedImage) ) m_sFocusedImage.Empty();
425 | else goto Label_ForeImage;
426 | }
427 | }
428 |
429 | if( !m_sNormalImage.IsEmpty() ) {
430 | if( !DrawImage(hDC, (LPCTSTR)m_sNormalImage) ) m_sNormalImage.Empty();
431 | else goto Label_ForeImage;
432 | }
433 |
434 | if(!m_sForeImage.IsEmpty() )
435 | goto Label_ForeImage;
436 |
437 | return;
438 |
439 | Label_ForeImage:
440 | if(!m_sForeImage.IsEmpty() ) {
441 | if( !DrawImage(hDC, (LPCTSTR)m_sForeImage) ) m_sForeImage.Empty();
442 | }
443 | }
444 | }
--------------------------------------------------------------------------------
/DuiLib/Control/UIEdit.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "UIEdit.h"
3 |
4 | namespace DuiLib
5 | {
6 | class CEditWnd : public CWindowWnd
7 | {
8 | public:
9 | CEditWnd();
10 |
11 | void Init(CEditUI* pOwner);
12 | RECT CalPos();
13 |
14 | LPCTSTR GetWindowClassName() const;
15 | LPCTSTR GetSuperClassName() const;
16 | void OnFinalMessage(HWND hWnd);
17 |
18 | LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
19 | LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
20 | LRESULT OnEditChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
21 |
22 | protected:
23 | CEditUI* m_pOwner;
24 | HBRUSH m_hBkBrush;
25 | bool m_bInit;
26 | };
27 |
28 |
29 | CEditWnd::CEditWnd() : m_pOwner(NULL), m_hBkBrush(NULL), m_bInit(false)
30 | {
31 | }
32 |
33 | void CEditWnd::Init(CEditUI* pOwner)
34 | {
35 | m_pOwner = pOwner;
36 | RECT rcPos = CalPos();
37 | UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;
38 | if( m_pOwner->IsPasswordMode() ) uStyle |= ES_PASSWORD;
39 | Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
40 | HFONT hFont=NULL;
41 | int iFontIndex=m_pOwner->GetFont();
42 | if (iFontIndex!=-1)
43 | hFont=m_pOwner->GetManager()->GetFont(iFontIndex);
44 | if (hFont==NULL)
45 | hFont=m_pOwner->GetManager()->GetDefaultFontInfo()->hFont;
46 |
47 | SetWindowFont(m_hWnd, hFont, TRUE);
48 | Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
49 | if( m_pOwner->IsPasswordMode() ) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
50 | Edit_SetText(m_hWnd, m_pOwner->GetText());
51 | Edit_SetModify(m_hWnd, FALSE);
52 | SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
53 | Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
54 | Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
55 | //Styls
56 | LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE);
57 | styleValue |= pOwner->GetWindowStyls();
58 | ::SetWindowLong(GetHWND(), GWL_STYLE, styleValue);
59 | ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
60 | ::SetFocus(m_hWnd);
61 | m_bInit = true;
62 | }
63 |
64 | RECT CEditWnd::CalPos()
65 | {
66 | CDuiRect rcPos = m_pOwner->GetPos();
67 | RECT rcInset = m_pOwner->GetTextPadding();
68 | rcPos.left += rcInset.left;
69 | rcPos.top += rcInset.top;
70 | rcPos.right -= rcInset.right;
71 | rcPos.bottom -= rcInset.bottom;
72 | LONG lEditHeight = m_pOwner->GetManager()->GetFontInfo(m_pOwner->GetFont())->tm.tmHeight;
73 | if( lEditHeight < rcPos.GetHeight() ) {
74 | rcPos.top += (rcPos.GetHeight() - lEditHeight) / 2;
75 | rcPos.bottom = rcPos.top + lEditHeight;
76 | }
77 | return rcPos;
78 | }
79 |
80 | LPCTSTR CEditWnd::GetWindowClassName() const
81 | {
82 | return _T("EditWnd");
83 | }
84 |
85 | LPCTSTR CEditWnd::GetSuperClassName() const
86 | {
87 | return WC_EDIT;
88 | }
89 |
90 | void CEditWnd::OnFinalMessage(HWND /*hWnd*/)
91 | {
92 | m_pOwner->Invalidate();
93 | // Clear reference and die
94 | if( m_hBkBrush != NULL ) ::DeleteObject(m_hBkBrush);
95 | m_pOwner->m_pWindow = NULL;
96 | delete this;
97 | }
98 |
99 | LRESULT CEditWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
100 | {
101 | LRESULT lRes = 0;
102 | BOOL bHandled = TRUE;
103 | if( uMsg == WM_KILLFOCUS ) lRes = OnKillFocus(uMsg, wParam, lParam, bHandled);
104 | else if( uMsg == OCM_COMMAND ) {
105 | if( GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE ) lRes = OnEditChanged(uMsg, wParam, lParam, bHandled);
106 | else if( GET_WM_COMMAND_CMD(wParam, lParam) == EN_UPDATE ) {
107 | RECT rcClient;
108 | ::GetClientRect(m_hWnd, &rcClient);
109 | ::InvalidateRect(m_hWnd, &rcClient, FALSE);
110 | }
111 | }
112 | else if( uMsg == WM_KEYDOWN && TCHAR(wParam) == VK_RETURN ) {
113 | m_pOwner->GetManager()->SendNotify(m_pOwner, DUI_MSGTYPE_RETURN);
114 | }
115 | else if( uMsg == OCM__BASE + WM_CTLCOLOREDIT || uMsg == OCM__BASE + WM_CTLCOLORSTATIC ) {
116 | if( m_pOwner->GetNativeEditBkColor() == 0xFFFFFFFF ) return NULL;
117 | ::SetBkMode((HDC)wParam, TRANSPARENT);
118 | DWORD dwTextColor = m_pOwner->GetTextColor();
119 | ::SetTextColor((HDC)wParam, RGB(GetBValue(dwTextColor),GetGValue(dwTextColor),GetRValue(dwTextColor)));
120 | if( m_hBkBrush == NULL ) {
121 | DWORD clrColor = m_pOwner->GetNativeEditBkColor();
122 | m_hBkBrush = ::CreateSolidBrush(RGB(GetBValue(clrColor), GetGValue(clrColor), GetRValue(clrColor)));
123 | }
124 | return (LRESULT)m_hBkBrush;
125 | }
126 | else bHandled = FALSE;
127 | if( !bHandled ) return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
128 | return lRes;
129 | }
130 |
131 | LRESULT CEditWnd::OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
132 | {
133 | LRESULT lRes = ::DefWindowProc(m_hWnd, uMsg, wParam, lParam);
134 | PostMessage(WM_CLOSE);
135 | return lRes;
136 | }
137 |
138 | LRESULT CEditWnd::OnEditChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
139 | {
140 | if( !m_bInit ) return 0;
141 | if( m_pOwner == NULL ) return 0;
142 | // Copy text back
143 | int cchLen = ::GetWindowTextLength(m_hWnd) + 1;
144 | LPTSTR pstr = static_cast(_alloca(cchLen * sizeof(TCHAR)));
145 | ASSERT(pstr);
146 | if( pstr == NULL ) return 0;
147 | ::GetWindowText(m_hWnd, pstr, cchLen);
148 | m_pOwner->m_sText = pstr;
149 | m_pOwner->GetManager()->SendNotify(m_pOwner, DUI_MSGTYPE_TEXTCHANGED);
150 | return 0;
151 | }
152 |
153 |
154 | /////////////////////////////////////////////////////////////////////////////////////
155 | //
156 | //
157 |
158 | CEditUI::CEditUI() : m_pWindow(NULL), m_uMaxChar(255), m_bReadOnly(false),
159 | m_bPasswordMode(false), m_cPasswordChar(_T('*')), m_uButtonState(0),
160 | m_dwEditbkColor(0xFFFFFFFF), m_iWindowStyls(0)
161 | {
162 | SetTextPadding(CDuiRect(4, 3, 4, 3));
163 | SetBkColor(0xFFFFFFFF);
164 | }
165 |
166 | LPCTSTR CEditUI::GetClass() const
167 | {
168 | return _T("EditUI");
169 | }
170 |
171 | LPVOID CEditUI::GetInterface(LPCTSTR pstrName)
172 | {
173 | if( _tcscmp(pstrName, DUI_CTR_EDIT) == 0 ) return static_cast(this);
174 | return CLabelUI::GetInterface(pstrName);
175 | }
176 |
177 | UINT CEditUI::GetControlFlags() const
178 | {
179 | if( !IsEnabled() ) return CControlUI::GetControlFlags();
180 |
181 | return UIFLAG_SETCURSOR | UIFLAG_TABSTOP;
182 | }
183 |
184 | void CEditUI::DoEvent(TEventUI& event)
185 | {
186 | if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) {
187 | if( m_pParent != NULL ) m_pParent->DoEvent(event);
188 | else CLabelUI::DoEvent(event);
189 | return;
190 | }
191 |
192 | if( event.Type == UIEVENT_SETCURSOR && IsEnabled() )
193 | {
194 | ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_IBEAM)));
195 | return;
196 | }
197 | if( event.Type == UIEVENT_WINDOWSIZE )
198 | {
199 | if( m_pWindow != NULL ) m_pManager->SetFocusNeeded(this);
200 | }
201 | if( event.Type == UIEVENT_SCROLLWHEEL )
202 | {
203 | if( m_pWindow != NULL ) return;
204 | }
205 | if( event.Type == UIEVENT_SETFOCUS && IsEnabled() )
206 | {
207 | if( m_pWindow ) return;
208 | m_pWindow = new CEditWnd();
209 | ASSERT(m_pWindow);
210 | m_pWindow->Init(this);
211 | Invalidate();
212 | }
213 | if( event.Type == UIEVENT_KILLFOCUS && IsEnabled() )
214 | {
215 | Invalidate();
216 | }
217 | if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK || event.Type == UIEVENT_RBUTTONDOWN)
218 | {
219 | if( IsEnabled() ) {
220 | GetManager()->ReleaseCapture();
221 | if( IsFocused() && m_pWindow == NULL )
222 | {
223 | m_pWindow = new CEditWnd();
224 | ASSERT(m_pWindow);
225 | m_pWindow->Init(this);
226 |
227 | if( PtInRect(&m_rcItem, event.ptMouse) )
228 | {
229 | int nSize = GetWindowTextLength(*m_pWindow);
230 | if( nSize == 0 )
231 | nSize = 1;
232 |
233 | Edit_SetSel(*m_pWindow, 0, nSize);
234 | }
235 | }
236 | else if( m_pWindow != NULL )
237 | {
238 | #if 1
239 | int nSize = GetWindowTextLength(*m_pWindow);
240 | if( nSize == 0 )
241 | nSize = 1;
242 |
243 | Edit_SetSel(*m_pWindow, 0, nSize);
244 | #else
245 | POINT pt = event.ptMouse;
246 | pt.x -= m_rcItem.left + m_rcTextPadding.left;
247 | pt.y -= m_rcItem.top + m_rcTextPadding.top;
248 | ::SendMessage(*m_pWindow, WM_LBUTTONDOWN, event.wParam, MAKELPARAM(pt.x, pt.y));
249 | #endif
250 | }
251 | }
252 | return;
253 | }
254 | if( event.Type == UIEVENT_MOUSEMOVE )
255 | {
256 | return;
257 | }
258 | if( event.Type == UIEVENT_BUTTONUP )
259 | {
260 | return;
261 | }
262 | if( event.Type == UIEVENT_CONTEXTMENU )
263 | {
264 | return;
265 | }
266 | if( event.Type == UIEVENT_MOUSEENTER )
267 | {
268 | if( IsEnabled() ) {
269 | m_uButtonState |= UISTATE_HOT;
270 | Invalidate();
271 | }
272 | return;
273 | }
274 | if( event.Type == UIEVENT_MOUSELEAVE )
275 | {
276 | if( IsEnabled() ) {
277 | m_uButtonState &= ~UISTATE_HOT;
278 | Invalidate();
279 | }
280 | return;
281 | }
282 | CLabelUI::DoEvent(event);
283 | }
284 |
285 | void CEditUI::SetEnabled(bool bEnable)
286 | {
287 | CControlUI::SetEnabled(bEnable);
288 | if( !IsEnabled() ) {
289 | m_uButtonState = 0;
290 | }
291 | }
292 |
293 | void CEditUI::SetText(LPCTSTR pstrText)
294 | {
295 | m_sText = pstrText;
296 | if( m_pWindow != NULL ) Edit_SetText(*m_pWindow, m_sText);
297 | Invalidate();
298 | }
299 |
300 | void CEditUI::SetMaxChar(UINT uMax)
301 | {
302 | m_uMaxChar = uMax;
303 | if( m_pWindow != NULL ) Edit_LimitText(*m_pWindow, m_uMaxChar);
304 | }
305 |
306 | UINT CEditUI::GetMaxChar()
307 | {
308 | return m_uMaxChar;
309 | }
310 |
311 | void CEditUI::SetReadOnly(bool bReadOnly)
312 | {
313 | if( m_bReadOnly == bReadOnly ) return;
314 |
315 | m_bReadOnly = bReadOnly;
316 | if( m_pWindow != NULL ) Edit_SetReadOnly(*m_pWindow, m_bReadOnly);
317 | Invalidate();
318 | }
319 |
320 | bool CEditUI::IsReadOnly() const
321 | {
322 | return m_bReadOnly;
323 | }
324 |
325 | void CEditUI::SetNumberOnly(bool bNumberOnly)
326 | {
327 | if( bNumberOnly )
328 | {
329 | m_iWindowStyls |= ES_NUMBER;
330 | }
331 | else
332 | {
333 | m_iWindowStyls |= ~ES_NUMBER;
334 | }
335 | }
336 |
337 | bool CEditUI::IsNumberOnly() const
338 | {
339 | return m_iWindowStyls&ES_NUMBER ? true:false;
340 | }
341 |
342 | int CEditUI::GetWindowStyls() const
343 | {
344 | return m_iWindowStyls;
345 | }
346 |
347 | void CEditUI::SetPasswordMode(bool bPasswordMode)
348 | {
349 | if( m_bPasswordMode == bPasswordMode ) return;
350 | m_bPasswordMode = bPasswordMode;
351 | Invalidate();
352 | }
353 |
354 | bool CEditUI::IsPasswordMode() const
355 | {
356 | return m_bPasswordMode;
357 | }
358 |
359 | void CEditUI::SetPasswordChar(TCHAR cPasswordChar)
360 | {
361 | if( m_cPasswordChar == cPasswordChar ) return;
362 | m_cPasswordChar = cPasswordChar;
363 | if( m_pWindow != NULL ) Edit_SetPasswordChar(*m_pWindow, m_cPasswordChar);
364 | Invalidate();
365 | }
366 |
367 | TCHAR CEditUI::GetPasswordChar() const
368 | {
369 | return m_cPasswordChar;
370 | }
371 |
372 | LPCTSTR CEditUI::GetNormalImage()
373 | {
374 | return m_sNormalImage;
375 | }
376 |
377 | void CEditUI::SetNormalImage(LPCTSTR pStrImage)
378 | {
379 | m_sNormalImage = pStrImage;
380 | Invalidate();
381 | }
382 |
383 | LPCTSTR CEditUI::GetHotImage()
384 | {
385 | return m_sHotImage;
386 | }
387 |
388 | void CEditUI::SetHotImage(LPCTSTR pStrImage)
389 | {
390 | m_sHotImage = pStrImage;
391 | Invalidate();
392 | }
393 |
394 | LPCTSTR CEditUI::GetFocusedImage()
395 | {
396 | return m_sFocusedImage;
397 | }
398 |
399 | void CEditUI::SetFocusedImage(LPCTSTR pStrImage)
400 | {
401 | m_sFocusedImage = pStrImage;
402 | Invalidate();
403 | }
404 |
405 | LPCTSTR CEditUI::GetDisabledImage()
406 | {
407 | return m_sDisabledImage;
408 | }
409 |
410 | void CEditUI::SetDisabledImage(LPCTSTR pStrImage)
411 | {
412 | m_sDisabledImage = pStrImage;
413 | Invalidate();
414 | }
415 |
416 | void CEditUI::SetNativeEditBkColor(DWORD dwBkColor)
417 | {
418 | m_dwEditbkColor = dwBkColor;
419 | }
420 |
421 | DWORD CEditUI::GetNativeEditBkColor() const
422 | {
423 | return m_dwEditbkColor;
424 | }
425 |
426 | void CEditUI::SetSel(long nStartChar, long nEndChar)
427 | {
428 | if( m_pWindow != NULL ) Edit_SetSel(*m_pWindow, nStartChar,nEndChar);
429 | }
430 |
431 | void CEditUI::SetSelAll()
432 | {
433 | SetSel(0,-1);
434 | }
435 |
436 | void CEditUI::SetReplaceSel(LPCTSTR lpszReplace)
437 | {
438 | if( m_pWindow != NULL ) Edit_ReplaceSel(*m_pWindow, lpszReplace);
439 | }
440 |
441 | void CEditUI::SetPos(RECT rc)
442 | {
443 | CControlUI::SetPos(rc);
444 | if( m_pWindow != NULL ) {
445 | RECT rcPos = m_pWindow->CalPos();
446 | ::SetWindowPos(m_pWindow->GetHWND(), NULL, rcPos.left, rcPos.top, rcPos.right - rcPos.left,
447 | rcPos.bottom - rcPos.top, SWP_NOZORDER | SWP_NOACTIVATE);
448 | }
449 | }
450 |
451 | void CEditUI::SetVisible(bool bVisible)
452 | {
453 | CControlUI::SetVisible(bVisible);
454 | if( !IsVisible() && m_pWindow != NULL ) m_pManager->SetFocus(NULL);
455 | }
456 |
457 | void CEditUI::SetInternVisible(bool bVisible)
458 | {
459 | if( !IsVisible() && m_pWindow != NULL ) m_pManager->SetFocus(NULL);
460 | }
461 |
462 | SIZE CEditUI::EstimateSize(SIZE szAvailable)
463 | {
464 | if( m_cxyFixed.cy == 0 ) return CSize(m_cxyFixed.cx, m_pManager->GetFontInfo(GetFont())->tm.tmHeight + 6);
465 | return CControlUI::EstimateSize(szAvailable);
466 | }
467 |
468 | void CEditUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
469 | {
470 | if( _tcscmp(pstrName, _T("readonly")) == 0 ) SetReadOnly(_tcscmp(pstrValue, _T("true")) == 0);
471 | else if( _tcscmp(pstrName, _T("numberonly")) == 0 ) SetNumberOnly(_tcscmp(pstrValue, _T("true")) == 0);
472 | else if( _tcscmp(pstrName, _T("password")) == 0 ) SetPasswordMode(_tcscmp(pstrValue, _T("true")) == 0);
473 | else if( _tcscmp(pstrName, _T("maxchar")) == 0 ) SetMaxChar(_ttoi(pstrValue));
474 | else if( _tcscmp(pstrName, _T("normalimage")) == 0 ) SetNormalImage(pstrValue);
475 | else if( _tcscmp(pstrName, _T("hotimage")) == 0 ) SetHotImage(pstrValue);
476 | else if( _tcscmp(pstrName, _T("focusedimage")) == 0 ) SetFocusedImage(pstrValue);
477 | else if( _tcscmp(pstrName, _T("disabledimage")) == 0 ) SetDisabledImage(pstrValue);
478 | else if( _tcscmp(pstrName, _T("nativebkcolor")) == 0 ) {
479 | if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
480 | LPTSTR pstr = NULL;
481 | DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
482 | SetNativeEditBkColor(clrColor);
483 | }
484 | else CLabelUI::SetAttribute(pstrName, pstrValue);
485 | }
486 |
487 | void CEditUI::PaintStatusImage(HDC hDC)
488 | {
489 | if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED;
490 | else m_uButtonState &= ~ UISTATE_FOCUSED;
491 | if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED;
492 | else m_uButtonState &= ~ UISTATE_DISABLED;
493 |
494 | if( (m_uButtonState & UISTATE_DISABLED) != 0 ) {
495 | if( !m_sDisabledImage.IsEmpty() ) {
496 | if( !DrawImage(hDC, (LPCTSTR)m_sDisabledImage) ) m_sDisabledImage.Empty();
497 | else return;
498 | }
499 | }
500 | else if( (m_uButtonState & UISTATE_FOCUSED) != 0 ) {
501 | if( !m_sFocusedImage.IsEmpty() ) {
502 | if( !DrawImage(hDC, (LPCTSTR)m_sFocusedImage) ) m_sFocusedImage.Empty();
503 | else return;
504 | }
505 | }
506 | else if( (m_uButtonState & UISTATE_HOT) != 0 ) {
507 | if( !m_sHotImage.IsEmpty() ) {
508 | if( !DrawImage(hDC, (LPCTSTR)m_sHotImage) ) m_sHotImage.Empty();
509 | else return;
510 | }
511 | }
512 |
513 | if( !m_sNormalImage.IsEmpty() ) {
514 | if( !DrawImage(hDC, (LPCTSTR)m_sNormalImage) ) m_sNormalImage.Empty();
515 | else return;
516 | }
517 | }
518 |
519 | void CEditUI::PaintText(HDC hDC)
520 | {
521 | if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor();
522 | if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor();
523 |
524 | if( m_sText.IsEmpty() ) return;
525 |
526 | CDuiString sText = m_sText;
527 | if( m_bPasswordMode ) {
528 | sText.Empty();
529 | LPCTSTR p = m_sText.GetData();
530 | while( *p != _T('\0') ) {
531 | sText += m_cPasswordChar;
532 | p = ::CharNext(p);
533 | }
534 | }
535 |
536 | RECT rc = m_rcItem;
537 | rc.left += m_rcTextPadding.left;
538 | rc.right -= m_rcTextPadding.right;
539 | rc.top += m_rcTextPadding.top;
540 | rc.bottom -= m_rcTextPadding.bottom;
541 | if( IsEnabled() ) {
542 | CRenderEngine::DrawText(hDC, m_pManager, rc, sText, m_dwTextColor, \
543 | m_iFont, DT_SINGLELINE | m_uTextStyle);
544 | }
545 | else {
546 | CRenderEngine::DrawText(hDC, m_pManager, rc, sText, m_dwDisabledTextColor, \
547 | m_iFont, DT_SINGLELINE | m_uTextStyle);
548 |
549 | }
550 | }
551 | }
552 |
--------------------------------------------------------------------------------