Skip to content

Commit

Permalink
1、修正list布局计算错误的问题
Browse files Browse the repository at this point in the history
2、修正控件剪裁区域局计算错误的问题
3、duidemo增加启动闪屏的例子
  • Loading branch information
qdtroy committed May 2, 2018
1 parent f16023e commit 0170cc5
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 13 deletions.
5 changes: 4 additions & 1 deletion Demos/duidemo/DuiDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "SkinFrame.h"
#include "MainWnd.h"
#include "PopWnd.h"

#include "SplashWnd.h"
void InitResource()
{
// 资源类型
Expand Down Expand Up @@ -88,6 +88,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*l
CPaintManagerUI::SetInstance(hInstance);
// 初始化资源
InitResource();

CSplashWnd::MessageBox(NULL);

// 创建主窗口
CMainWnd* pMainWnd = new CMainWnd();
if( pMainWnd == NULL ) return 0;
Expand Down
67 changes: 67 additions & 0 deletions Demos/duidemo/SplashWnd.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include "StdAfx.h"
#include "SplashWnd.h"
#include <process.h>

//////////////////////////////////////////////////////////////////////////
///

DUI_BEGIN_MESSAGE_MAP(CSplashWnd, WindowImplBase)
DUI_ON_MSGTYPE(DUI_MSGTYPE_CLICK,OnClick)
DUI_END_MESSAGE_MAP()

CSplashWnd::CSplashWnd(void)
{
}

CSplashWnd::~CSplashWnd(void)
{
}

void CSplashWnd::OnFinalMessage( HWND hWnd)
{
__super::OnFinalMessage(hWnd);
delete this;
}

DuiLib::CDuiString CSplashWnd::GetSkinFile()
{
return _T("splash.xml");
}

LPCTSTR CSplashWnd::GetWindowClassName( void ) const
{
return _T("SplashWnd");
}

void CSplashWnd::OnClick( TNotifyUI &msg )
{
CDuiString sName = msg.pSender->GetName();
sName.MakeLower();

}

LRESULT CSplashWnd::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = FALSE;
return 0;
}

LRESULT CSplashWnd::OnSysCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
bHandled = FALSE;
return 0L;
}

void Busy( void* param )
{
int i = 0;
while(i++ < 5)
{
Sleep(300);
}
::PostMessage((HWND)param, WM_CLOSE, 0, 0);
}
void CSplashWnd::InitWindow()
{
_beginthread(Busy, 0, m_hWnd);
}
32 changes: 32 additions & 0 deletions Demos/duidemo/SplashWnd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

//////////////////////////////////////////////////////////////////////////
///

class CSplashWnd : public WindowImplBase
{
public:
static int MessageBox(HWND hParent)
{
CSplashWnd* pWnd = new CSplashWnd();
pWnd->Create(hParent, _T("msgwnd"), WS_POPUP | WS_CLIPCHILDREN, WS_EX_TOOLWINDOW);
pWnd->CenterWindow();
return pWnd->ShowModal();
}

public:
CSplashWnd(void);
~CSplashWnd(void);

public:
virtual void OnFinalMessage( HWND );
virtual CDuiString GetSkinFile();
virtual LPCTSTR GetWindowClassName( void ) const;
virtual void InitWindow();

DUI_DECLARE_MESSAGE_MAP()
virtual void OnClick(TNotifyUI& msg);

virtual LRESULT OnSysCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
LRESULT HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
};
3 changes: 3 additions & 0 deletions Demos/duidemo/duidemo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@
<ClCompile Include="MsgWnd.cpp" />
<ClCompile Include="PopWnd.cpp" />
<ClCompile Include="SkinManager.cpp" />
<ClCompile Include="SplashWnd.cpp" />
<ClCompile Include="StdAfx.cpp">
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -960,6 +961,7 @@
<ClInclude Include="resource.h" />
<ClInclude Include="SkinFrame.h" />
<ClInclude Include="SkinManager.h" />
<ClInclude Include="SplashWnd.h" />
<ClInclude Include="StdAfx.h" />
</ItemGroup>
<ItemGroup>
Expand All @@ -986,6 +988,7 @@
<None Include="..\..\bin\skin\duidemo\skin.xml">
<SubType>Designer</SubType>
</None>
<None Include="..\..\bin\skin\duidemo\splash.xml" />
<None Include="..\..\bin\skin\duidemo\treeitem.xml">
<SubType>Designer</SubType>
</None>
Expand Down
9 changes: 9 additions & 0 deletions Demos/duidemo/duidemo.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<ClCompile Include="SkinManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SplashWnd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ControlEx.h">
Expand All @@ -64,6 +67,9 @@
<ClInclude Include="MsgWnd.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SplashWnd.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Res\duidemo.ico">
Expand Down Expand Up @@ -105,6 +111,9 @@
<None Include="..\..\bin\skin\duidemo\lan_en.xml">
<Filter>Resources\xmls</Filter>
</None>
<None Include="..\..\bin\skin\duidemo\splash.xml">
<Filter>Resources\xmls</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="duidemo.rc">
Expand Down
28 changes: 27 additions & 1 deletion DuiLib/Control/UIButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ namespace DuiLib
void CButtonUI::SetHotBkColor( DWORD dwColor )
{
m_dwHotBkColor = dwColor;
Invalidate();
}

DWORD CButtonUI::GetHotBkColor() const
Expand All @@ -178,13 +179,25 @@ namespace DuiLib
void CButtonUI::SetPushedBkColor( DWORD dwColor )
{
m_dwPushedBkColor = dwColor;
Invalidate();
}

DWORD CButtonUI::GetPushedBkColor() const
{
return m_dwPushedBkColor;
}

void CButtonUI::SetDisabledBkColor( DWORD dwColor )
{
m_dwDisabledBkColor = dwColor;
Invalidate();
}

DWORD CButtonUI::GetDisabledBkColor() const
{
return m_dwDisabledBkColor;
}

void CButtonUI::SetHotTextColor(DWORD dwColor)
{
m_dwHotTextColor = dwColor;
Expand Down Expand Up @@ -369,6 +382,13 @@ namespace DuiLib
DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
SetPushedBkColor(clrColor);
}
else if( _tcsicmp(pstrName, _T("disabledbkcolor")) == 0 )
{
if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
LPTSTR pstr = NULL;
DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
SetDisabledBkColor(clrColor);
}
else if( _tcsicmp(pstrName, _T("hottextcolor")) == 0 )
{
if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue);
Expand Down Expand Up @@ -446,7 +466,13 @@ namespace DuiLib

void CButtonUI::PaintBkColor(HDC hDC)
{
if( (m_uButtonState & UISTATE_PUSHED) != 0 ) {
if( (m_uButtonState & UISTATE_DISABLED) != 0 ) {
if(m_dwDisabledBkColor != 0) {
CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwDisabledBkColor));
return;
}
}
else if( (m_uButtonState & UISTATE_PUSHED) != 0 ) {
if(m_dwPushedBkColor != 0) {
CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwPushedBkColor));
return;
Expand Down
3 changes: 3 additions & 0 deletions DuiLib/Control/UIButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ namespace DuiLib
DWORD GetHotBkColor() const;
void SetPushedBkColor(DWORD dwColor);
DWORD GetPushedBkColor() const;
void SetDisabledBkColor(DWORD dwColor);
DWORD GetDisabledBkColor() const;
void SetHotTextColor(DWORD dwColor);
DWORD GetHotTextColor() const;
void SetPushedTextColor(DWORD dwColor);
Expand All @@ -78,6 +80,7 @@ namespace DuiLib

DWORD m_dwHotBkColor;
DWORD m_dwPushedBkColor;
DWORD m_dwDisabledBkColor;
DWORD m_dwHotTextColor;
DWORD m_dwPushedTextColor;
DWORD m_dwFocusedTextColor;
Expand Down
4 changes: 1 addition & 3 deletions DuiLib/Control/UIList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2898,7 +2898,6 @@ namespace DuiLib {

void CListContainerElementUI::SetPos(RECT rc, bool bNeedInvalidate)
{
CHorizontalLayoutUI::SetPos(rc, bNeedInvalidate);
if( m_pOwner == NULL ) return;

UINT uListType = m_pOwner->GetListType();
Expand All @@ -2920,11 +2919,10 @@ namespace DuiLib {
}
}
}
CHorizontalLayoutUI::SetPos(rc, bNeedInvalidate);

if(uListType != LT_LIST && uListType != LT_TREE) return;

CListUI* pList = static_cast<CListUI*>(m_pOwner);

if (uListType == LT_TREE)
{
pList = (CListUI*)pList->CControlUI::GetInterface(_T("List"));
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Core/UIControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ namespace DuiLib {
//if( OnPaint ) {
// if( !OnPaint(this) ) return true;
//}
if (!DoPaint(hDC, rcPaint, pStopControl)) return false;
if (!DoPaint(hDC, m_rcPaint, pStopControl)) return false;
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion bin/skin/duidemo/listitem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Label text="1002" align="center"/>
<Label text="99" align="center"/>
<Container >
<Button style="btn_style" float="true" pos="30,0,100,30" text="确认" font="100"/>
<Button float="true" pos="30,0,100,30" style="btn_style" text="确认" font="100"/>
</Container>
</ListContainerElement>
</Window>
13 changes: 7 additions & 6 deletions bin/skin/duidemo/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,10 @@
<HorizontalLayout height="120" inset="0,6,0,6">
<Label text="Tree控件" textcolor="#FF000000" glowsize="0" font="font13" width="80"/>
<VerticalLayout bordersize="1" bordercolor="#FF333333" inset="2,2,2,2">
<TreeView name="treeview" bkcolor="#ffffffff" visiblefolderbtn="true" visiblecheckbtn="true" vscrollbar="true" >
<TreeNode text="A1" style="treeview_style" itemattr="visible=&quot;true&quot; font=&quot;3&quot;">
<TreeNode text="B1" innerstyle="selitemtextcolor=&quot;#FFFF0000&quot; folderattr=&quot;treenode_folder_style&quot; checkboxattr=&quot;treenode_checkbox_style&quot;" itemattr="font=&quot;3&quot;" >
<TreeView name="treeview" bkcolor="#ffffffff" visiblefolderbtn="true" visiblecheckbtn="false" vscrollbar="true" >
<TreeNode text="A1" itemattr="visible=&quot;true&quot; font=&quot;3&quot;">
<Button text="扩展按钮" width="100" />
<!--<TreeNode text="B1" innerstyle="selitemtextcolor=&quot;#FFFF0000&quot; folderattr=&quot;treenode_folder_style&quot; checkboxattr=&quot;treenode_checkbox_style&quot;" itemattr="font=&quot;3&quot;" >
<TreeNode text="C1" innerstyle="selitemtextcolor=&quot;#FFFF0000&quot; folderattr=&quot;treenode_folder_style&quot; checkboxattr=&quot;treenode_checkbox_style&quot;" >
<TreeNode text="D1" horizattr="width=&quot;128&quot; bkcolor=&quot;#FFFF0000&quot;" innerstyle="folderattr=&quot;treenode_folder_style&quot; checkboxattr=&quot;treenode_checkbox_style&quot;" >
<HorizontalLayout bkcolor="#FFFF00FF" width="300">
Expand All @@ -218,9 +219,9 @@
</TreeNode>
<Edit text="请输入编辑内容" style="edit_style" tipvalue="扩展文本框" />
</TreeNode>
<Edit text="我是Troy" style="edit_style" tipvalue="扩展文本框" />
<Edit text="我是Troy" style="edit_style" tipvalue="扩展文本框" />-->
</TreeNode>
<TreeNode text="A2" itemtextcolor="#FFFF0000" itemattr="font=&quot;3&quot;" folderattr="padding=&quot;0,1,0,0&quot; width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/treeview_b.png' source='0,0,16,16' &quot; hotimage=&quot;file='common/treeview_b.png' source='16,0,32,16' &quot; selectedimage=&quot;file='common/treeview_a.png' source='0,0,16,16' &quot; selectedhotimage=&quot;file='common/treeview_a.png' source='16,0,32,16' &quot;" checkboxattr="width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/unchecked.png' &quot; selectedimage=&quot;file='common/checked.png' &quot;" >
<!--<TreeNode text="A2" itemtextcolor="#FFFF0000" itemattr="font=&quot;3&quot;" folderattr="padding=&quot;0,1,0,0&quot; width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/treeview_b.png' source='0,0,16,16' &quot; hotimage=&quot;file='common/treeview_b.png' source='16,0,32,16' &quot; selectedimage=&quot;file='common/treeview_a.png' source='0,0,16,16' &quot; selectedhotimage=&quot;file='common/treeview_a.png' source='16,0,32,16' &quot;" checkboxattr="width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/unchecked.png' &quot; selectedimage=&quot;file='common/checked.png' &quot;" >
<TreeNode text="B2" itemattr="font=&quot;3&quot;" folderattr="padding=&quot;0,1,0,0&quot; width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/treeview_b.png' source='0,0,16,16' &quot; hotimage=&quot;file='common/treeview_b.png' source='16,0,32,16' &quot; selectedimage=&quot;file='common/treeview_a.png' source='0,0,16,16' &quot; selectedhotimage=&quot;file='common/treeview_a.png' source='16,0,32,16' &quot;" checkboxattr="width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/unchecked.png' &quot; selectedimage=&quot;file='common/checked.png' &quot;" >
<TreeNode text="C2" itemattr="font=&quot;3&quot;" folderattr="padding=&quot;0,1,0,0&quot; width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/treeview_b.png' source='0,0,16,16' &quot; hotimage=&quot;file='common/treeview_b.png' source='16,0,32,16' &quot; selectedimage=&quot;file='common/treeview_a.png' source='0,0,16,16' &quot; selectedhotimage=&quot;file='common/treeview_a.png' source='16,0,32,16' &quot;" checkboxattr="width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/unchecked.png' &quot; selectedimage=&quot;file='common/checked.png' &quot;" >
<TreeNode text="D2" itemattr="font=&quot;3&quot;" folderattr="padding=&quot;0,1,0,0&quot; width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/treeview_b.png' source='0,0,16,16' &quot; hotimage=&quot;file='common/treeview_b.png' source='16,0,32,16' &quot; selectedimage=&quot;file='common/treeview_a.png' source='0,0,16,16' &quot; selectedhotimage=&quot;file='common/treeview_a.png' source='16,0,32,16' &quot;" checkboxattr="width=&quot;16&quot; height=&quot;16&quot; normalimage=&quot;file='common/unchecked.png' &quot; selectedimage=&quot;file='common/checked.png' &quot;" >
Expand All @@ -231,7 +232,7 @@
<CheckBox text="扩展复选框" width="100" />
</TreeNode>
<CheckBox text="扩展复选框" width="100" />
</TreeNode>
</TreeNode>-->
</TreeView>
</VerticalLayout>
</HorizontalLayout>
Expand Down
11 changes: 11 additions & 0 deletions bin/skin/duidemo/splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<Window caption="0,0,0,300" size="400,300" mininfo="400,300" sizebox="6,6,6,6" >
<VerticalLayout name="root" bkcolor="#EE202223">
<VerticalLayout bkcolor="#EEFFFFFF" childalign="center">
<Control />
<Ring name="ring" text="Ring" textcolor="#FF333333" align="center" valign="vcenter" height="200" width="200" bkimage="common/ring.png"/>
<Control />
</VerticalLayout>
</VerticalLayout>
</Window>

0 comments on commit 0170cc5

Please sign in to comment.