Skip to content

Commit

Permalink
增加控件uipagecontrl,demo增加使用例子,帮助文档更新属性
Browse files Browse the repository at this point in the history
  • Loading branch information
nakkler committed Nov 18, 2022
1 parent 4d14409 commit 0a1ff3b
Show file tree
Hide file tree
Showing 10 changed files with 820 additions and 26 deletions.
671 changes: 671 additions & 0 deletions DuiLib/Control/UIPageControl.cpp

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions DuiLib/Control/UIPageControl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#ifndef __UIPageControl_H
#define __UIPageControl_H

#pragma once
namespace DuiLib
{
class UILIB_API CPageControlUI : public CHorizontalLayoutUI
{
DECLARE_DUICONTROL(CPageControlUI)
public:
CPageControlUI();
~CPageControlUI();
//maxpage="20,6"
void SetMaxPages(int nPages, int nShowNum = 6);
void SetMaxChar(int nNum = 2);
//设置字体[font="1"]
void SetFont(int nFont);

//设置页码选中的颜色[pageselectedtextcolor]
void SetPageSelectedTextColor(DWORD cr = 0xFF4EB857);
//设置选中的页按钮背景色[pageselectedbkcolor]
void SetPageSelectedBkColor(DWORD cr = 0x00000000);

//设置页码文字颜色[pagetextcolor]
void SetPageNormalTextColor(DWORD cr = 0xff000000);
//设置按钮背景颜色[pagebkcolor]
void SetPageBkColor(DWORD cr = 0x00000000);

//设置hot按钮背景色[pagehotbkcolor]
void SetPageHotBkColor(DWORD cr = 0x00000000);
//设置hot字体颜色[pagehottextcolor]
void SetPageHotTextColor(DWORD cr = 0x00000000);


//设置页码按钮的大小[pagesize="30,30"]
void SetPageNoSize(int w = 30, int h = 30);
//设置goto按钮的大小[gotoeditsize="1,1"]
void SetGotoEditSize(int w = 30, int h = 26);
//设置GotoEdit边框颜色[gotoeditbordercolor="0x00000000"]
void SetGotoEditBorderColor(DWORD cr = 0x00000000);
//设置GotoEdit边框的大小[gotoeditbordersize="1"]
void SetGotoEditBorderSize(int size = 1);

public:
void GotoPage(int nPageNo, bool bAutoGotoOneWhenError = true);
public:
virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);

protected:
void ResetAllPages();
void UpdatePosition();
void SelectPage(int nPageIdx);
int GetCurSel();

void UpdateMoreBtnVisiable();
bool IsExistNextMore();

bool OnOptionSelChanged(void* p);
bool OnBtnClick(void* p);

private:
int GetPageNoByControl(CControlUI* pcon);
void UpdatePageNo(int iDelta, bool bReset = false);
void UpdateItemIndex();
int GetIndexByPageNo(int nPageNo);
int GetShowPageNum() { return min(m_nShowPage, m_nMaxPage); };
private:
int m_nFont;

int m_nShowPage;
int m_nMaxPage;
SIZE m_szPage;
SIZE m_szGotoEdit;
int m_nSelPageNo;

DWORD m_dwSelTextColor;
DWORD m_dwSelectedBkColor;
DWORD m_dwNormalTextColor;
DWORD m_dwNormalBkColor;
DWORD m_dwHotBkColor;
DWORD m_dwHotTextColor;

CButtonUI* m_BtnPrevious;
CButtonUI* m_BtnNext;
CButtonUI* m_BtnNextMore;
CStdPtrArray m_OptPageNoArr; //COptionUI*
CButtonUI* m_BtnGoto;
CEditUI* m_EdtPageNo;

COptionUI* m_ConCurSel; //当前是第几页
};
}
#endif //__UIPageControl_H
2 changes: 1 addition & 1 deletion DuiLib/Control/UIRing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace DuiLib
Gdiplus::Graphics graphics(hDC);
graphics.TranslateTransform(centerPos.X,centerPos.Y);
graphics.RotateTransform(m_fCurAngle);
graphics.TranslateTransform(-centerPos.X, -centerPos.Y);//»¹Ô­Ô´µã
graphics.TranslateTransform(-centerPos.X, -centerPos.Y);//还原源点
graphics.DrawImage(m_pBkimage,rcItem.left,rcItem.top,iWidth,iHeight);
}
}
Expand Down
1 change: 1 addition & 0 deletions DuiLib/Core/ControlFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace DuiLib
INNER_REGISTER_DUICONTROL(CFadeButtonUI);
INNER_REGISTER_DUICONTROL(CRingUI);
INNER_REGISTER_DUICONTROL(CLoadingUI);
INNER_REGISTER_DUICONTROL(CPageControlUI);

INNER_REGISTER_DUICONTROL_EX(DUI_CTR_BOX, CContainerUI);
INNER_REGISTER_DUICONTROL_EX(DUI_CTR_HBOX, CHorizontalLayoutUI);
Expand Down
3 changes: 3 additions & 0 deletions DuiLib/Core/UIDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ namespace DuiLib
#define DUI_MSGTYPE_LISTHEADITEMCHECKED (_T("listheaditemchecked"))
#define DUI_MSGTYPE_LISTPAGECHANGED (_T("listpagechanged"))

#define DUI_MSGTYPE_PAGECHANED (_T("page_selected_changed"))


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

struct DUI_MSGMAP_ENTRY;
Expand Down
2 changes: 2 additions & 0 deletions DuiLib/DuiLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@
<ItemGroup>
<ClCompile Include="Control\UIIPAddressEx.cpp" />
<ClCompile Include="Control\UILoading.cpp" />
<ClCompile Include="Control\UIPageControl.cpp" />
<ClCompile Include="Control\UIRollText.cpp" />
<ClCompile Include="Control\UIAnimation.cpp" />
<ClCompile Include="Control\UIColorPalette.cpp" />
Expand Down Expand Up @@ -1011,6 +1012,7 @@
<ItemGroup>
<ClInclude Include="Control\UIIPAddressEx.h" />
<ClInclude Include="Control\UILoading.h" />
<ClInclude Include="Control\UIPageControl.h" />
<ClInclude Include="Control\UIRollText.h" />
<ClInclude Include="Control\UIAnimation.h" />
<ClInclude Include="Control\UIColorPalette.h" />
Expand Down
6 changes: 6 additions & 0 deletions DuiLib/DuiLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@
<ClCompile Include="Control\UILoading.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
<ClCompile Include="Control\UIPageControl.cpp">
<Filter>Source Files\Control</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="StdAfx.h">
Expand Down Expand Up @@ -394,5 +397,8 @@
<ClInclude Include="Control\UILoading.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
<ClInclude Include="Control\UIPageControl.h">
<Filter>Header Files\Control</Filter>
</ClInclude>
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions DuiLib/UIlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
#include "Control/UIFadeButton.h"
#include "Control/UIRing.h"
#include "Control/UILoading.h"
#include "Control/UIPageControl.h"

#pragma comment( lib, "comctl32.lib" )
#pragma comment( lib, "GdiPlus.lib" )
Expand Down
14 changes: 13 additions & 1 deletion Help/属性列表.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1367,5 +1367,17 @@
<Attribute name="expland" default="false" type="BOOL" comment="是否显示下级菜单的小三角图片(需要通过Default标签设置ExplandIcon属性图片的路径)"/>
<Attribute name="height" default="30" type="INT" comment="菜单项高度(分割线默认高度是6)"/>
</MenuElement>

<PageControl parent="CHorizontalLayoutUI" notifies="click select changed DUI_MSGTYPE_PAGECHANED">
<maxpage default="1,5" type="INT" comment="最大页码1,最大显示页码5" />
<font default="-1" type="INT" comment="字体" />
<pageselectedtextcolor default="0xFF4EB857" type="DWORD" comment="选中页颜色" />
<pageselectedbkcolor default="0x00000000" type="DWORD" comment="选中页背景颜色" />
<pagetextcolor default="0xff000000" type="DWORD" comment="页字体颜色" />
<pagebkcolor default="0x00000000" type="DWORD" comment="页背景颜色" />
<pagehotbkcolor default="0x00000000" type="DWORD" comment="页hot文字颜色" />
<pagehottextcolor default="0x00000000" type="DWORD" comment="页hot背景颜色" />
<gotoeditbordercolor default="0x00000000" type="DWORD" comment="goto编辑框边框颜色" />
<gotoeditbordersize default="1" type="INT" comment="oto编辑框线宽" />
<editmaxchar default="2" type="INT" comment="页码编辑框默认最大2字符" />
</PageControl>
</Controls>
53 changes: 29 additions & 24 deletions bin/skin/duidemo/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,34 +74,39 @@
</HorizontalLayout>

<Label height="1" bkimage="common/hor_line.png"/>
<HorizontalLayout height="64" childvalign="vcenter">
<Label text="按钮控件" textcolor="#FF000000" font="font13" width="80"/>
<HorizontalLayout childvalign="vcenter" childpadding="12" bordersize="1,1,1,1" bordercolor="#0">
<Button name="button1" text="普通按钮" textcolor="#FF000000" textpadding="6,0,6,0" style="btn_style" width="0" autocalcwidth="true" richevent="true"/>
<Button name="button2" text="图标按钮" textcolor="#FF000000" style="btn_style" height="40" width="90" textpadding="25,0,0,0" align="center" valign="left" foreimage="size='16,16' padding='6,12' align='left,top' res='other/icon.png'" />
<Button name="cmdbtn" text="命令按钮(&S)" textcolor="#FF000000" style="btn_style" shortcut="S" width="120"/>
<Button text="Button按钮{\n}控件自动换行测试" width="60" height="50" align="left" wordbreak="true" endellipsis="true" textcolor="#FF000000" textpadding="6,0,6,0" style="colorbtn_style"/>
<Button name="autobtn" text="自适应比例按钮" minw1idth="120" colorhsl="true" float="0.7,0.2,0.9,0.8" textcolor="#FF000000" bkcolor="#FFFF5555" hotbkcolor="#AAFFFF00" pushedbkcolor="#FFFF00FF" borderround="4,4"/>
<Button name="floatbtn" text="浮动按钮" colorhsl="true" float="true" pos="-20,0,-80,30" textcolor="#FF000000" bkcolor="#FFFF5555" hotbkcolor="#AAFFFF00" pushedbkcolor="#FFFF00FF" borderround="4,4"/>
<VerticalLayout height="100">
<HorizontalLayout height="64" childvalign="vcenter">
<Label text="按钮控件" textcolor="#FF000000" font="font13" width="80"/>
<HorizontalLayout childvalign="vcenter" childpadding="12" bordersize="1,1,1,1" bordercolor="#0">
<Button name="button1" text="普通按钮" textcolor="#FF000000" textpadding="6,0,6,0" style="btn_style" width="0" autocalcwidth="true" richevent="true"/>
<Button name="button2" text="图标按钮" textcolor="#FF000000" style="btn_style" height="40" width="90" textpadding="25,0,0,0" align="center" valign="left" foreimage="size='16,16' padding='6,12' align='left,top' res='other/icon.png'" />
<Button name="cmdbtn" text="命令按钮(&S)" textcolor="#FF000000" style="btn_style" shortcut="S" width="120"/>
<Button text="Button按钮{\n}控件自动换行测试" width="60" height="50" align="left" wordbreak="true" endellipsis="true" textcolor="#FF000000" textpadding="6,0,6,0" style="colorbtn_style"/>
<Button name="autobtn" text="自适应比例按钮" minw1idth="120" colorhsl="true" float="0.7,0.2,0.9,0.8" textcolor="#FF000000" bkcolor="#FFFF5555" hotbkcolor="#AAFFFF00" pushedbkcolor="#FFFF00FF" borderround="4,4"/>
<Button name="floatbtn" text="浮动按钮" colorhsl="true" float="true" pos="-20,0,-80,30" textcolor="#FF000000" bkcolor="#FFFF5555" hotbkcolor="#AAFFFF00" pushedbkcolor="#FFFF00FF" borderround="4,4"/>

<Loading name="loading" width="64" height="64" time="50" color="0xffffff00" />
<Container width="64" height="64">
<Button name="autobtn" textcolor="#FF000000" bkimage="logo.jpg" bordercolor="#FFFF6666" bordersize="2" borderround="64,64" borderstyle="2"/>
</Container>

<Loading name="loading" width="64" height="64" time="50" color="0xffffff00" />
<Container width="64" height="64">
<Button name="autobtn" textcolor="#FF000000" bkimage="logo.jpg" bordercolor="#FFFF6666" bordersize="2" borderround="64,64" borderstyle="2"/>
</Container>

</HorizontalLayout>
</HorizontalLayout>
</HorizontalLayout>
<HorizontalLayout>
<PageControl name="pagecontrol" maxpage="100,10" editmaxchar="3"></PageControl>
</HorizontalLayout>
</VerticalLayout>

<Label height="1" bkimage="common/hor_line.png"/>
<HorizontalLayout height="60" childvalign="vcenter">
<Label text="选择控件" textcolor="#FF000000" font="font13" width="80"/>
<HorizontalLayout childvalign="vcenter" childalign="right" childpadding="12" bordersize="1,1,1,1" bordercolor="#0">
<Option name="option1" text="复选框" textcolor="#FF000000" textpadding="6,0,6,0" style="cb_style" width="0" autocalcwidth="true"/>
<Option name="radio1" group="radio" text="单选框" textcolor="#FF000000" textpadding="6,0,6,0" style="radio_style" width="0" autocalcwidth="true"/>
<Option name="radio2" group="radio" text="单选框" textcolor="#FF000000" textpadding="6,0,6,0" style="radio_style" width="0" autocalcwidth="true"/>

<Label height="1" bkimage="common/hor_line.png"/>
<HorizontalLayout height="60" childvalign="vcenter">
<Label text="选择控件" textcolor="#FF000000" font="font13" width="80"/>
<HorizontalLayout childvalign="vcenter" childalign="right" childpadding="12" bordersize="1,1,1,1" bordercolor="#0">
<Option name="option1" text="复选框" textcolor="#FF000000" textpadding="6,0,6,0" style="cb_style" width="0" autocalcwidth="true"/>
<Option name="radio1" group="radio" text="单选框" textcolor="#FF000000" textpadding="6,0,6,0" style="radio_style" width="0" autocalcwidth="true"/>
<Option name="radio2" group="radio" text="单选框" textcolor="#FF000000" textpadding="6,0,6,0" style="radio_style" width="0" autocalcwidth="true"/>

</HorizontalLayout>
</HorizontalLayout>
</HorizontalLayout>

<Label height="1" bkimage="common/hor_line.png"/>
<HorizontalLayout height="60" childvalign="vcenter">
Expand Down

0 comments on commit 0a1ff3b

Please sign in to comment.