diff --git a/.gitignore b/.gitignore index 1f4b7047..368bc769 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ *.log *.idb *.opensdf -*.lastbuildstate \ No newline at end of file +*.lastbuildstate +*.exe +*.dll \ No newline at end of file diff --git a/Demos/ADMonSetup/ADMonSetup.cpp b/Demos/ADMonSetup/ADMonSetup.cpp new file mode 100644 index 00000000..f40dcf03 --- /dev/null +++ b/Demos/ADMonSetup/ADMonSetup.cpp @@ -0,0 +1,65 @@ +// ADMonSetup.cpp : Defines the entry point for the application. +// + +#include "stdafx.h" +#include "ADMonSetup.h" +#include "MainWnd.h" + +//#include +//#pragma comment( lib, "GdiPlus.lib" ) +//using namespace Gdiplus; + +//---------------------------------------------------------------------------------------------------------------------------------------- + +//程序入口处调用该函数进行内存泄露检测 +//程序退出前调用_CrtDumpMemoryLeaks();函数可查看内存泄露的ID号,该ID号可作为Breakpoint的参数,运行时将会在相应位置自动断点 +inline void EnableMemLeakCheck(int Breakpoint = 0){ + _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); + if(Breakpoint) + _CrtSetBreakAlloc ( 1912 ); +} + +#ifdef _DEBUG +#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif +#define _CRT_SECURE_NO_DEPRECATE + +//---------------------------------------------------------------------------------------------------------------------------------------- + +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + + EnableMemLeakCheck(); + CPaintManagerUI::SetInstance(hInstance); + CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin\\ADMonSetup")); + + //GdiplusStartupInput gdiplusStartupInput; + //ULONG_PTR gdiplusToken; + //GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); + + HRESULT Hr = ::CoInitialize(NULL); + if( FAILED(Hr) ) return 0; + + if( ::LoadLibrary(_T("d3d9.dll")) == NULL ) + ::MessageBox(NULL, _T("加载 d3d9.dll 失败,一些特效可能无法显示!"), _T("信息提示"),MB_OK|MB_ICONWARNING); + + CMainWnd* pFrame = new CMainWnd(); + if(pFrame == NULL) + return 0; + + pFrame->Create(NULL,_T("视频广告过滤大师安装向导"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 900, 600); + pFrame->CenterWindow(); + ::ShowWindow(*pFrame, SW_SHOW); + CPaintManagerUI::MessageLoop(); + + ::CoUninitialize(); + //GdiplusShutdown(gdiplusToken); + + _CrtDumpMemoryLeaks(); + return 0; +} diff --git a/Demos/ADMonSetup/ADMonSetup.h b/Demos/ADMonSetup/ADMonSetup.h new file mode 100644 index 00000000..d00d47e7 --- /dev/null +++ b/Demos/ADMonSetup/ADMonSetup.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/Demos/ADMonSetup/ADMonSetup.ico b/Demos/ADMonSetup/ADMonSetup.ico new file mode 100644 index 00000000..d551aa3a Binary files /dev/null and b/Demos/ADMonSetup/ADMonSetup.ico differ diff --git a/Demos/ADMonSetup/ADMonSetup.rc b/Demos/ADMonSetup/ADMonSetup.rc new file mode 100644 index 00000000..cc01342f --- /dev/null +++ b/Demos/ADMonSetup/ADMonSetup.rc @@ -0,0 +1,150 @@ +//Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#ifndef APSTUDIO_INVOKED +#include "targetver.h" +#endif +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(936) + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. + +IDI_ADMONSETUP ICON "ADMonSetup.ico" +IDI_SMALL ICON "small.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_ADMONSETUP MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", IDM_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", IDM_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDC_ADMONSETUP ACCELERATORS +BEGIN + "?", IDM_ABOUT, ASCII, ALT + "/", IDM_ABOUT, ASCII, ALT +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About ADMonSetup" +FONT 8, "MS Shell Dlg" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,14,14,21,20 + LTEXT "ADMonSetup, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX + LTEXT "Copyright (C) 2015",IDC_STATIC,42,26,114,8 + DEFPUSHBUTTON "OK",IDOK,113,41,50,14,WS_GROUP +END + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 163 + TOPMARGIN, 7 + BOTTOMMARGIN, 55 + END +END +#endif // APSTUDIO_INVOKED + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#ifndef APSTUDIO_INVOKED\r\n" + "#include ""targetver.h""\r\n" + "#endif\r\n" + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDC_ADMONSETUP "ADMONSETUP" + IDS_APP_TITLE "ADMonSetup" +END + +#endif +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/Demos/ADMonSetup/ADMonSetup.vcxproj b/Demos/ADMonSetup/ADMonSetup.vcxproj new file mode 100644 index 00000000..5be76634 --- /dev/null +++ b/Demos/ADMonSetup/ADMonSetup.vcxproj @@ -0,0 +1,118 @@ +锘 + + + + Debug + Win32 + + + Release + Win32 + + + + {46E0954B-D9BE-48D6-8573-10B4F41E0171} + ADMonSetup + Win32Proj + + + + Application + Unicode + true + + + Application + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)Bin\ + $(Configuration)\ + true + $(SolutionDir)Bin\ + $(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + Level3 + EditAndContinue + + + true + Windows + MachineX86 + + + compatibility.manifest + + + + + MaxSpeed + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + true + Use + Level3 + ProgramDatabase + + + true + Windows + true + true + MachineX86 + + + + + + Create + Create + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demos/ADMonSetup/ADMonSetup.vcxproj.filters b/Demos/ADMonSetup/ADMonSetup.vcxproj.filters new file mode 100644 index 00000000..f26df7b2 --- /dev/null +++ b/Demos/ADMonSetup/ADMonSetup.vcxproj.filters @@ -0,0 +1,62 @@ +锘 + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + {ea0e8b11-2213-437d-b626-eae832fbce7e} + + + + + Source Files + + + Source Files + + + Windows + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Windows + + + + + Resource Files + + + Resource Files + + + + + + Resource Files + + + \ No newline at end of file diff --git a/Demos/ADMonSetup/MainWnd.cpp b/Demos/ADMonSetup/MainWnd.cpp new file mode 100644 index 00000000..a2160323 --- /dev/null +++ b/Demos/ADMonSetup/MainWnd.cpp @@ -0,0 +1,145 @@ +// MainWnd.cpp + +#include "StdAfx.h" +#include "MainWnd.h" + +CMainWnd::CMainWnd() + : m_pStepTabLayout(NULL) + , m_pInstallText(NULL) + , m_pBtnOneClick(NULL) + , m_pBtnOverwrite(NULL) + , m_pProgressBar(NULL) +{ +} + +CDuiString CMainWnd::GetSkinFile() +{ + try + { + return CDuiString(_T("DlgMain.xml")); + } + catch (...) + { + throw "CMainWnd::GetSkinFile"; + } +} + +CDuiString CMainWnd::GetSkinFolder() +{ + return _T(""); +} + +LPCTSTR CMainWnd::GetWindowClassName() const +{ + try + { + return _T("视频广告过滤大师安装向导"); + } + catch (...) + { + throw "CMainWnd::GetWindowClassName"; + } +} + +void CMainWnd::InitWindow() +{ + try + { + WindowImplBase::InitWindow(); + + Init(); + + } + catch (...) + { + throw "CMainWnd::Init"; + } +} + +void CMainWnd::Notify( TNotifyUI& msg ) +{ + if( msg.sType == _T("click") ) + { + if( msg.pSender == m_pBtnOneClick ) + { + InstallStart(); + return ; + } + } + + WindowImplBase::Notify(msg); +} + +void CMainWnd::OnFinalMessage( HWND hWnd ) +{ + try + { + WindowImplBase::OnFinalMessage(hWnd); + PostQuitMessage(0); + delete this; + } + catch (...) + { + throw "CMainWnd::OnFinalMessage"; + } +} + +LRESULT CMainWnd::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + LRESULT lRes = 0; + + switch (uMsg) + { + case WM_TIMER: lRes = OnTimer(uMsg, wParam, lParam, bHandled); break; + default: break; + } + + return lRes; +} + +LRESULT CMainWnd::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + if (TIMER_ID_PROGRESS == wParam) + { + int nVal = m_pProgressBar->GetValue(); + CDuiString strPercent; + strPercent.Format(_T("正在安装(%d%%)"), nVal); + m_pInstallText->SetText( strPercent ); + if (nVal > 95) + { + m_pProgressBar->SetValue(100); + InstallFinished(); + } + else + { + nVal += 5; + m_pProgressBar->SetValue(nVal); + } + } + return 0; +} + +void CMainWnd::Init() +{ + m_pStepTabLayout = static_cast(m_PaintManager.FindControl(_T("stepTabLayout"))); + m_pInstallText = static_cast(m_PaintManager.FindControl(_T("textProgress"))); + m_pBtnOneClick = static_cast(m_PaintManager.FindControl(_T("BtnOneClick"))); + m_pBtnOverwrite = static_cast(m_PaintManager.FindControl(_T("BtnOverwrite"))); + m_pProgressBar = static_cast(m_PaintManager.FindControl(_T("install"))); + + m_pProgressBar->SetValue(0); +} + +void CMainWnd::InstallStart() +{ + m_pStepTabLayout->SelectItem(1); + //m_pInstallText->SetText(_T("正在安装中,请稍候...")); + + SetTimer(GetHWND(), TIMER_ID_PROGRESS, 100, NULL); +} + +void CMainWnd::InstallFinished() +{ + m_pInstallText->SetText(_T("安装完成!")); + KillTimer(GetHWND(), TIMER_ID_PROGRESS); +} \ No newline at end of file diff --git a/Demos/ADMonSetup/MainWnd.h b/Demos/ADMonSetup/MainWnd.h new file mode 100644 index 00000000..e0c504c7 --- /dev/null +++ b/Demos/ADMonSetup/MainWnd.h @@ -0,0 +1,33 @@ +// MainWnd.h + +#pragma once + +#define TIMER_ID_PROGRESS (1000) + +class CMainWnd : public WindowImplBase +{ +public: + CMainWnd(); + CDuiString GetSkinFolder(); + CDuiString GetSkinFile(); + LPCTSTR GetWindowClassName() const ; + + void InitWindow(); + void Notify(TNotifyUI& msg); + void OnFinalMessage(HWND hWnd); + + LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + +private: + void Init(); + void InstallStart(); + void InstallFinished(); + +private: + CAnimationTabLayoutUI *m_pStepTabLayout; + CLabelUI *m_pInstallText; + CButtonUI *m_pBtnOneClick; + CButtonUI *m_pBtnOverwrite; + CProgressUI *m_pProgressBar; +}; \ No newline at end of file diff --git a/Demos/ADMonSetup/ReadMe.txt b/Demos/ADMonSetup/ReadMe.txt new file mode 100644 index 00000000..4ad43c8e --- /dev/null +++ b/Demos/ADMonSetup/ReadMe.txt @@ -0,0 +1,55 @@ +======================================================================== + WIN32 APPLICATION : ADMonSetup Project Overview +======================================================================== + +AppWizard has created this ADMonSetup application for you. + +This file contains a summary of what you will find in each of the files that +make up your ADMonSetup application. + + +ADMonSetup.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +ADMonSetup.cpp + This is the main application source file. + +///////////////////////////////////////////////////////////////////////////// +AppWizard has created the following resources: + +ADMonSetup.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +ADMonSetup.ico + This is an icon file, which is used as the application's icon (32x32). + This icon is included by the main resource file ADMonSetup.rc. + +small.ico + This is an icon file, which contains a smaller version (16x16) + of the application's icon. This icon is included by the main resource + file ADMonSetup.rc. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named ADMonSetup.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Demos/ADMonSetup/Resource.h b/Demos/ADMonSetup/Resource.h new file mode 100644 index 00000000..f1643e4d --- /dev/null +++ b/Demos/ADMonSetup/Resource.h @@ -0,0 +1,31 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ADMonSetup.rc +// + +#define IDS_APP_TITLE 103 + +#define IDR_MAINFRAME 128 +#define IDD_ADMONSETUP_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_ADMONSETUP 107 +#define IDI_SMALL 108 +#define IDC_ADMONSETUP 109 +#define IDC_MYICON 2 +#ifndef IDC_STATIC +#define IDC_STATIC -1 +#endif +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NO_MFC 130 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/Demos/ADMonSetup/small.ico b/Demos/ADMonSetup/small.ico new file mode 100644 index 00000000..d551aa3a Binary files /dev/null and b/Demos/ADMonSetup/small.ico differ diff --git a/Demos/ADMonSetup/stdafx.cpp b/Demos/ADMonSetup/stdafx.cpp new file mode 100644 index 00000000..080d9de9 --- /dev/null +++ b/Demos/ADMonSetup/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// ADMonSetup.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/Demos/ADMonSetup/stdafx.h b/Demos/ADMonSetup/stdafx.h new file mode 100644 index 00000000..8256d4e4 --- /dev/null +++ b/Demos/ADMonSetup/stdafx.h @@ -0,0 +1,31 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + +// C RunTime Header Files +//#include +//#include +//#include +#include + +#include "..\..\DuiLib\UIlib.h" + +using namespace DuiLib; + +#ifdef _DEBUG +# pragma comment(lib, "..\\..\\Lib\\DuiLib_d.lib") +#else +# pragma comment(lib, "..\\..\\Lib\\DuiLib.lib") +#endif + + +// TODO: reference additional headers your program requires here diff --git a/Demos/ADMonSetup/targetver.h b/Demos/ADMonSetup/targetver.h new file mode 100644 index 00000000..203dfbcf --- /dev/null +++ b/Demos/ADMonSetup/targetver.h @@ -0,0 +1,24 @@ +#pragma once + +// The following macros define the minimum required platform. The minimum required platform +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to and +// including the version specified. + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Specifies that the minimum required platform is Windows Vista. +#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. +#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. +#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. +#endif diff --git a/DuiLib.sln b/DuiLib.sln index cd07d409..dc39d17c 100644 --- a/DuiLib.sln +++ b/DuiLib.sln @@ -15,6 +15,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "transwnd", "Demos\transwnd\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XLGameBox", "Demos\xlgamebox\XLGameBox.vcxproj", "{0278E09B-92AA-4C18-ACB5-EEDF958395B1}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ADMonSetup", "Demos\ADMonSetup\ADMonSetup.vcxproj", "{46E0954B-D9BE-48D6-8573-10B4F41E0171}" + ProjectSection(ProjectDependencies) = postProject + {E106ACD7-4E53-4AEE-942B-D0DD426DB34E} = {E106ACD7-4E53-4AEE-942B-D0DD426DB34E} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -71,6 +76,14 @@ Global {0278E09B-92AA-4C18-ACB5-EEDF958395B1}.Release|Win32.Build.0 = Release|Win32 {0278E09B-92AA-4C18-ACB5-EEDF958395B1}.ReleaseA|Win32.ActiveCfg = Release|Win32 {0278E09B-92AA-4C18-ACB5-EEDF958395B1}.ReleaseA|Win32.Build.0 = Release|Win32 + {46E0954B-D9BE-48D6-8573-10B4F41E0171}.Debug|Win32.ActiveCfg = Debug|Win32 + {46E0954B-D9BE-48D6-8573-10B4F41E0171}.Debug|Win32.Build.0 = Debug|Win32 + {46E0954B-D9BE-48D6-8573-10B4F41E0171}.DebugA|Win32.ActiveCfg = Debug|Win32 + {46E0954B-D9BE-48D6-8573-10B4F41E0171}.DebugA|Win32.Build.0 = Debug|Win32 + {46E0954B-D9BE-48D6-8573-10B4F41E0171}.Release|Win32.ActiveCfg = Release|Win32 + {46E0954B-D9BE-48D6-8573-10B4F41E0171}.Release|Win32.Build.0 = Release|Win32 + {46E0954B-D9BE-48D6-8573-10B4F41E0171}.ReleaseA|Win32.ActiveCfg = Release|Win32 + {46E0954B-D9BE-48D6-8573-10B4F41E0171}.ReleaseA|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -81,5 +94,6 @@ Global {3EF9795D-3509-4664-8E73-8D315CC0B944} = {D01B5755-53F2-4929-B69C-75C99D151E6F} {2C0EADA2-111E-4D58-B171-B1C896D7A0DE} = {D01B5755-53F2-4929-B69C-75C99D151E6F} {0278E09B-92AA-4C18-ACB5-EEDF958395B1} = {D01B5755-53F2-4929-B69C-75C99D151E6F} + {46E0954B-D9BE-48D6-8573-10B4F41E0171} = {D01B5755-53F2-4929-B69C-75C99D151E6F} EndGlobalSection EndGlobal diff --git a/DuiLib/Control/UIAnimation.cpp b/DuiLib/Control/UIAnimation.cpp new file mode 100644 index 00000000..309467a0 --- /dev/null +++ b/DuiLib/Control/UIAnimation.cpp @@ -0,0 +1,164 @@ +#include "StdAfx.h" +#include "UIAnimation.h" +#include +#include + +namespace DuiLib { + struct CUIAnimation::Imp + { + std::vector m_arAnimations; + }; + + CUIAnimation::CUIAnimation(CControlUI* pOwner):m_pImp(new CUIAnimation::Imp()) + { + ASSERT(pOwner != NULL); + m_pControl = pOwner; + } + CUIAnimation:: ~CUIAnimation() + { + if(m_pImp) + { + delete m_pImp; + m_pImp = NULL; + } + } + BOOL CUIAnimation::StartAnimation(int nElapse, int nTotalFrame, int nAnimationID /*= 0*/, BOOL bLoop/* = FALSE*/) + { + CAnimationData* pData = GetAnimationDataByID(nAnimationID); + if( NULL != pData + || nElapse <= 0 + || nTotalFrame <= 0 + || NULL == m_pControl ) + { + ASSERT(FALSE); + return FALSE; + } + + CAnimationData* pAnimation = new CAnimationData(nElapse, nTotalFrame, nAnimationID, bLoop); + if( NULL == pAnimation ) return FALSE; + + if(m_pControl->GetManager()->SetTimer( m_pControl, nAnimationID, nElapse )) + { + m_pImp->m_arAnimations.push_back(pAnimation); + return TRUE; + } + return FALSE; + } + + void CUIAnimation::StopAnimation(int nAnimationID /*= 0*/) + { + if(m_pControl == NULL) return; + + if(nAnimationID != 0) + { + CAnimationData* pData = GetAnimationDataByID(nAnimationID); + if( NULL != pData ) + { + m_pControl->GetManager()->KillTimer( m_pControl, nAnimationID ); + m_pImp->m_arAnimations.erase(std::remove(m_pImp->m_arAnimations.begin(), m_pImp->m_arAnimations.end(), pData), m_pImp->m_arAnimations.end()); + return; + } + } + else + { + int nCount = m_pImp->m_arAnimations.size(); + for(int i=0; iGetManager()->KillTimer( m_pControl, m_pImp->m_arAnimations[i]->m_nAnimationID ); + } + m_pImp->m_arAnimations.clear(); + } + } + + BOOL CUIAnimation::IsAnimationRunning(int nAnimationID) + { + CAnimationData* pData = GetAnimationDataByID(nAnimationID); + return NULL != pData; + } + + int CUIAnimation::GetCurrentFrame(int nAnimationID/* = 0*/) + { + CAnimationData* pData = GetAnimationDataByID(nAnimationID); + if( NULL == pData ) + { + ASSERT(FALSE); + return -1; + } + return pData->m_nCurFrame; + } + + BOOL CUIAnimation::SetCurrentFrame(int nFrame, int nAnimationID/* = 0*/) + { + CAnimationData* pData = GetAnimationDataByID(nAnimationID); + if( NULL == pData) + { + ASSERT(FALSE); + return FALSE; + } + + if(nFrame >= 0 && nFrame <= pData->m_nTotalFrame) + { + pData->m_nCurFrame = nFrame; + return TRUE; + } + else + { + ASSERT(FALSE); + } + return FALSE; + } + + void CUIAnimation::OnAnimationElapse(int nAnimationID) + { + if(m_pControl == NULL) return; + + CAnimationData* pData = GetAnimationDataByID(nAnimationID); + if( NULL == pData ) return; + + int nCurFrame = pData->m_nCurFrame; + if(nCurFrame == 0) + { + OnAnimationStart(nAnimationID, pData->m_bFirstLoop); + pData->m_bFirstLoop = FALSE; + } + + OnAnimationStep(pData->m_nTotalFrame, nCurFrame, nAnimationID); + + if(nCurFrame >= pData->m_nTotalFrame) + { + OnAnimationStop(nAnimationID); + if(pData->m_bLoop) + { + pData->m_nCurFrame = 0; + } + else + { + m_pControl->GetManager()->KillTimer( m_pControl, nAnimationID ); + m_pImp->m_arAnimations.erase(std::remove(m_pImp->m_arAnimations.begin(), m_pImp->m_arAnimations.end(), pData), m_pImp->m_arAnimations.end()); + pData = NULL; + } + } + + if( NULL != pData ) + { + ++(pData->m_nCurFrame); + } + } + + CAnimationData* CUIAnimation::GetAnimationDataByID(int nAnimationID) + { + CAnimationData* pRet = NULL; + int nCount = m_pImp->m_arAnimations.size(); + for(int i=0; im_arAnimations[i]->m_nAnimationID == nAnimationID) + { + pRet = m_pImp->m_arAnimations[i]; + break; + } + } + + return pRet; + } + +} // namespace DuiLib \ No newline at end of file diff --git a/DuiLib/Control/UIAnimation.h b/DuiLib/Control/UIAnimation.h new file mode 100644 index 00000000..b735fc0a --- /dev/null +++ b/DuiLib/Control/UIAnimation.h @@ -0,0 +1,83 @@ +#ifndef __UIANIMATION_H__ +#define __UIANIMATION_H__ + +#include "UIButton.h" +#pragma once + +namespace DuiLib { + + class UILIB_API IUIAnimation + { + public: + virtual ~IUIAnimation() { NULL; } + + virtual BOOL StartAnimation(int nElapse, int nTotalFrame, int nAnimationID = 0, BOOL bLoop = FALSE) = 0; + virtual void StopAnimation(int nAnimationID = 0) = 0; + virtual BOOL IsAnimationRunning(int nAnimationID) = 0; + virtual int GetCurrentFrame(int nAnimationID = 0) = 0; + virtual BOOL SetCurrentFrame(int nFrame, int nAnimationID = 0) = 0; + + virtual void OnAnimationStep(int nTotalFrame, int nCurFrame, int nAnimationID) = 0; + virtual void OnAnimationStart(int nAnimationID, BOOL bFirstLoop) = 0; + virtual void OnAnimationStop(int nAnimationID) = 0; + + virtual void OnAnimationElapse(int nAnimationID) = 0; + }; + + class UILIB_API CAnimationData + { + public: + CAnimationData(int nElipse, int nFrame, int nID, BOOL bLoop) + { + m_bFirstLoop = TRUE; + m_nCurFrame = 0; + m_nElapse = nElipse; + m_nTotalFrame = nFrame; + m_bLoop = bLoop; + m_nAnimationID = nID; + } + + //protected: + public: + friend class CDUIAnimation; + + int m_nAnimationID; + int m_nElapse; + + int m_nTotalFrame; + int m_nCurFrame; + + BOOL m_bLoop; + BOOL m_bFirstLoop; + }; + + class UILIB_API CUIAnimation: public IUIAnimation + { + struct Imp; + public: + CUIAnimation(CControlUI* pOwner); + ~CUIAnimation(); + + virtual BOOL StartAnimation(int nElapse, int nTotalFrame, int nAnimationID = 0, BOOL bLoop = FALSE); + virtual void StopAnimation(int nAnimationID = 0); + virtual BOOL IsAnimationRunning(int nAnimationID); + virtual int GetCurrentFrame(int nAnimationID = 0); + virtual BOOL SetCurrentFrame(int nFrame, int nAnimationID = 0); + + virtual void OnAnimationStart(int nAnimationID, BOOL bFirstLoop) {}; + virtual void OnAnimationStep(int nTotalFrame, int nCurFrame, int nAnimationID) {}; + virtual void OnAnimationStop(int nAnimationID) {}; + + virtual void OnAnimationElapse(int nAnimationID); + + protected: + CAnimationData* GetAnimationDataByID(int nAnimationID); + + protected: + CControlUI* m_pControl; + Imp * m_pImp; + }; + +} // namespace DuiLib + +#endif // __UIANIMATION_H__ \ No newline at end of file diff --git a/DuiLib/Core/UIDefine.h b/DuiLib/Core/UIDefine.h index e4e7d18d..28d0f717 100644 --- a/DuiLib/Core/UIDefine.h +++ b/DuiLib/Core/UIDefine.h @@ -262,6 +262,8 @@ protected: \ #define DUI_CTR_HORIZONTALLAYOUT (_T("HorizontalLayout")) #define DUI_CTR_LISTLABELELEMENT (_T("ListLabelElement")) +#define DUI_CTR_ANIMATIONTABLAYOUT (_T("AnimationTabLayout")) + #define DUI_CTR_LISTCONTAINERELEMENT (_T("ListContainerElement")) /// diff --git a/DuiLib/Core/UIDlgBuilder.cpp b/DuiLib/Core/UIDlgBuilder.cpp index 2cdd3fdb..67eaba6f 100644 --- a/DuiLib/Core/UIDlgBuilder.cpp +++ b/DuiLib/Core/UIDlgBuilder.cpp @@ -416,6 +416,9 @@ CControlUI* CDialogBuilder::_Parse(CMarkupNode* pRoot, CControlUI* pParent, CPai if( _tcscmp(pstrClass, DUI_CTR_HORIZONTALLAYOUT) == 0 ) pControl = new CHorizontalLayoutUI; else if( _tcscmp(pstrClass, DUI_CTR_LISTLABELELEMENT) == 0 ) pControl = new CListLabelElementUI; break; + case 18: + if( _tcscmp(pstrClass, DUI_CTR_ANIMATIONTABLAYOUT) == 0 ) pControl = new CAnimationTabLayoutUI; + break; case 20: if( _tcscmp(pstrClass, DUI_CTR_LISTCONTAINERELEMENT) == 0 ) pControl = new CListContainerElementUI; break; diff --git a/DuiLib/DuiLib.vcxproj b/DuiLib/DuiLib.vcxproj index 8df8db8c..4c41fe26 100644 --- a/DuiLib/DuiLib.vcxproj +++ b/DuiLib/DuiLib.vcxproj @@ -244,8 +244,10 @@ + + Create Create @@ -308,8 +310,10 @@ + + diff --git a/DuiLib/DuiLib.vcxproj.filters b/DuiLib/DuiLib.vcxproj.filters index 26af114d..d19aa0b3 100644 --- a/DuiLib/DuiLib.vcxproj.filters +++ b/DuiLib/DuiLib.vcxproj.filters @@ -156,6 +156,12 @@ Source Files\Control + + Source Files\Control + + + Source Files\Layout + @@ -284,5 +290,11 @@ Header Files\Utils + + Header Files\Control + + + Header Files\Layout + \ No newline at end of file diff --git a/DuiLib/Layout/UIAnimationTabLayout.cpp b/DuiLib/Layout/UIAnimationTabLayout.cpp new file mode 100644 index 00000000..2a9425d3 --- /dev/null +++ b/DuiLib/Layout/UIAnimationTabLayout.cpp @@ -0,0 +1,142 @@ +#include "stdafx.h" +#include "UIAnimationTabLayout.h" + +namespace DuiLib { + CAnimationTabLayoutUI::CAnimationTabLayoutUI() : + CUIAnimation( this ), + m_bIsVerticalDirection( false ), + m_nPositiveDirection( 1 ), + m_pCurrentControl( NULL ), + m_bControlVisibleFlag( false ) + { + } + + LPCTSTR CAnimationTabLayoutUI::GetClass() const + { + return _T("AnimationTabLayoutUI"); + } + + LPVOID CAnimationTabLayoutUI::GetInterface(LPCTSTR pstrName) + { + if( _tcscmp(pstrName, _T("AnimationTabLayout")) == 0 ) + return static_cast(this); + return CTabLayoutUI::GetInterface(pstrName); + } + + bool CAnimationTabLayoutUI::SelectItem( int iIndex ) + { + if( iIndex < 0 || iIndex >= m_items.GetSize() ) return false; + if( iIndex == m_iCurSel ) return true; + if( iIndex > m_iCurSel ) m_nPositiveDirection = -1; + if( iIndex < m_iCurSel ) m_nPositiveDirection = 1; + + int iOldSel = m_iCurSel; + m_iCurSel = iIndex; + for( int it = 0; it < m_items.GetSize(); it++ ) + { + if( it == iIndex ) { + GetItemAt(it)->SetVisible(true); + GetItemAt(it)->SetFocus(); + + m_bControlVisibleFlag = false; + m_pCurrentControl = static_cast(m_items[it]); + if( NULL != m_pCurrentControl ) + m_pCurrentControl->SetVisible( false ); + AnimationSwitch(); + } + else GetItemAt(it)->SetVisible(false); + } + NeedParentUpdate(); + + if( m_pManager != NULL ) { + m_pManager->SetNextTabControl(); + m_pManager->SendNotify(this, _T("tabselect"), m_iCurSel, iOldSel); + } + return true; + } + + void CAnimationTabLayoutUI::AnimationSwitch() + { + m_rcItemOld = m_rcItem; + if( !m_bIsVerticalDirection ) + { + m_rcCurPos.top = m_rcItem.top; + m_rcCurPos.bottom = m_rcItem.bottom; + m_rcCurPos.left = m_rcItem.left - ( m_rcItem.right - m_rcItem.left ) * m_nPositiveDirection + 52 * m_nPositiveDirection; + m_rcCurPos.right = m_rcItem.right - ( m_rcItem.right - m_rcItem.left ) * m_nPositiveDirection+ 52 * m_nPositiveDirection; + } + else + { + m_rcCurPos.left = m_rcItem.left; + m_rcCurPos.right = m_rcItem.right; + m_rcCurPos.top = m_rcItem.top - ( m_rcItem.bottom - m_rcItem.top ) * m_nPositiveDirection; + m_rcCurPos.bottom = m_rcItem.bottom - ( m_rcItem.bottom - m_rcItem.top ) * m_nPositiveDirection; + } + + StopAnimation( TAB_ANIMATION_ID ); + StartAnimation( TAB_ANIMATION_ELLAPSE, TAB_ANIMATION_FRAME_COUNT, TAB_ANIMATION_ID ); + } + + void CAnimationTabLayoutUI::DoEvent(TEventUI& event) + { + if( event.Type == UIEVENT_TIMER ) + { + OnTimer( event.wParam ); + } + __super::DoEvent( event ); + } + + void CAnimationTabLayoutUI::OnTimer( int nTimerID ) + { + OnAnimationElapse( nTimerID ); + } + + void CAnimationTabLayoutUI::OnAnimationStep(INT nTotalFrame, INT nCurFrame, INT nAnimationID) + { + if( !m_bControlVisibleFlag ) + { + m_bControlVisibleFlag = true; + m_pCurrentControl->SetVisible( true ); + } + + int iStepLen = 0; + if( !m_bIsVerticalDirection ) + { + iStepLen = ( m_rcItemOld.right - m_rcItemOld.left ) * m_nPositiveDirection / nTotalFrame; + if( nCurFrame != nTotalFrame ) + { + m_rcCurPos.left = m_rcCurPos.left + iStepLen; + m_rcCurPos.right = m_rcCurPos.right +iStepLen; + } + else + { + m_rcItem = m_rcCurPos = m_rcItemOld; + } + } + else + { + iStepLen = ( m_rcItemOld.bottom - m_rcItemOld.top ) * m_nPositiveDirection / nTotalFrame; + if( nCurFrame != nTotalFrame ) + { + m_rcCurPos.top = m_rcCurPos.top + iStepLen; + m_rcCurPos.bottom = m_rcCurPos.bottom +iStepLen; + } + else + { + m_rcItem = m_rcCurPos = m_rcItemOld; + } + } + SetPos(m_rcCurPos); + } + + void CAnimationTabLayoutUI::OnAnimationStop(INT nAnimationID) + { + NeedParentUpdate(); + } + + void CAnimationTabLayoutUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) + { + if( _tcscmp(pstrName, _T("animation_direction")) == 0 && _tcscmp( pstrValue, _T("vertical")) == 0 ) m_bIsVerticalDirection = true; // pstrValue = "vertical" or "horizontal" + return CTabLayoutUI::SetAttribute(pstrName, pstrValue); + } +} // namespace DuiLib \ No newline at end of file diff --git a/DuiLib/Layout/UIAnimationTabLayout.h b/DuiLib/Layout/UIAnimationTabLayout.h new file mode 100644 index 00000000..3f7444fa --- /dev/null +++ b/DuiLib/Layout/UIAnimationTabLayout.h @@ -0,0 +1,44 @@ +#ifndef __UIANIMATIONTABLAYOUT_H__ +#define __UIANIMATIONTABLAYOUT_H__ + +#pragma once +using namespace std; +namespace DuiLib +{ + + class UILIB_API CAnimationTabLayoutUI : public CTabLayoutUI, public CUIAnimation + { + public: + CAnimationTabLayoutUI(); + + LPCTSTR GetClass() const; + LPVOID GetInterface(LPCTSTR pstrName); + + bool SelectItem( int iIndex ); + void AnimationSwitch(); + void DoEvent(TEventUI& event); + void OnTimer( int nTimerID ); + + virtual void OnAnimationStart(INT nAnimationID, BOOL bFirstLoop) {} + virtual void OnAnimationStep(INT nTotalFrame, INT nCurFrame, INT nAnimationID); + virtual void OnAnimationStop(INT nAnimationID); + + void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue); + + protected: + bool m_bIsVerticalDirection; + int m_nPositiveDirection; + RECT m_rcCurPos; + RECT m_rcItemOld; + CControlUI* m_pCurrentControl; + bool m_bControlVisibleFlag; + enum + { + TAB_ANIMATION_ID = 1, + + TAB_ANIMATION_ELLAPSE = 10, + TAB_ANIMATION_FRAME_COUNT = 15, + }; + }; +} +#endif // __UIANIMATIONTABLAYOUT_H__ \ No newline at end of file diff --git a/DuiLib/UIlib.h b/DuiLib/UIlib.h index b395e6b8..b2b1dbb2 100644 --- a/DuiLib/UIlib.h +++ b/DuiLib/UIlib.h @@ -66,6 +66,8 @@ #include "Control/UIEdit.h" #include "Control/UIGifAnim.h" +#include "Control/UIAnimation.h" +#include "Layout/UIAnimationTabLayout.h" #include "Control/UIButton.h" #include "Control/UIOption.h" diff --git a/bin/skin/ADMonSetup/DlgMain.xml b/bin/skin/ADMonSetup/DlgMain.xml new file mode 100644 index 00000000..53d6feba --- /dev/null +++ b/bin/skin/ADMonSetup/DlgMain.xml @@ -0,0 +1,31 @@ + + + + + + + +