!19 Refactor wnd, add HelloWidgets
This commit is contained in:
parent
ef7e8f8b70
commit
c38b8b0cf1
|
@ -4,15 +4,15 @@ PROJECT(GuiLite)
|
|||
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR})
|
||||
|
||||
INCLUDE_DIRECTORIES(core widgets)
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
|
||||
|
||||
# core
|
||||
FILE(GLOB CORE_SRC core/src/*.cpp)
|
||||
FILE(GLOB CORE_ADAPTER core/src/adapter/api_linux.cpp
|
||||
core/src/adapter/audio_linux.cpp
|
||||
core/src/adapter/msg_linux.cpp)
|
||||
FILE(GLOB CORE_SRC core/*.cpp)
|
||||
FILE(GLOB CORE_ADAPTER core/adapter/api_linux.cpp
|
||||
core/adapter/audio_linux.cpp
|
||||
core/adapter/msg_linux.cpp)
|
||||
# gui
|
||||
FILE(GLOB WIDGETS_SRC widgets/src/*.cpp)
|
||||
FILE(GLOB WIDGETS_SRC widgets/*.cpp)
|
||||
|
||||
# build static library
|
||||
ADD_LIBRARY(GuiLite STATIC ${CORE_SRC} ${CORE_ADAPTER} ${WIDGETS_SRC})
|
||||
|
|
|
@ -338,7 +338,7 @@
|
|||
<MiscControls></MiscControls>
|
||||
<Define></Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>.\core</IncludePath>
|
||||
<IncludePath>./</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
|
@ -385,52 +385,52 @@
|
|||
<File>
|
||||
<FileName>bitmap.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\bitmap.cpp</FilePath>
|
||||
<FilePath>.\core\bitmap.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>cmd_target.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\cmd_target.cpp</FilePath>
|
||||
<FilePath>.\core\cmd_target.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>display.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\display.cpp</FilePath>
|
||||
<FilePath>.\core\display.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>rect.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\rect.cpp</FilePath>
|
||||
<FilePath>.\core\rect.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>surface.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\surface.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>wnd.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\wnd.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>word.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\word.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>api_unknow.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\adapter\api_unknow.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>msg_unknow.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\adapter\msg_unknow.cpp</FilePath>
|
||||
<FilePath>.\core\surface.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>theme.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\src\theme.cpp</FilePath>
|
||||
<FilePath>.\core\theme.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>wnd.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\wnd.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>word.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\word.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>api_unknow.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\adapter\api_unknow.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>msg_unknow.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\core\adapter\msg_unknow.cpp</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
|
@ -440,22 +440,22 @@
|
|||
<File>
|
||||
<FileName>button.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\widgets\src\button.cpp</FilePath>
|
||||
<FilePath>.\widgets\button.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>label.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\widgets\src\label.cpp</FilePath>
|
||||
<FilePath>.\widgets\label.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>wave_buffer.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\widgets\src\wave_buffer.cpp</FilePath>
|
||||
<FilePath>.\widgets\wave_buffer.cpp</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>wave_ctrl.cpp</FileName>
|
||||
<FileType>8</FileType>
|
||||
<FilePath>.\widgets\src\wave_ctrl.cpp</FilePath>
|
||||
<FilePath>.\widgets\wave_ctrl.cpp</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>core;widgets;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AssemblerListingLocation>Debug/</AssemblerListingLocation>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
|
@ -151,7 +151,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>core;widgets;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AssemblerListingLocation>Debug/</AssemblerListingLocation>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
|
@ -187,7 +187,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>core;widgets;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AssemblerListingLocation>Release/</AssemblerListingLocation>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
|
@ -223,7 +223,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>core;widgets;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AssemblerListingLocation>Release/</AssemblerListingLocation>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
|
@ -388,29 +388,29 @@
|
|||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="core\src\adapter\api_win.cpp" />
|
||||
<ClCompile Include="core\src\adapter\audio_win.cpp" />
|
||||
<ClCompile Include="core\src\adapter\msg_win.cpp" />
|
||||
<ClCompile Include="core\src\bitmap.cpp" />
|
||||
<ClCompile Include="core\src\cmd_target.cpp" />
|
||||
<ClCompile Include="core\src\display.cpp" />
|
||||
<ClCompile Include="core\src\rect.cpp" />
|
||||
<ClCompile Include="core\src\surface.cpp" />
|
||||
<ClCompile Include="core\src\theme.cpp" />
|
||||
<ClCompile Include="core\src\wnd.cpp" />
|
||||
<ClCompile Include="core\src\word.cpp" />
|
||||
<ClCompile Include="widgets\src\button.cpp" />
|
||||
<ClCompile Include="widgets\src\dialog.cpp" />
|
||||
<ClCompile Include="widgets\src\edit.cpp" />
|
||||
<ClCompile Include="widgets\src\gesture.cpp" />
|
||||
<ClCompile Include="widgets\src\keyboard.cpp" />
|
||||
<ClCompile Include="widgets\src\label.cpp" />
|
||||
<ClCompile Include="widgets\src\list_box.cpp" />
|
||||
<ClCompile Include="widgets\src\slide_group.cpp" />
|
||||
<ClCompile Include="widgets\src\spinbox.cpp" />
|
||||
<ClCompile Include="widgets\src\table.cpp" />
|
||||
<ClCompile Include="widgets\src\wave_buffer.cpp" />
|
||||
<ClCompile Include="widgets\src\wave_ctrl.cpp" />
|
||||
<ClCompile Include="core\adapter\api_win.cpp" />
|
||||
<ClCompile Include="core\adapter\audio_win.cpp" />
|
||||
<ClCompile Include="core\adapter\msg_win.cpp" />
|
||||
<ClCompile Include="core\bitmap.cpp" />
|
||||
<ClCompile Include="core\cmd_target.cpp" />
|
||||
<ClCompile Include="core\display.cpp" />
|
||||
<ClCompile Include="core\rect.cpp" />
|
||||
<ClCompile Include="core\surface.cpp" />
|
||||
<ClCompile Include="core\theme.cpp" />
|
||||
<ClCompile Include="core\wnd.cpp" />
|
||||
<ClCompile Include="core\word.cpp" />
|
||||
<ClCompile Include="widgets\button.cpp" />
|
||||
<ClCompile Include="widgets\dialog.cpp" />
|
||||
<ClCompile Include="widgets\edit.cpp" />
|
||||
<ClCompile Include="widgets\gesture.cpp" />
|
||||
<ClCompile Include="widgets\keyboard.cpp" />
|
||||
<ClCompile Include="widgets\label.cpp" />
|
||||
<ClCompile Include="widgets\list_box.cpp" />
|
||||
<ClCompile Include="widgets\slide_group.cpp" />
|
||||
<ClCompile Include="widgets\spinbox.cpp" />
|
||||
<ClCompile Include="widgets\table.cpp" />
|
||||
<ClCompile Include="widgets\wave_buffer.cpp" />
|
||||
<ClCompile Include="widgets\wave_ctrl.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
|
|
@ -1,75 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="core\src\adapter\api_win.cpp">
|
||||
<ClCompile Include="widgets\button.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\dialog.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\edit.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\gesture.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\keyboard.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\label.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\list_box.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\slide_group.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\spinbox.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\table.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\wave_buffer.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\wave_ctrl.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\bitmap.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\cmd_target.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\display.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\rect.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\surface.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\theme.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\wnd.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\word.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\adapter\api_win.cpp">
|
||||
<Filter>core\adapter</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\adapter\audio_win.cpp">
|
||||
<ClCompile Include="core\adapter\audio_win.cpp">
|
||||
<Filter>core\adapter</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\adapter\msg_win.cpp">
|
||||
<ClCompile Include="core\adapter\msg_win.cpp">
|
||||
<Filter>core\adapter</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\button.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\dialog.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\edit.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\gesture.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\keyboard.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\label.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\list_box.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\slide_group.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\spinbox.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\table.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\wave_buffer.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="widgets\src\wave_ctrl.cpp">
|
||||
<Filter>widgets</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\bitmap.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\cmd_target.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\display.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\rect.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\surface.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\theme.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\wnd.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="core\src\word.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="core">
|
||||
|
|
11
README.md
11
README.md
|
@ -16,10 +16,11 @@
|
|||
- ⚙️希望GuiLite小到足够帮助大家掌握UI工作原理,从而摆脱UI框架的束缚,构建自己独一无二的UI
|
||||
- 👑任何UI框架都不为你我而生,你才是自己真正的主人
|
||||
|
||||
## 🔥新功能:星空效果
|
||||
![HelloStar](doc/HelloStar.gif)
|
||||
- Hello Star 仅有[100+行代码](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloStar/UIcode/UIcode.cpp),用于向开发者展示:如何使用GuiLite开发“星空”效果。
|
||||
- 支持:MCU / Windows / Linux
|
||||
## 🔥新功能:控件的应用
|
||||
![HelloWidgets](doc/HelloWidgets.gif)
|
||||
|
||||
Hello Widgets 仅有[100多行代码](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloWidgets/UIcode/UIcode.cpp),用于向初学者展示:如何使用GuiLite自带的控件。
|
||||
- 支持:Windows / Linux
|
||||
|
||||
## 功能介绍
|
||||
### 卓越的跨平台能力
|
||||
|
@ -63,7 +64,7 @@ GuiLite只是一个框架,本身并不能生成UI。为了能够展示如何
|
|||
| HelloStar | Windows, Linux, STM32F103, STM32F429 | 星空效果的应用 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloStar/README.md) | ★|
|
||||
| HelloGuiLite | Windows, Linux | 初始化GuiLite,加载资源,布局界面元素,按钮响应 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloGuiLite/README.md) | ★★|
|
||||
| HelloMario | Windows, Linux, STM32F103, STM32F429 | 多图层的UI系统 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloMario/README.md) | ★★|
|
||||
| HelloNavigation | Windows, Linux, STM32F103, STM32F429 | 用于非触摸屏场景,通过硬按键进行UI“导航” | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloNavigation/README.md) | ★★|
|
||||
| HelloNoTouch | Windows, Linux, STM32F103, STM32F429 | 用于非触摸屏场景,通过硬按键进行UI“导航” | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloNoTouch/README.md) | ★★|
|
||||
| HelloFont | Windows, Linux | 显示多种语言(不限:中、英文) | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloFont/README.md) | ★★|
|
||||
| HelloAnimation | Windows, Linux | 动画的应用 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloAnimation/README.md) | ★★|
|
||||
| HelloSlide | Windows, Linux | 滑屏界面的应用 | [编译/运行](https://gitee.com/idea4good/GuiLiteSamples/blob/master/HelloSlide/README.md) | ★★★|
|
||||
|
|
|
@ -22,6 +22,7 @@ int c_wnd::connect(c_wnd *parent, unsigned short resource_id, const char* str,
|
|||
}
|
||||
|
||||
m_resource_id = resource_id;
|
||||
set_str(str);
|
||||
m_parent = parent;
|
||||
m_status = STATUS_NORMAL;
|
||||
|
||||
|
@ -47,7 +48,6 @@ int c_wnd::connect(c_wnd *parent, unsigned short resource_id, const char* str,
|
|||
ASSERT(m_surface->is_valid(rect));
|
||||
|
||||
pre_create_wnd();
|
||||
set_str(str);
|
||||
|
||||
if ( 0 != parent )
|
||||
{
|
||||
|
@ -100,6 +100,7 @@ c_wnd* c_wnd::connect_clone(c_wnd *parent, unsigned short resource_id, const cha
|
|||
|
||||
c_wnd* wnd = clone();
|
||||
wnd->m_resource_id = resource_id;
|
||||
wnd->set_str(str);
|
||||
wnd->m_parent = parent;
|
||||
wnd->m_status = STATUS_NORMAL;
|
||||
|
||||
|
@ -129,7 +130,6 @@ c_wnd* c_wnd::connect_clone(c_wnd *parent, unsigned short resource_id, const cha
|
|||
ASSERT(wnd->m_surface->is_valid(rect));
|
||||
|
||||
wnd->pre_create_wnd();
|
||||
wnd->set_str(str);
|
||||
|
||||
if ( 0 != parent )
|
||||
{
|
||||
|
@ -208,10 +208,9 @@ c_wnd* c_wnd::get_wnd_ptr(unsigned short id) const
|
|||
return child;
|
||||
}
|
||||
|
||||
void c_wnd::modify_style(unsigned int add_style, unsigned int remove_style)
|
||||
void c_wnd::set_style(unsigned int style)
|
||||
{
|
||||
m_style &= ~remove_style;
|
||||
m_style |= add_style;
|
||||
m_style = style;
|
||||
|
||||
if ( GL_ATTR_DISABLED == (m_style & GL_ATTR_DISABLED) )
|
||||
{
|
||||
|
@ -342,37 +341,6 @@ c_wnd* c_wnd::set_child_focus(c_wnd * focus_child)
|
|||
return m_focus_child;
|
||||
}
|
||||
|
||||
int c_wnd::on_notify(unsigned short notify_code, unsigned short ctrl_id, long l_param)
|
||||
{
|
||||
const GL_MSG_ENTRY *entry = FindMsgEntry(GetMSgEntries(), MSG_TYPE_WND, notify_code, ctrl_id);
|
||||
if ( NULL != entry )
|
||||
{
|
||||
MSGFUNCS msg_funcs;
|
||||
msg_funcs.func = entry->func;
|
||||
|
||||
switch ( entry->callbackType)
|
||||
{
|
||||
case MSG_CALLBACK_VV:
|
||||
(this->*msg_funcs.func)();
|
||||
break;
|
||||
case MSG_CALLBACK_VVL:
|
||||
(this->*msg_funcs.func_vvl)(l_param);
|
||||
break;
|
||||
case MSG_CALLBACK_VWV:
|
||||
(this->*msg_funcs.func_vwv)(ctrl_id);
|
||||
break;
|
||||
case MSG_CALLBACK_VWL:
|
||||
(this->*msg_funcs.func_vwl)(ctrl_id, l_param);
|
||||
break;
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void c_wnd::add_child_2_tail(c_wnd *child)
|
||||
{
|
||||
if( NULL == child )return;
|
||||
|
@ -499,24 +467,36 @@ bool c_wnd::on_touch(int x, int y, TOUCH_ACTION action)
|
|||
c_rect rect;
|
||||
x -= m_wnd_rect.m_left;
|
||||
y -= m_wnd_rect.m_top;
|
||||
c_wnd *pChild = m_top_child;
|
||||
c_wnd* child = m_top_child;
|
||||
|
||||
while ( pChild )
|
||||
c_wnd* target_wnd = NULL;
|
||||
int target_z_order = Z_ORDER_LEVEL_0;
|
||||
|
||||
while (child)
|
||||
{
|
||||
if (GL_ATTR_VISIBLE == (pChild->m_style & GL_ATTR_VISIBLE))
|
||||
if (GL_ATTR_VISIBLE == (child->m_style & GL_ATTR_VISIBLE))
|
||||
{
|
||||
pChild->get_wnd_rect(rect);
|
||||
if ( TRUE == rect.PtInRect(x, y) )
|
||||
child->get_wnd_rect(rect);
|
||||
if (TRUE == rect.PtInRect(x, y) || child->m_style & GL_ATTR_PRIORITY)
|
||||
{
|
||||
if ( TRUE == pChild->is_focus_wnd() )
|
||||
if (TRUE == child->is_focus_wnd())
|
||||
{
|
||||
pChild->on_touch(x, y, action);
|
||||
if (child->m_z_order >= target_z_order)
|
||||
{
|
||||
target_wnd = child;
|
||||
target_z_order = child->m_z_order;
|
||||
}
|
||||
}
|
||||
}
|
||||
pChild = pChild->m_next_sibling;
|
||||
}
|
||||
return true;
|
||||
child = child->m_next_sibling;
|
||||
}
|
||||
|
||||
if (target_wnd == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return target_wnd->on_touch(x, y, action);
|
||||
}
|
||||
|
||||
bool c_wnd::on_key(KEY_TYPE key)
|
||||
|
@ -541,21 +521,21 @@ bool c_wnd::on_key(KEY_TYPE key)
|
|||
}
|
||||
if (!old_focus_wnd)
|
||||
{// No current focus wnd, new one.
|
||||
c_wnd *pChild = m_top_child;
|
||||
c_wnd *child = m_top_child;
|
||||
c_wnd *new_focus_wnd = NULL;
|
||||
while (pChild)
|
||||
while (child)
|
||||
{
|
||||
if (GL_ATTR_VISIBLE == (pChild->m_style & GL_ATTR_VISIBLE))
|
||||
if (GL_ATTR_VISIBLE == (child->m_style & GL_ATTR_VISIBLE))
|
||||
{
|
||||
if (TRUE == pChild->is_focus_wnd())
|
||||
if (TRUE == child->is_focus_wnd())
|
||||
{
|
||||
new_focus_wnd = pChild;
|
||||
new_focus_wnd = child;
|
||||
new_focus_wnd->m_parent->set_child_focus(new_focus_wnd);
|
||||
pChild = pChild->m_top_child;
|
||||
child = child->m_top_child;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
pChild = pChild->m_next_sibling;
|
||||
child = child->m_next_sibling;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -581,10 +561,37 @@ bool c_wnd::on_key(KEY_TYPE key)
|
|||
return true;
|
||||
}
|
||||
|
||||
void c_wnd::notify_parent(unsigned short msg_id, unsigned int w_param, long l_param)
|
||||
void c_wnd::notify_parent(unsigned int msg_id, unsigned int ctrl_id, int param)
|
||||
{
|
||||
if (m_parent)
|
||||
if (!m_parent)
|
||||
{
|
||||
m_parent->on_notify(msg_id, w_param, l_param);
|
||||
return;
|
||||
}
|
||||
const GL_MSG_ENTRY* entry = m_parent->FindMsgEntry(m_parent->GetMSgEntries(), MSG_TYPE_WND, msg_id, ctrl_id);
|
||||
if (NULL == entry)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MSGFUNCS msg_funcs;
|
||||
msg_funcs.func = entry->func;
|
||||
|
||||
switch (entry->callbackType)
|
||||
{
|
||||
case MSG_CALLBACK_VV:
|
||||
(m_parent->*msg_funcs.func)();
|
||||
break;
|
||||
case MSG_CALLBACK_VVL:
|
||||
(m_parent->*msg_funcs.func_vvl)(param);
|
||||
break;
|
||||
case MSG_CALLBACK_VWV:
|
||||
(m_parent->*msg_funcs.func_vwv)(ctrl_id);
|
||||
break;
|
||||
case MSG_CALLBACK_VWL:
|
||||
(m_parent->*msg_funcs.func_vwl)(ctrl_id, param);
|
||||
break;
|
||||
default:
|
||||
ASSERT(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -12,11 +12,6 @@ private:
|
|||
static void draw_bitmap_565(c_surface* surface, int z_order, int x, int y, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_color);
|
||||
static void get_bitmap_pos(const BITMAP_INFO *pBitmap, c_rect rect, unsigned int align_type, int &x, int &y);
|
||||
static void draw_bitmap_565_in_rect(c_surface* surface, int z_order, int x, int y, int width, int height, int xsize, int ysize, const unsigned char* pPixel, unsigned int mask_color);
|
||||
|
||||
c_bitmap(){}
|
||||
c_bitmap(const c_bitmap&);
|
||||
c_bitmap& operator=(const c_bitmap&);
|
||||
~c_bitmap(){}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -21,11 +21,6 @@ enum FONT_TYPE
|
|||
|
||||
enum BITMAP_TYPE
|
||||
{
|
||||
BITMAP_UP_ARROW1,
|
||||
BITMAP_UP_ARROW2,
|
||||
BITMAP_DOWN_ARROW1,
|
||||
BITMAP_DOWN_ARROW2,
|
||||
|
||||
BITMAP_CUSTOM1,
|
||||
BITMAP_CUSTOM2,
|
||||
BITMAP_CUSTOM3,
|
|
@ -5,6 +5,7 @@
|
|||
#define GL_ATTR_VISIBLE 0x80000000L
|
||||
#define GL_ATTR_DISABLED 0x40000000L
|
||||
#define GL_ATTR_FOCUS 0x20000000L
|
||||
#define GL_ATTR_PRIORITY 0x10000000L// Handle touch action at high priority
|
||||
|
||||
typedef struct struct_font_info FONT_INFO;
|
||||
typedef struct struct_color_rect COLOR_RECT;
|
||||
|
@ -66,7 +67,7 @@ public:
|
|||
int get_z_order() { return m_z_order; }
|
||||
c_wnd* get_wnd_ptr(unsigned short id) const;
|
||||
unsigned int get_style() const { return m_style; }
|
||||
virtual void modify_style(unsigned int add_style = 0, unsigned int remove_style = 0);
|
||||
void set_style(unsigned int style);
|
||||
|
||||
void set_str(const char* str) { m_str = str; }
|
||||
int is_focus_wnd() const;
|
||||
|
@ -90,11 +91,10 @@ public:
|
|||
c_wnd* get_prev_sibling() const { return m_prev_sibling; }
|
||||
c_wnd* get_next_sibling() const { return m_next_sibling; }
|
||||
|
||||
void notify_parent(unsigned short msg_id, unsigned int w_param, long l_param);
|
||||
virtual int on_notify(unsigned short notify_code, unsigned short ctrl_id, long l_param);
|
||||
void notify_parent(unsigned int msg_id, unsigned int ctrl_id, int param);
|
||||
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
|
||||
virtual bool on_key(KEY_TYPE key);
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);// return true: handled; false: not be handled.
|
||||
virtual bool on_key(KEY_TYPE key);// return false: skip handling by parent;
|
||||
|
||||
c_surface* get_surface() { return m_surface; }
|
||||
void set_surface(c_surface* surface) { m_surface = surface; }
|
|
@ -18,11 +18,6 @@ private:
|
|||
|
||||
static const LATTICE* get_lattice(const FONT_INFO* font, unsigned int utf8_code);
|
||||
static void get_string_pos(const char *s, const FONT_INFO* font, c_rect rect, unsigned int align_type, int &x, int &y);
|
||||
private:
|
||||
c_word(){};
|
||||
c_word(const c_word&);
|
||||
c_word& operator=(const c_word&);
|
||||
~c_word(){}
|
||||
};
|
||||
|
||||
#endif
|
Binary file not shown.
Before Width: | Height: | Size: 153 KiB |
Binary file not shown.
Before Width: | Height: | Size: 75 KiB |
Binary file not shown.
Before Width: | Height: | Size: 508 KiB |
Binary file not shown.
After Width: | Height: | Size: 243 KiB |
BIN
doc/MCU.gif
BIN
doc/MCU.gif
Binary file not shown.
Before Width: | Height: | Size: 671 KiB |
|
@ -42,7 +42,7 @@ bool c_button::on_touch(int x, int y, TOUCH_ACTION action)
|
|||
on_paint();
|
||||
notify_parent(GL_BN_CLICKED, get_id(), 0);
|
||||
}
|
||||
return false;// Do not handle TOUCH_ACTION by other wnd.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool c_button::on_key(KEY_TYPE key)
|
|
@ -2,22 +2,17 @@
|
|||
#include "core_include/rect.h"
|
||||
#include "core_include/cmd_target.h"
|
||||
#include "core_include/wnd.h"
|
||||
#include "core_include/msg.h"
|
||||
#include "core_include/surface.h"
|
||||
#include "core_include/display.h"
|
||||
#include "core_include/resource.h"
|
||||
#include "core_include/bitmap.h"
|
||||
#include "core_include/word.h"
|
||||
#include "core_include/theme.h"
|
||||
#include "../widgets_include/button.h"
|
||||
#include "../widgets_include/dialog.h"
|
||||
|
||||
#include <string.h>
|
||||
#include "widgets_include/dialog.h"
|
||||
|
||||
DIALOG_ARRAY c_dialog::ms_the_dialogs[SURFACE_CNT_MAX];
|
||||
void c_dialog::pre_create_wnd()
|
||||
{
|
||||
m_style = GL_ATTR_FOCUS;
|
||||
m_style = 0;// no focus/visible
|
||||
m_z_order = Z_ORDER_LEVEL_1;
|
||||
m_bg_color = GL_RGB(33, 42, 53);
|
||||
}
|
||||
|
@ -61,14 +56,14 @@ int c_dialog::open_dialog(c_dialog* p_dlg)
|
|||
|
||||
if(cur_dlg)
|
||||
{
|
||||
cur_dlg->modify_style(0, GL_ATTR_VISIBLE);
|
||||
cur_dlg->set_style(0);
|
||||
}
|
||||
|
||||
c_rect rc;
|
||||
p_dlg->get_screen_rect(rc);
|
||||
p_dlg->get_surface()->set_frame_layer(rc, Z_ORDER_LEVEL_1);
|
||||
|
||||
p_dlg->modify_style(GL_ATTR_VISIBLE, 0);
|
||||
p_dlg->set_style(GL_ATTR_VISIBLE | GL_ATTR_FOCUS | GL_ATTR_PRIORITY);
|
||||
p_dlg->show_window();
|
||||
p_dlg->set_me_the_dialog();
|
||||
return 1;
|
||||
|
@ -84,7 +79,7 @@ int c_dialog::close_dialog(c_surface* surface)
|
|||
}
|
||||
c_rect rc;
|
||||
|
||||
dlg->modify_style(0, GL_ATTR_VISIBLE);
|
||||
dlg->set_style(0);
|
||||
surface->set_frame_layer(rc, dlg->m_z_order);
|
||||
|
||||
//clear the dialog
|
||||
|
@ -100,29 +95,6 @@ int c_dialog::close_dialog(c_surface* surface)
|
|||
return -1;
|
||||
}
|
||||
|
||||
bool c_dialog::on_touch(int x, int y, TOUCH_ACTION action)
|
||||
{
|
||||
c_wnd *child = m_top_child;
|
||||
c_rect rect;
|
||||
get_wnd_rect(rect);
|
||||
|
||||
if ( NULL != child )
|
||||
{
|
||||
while ( child )
|
||||
{
|
||||
if (child->m_z_order > m_z_order)
|
||||
{
|
||||
x -= rect.m_left;
|
||||
y -= rect.m_top;
|
||||
child->on_touch(x, y, action);
|
||||
return true;
|
||||
}
|
||||
child = child->m_next_sibling;
|
||||
}
|
||||
}
|
||||
return c_wnd::on_touch(x, y, action);
|
||||
}
|
||||
|
||||
int c_dialog::set_me_the_dialog()
|
||||
{
|
||||
c_surface* surface = get_surface();
|
|
@ -30,6 +30,7 @@ void c_edit::pre_create_wnd()
|
|||
|
||||
memset(m_str_input, 0, sizeof(m_str_input));
|
||||
memset(m_str, 0, sizeof(m_str));
|
||||
set_text(c_wnd::m_str);
|
||||
}
|
||||
|
||||
void c_edit::set_text(const char* str)
|
||||
|
@ -123,6 +124,7 @@ void c_edit::on_paint()
|
|||
s_keyboard.disconnect();
|
||||
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
|
||||
m_z_order = m_parent->get_z_order();
|
||||
m_style &= ~GL_ATTR_PRIORITY;
|
||||
}
|
||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
||||
break;
|
||||
|
@ -132,6 +134,7 @@ void c_edit::on_paint()
|
|||
s_keyboard.disconnect();
|
||||
m_surface->set_frame_layer(empty_rect, s_keyboard.get_z_order());
|
||||
m_z_order = m_parent->get_z_order();
|
||||
m_style &= ~GL_ATTR_PRIORITY;
|
||||
}
|
||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
||||
break;
|
||||
|
@ -139,6 +142,7 @@ void c_edit::on_paint()
|
|||
if (m_z_order == m_parent->get_z_order())
|
||||
{
|
||||
m_z_order++;
|
||||
m_style |= GL_ATTR_PRIORITY;
|
||||
show_keyboard();
|
||||
}
|
||||
m_surface->fill_rect(rect.m_left, rect.m_top, rect.m_right, rect.m_bottom, c_theme::get_color(COLOR_WND_PUSHED), m_parent->get_z_order());
|
|
@ -40,7 +40,6 @@ void c_list_box::on_paint()
|
|||
{
|
||||
c_rect rect, empty_rect;
|
||||
get_screen_rect(rect);
|
||||
empty_rect.Empty();
|
||||
|
||||
switch(m_status)
|
||||
{
|
||||
|
@ -49,6 +48,7 @@ void c_list_box::on_paint()
|
|||
{
|
||||
m_surface->set_frame_layer(empty_rect, m_z_order);
|
||||
m_z_order = m_parent->get_z_order();
|
||||
m_style &= ~GL_ATTR_PRIORITY;
|
||||
}
|
||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
||||
break;
|
||||
|
@ -57,6 +57,7 @@ void c_list_box::on_paint()
|
|||
{
|
||||
m_surface->set_frame_layer(empty_rect, m_z_order);
|
||||
m_z_order = m_parent->get_z_order();
|
||||
m_style &= ~GL_ATTR_PRIORITY;
|
||||
}
|
||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
||||
break;
|
||||
|
@ -72,6 +73,7 @@ void c_list_box::on_paint()
|
|||
m_z_order++;
|
||||
}
|
||||
m_surface->set_frame_layer(m_list_screen_rect, m_z_order);
|
||||
m_style |= GL_ATTR_PRIORITY;
|
||||
show_list();
|
||||
return;
|
||||
}
|
||||
|
@ -113,7 +115,7 @@ void c_list_box::on_touch_down(int x, int y)
|
|||
{
|
||||
m_status = STATUS_FOCUSED;
|
||||
on_paint();
|
||||
notify_parent(GL_LIST_CONFIRM, get_id(), 0);
|
||||
notify_parent(GL_LIST_CONFIRM, get_id(), m_selected_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +126,6 @@ void c_list_box::on_touch_up(int x, int y)
|
|||
{
|
||||
m_status = STATUS_PUSHED;
|
||||
on_paint();
|
||||
notify_parent(GL_LIST_SELECT, get_id(), 0);
|
||||
}
|
||||
else if (STATUS_PUSHED == m_status)
|
||||
{
|
||||
|
@ -138,7 +139,7 @@ void c_list_box::on_touch_up(int x, int y)
|
|||
m_status = STATUS_FOCUSED;
|
||||
select_item((y - m_list_wnd_rect.m_top) / ITEM_HEIGHT);
|
||||
on_paint();
|
||||
notify_parent(GL_LIST_CONFIRM, get_id(), 0);
|
||||
notify_parent(GL_LIST_CONFIRM, get_id(), m_selected_item);
|
||||
}
|
||||
else
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
#include "core_include/api.h"
|
||||
#include "core_include/api.h"
|
||||
#include "core_include/rect.h"
|
||||
#include "core_include/cmd_target.h"
|
||||
#include "core_include/wnd.h"
|
||||
|
@ -47,65 +47,39 @@ void c_spin_box::pre_create_wnd()
|
|||
bool c_spin_box::on_touch(int x, int y, TOUCH_ACTION action)
|
||||
{
|
||||
(action == TOUCH_DOWN) ? on_touch_down(x, y) : on_touch_up(x, y);
|
||||
return true;
|
||||
return c_wnd::on_touch(x, y, action);
|
||||
}
|
||||
|
||||
void c_spin_box::on_touch_down(int x, int y)
|
||||
{
|
||||
c_rect arrow_rect = m_wnd_rect;
|
||||
arrow_rect.m_right = m_bt_down_rect.m_right;
|
||||
arrow_rect.m_bottom = m_bt_down_rect.m_bottom;
|
||||
|
||||
if ( TRUE == m_wnd_rect.PtInRect(x, y) )
|
||||
{//click spin box
|
||||
if (FALSE == m_wnd_rect.PtInRect(x, y))
|
||||
{//maybe click on up/down arrow button
|
||||
return;
|
||||
}
|
||||
if (STATUS_NORMAL == m_status)
|
||||
{
|
||||
m_parent->set_child_focus(this);
|
||||
}
|
||||
}
|
||||
else if (TRUE == arrow_rect.PtInRect(x, y))
|
||||
{//click arrow button
|
||||
c_wnd::on_touch(x, y, TOUCH_DOWN);
|
||||
}
|
||||
else
|
||||
{//click invalid place.
|
||||
if (STATUS_PUSHED == m_status)
|
||||
{
|
||||
if (m_value != m_cur_value)
|
||||
{
|
||||
m_value = m_cur_value;
|
||||
}
|
||||
m_status = STATUS_FOCUSED;
|
||||
on_paint();
|
||||
notify_parent(GL_SPIN_CONFIRM, get_id(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void c_spin_box::on_touch_up(int x, int y)
|
||||
{
|
||||
if (FALSE == m_wnd_rect.PtInRect(x, y))
|
||||
{//maybe click on up/down arrow button
|
||||
return;
|
||||
}
|
||||
|
||||
if (STATUS_FOCUSED == m_status)
|
||||
{
|
||||
m_status = STATUS_PUSHED;
|
||||
on_paint();
|
||||
notify_parent(GL_SPIN_SELECT, get_id(), 0);
|
||||
}
|
||||
else if (STATUS_PUSHED == m_status)
|
||||
{
|
||||
if (m_wnd_rect.PtInRect(x, y))
|
||||
{//click spin box.
|
||||
if (m_value != m_cur_value)
|
||||
{
|
||||
m_value = m_cur_value;
|
||||
}
|
||||
m_status = STATUS_FOCUSED;
|
||||
on_paint();
|
||||
notify_parent(GL_SPIN_CONFIRM, get_id(), 0);
|
||||
}
|
||||
else
|
||||
{//click arrow button.
|
||||
c_wnd::on_touch(x, y, TOUCH_UP);
|
||||
}
|
||||
notify_parent(GL_SPIN_CONFIRM, get_id(), m_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,30 +98,24 @@ void c_spin_box::on_kill_focus()
|
|||
|
||||
void c_spin_box::show_arrow_button()
|
||||
{
|
||||
m_surface->fill_rect(m_bt_up_rect.m_left, m_bt_up_rect.m_top, m_bt_down_rect.m_right, m_bt_down_rect.m_bottom, GL_RGB(99,108,124), m_z_order);
|
||||
|
||||
m_bt_up.connect(this, ID_BT_ARROW_UP, 0, 0, m_wnd_rect.Height(), m_bt_up_rect.Width(),m_bt_up_rect.Height());
|
||||
m_bt_up.set_bitmap(c_theme::get_bmp(BITMAP_UP_ARROW1));
|
||||
m_bt_up.set_focus_bitmap(c_theme::get_bmp(BITMAP_UP_ARROW2));
|
||||
m_bt_up.set_pushed_bitmap(c_theme::get_bmp(BITMAP_UP_ARROW2));
|
||||
m_bt_up.connect(this, ID_BT_ARROW_UP, "\xe2\x96\xb2"/*▲*/, 0, m_wnd_rect.Height(), m_bt_up_rect.Width(),m_bt_up_rect.Height());
|
||||
m_bt_up.show_window();
|
||||
|
||||
m_bt_down.connect(this, ID_BT_ARROW_DOWN, 0, m_bt_up_rect.Width(), m_wnd_rect.Height(), m_bt_down_rect.Width(),m_bt_down_rect.Height());
|
||||
m_bt_down.set_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW1));
|
||||
m_bt_down.set_focus_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW2));
|
||||
m_bt_down.set_pushed_bitmap(c_theme::get_bmp(BITMAP_DOWN_ARROW2));
|
||||
m_bt_down.connect(this, ID_BT_ARROW_DOWN, "\xe2\x96\xbc"/*▼*/, m_bt_up_rect.Width(), m_wnd_rect.Height(), m_bt_down_rect.Width(),m_bt_down_rect.Height());
|
||||
m_bt_down.show_window();
|
||||
|
||||
m_style |= GL_ATTR_PRIORITY;
|
||||
}
|
||||
|
||||
void c_spin_box::hide_arrow_button()
|
||||
{
|
||||
m_bt_up.disconnect();
|
||||
m_bt_down.disconnect();
|
||||
m_style &= ~GL_ATTR_PRIORITY;
|
||||
}
|
||||
|
||||
void c_spin_box::on_paint()
|
||||
{
|
||||
c_rect rect,tmp_rect;
|
||||
c_rect rect, tmp_rect, empty_rect;
|
||||
get_screen_rect(rect);
|
||||
tmp_rect.m_left = rect.m_left;
|
||||
tmp_rect.m_right = rect.m_right;
|
||||
|
@ -158,8 +126,7 @@ void c_spin_box::on_paint()
|
|||
if (m_z_order > m_parent->get_z_order())
|
||||
{
|
||||
hide_arrow_button();
|
||||
tmp_rect.Empty();
|
||||
m_surface->set_frame_layer(tmp_rect, m_z_order);
|
||||
m_surface->set_frame_layer(empty_rect, m_z_order);
|
||||
m_z_order = m_parent->get_z_order();
|
||||
}
|
||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_NORMAL), m_z_order);
|
||||
|
@ -168,8 +135,7 @@ void c_spin_box::on_paint()
|
|||
if (m_z_order > m_parent->get_z_order())
|
||||
{
|
||||
hide_arrow_button();
|
||||
tmp_rect.Empty();
|
||||
m_surface->set_frame_layer(tmp_rect, m_z_order);
|
||||
m_surface->set_frame_layer(empty_rect, m_z_order);
|
||||
m_z_order = m_parent->get_z_order();
|
||||
}
|
||||
m_surface->fill_rect(rect, c_theme::get_color(COLOR_WND_FOCUS), m_z_order);
|
||||
|
@ -199,26 +165,22 @@ void c_spin_box::on_paint()
|
|||
|
||||
void c_spin_box::on_arrow_up_bt_click(unsigned int ctr_id)
|
||||
{
|
||||
if (m_cur_value + m_step > m_max)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_cur_value += m_step;
|
||||
if (m_cur_value > m_max)
|
||||
{
|
||||
m_cur_value = m_max;
|
||||
}
|
||||
else
|
||||
{
|
||||
notify_parent(GL_SPIN_CHANGE, get_id(), m_cur_value);
|
||||
on_paint();
|
||||
}
|
||||
}
|
||||
|
||||
void c_spin_box::on_arrow_down_bt_click(unsigned int ctr_id)
|
||||
{
|
||||
m_cur_value -= m_step;
|
||||
if (m_cur_value < m_min)
|
||||
if (m_cur_value - m_step < m_min)
|
||||
{
|
||||
m_cur_value = m_min;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cur_value -= m_step;
|
||||
notify_parent(GL_SPIN_CHANGE, get_id(), m_cur_value);
|
||||
on_paint();
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@ public:
|
|||
static int open_dialog(c_dialog* p_dlg);
|
||||
static int close_dialog(c_surface* surface);
|
||||
static c_dialog* get_the_dialog(c_surface* surface);
|
||||
virtual bool on_touch(int x, int y, TOUCH_ACTION action);
|
||||
protected:
|
||||
virtual const char* get_class_name(void) const {return "c_dialog";}
|
||||
virtual void pre_create_wnd();
|
|
@ -1,20 +1,11 @@
|
|||
#ifndef LIST_BOX_H
|
||||
#define LIST_BOX_H
|
||||
|
||||
#define MAX_ITEM_NUM 12
|
||||
|
||||
#define GL_LIST_SELECT 0x1
|
||||
#define GL_LIST_CONFIRM 0x2
|
||||
#define GL_LIST_ROTATION 0x3
|
||||
|
||||
#define ON_LIST_SELECT(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_LIST_SELECT, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWV, reinterpret_cast<MsgFuncVV>(&func)},
|
||||
#define MAX_ITEM_NUM 4
|
||||
#define GL_LIST_CONFIRM 0x1
|
||||
|
||||
#define ON_LIST_CONFIRM(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_LIST_CONFIRM, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWV, reinterpret_cast<MsgFuncVV>(&func)},
|
||||
|
||||
#define ON_LIST_ROTATION(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_LIST_ROTATION, (c_cmd_target*)ctrlId, ctrlId, MSG_CALLBACK_VWL, reinterpret_cast<MsgFuncVV>(&func)},
|
||||
{MSG_TYPE_WND, GL_LIST_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, int)>(&func))},
|
||||
|
||||
class c_list_box : public c_wnd
|
||||
{
|
|
@ -1,18 +1,14 @@
|
|||
#ifndef SPIN_BOX_H
|
||||
#define SPIN_BOX_H
|
||||
|
||||
#define GL_SPIN_SELECT 0x2222
|
||||
#define GL_SPIN_CONFIRM 0x3333
|
||||
#define GL_SPIN_ROTATION 0x4444
|
||||
|
||||
#define ON_SPIN_SELECT(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_SPIN_SELECT, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int)>(&func))},
|
||||
#define GL_SPIN_CONFIRM 0x2222
|
||||
#define GL_SPIN_CHANGE 0x3333
|
||||
|
||||
#define ON_SPIN_CONFIRM(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_SPIN_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWV, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int)>(&func))},
|
||||
{MSG_TYPE_WND, GL_SPIN_CONFIRM, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, int)>(&func))},
|
||||
|
||||
#define ON_SPIN_ROTATION(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_SPIN_ROTATION, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int)>(&func))},
|
||||
#define ON_SPIN_CHANGE(ctrlId, func) \
|
||||
{MSG_TYPE_WND, GL_SPIN_CHANGE, (c_cmd_target*)ctrlId, MSG_CALLBACK_VWL, (MsgFuncVV)(static_cast<void (c_cmd_target::*)(unsigned int, int)>(&func))},
|
||||
|
||||
class c_spin_box : public c_wnd
|
||||
{
|
Loading…
Reference in New Issue