nim_duilib(11)之menu(1)
introduction
xml文件添加代码
基于上一篇, 继续向basic.xml中添加下面的代码。 xml完整源码在文末。
这段代码添加到最小化按钮的上面
<HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor">
<Control />
<!--设置按钮-->
<Button class="btn_wnd_settings" name="settings" margin="4,6,0,0"/>
<Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0" />
<Box width="21" margin="4,6,0,0">
<Button class="btn_wnd_max" name="maxbtn"/>
<Button class="btn_wnd_restore" name="restorebtn" visible="false"/>
</Box>
<Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0"/>
</HBox>
核心代码是
<!--设置按钮-->
<Button class="btn_wnd_settings" name="settings" margin="4,6,0,0"/>
项目文件配置
menu控件来自另一个项目ui_components, 而ui_component又依赖项目libcef_dll_wrapper。libcef_dll_wrapper位于文件夹third_party下。
stage 1
从源码目录拷贝ui_component和libcef_dll_wrapper和libs文件夹到先前创建好的kit的文件夹下,此时目录结构如下:
.kit
├─base
├─build
├─duilib
├─libs
├─third_party
└─ui_components
stage 2
习惯将项目输出到VS默认输出的目录Debug, 所以将项目ui_components、libcef_dll_wrapper的输出目录和中间目录改为如下:
name | value |
---|---|
输出目录 | $(SolutionDir)$(Configuration)| |
中间目录 | $(Configuration)| |
stage 3
设置ui_components项目链接lib目录指向 kit\libs\。 打开ui_components属性->库管理器->常规->附加库目录->编辑,改为下面的值:
$(SolutionDir)kit\libs\
Note: 注意Release和Debug需要都修改。效果图
stage 4
为什么要做上面的配置? 因为 项目ui_components需要依赖libs目录下的nim_libcef库
代码中关联
BasicForm.h
- 打开BasicForm.h,类中添加下面的代码用于关联界面控件。
// settings按钮
ui::Button* psettings_;
监听选择子项事件
类中继续添加下面的代码,用于监听滑块的值发生变化
// settings按钮点击事件
bool OnSettingsBtnClicked(ui::EventArgs* msg);
BasicForm.cpp
InitWindow函数
- 转到BasicForm.cpp,找到 InitWindow 函数,向其增加下面的代码
void BasicForm::InitWindow()
{
......
// 12.关联设置按钮
//----------------------------------------------------------------------------------------
psettings_ = dynamic_cast<ui::Button*>(FindControl(L"settings"));
// 关联点击事件
if (psettings_)
{
psettings_->AttachClick(nbase::Bind(&BasicForm::OnSettingsBtnClicked, this, std::placeholders::_1));
}
}
OnSettingsBtnClicked
OnSettingsBtnClicked函数源码如下:
bool BasicForm::OnSettingsBtnClicked(ui::EventArgs* msg)
{
// 点击设置按钮,弹出菜单
RECT rect = msg->pSender->GetPos();
ui::CPoint point;
point.x = rect.left - 175;
point.y = rect.top + 10;
ClientToScreen(m_hWnd, &point);
nim_comp::CMenuWnd* pmenu = new(std::nothrow) nim_comp::CMenuWnd(NULL);
if (pmenu)
{
ui::STRINGorID xml(L"settings_menu.xml");
pmenu->Init(xml, _T("xml"), point);
}
return false;
}
运行结果
xml完整源码
<?xml version="1.0" encoding="UTF-8"?>
<Window size="900,600" caption="0,0,0,35">
<VBox bkcolor="bk_wnd_darkcolor">
<HBox width="stretch" height="35" bkcolor="bk_wnd_lightcolor">
<Control />
<!--设置按钮-->
<Button class="btn_wnd_settings" name="settings" margin="4,6,0,0"/>
<Button class="btn_wnd_min" name="minbtn" margin="4,6,0,0" />
<Box width="21" margin="4,6,0,0">
<Button class="btn_wnd_max" name="maxbtn"/>
<Button class="btn_wnd_restore" name="restorebtn" visible="false"/>
</Box>
<Button class="btn_wnd_close" name="closebtn" margin="4,6,8,0"/>
</HBox>
<!--下面是中间的控件-->
<VBox padding="30, 30, 30, 30" >
<HBox height="120">
<VBox>
<!-- Buttons -->
<Button class="btn_global_blue_80x30" name="btn_blue" text="blue" />
<Button class="btn_global_white_80x30" name="btn_white" text="white"/>
<Button class="btn_global_red_80x30" name="btn_red" text="red"/>
</VBox>
<!--checkbox-->
<VBox>
<CheckBox class="checkbox_font12" name="checkbox1" text="checkbox1" margin="0,5,0,10" selected="true"/>
<CheckBox class="checkbox_font12" name="checkbox2" text="checkbox2" margin="0,5,0,10"/>
<CheckBox class="checkbox_font12" name="checkbox3" text="checkbox3" margin="0,5,0,10"/>
</VBox>
<!-- option-->
<VBox>
<Option class="circle_option_2" name="option1" group="option_group" text="option1" margin="0,3,0,10" selected="true"/>
<Option class="circle_option_2" name="option2" group="option_group" text="option2" margin="0,3,0,10"/>
<Option class="circle_option_2" name="option3" group="option_group" text="option3" margin="0,3,0,10"/>
</VBox>
<HBox>
<!-- List -->
<VListBox class="list" name="list" padding="5,3,5,3">
</VListBox>
<VBox>
<!-- Buttons -->
<CheckBox class="checkbox_font12" name="list_checkbox_add_to_top" text="add to top" margin="0,5,0,10"/>
<Button class="btn_global_blue_80x30" name="list_btn_add" text="add" />
<CheckBox class="checkbox_font12" name="list_checkbox_remove_all" text="del all?" margin="0,5,0,10"/>
<Button class="btn_global_white_80x30" name="list_btn_remove" text="remove"/>
</VBox>
</HBox>
<!-- TreeView -->
<TreeView class="list" name="tree" padding="5,3,5,3" margin="20">
</TreeView>
</HBox>
<!--第二行控件开始-->
<HBox height="85">
<VBox>
<!--combobox-->
<Combo class="list" name="combo" height="30" margin="0,12,0,0" padding="6" bkimage="file='../public/combo/normal.png' corner='5,5,30,5'"/>
<HBox>
<RichEdit class="simple input" name="rich_edit_1" text="输入演示" height="30" margin="0,3" padding="6,6,6" promptmode="true" prompttext="Single line text control" promptcolor="lightcolor"/>
<CheckBox class="checkbox_font12" name="rich_edit_readonly" text="read only" margin="0,5,0,10"/>
</HBox>
</VBox>
<HBox>
<VBox>
<!-- Progress -->
<HBox margin="0,10" height="32">
<Progress class="progress_blue" name="progress" value="0" margin="10"/>
</HBox>
<!-- Slider -->
<HBox margin="0,0,0,10" height="32">
<Slider class="slider_green" name="slider" value="0" margin="10"/>
</HBox>
</VBox>
<VBox width="120">
<CircleProgress name="circle_progress" circular="true" height="80" width="80"
circlewidth="10" bgcolor="gray" fgcolor="green" value="0" clockwise="true" min="1" max="100" margin="10"
textpadding="10,32,10,10" normaltextcolor="darkcolor" indicator="logo_18x18.png"/>
</VBox>
</HBox>
</HBox>
</VBox> <!--下面是中间的控件 结束-->
</VBox>
</Window>
nim_duilib(11)之menu(1)的更多相关文章
- nim_duilib(12)之menu(2)
introduction 更多控件用法,请参考 here 和 源码. 本文将介绍menu的选项注册回调 before starting 本文的代码基于上一篇 stage1 回到项目demo_xml, ...
- 自动化安装smokeping-2.6.11脚本
自动化安装Smokeping-2.6.11脚本 一.目的 1.1 监控目的 为方便监测各数据中心网络状况,自定义全国各节点,从而发现网络异常,判断网络故障. 1.2 本文目的 快速部署Smokepin ...
- Python Tkinter Menu
本人想开发一个简易的搜图GUI,基于此,选择用Tkinter模块开发. 需要开发出菜单栏 1 from Tkinter import * 2 3 4 root = Tk() 5 root.title( ...
- Jquery学习笔记--性能优化建议
一.选择器性能优化建议 1. 总是从#id选择器来继承 这是jQuery选择器的一条黄金法则.jQuery选择一个元素最快的方法就是用ID来选择了. 1 $('#content').hide(); 或 ...
- 云盘WEB资料下载链接
入门三板斧:http://www.cnblogs.com/jikey/p/3613082.html 入门看这个:http://pan.baidu.com/s/1pJqJvAV 入门JS视频:http: ...
- 【转载】Linux系统启动流程
原文:Linux系统启动流程 POST(Power On Self Test/上电自检)-->BootLoader(MBR)-->Kernel(硬件探测.加载驱动.挂载根文件系统./sbi ...
- 课程设计(部分代码)之java版(记事本)
/* *java课程设计之记事本(coder @Gxjun) * 编写一个记事本程序 * 要求: * 用图形用户界面实现. * 能实现编辑.保存.另存为.查找替换等功能. * 提示:使用文件输入输出流 ...
- CentOS6.4安装Smokeping节点监控软件
Smokeping:它是rrdtool的作者制作的,在图形显示方面很漂亮,可以用来很好的检测网络状态和稳定性,下面简单说一下Smokeping的安装以及配置方法. 0.首先关闭selinux和防火墙 ...
- Android知识思维导图
注:图片来源于网络,谢谢分享. 一. 项目目录结构: 布局控件 ListVIew控件 Widget:(窗口小部件) Activity Manager 二. 应用程序的5个模块构成: Activit ...
随机推荐
- 【低门槛 手把手】python 装饰器(Decorators)原理说明
本文目的是由浅入深地介绍python装饰器原理 装饰器(Decorators)是 Python 的一个重要部分 其功能是,在不修改原函数(类)定义代码的情况下,增加新的功能 为了理解和实现装饰器,我们 ...
- 金蝶EAS——客户端打开时,提示正在更新的文件d:\eas\client\bin\lib\proxy.jar被其他应用程序占用.请关闭
解决办法: 一.通过调用任务管理器来退出,启用任务管理器需同时按下键Ctrl+Alt+Del,在应用程序中找到金蝶EAS,单击,选择结束任务即可:或者在任务管理器中选择"进程",点 ...
- Oracle-SQL语句的语法顺序和执行顺序
SQL语句的语法顺序和执行顺序了,我们常见的SQL语法顺序如下: SELECT DISTINCT <Top Num> <select list>FROM [left_table ...
- 以DevExpress开发的WinFrom程序的多语言功能的实现
以DevExpress开发的WinFrom程序的多语言功能的实现 写在前面: 多语言切换功能在Winform程序中是经常遇到的需求,尤其是需要给国外客户使用的情况下,多语言功能是必不可少的.前一段时间 ...
- 对Javascript中的对象Object改变内存及其变量改变的图解
Object 存储变量时,变量属性的内存改变图解 左边: 对象的内存 中间:变量属性的内存 右边:属性值的内存 [图一]创建一个对象,存obj1 变量--里面存age 属性和属性值--12. ...
- javaSE基础知识(走向编程的门口)— 更新完毕
前言:玩儿编程最重要的一点:不要怕麻烦,感觉是在浪费时间: 能动手绝不哔哔:只要脑袋不傻,编程都是"一看就会,一练就废",开始学的时候,就算再基础的东西都建议手敲一遍 要有囫囵吞枣 ...
- A Child's History of England.24
Besides all these troubles, William the Conqueror was troubled by quarrels among his sons. He had th ...
- Flink(四)【IDEA执行查看Web UI】
1.导入依赖 <!-- flink Web UI --> <dependency> <groupId>org.apache.flink</groupId> ...
- 【leetcode】208. Implement Trie (Prefix Tree 字典树)
A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently s ...
- keil 生成 bin 文件 gd32为例
fromelf --bin --output .\update\GD32F4xZ.bin .\Output\GD32450Z_EVAL.axf代表使用的keil内的工具代表输出公式,..表示: 输出 ...