Skip to content

Commit 52242da

Browse files
字体增加默认属性,修改Demo中的XML使用新的Class和Font方式
1 parent f004f79 commit 52242da

File tree

13 files changed

+109
-104
lines changed

13 files changed

+109
-104
lines changed

bin/resources/themes/default/cef/cef.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<HBox height="auto">
1515
<Button class="btn_global_blue_80x30" name="btn_back" text="后退" width="60"/>
1616
<Button class="btn_global_blue_80x30" name="btn_forward" text="前进" width="60" margin="5,0,5"/>
17-
<RichEdit class="simple prompt input" name="edit_url" width="stretch" height="28" valign="center" padding="5,5,5,5" font="1" prompttext="请输入网址"/>
17+
<RichEdit class="simple prompt input" name="edit_url" width="stretch" height="28" valign="center" padding="5,5,5,5" prompttext="请输入网址"/>
1818
<Button class="btn_global_blue_80x30" name="btn_navigate" text="转到" width="60" margin="5"/>
1919
<Button class="btn_global_blue_80x30" name="btn_refresh" text="刷新" width="60" margin="5"/>
2020
</HBox>

bin/resources/themes/default/controls/controls.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<Control class="splitline_hor_level1"/>
5656
<!-- RichEdit -->
5757
<RichEdit class="prompt" name="edit" bkcolor="bk_wnd_lightcolor" width="stretch" height="stretch"
58-
font="1" multiline="true" vscrollbar="true" hscrollbar="true" autovscroll="true"
58+
multiline="true" vscrollbar="true" hscrollbar="true" autovscroll="true"
5959
normaltextcolor="darkcolor" wantreturnmsg="true" rich="true"/>
6060
</VBox>
6161
</VBox>

bin/resources/themes/default/global.xml

+71-71
Large diffs are not rendered by default.

bin/resources/themes/default/layouts/login.xml

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,33 @@
1414
</HBox>
1515
<HBox height="auto">
1616
<Control />
17-
<Button name="register_account" margin="0,5,15,10" halign="right" text="注册" cursortype="hand" font="24" normaltextcolor="link_green"/>
18-
<Button name="enter_login" margin="0,5,15,10" halign="right" text="直接登录" cursortype="hand" font="24" normaltextcolor="link_green" visible="false"/>
17+
<Button name="register_account" margin="0,5,15,10" halign="right" text="注册" cursortype="hand" font="system_underline_12" normaltextcolor="link_green"/>
18+
<Button name="enter_login" margin="0,5,15,10" halign="right" text="直接登录" cursortype="hand" font="system_underline_12" normaltextcolor="link_green" visible="false"/>
1919
</HBox>
2020
<!--帐号和密码-->
2121
<VBox name="enter_panel" width="240" height="auto" margin="20,0,20,0" bkimage="user_password.png">
2222
<HBox height="41" padding="14,1,10,0">
2323
<Control name="usericon" width="16" height="16" valign="center" normalimage="user_1.png" disabledimage="user_2.png"/>
24-
<RichEdit class="simple prompt" name="username" width="stretch" height="auto" margin="10,0,10,0" valign="center" font="2" prompttext="帐号"/>
24+
<RichEdit class="simple prompt" name="username" width="stretch" height="auto" margin="10,0,10,0" valign="center" font="system_14" prompttext="帐号"/>
2525
</HBox>
2626
<HBox name="nick_name_panel" height="40" padding="14,1,0,0" visible="false" margin="0,0,0,0">
2727
<Control name="nick_name_icon" width="16" height="16" valign="center" normalimage="nickname.png" disabledimage="nickname.png"/>
28-
<RichEdit class="simple prompt" name="nickname" width="stretch" height="auto" margin="10,0,10,0" valign="center" font="2" prompttext="昵称"/>
28+
<RichEdit class="simple prompt" name="nickname" width="stretch" height="auto" margin="10,0,10,0" valign="center" font="system_14" prompttext="昵称"/>
2929
</HBox>
3030
<HBox height="41" padding="14,0,10,1" margin="0,2,0,0">
3131
<Control name="passwordicon" width="16" height="16" valign="center" normalimage="password_1.png" disabledimage="password_2.png"/>
32-
<RichEdit class="simple prompt" name="password" width="stretch" height="auto" margin="10,0,10,0" valign="center" font="2" password="true" prompttext="密码"/>
32+
<RichEdit class="simple prompt" name="password" width="stretch" height="auto" margin="10,0,10,0" valign="center" font="system_14" password="true" prompttext="密码"/>
3333
</HBox>
3434
</VBox>
3535
</VBox>
3636
<!--登录提示-->
37-
<Label name="login_ing_tip" margin="20,20,20,0" font="1" text="正在登录..." visible="false"/>
38-
<Label name="login_error_tip" margin="20,20,20,0" font="1" normaltextcolor="obvious_tip" visible="false"/>
37+
<Label name="login_ing_tip" margin="20,20,20,0" font="system_12" text="正在登录..." visible="false"/>
38+
<Label name="login_error_tip" margin="20,20,20,0" font="system_12" normaltextcolor="obvious_tip" visible="false"/>
3939
<!--登录和取消按钮-->
4040
<Box width="240" height="40" margin="20,20,20,20">
41-
<Button class="btn_global_blue_80x30" name="btn_login" width="240" height="40" font="8" text="登录"/>
42-
<Button class="btn_global_blue_80x30" name="btn_register" width="240" height="40" font="8" text="注册" visible="false"/>
43-
<Button class="btn_global_red_80x30" name="btn_cancel" width="240" height="40" font="8" text="取消登录" visible="false"/>
41+
<Button class="btn_global_blue_80x30" name="btn_login" width="240" height="40" font="system_bold_16" text="登录"/>
42+
<Button class="btn_global_blue_80x30" name="btn_register" width="240" height="40" font="system_bold_16" text="注册" visible="false"/>
43+
<Button class="btn_global_red_80x30" name="btn_cancel" width="240" height="40" font="system_bold_16" text="取消登录" visible="false"/>
4444
</Box>
4545
</VBox>
4646
</Box>

bin/resources/themes/default/layouts/wechat.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- 好友列表 -->
99
<VBox width="270" bkcolor="light_gray">
1010
<Box padding="10,8,10,8" height="auto">
11-
<RichEdit class="simple prompt input" name="nickname" width="stretch" height="35" padding="25,8,8,8" font="1" borderround="5,5" prompttext="搜索"/>
11+
<RichEdit class="simple prompt input" name="nickname" width="stretch" height="35" padding="25,8,8,8" borderround="5,5" prompttext="搜索"/>
1212
<Control width="auto" height="auto" margin="6,9" bkimage="search_icon.png"/>
1313
</Box>
1414
<VBox>

bin/resources/themes/default/msgbox/msgbox.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Button class="btn_wnd_close" name="closebtn" margin="10,6,0,0"/>
77
</HBox>
88

9-
<RichEdit name="content" width="300" margin="20,30,20,30" font="3" multiline="true" vscrollbar="false" autovscroll="false" enabled="false" rich="true"/>
9+
<RichEdit name="content" width="300" margin="20,30,20,30" font="system_16" multiline="true" vscrollbar="false" autovscroll="false" enabled="false" rich="true"/>
1010

1111
<HBox height="auto" margin="0,0,20,20" childmargin="10">
1212
<Control />

bin/resources/themes/default/multi_browser/multi_browser.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
</HBox>
1111

1212
<HBox height="30" margin="10,2,10,2" childmargin="3">
13-
<Button class="btn_global_blue_80x30" name="btn_back" width="50" height="30" textid="STRID_CEF_BROWSER_BACKWARD" valign="center" font="1" />
14-
<Button class="btn_global_blue_80x30" name="btn_forward" width="50" height="30" textid="STRID_CEF_BROWSER_FORWARD" valign="center" font="1" />
15-
<Button class="btn_global_blue_80x30" name="btn_refresh" width="50" height="30" textid="STRID_CEF_BROWSER_REFRESH" valign="center" font="1" />
13+
<Button class="btn_global_blue_80x30" name="btn_back" width="50" height="30" textid="STRID_CEF_BROWSER_BACKWARD" valign="center" font="system_12" />
14+
<Button class="btn_global_blue_80x30" name="btn_forward" width="50" height="30" textid="STRID_CEF_BROWSER_FORWARD" valign="center" font="system_12" />
15+
<Button class="btn_global_blue_80x30" name="btn_refresh" width="50" height="30" textid="STRID_CEF_BROWSER_REFRESH" valign="center" font="system_12" />
1616
<RichEdit class="simple prompt" name="edit_url" width="400" height="30" padding="5,2,5,0" valign="center"
17-
bordercolor="gray" bordersize="1" font="2" prompttextid="STRID_CEF_BROWSER_INPUT_ADDRESS" vscrollbar="false" autovscroll="false" hscrollbar="false" autohscroll="true" wantreturnmsg="true" />
17+
bordercolor="gray" bordersize="1" font="system_14" prompttextid="STRID_CEF_BROWSER_INPUT_ADDRESS" vscrollbar="false" autovscroll="false" hscrollbar="false" autohscroll="true" wantreturnmsg="true" />
1818
<!-- 顶部标签列表 -->
1919
<HListBox class="list" name="tab_list" >
20-
<Button class="btn_global_blue_80x30" name="btn_add" text="+" width="20" height="20" valign="center" font="3" />
20+
<Button class="btn_global_blue_80x30" name="btn_add" text="+" width="20" height="20" valign="center" font="system_16" />
2121
</HListBox>
2222
</HBox>
2323
<Control class="splitline_hor_level1" margin="0,0,0,0" />

bin/resources/themes/default/multi_browser/tab_item.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Control name="tab_item_icon" width="38" height="38" borderround="38,38,38,38" margin="1,1,0,0"/>
77
<Control class="icon_headimage_mask_40x40"/>
88
</Box>
9-
<Label name="tab_item_name" width="stretch" valign="center" font="1" mouse="false"/>
9+
<Label name="tab_item_name" width="stretch" valign="center" font="system_12" mouse="false"/>
1010

1111
<Box width="auto" height="auto" float="true" halign="right" valign="center">
1212
<Button class="btn_del_search" name="tab_item_close" width="16" height="16" halign="center" valign="center" visible="false"/>

bin/resources/themes/default/richlist/richlist.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Window size="400,600" caption="0,0,0,35">
33
<VBox bkcolor="bk_wnd_darkcolor">
44
<HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor">
5-
<Label text="自定义列表示例" font="2" valign="center" margin="8"/>
5+
<Label text="自定义列表示例" font="system_14" valign="center" margin="8"/>
66
<Control />
77
<Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0"/>
88
<Box width="21" margin="4,6,0,0">
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Window size="340,180" caption="0,0,0,600" shadowattached="false" custom_shadow="10,10,10,10">
33
<Box width="340" height="auto" bkimage="file='win_bg.png' corner='15,15,15,15'">
4-
<RichEdit name="content" width="300" minheight="30" margin="20,20,20,20" font="2" multiline="true" vscrollbar="false" autovscroll="false" enabled="false" rich="false" mouse="false" disabledtextcolor="light_gray"/>
4+
<RichEdit name="content" width="300" minheight="30" margin="20,20,20,20" font="system_14" multiline="true" vscrollbar="false" autovscroll="false" enabled="false" rich="false" mouse="false" disabledtextcolor="light_gray"/>
55
<Button name="close_btn" width="25" height="24" valign="top" halign="right" visible="false" normalimage="file='close.png' source='0,0,24,24'" hotimage="file='close.png' source='25,0,49,24'" pushedimage="file='close.png' source='50,0,74,24'" disabledimage="file='close.png' source='75,0,99,24'"/>
66
</Box>
77
</Window>

tool_kits/duilib/Core/GlobalManager.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ GlobalManager::MapStringToImagePtr GlobalManager::m_mImageHash;
1515
std::map<std::wstring, DWORD> GlobalManager::m_mapTextColor;
1616
std::map<std::wstring, std::wstring> GlobalManager::m_mGlobalClass;
1717
std::map<std::wstring, TFontInfo*> GlobalManager::m_mCustomFonts;
18+
std::wstring GlobalManager::m_sDefaultFontId;
1819

1920
short GlobalManager::m_H = 180;
2021
short GlobalManager::m_S = 100;
@@ -366,7 +367,7 @@ void GlobalManager::RemoveAllImages()
366367
m_mImageHash.clear();
367368
}
368369

369-
HFONT GlobalManager::AddFont(const std::wstring& strFontId, const std::wstring& strFontName, int nSize, bool bBold, bool bUnderline, bool bItalic)
370+
HFONT GlobalManager::AddFont(const std::wstring& strFontId, const std::wstring& strFontName, int nSize, bool bBold, bool bUnderline, bool bItalic, bool bDefault)
370371
{
371372
std::wstring strNewFontId = strFontId;
372373
if (strNewFontId.empty())
@@ -406,21 +407,21 @@ HFONT GlobalManager::AddFont(const std::wstring& strFontId, const std::wstring&
406407

407408
m_mCustomFonts.insert(std::make_pair(strNewFontId, pFontInfo));
408409

410+
if (bDefault) m_sDefaultFontId = strNewFontId;
411+
409412
return hFont;
410413
}
411414

412415
TFontInfo* GlobalManager::GetTFontInfo(const std::wstring& strFontId)
413416
{
414-
if (strFontId.empty())
417+
std::wstring strFindId = strFontId;
418+
if (strFindId.empty())
415419
{
416-
for (auto it = m_mCustomFonts.begin(); it != m_mCustomFonts.end(); it++)
417-
{
418-
return it->second;
419-
}
420-
return NULL;
420+
ASSERT(!m_sDefaultFontId.empty());
421+
strFindId = m_sDefaultFontId;
421422
}
422423

423-
auto iter = m_mCustomFonts.find(strFontId);
424+
auto iter = m_mCustomFonts.find(strFindId);
424425
ASSERT(iter != m_mCustomFonts.end());
425426

426427
TFontInfo* pFontInfo = static_cast<TFontInfo*>(iter->second);

tool_kits/duilib/Core/GlobalManager.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ class UILIB_API GlobalManager
206206
* @param[in] bBold 是否粗体
207207
* @param[in] bUnderline 是否有下划线
208208
* @param[in] bItalic 是否倾斜
209+
* @param[in] bDefault 是否默认
209210
* @return 返回字体的 HFONT 句柄
210211
*/
211-
static HFONT AddFont(const std::wstring& strFontId, const std::wstring& strFontName, int nSize, bool bBold, bool bUnderline, bool bItalic);
212+
static HFONT AddFont(const std::wstring& strFontId, const std::wstring& strFontName, int nSize, bool bBold, bool bUnderline, bool bItalic, bool bDefault);
212213

213214
/**
214215
* @brief 根据索引返回一个字体信息
@@ -459,6 +460,8 @@ class UILIB_API GlobalManager
459460
static std::map<std::wstring, std::wstring> m_mGlobalClass;
460461
static std::map<std::wstring, TFontInfo*> m_mCustomFonts;
461462

463+
static std::wstring m_sDefaultFontId;
464+
462465
static short m_H;
463466
static short m_S;
464467
static short m_L;

tool_kits/duilib/Core/WindowBuilder.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ Box* WindowBuilder::Create(CreateControlCallback pCallback, Window* pManager, Bo
199199
bool bold = false;
200200
bool underline = false;
201201
bool italic = false;
202+
bool isDefault = false;
202203
for( int i = 0; i < nAttributes; i++ ) {
203204
strName = node.GetAttributeName(i);
204205
strValue = node.GetAttributeValue(i);
@@ -222,11 +223,11 @@ Box* WindowBuilder::Create(CreateControlCallback pCallback, Window* pManager, Bo
222223
italic = (strValue == _T("true"));
223224
}
224225
else if( strName == _T("default") ) {
225-
ASSERT(FALSE);//废弃
226+
isDefault = (strValue == _T("true"));
226227
}
227228
}
228229
if( !strFontName.empty() ) {
229-
GlobalManager::AddFont(strFontId, strFontName, size, bold, underline, italic);
230+
GlobalManager::AddFont(strFontId, strFontName, size, bold, underline, italic, isDefault);
230231
}
231232
}
232233
else if( strClass == _T("Class") ) {

0 commit comments

Comments
 (0)