Skip to content

Commit

Permalink
完善HiDPI相关功能.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaodeng committed Aug 10, 2016
1 parent 7a73857 commit 715562c
Show file tree
Hide file tree
Showing 38 changed files with 7,638 additions and 7,347 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ Temp
bin
*.ilk
Demos/ADMonSetup/SDebug/
3rd/libcef_dll_wrapper/Lib/
3rd/libcef_dll_wrapper/Lib/
DuiLib.VC.db
DuiLib2015.VC.db
DuiLib2015.sln
Demos/ADMonSetup/Debug/
89 changes: 0 additions & 89 deletions Demos/HiDPITest/DPI.cpp

This file was deleted.

25 changes: 0 additions & 25 deletions Demos/HiDPITest/DPI.h

This file was deleted.

103 changes: 57 additions & 46 deletions Demos/HiDPITest/FrameWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ LRESULT CFrameWnd::OnDPIChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
wstring optionName;
wstringstream wss;
wss << L"DPI";
wss << CResourceManager::GetInstance()->GetDPI();
wss << m_pm.GetDPIObj()->GetDPI();
wss >> optionName;
COptionUI *option = static_cast<COptionUI*>(m_pm.FindControl(optionName.c_str()));
option->Selected(true);
Expand All @@ -91,44 +91,45 @@ void CFrameWnd::Notify( TNotifyUI& msg )
{
if( msg.pSender->GetName() == _T("btnMenu") )
{
//CPoint point(0, 0);
//GetCursorPos(&point);
//point.x += 5;
//point.y -= 5;
//CMenuWnd* pMenu = CMenuWnd::CreateMenu(NULL, _T("menutest.xml"), point, &m_pm, &m_MenuCheckInfo, eMenuAlignment_Bottom);
////pMenu->setDPI(m_pm.GetDPIObj()->GetDPI());
//
//// 先获取到根项,然后就可以使用rootMenu插到到菜单内的任意子菜单项,然后做添加删除操作
//CMenuUI* rootMenu = pMenu->GetMenuUI();
//if (rootMenu != NULL)
//{
// CMenuElementUI* pNew = new CMenuElementUI;
// pNew->SetName(_T("Menu_Dynamic"));
// pNew->SetText(_T("动态一级菜单"));
// pNew->SetShowExplandIcon(true);
// pNew->SetIcon(_T("WebSit.png"));
// pNew->SetIconSize(16,16);


// CMenuElementUI* pSubNew = new CMenuElementUI;
// pSubNew->SetText(_T("动态二级菜单"));
// pSubNew->SetName(_T("Menu_Dynamic"));
// pSubNew->SetIcon(_T("Virus.png"));
// pSubNew->SetIconSize(16,16);
// pNew->Add(pSubNew);
//

// rootMenu->Add(pNew);


// CMenuElementUI* pNew2 = new CMenuElementUI;
// pNew2->SetName(_T("Menu_Dynamic"));
// pNew2->SetText(_T("动态一级菜单2"));
// rootMenu->AddAt(pNew2,2);
//}

//// 动态添加后重新设置菜单的大小
//pMenu->ResizeMenu();
POINT point;
GetCursorPos(&point);
point.x += 5;
point.y -= 5;
CMenuWnd* pMenu = CMenuWnd::CreateMenu(NULL, _T("menutest.xml"), point, &m_pm, &m_MenuCheckInfo, eMenuAlignment_Bottom);


// 先获取到根项,然后就可以使用rootMenu插到到菜单内的任意子菜单项,然后做添加删除操作
CMenuUI* rootMenu = pMenu->GetMenuUI();

if (rootMenu != NULL)
{
CMenuElementUI* pNew = new CMenuElementUI;
pNew->SetName(_T("Menu_Dynamic"));
pNew->SetText(_T("动态一级菜单"));
pNew->SetShowExplandIcon(true);
pNew->SetIcon(_T("WebSit.png"));
pNew->SetIconSize(16,16);


CMenuElementUI* pSubNew = new CMenuElementUI;
pSubNew->SetText(_T("动态二级菜单"));
pSubNew->SetName(_T("Menu_Dynamic"));
pSubNew->SetIcon(_T("Virus.png"));
pSubNew->SetIconSize(16,16);
pNew->Add(pSubNew);


rootMenu->Add(pNew);


CMenuElementUI* pNew2 = new CMenuElementUI;
pNew2->SetName(_T("Menu_Dynamic"));
pNew2->SetText(_T("动态一级菜单2"));
rootMenu->AddAt(pNew2,2);
}

// 动态添加后重新设置菜单的大小
pMenu->ResizeMenu();
}
else if (msg.pSender->GetName() == _T("DPI96") )
{
Expand Down Expand Up @@ -176,10 +177,20 @@ void CFrameWnd::setDPI(int DPI) {
{
if (uMsg == WM_MENUCLICK)
{
CDuiString *strMenuName = (CDuiString*)wParam;
BOOL bChecked = (BOOL)lParam;

if ( *strMenuName == _T("Menu_Test1"))
MenuCmd* pMenuCmd = (MenuCmd*)wParam;

BOOL bChecked = pMenuCmd->bChecked;
CDuiString strMenuName = pMenuCmd->szName;
CDuiString sUserData = pMenuCmd->szUserData;
CDuiString sText = pMenuCmd->szText;
m_pm.DeletePtr(pMenuCmd);





if ( strMenuName == _T("Menu_Test1"))
{
if (bChecked)
{
Expand All @@ -190,11 +201,11 @@ void CFrameWnd::setDPI(int DPI) {
MessageBox(m_hWnd, L"你取消Menu_Test1", L"", 0);
}
}
else if ( *strMenuName == _T("Menu_Test2"))
else if ( strMenuName == _T("Menu_Test2"))
{
MessageBox(m_hWnd, L"你单击了Menu_Test2", L"", 0);
}
else if ( *strMenuName == _T("Menu_Test3"))
else if ( strMenuName == _T("Menu_Test3"))
{
if (bChecked)
{
Expand All @@ -205,7 +216,7 @@ void CFrameWnd::setDPI(int DPI) {
MessageBox(m_hWnd, L"你取消Menu_Test3", L"", 0);
}
}
else if ( *strMenuName == _T("Menu_Dynamic"))
else if ( strMenuName == _T("Menu_Dynamic"))
{
MessageBox(m_hWnd, L"你单击了动态添加菜单", L"", 0);
}
Expand All @@ -226,7 +237,7 @@ void CFrameWnd::setDPI(int DPI) {
wstring optionName;
wstringstream wss;
wss << L"DPI";
wss << CResourceManager::GetInstance()->GetDPI();
wss << m_pm.GetDPIObj()->GetDPI();
wss >> optionName;
COptionUI *option = static_cast<COptionUI*>(m_pm.FindControl(optionName.c_str()));
option->Selected(true);
Expand Down
2 changes: 0 additions & 2 deletions Demos/HiDPITest/HiDPITest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
<None Include="small.ico" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="DPI.h" />
<ClInclude Include="duilib.h" />
<ClInclude Include="FrameWnd.h" />
<ClInclude Include="HiDPITest.h" />
Expand All @@ -93,7 +92,6 @@
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="DPI.cpp" />
<ClCompile Include="FrameWnd.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="stdafx.cpp">
Expand Down
9 changes: 0 additions & 9 deletions Demos/HiDPITest/HiDPITest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,12 @@
<ClInclude Include="Resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="HiDPITest.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="duilib.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="FrameWnd.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="DPI.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
Expand All @@ -56,9 +50,6 @@
<ClCompile Include="main.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="DPI.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="HiDPITest.rc">
Expand Down
2 changes: 1 addition & 1 deletion Demos/HiDPITest/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "duilib.h"
#include "DPI.h"




Expand Down
5 changes: 3 additions & 2 deletions Demos/duidemo/MainWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,9 @@ class CDemoFrame : public WindowImplBase, public CWebBrowserEventHandler, public
CMenuWnd::GetGlobalContextMenuObserver().SetMenuCheckInfo(&m_MenuInfos);
CDuiPoint point;
::GetCursorPos(&point);

m_pMenu->Init(NULL, _T("menu.xml"), point, &m_pm);

CMenuUI* rootMenu = m_pMenu->GetMenuUI();
if (rootMenu != NULL)
{
Expand Down Expand Up @@ -514,7 +515,7 @@ class CDemoFrame : public WindowImplBase, public CWebBrowserEventHandler, public
}
}
else if (uMsg == WM_DPICHANGED) {
CResourceManager::GetInstance()->SetScale(LOWORD(wParam)); // Set the new DPI, retrieved from the wParam
m_pm.SetDPI(LOWORD(wParam)); // Set the new DPI, retrieved from the wParam
m_pm.ResetDPIAssets();
RECT* const prcNewWindow = (RECT*)lParam;
SetWindowPos(m_hWnd, NULL, prcNewWindow->left, prcNewWindow->top, prcNewWindow->right - prcNewWindow->left, prcNewWindow->bottom - prcNewWindow->top, SWP_NOZORDER | SWP_NOACTIVATE);
Expand Down
Binary file modified DuiLib.suo
Binary file not shown.
Loading

0 comments on commit 715562c

Please sign in to comment.