From 9471ff79c5c949955939c8edc85956395408cf39 Mon Sep 17 00:00:00 2001 From: werelone <569629550@qq.com> Date: Tue, 12 Sep 2017 12:53:34 +0800 Subject: [PATCH] Slightly optimized --- Easy2D/{Application.cpp => App.cpp} | 128 ++++++++++++++-------------- Easy2D/Easy2D.vcxproj | 2 +- Easy2D/Easy2D.vcxproj.filters | 30 +++---- Easy2D/FreePool.cpp | 3 +- Easy2D/Msg/MouseMsg.cpp | 33 ++++--- Easy2D/Node/BatchNode.cpp | 4 +- Easy2D/Node/Button/Button.cpp | 2 +- Easy2D/Node/Button/ImageButton.cpp | 10 +-- Easy2D/Node/Button/TextButton.cpp | 10 +-- Easy2D/Node/Image.cpp | 2 +- Easy2D/Node/MouseNode.cpp | 2 +- Easy2D/Node/Shape/Shape.cpp | 4 +- Easy2D/easy2d.h | 78 +++++++++-------- 13 files changed, 156 insertions(+), 152 deletions(-) rename Easy2D/{Application.cpp => App.cpp} (67%) diff --git a/Easy2D/Application.cpp b/Easy2D/App.cpp similarity index 67% rename from Easy2D/Application.cpp rename to Easy2D/App.cpp index a0abbb56..5a109ab5 100644 --- a/Easy2D/Application.cpp +++ b/Easy2D/App.cpp @@ -8,13 +8,13 @@ #pragma comment(lib, "winmm.lib") -// Application 的唯一实例 -static Application * s_pInstance = nullptr; +// App 的唯一实例 +static App * s_pInstance = nullptr; // 坐标原点的物理坐标 static int originX = 0; static int originY = 0; -Application::Application() : +App::App() : m_currentScene(nullptr), m_nextScene(nullptr), m_bRunning(false), @@ -23,40 +23,40 @@ Application::Application() : m_nHeight(0), m_nWindowMode(0) { - assert(!s_pInstance); // 不能同时存在两个 Application 实例 + assert(!s_pInstance); // 不能同时存在两个 App 实例 s_pInstance = this; // 保存实例对象 setFPS(60); // 默认 FPS 为 60 } -Application::~Application() +App::~App() { - destory(); // 销毁 Application + destory(); // 销毁 App } -Application * Application::get() +App * App::get() { assert(s_pInstance); // 断言实例存在 - return s_pInstance; // 获取 Application 的唯一实例 + return s_pInstance; // 获取 App 的唯一实例 } -void Application::setOrigin(int originX, int originY) +void App::setOrigin(int originX, int originY) { ::originX = originX; ::originY = originY; setorigin(originX, originY); } -int Application::getOriginX() +int App::getOriginX() { return ::originX; } -int Application::getOriginY() +int App::getOriginY() { return ::originY; } -int Application::run() +int App::run() { // 开启批量绘图 BeginBatchDraw(); @@ -115,7 +115,7 @@ int Application::run() return 0; } -void Application::_initGraph() +void App::_initGraph() { // 创建绘图环境 initgraph(m_nWidth, m_nHeight, m_nWindowMode); @@ -152,7 +152,7 @@ void Application::_initGraph() } } -void Application::_mainLoop() +void App::_mainLoop() { // 游戏暂停 if (m_bPause) @@ -178,7 +178,7 @@ void Application::_mainLoop() FreePool::__flush(); // 刷新内存池 } -void Application::createWindow(int width, int height, int mode) +void App::createWindow(int width, int height, int mode) { // 保存窗口信息 m_nWidth = width; @@ -188,7 +188,7 @@ void Application::createWindow(int width, int height, int mode) _initGraph(); } -void Application::createWindow(tstring title, int width, int height, int mode) +void App::createWindow(tstring title, int width, int height, int mode) { // 保存窗口信息 m_nWidth = width; @@ -199,43 +199,37 @@ void Application::createWindow(tstring title, int width, int height, int mode) _initGraph(); } -void Application::setWindowSize(int width, int height) +void App::setWindowSize(int width, int height) { // 游戏正在运行时才允许修改窗口大小 assert(m_bRunning); - // 重启窗口 - closegraph(); - /* 重启窗口会导致内存占用急剧增加,也许是 EasyX 遗留的 BUG,已向 yangw80 报告了这个情况 */ - initgraph(width, height, m_nWindowMode); - - /* EasyX 不支持用 Windows API 修改窗口大小 */ - ///////////////////////////////////////////////////////////////////////////////// - // // 获取屏幕分辨率 - // int screenWidth = GetSystemMetrics(SM_CXSCREEN); - // int screenHeight = GetSystemMetrics(SM_CYSCREEN); - // // 获取窗口大小(包含菜单栏) - // CRect rcWindow; - // GetWindowRect(GetHWnd(), &rcWindow); - // // 获取客户区大小 - // CRect rcClient; - // GetClientRect(GetHWnd(), &rcClient); - // // 计算边框大小 - // width += (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left); - // height += (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top); - // // 修改窗口大小,并设置窗口在屏幕居中 - // SetWindowPos( - // GetHWnd(), - // HWND_TOP, - // (screenWidth - width) / 2, - // (screenHeight - height) / 2, - // width, - // height, - // SWP_SHOWWINDOW | SWP_NOREDRAW); - ////////////////////////////////////////////////////////////////////////////////// + // 获取屏幕分辨率 + int screenWidth = GetSystemMetrics(SM_CXSCREEN); + int screenHeight = GetSystemMetrics(SM_CYSCREEN); + // 获取窗口大小(包含菜单栏) + CRect rcWindow; + GetWindowRect(GetHWnd(), &rcWindow); + // 获取客户区大小 + CRect rcClient; + GetClientRect(GetHWnd(), &rcClient); + // 计算边框大小 + width += (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left); + height += (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top); + // 销毁当前窗口 + // DestroyWindow(GetHWnd());/* 无法操作多线程导致失效 */ + // 修改窗口大小,并设置窗口在屏幕居中 + SetWindowPos(GetHWnd(), HWND_TOP, + (screenWidth - width) / 2, + (screenHeight - height) / 2, + width, + height, + SWP_SHOWWINDOW); + // 重置窗口属性 + reset(); } -void Application::setWindowText(tstring title) +void App::setWindowText(tstring title) { // 设置窗口标题 SetWindowText(GetHWnd(), title.c_str()); @@ -243,13 +237,12 @@ void Application::setWindowText(tstring title) m_sTitle = title; } -void Application::close() +void App::close() { - // 关闭绘图环境 - closegraph(); + closegraph(); // 关闭绘图环境 } -void Application::enterScene(Scene * scene, bool save) +void App::enterScene(Scene * scene, bool save) { // 保存下一场景的指针 m_nextScene = scene; @@ -257,7 +250,7 @@ void Application::enterScene(Scene * scene, bool save) m_bSaveScene = save; } -void Application::backScene() +void App::backScene() { // 从栈顶取出场景指针,作为下一场景 m_nextScene = m_sceneStack.top(); @@ -265,7 +258,12 @@ void Application::backScene() m_bSaveScene = false; } -void Application::_enterNextScene() +void App::setBkColor(COLORREF color) +{ + setbkcolor(color); +} + +void App::_enterNextScene() { // 若下一场景处于栈顶,说明正在返回上一场景 if (m_sceneStack.size() && m_nextScene == m_sceneStack.top()) @@ -286,27 +284,27 @@ void Application::_enterNextScene() m_nextScene = nullptr; // 下一场景置空 } -void Application::quit() +void App::quit() { m_bRunning = false; } -void Application::end() +void App::end() { m_bRunning = false; } -void Application::pause() +void App::pause() { m_bPause = true; } -bool Application::isRunning() +bool App::isRunning() { return m_bRunning && !m_bPause; } -void Application::reset() +void App::reset() { // 重置绘图环境 graphdefaults(); @@ -314,18 +312,18 @@ void Application::reset() setbkcolor(Color::black); } -Scene * Application::getCurrentScene() +Scene * App::getCurrentScene() { // 获取当前场景的指针 return m_currentScene; } -LPCTSTR easy2d::Application::getVersion() +LPCTSTR easy2d::App::getVersion() { return _T("1.0.0"); } -void Application::setFPS(DWORD fps) +void App::setFPS(DWORD fps) { // 设置画面帧率,以毫秒为单位 LARGE_INTEGER nFreq; @@ -333,17 +331,17 @@ void Application::setFPS(DWORD fps) m_nAnimationInterval.QuadPart = (LONGLONG)(1.0 / fps * nFreq.QuadPart); } -int Application::getWidth() const +int App::getWidth() const { return m_nWidth; } -int Application::getHeight() const +int App::getHeight() const { return m_nHeight; } -void Application::free() +void App::free() { // 释放场景内存 SAFE_DELETE(m_currentScene); @@ -359,7 +357,7 @@ void Application::free() Timer::clearAllTimers(); } -void Application::destory() +void App::destory() { // 释放所有内存 free(); diff --git a/Easy2D/Easy2D.vcxproj b/Easy2D/Easy2D.vcxproj index da303326..2390ea2a 100644 --- a/Easy2D/Easy2D.vcxproj +++ b/Easy2D/Easy2D.vcxproj @@ -338,7 +338,7 @@ - + diff --git a/Easy2D/Easy2D.vcxproj.filters b/Easy2D/Easy2D.vcxproj.filters index e17f1845..f3559bc9 100644 --- a/Easy2D/Easy2D.vcxproj.filters +++ b/Easy2D/Easy2D.vcxproj.filters @@ -25,23 +25,20 @@ {e5ec6183-113b-4140-8285-18b18ea37d15} - - {051f9343-e5a5-4491-8110-f13fc27c3827} - {065a3244-7169-4a45-bc9f-f2a80d8a9759} {72dbabab-8278-4ee4-917f-bfffb474a51b} + + {bdcd902b-b53d-4537-9632-76ea14c141a0} + - - 婧愭枃浠 - 婧愭枃浠 @@ -87,18 +84,9 @@ 婧愭枃浠禱Node\Shape - - 婧愭枃浠禱Node\Button - 婧愭枃浠禱Node - - 婧愭枃浠禱Node\Button - - - 婧愭枃浠禱Node\Button - 婧愭枃浠禱Style @@ -117,6 +105,18 @@ 婧愭枃浠禱Msg + + 婧愭枃浠 + + + 婧愭枃浠禱Node\Button + + + 婧愭枃浠禱Node\Button + + + 婧愭枃浠禱Node\Button + diff --git a/Easy2D/FreePool.cpp b/Easy2D/FreePool.cpp index f177c2d5..01b5a72b 100644 --- a/Easy2D/FreePool.cpp +++ b/Easy2D/FreePool.cpp @@ -34,6 +34,5 @@ void FreePool::__flush() void FreePool::add(Object * nptr) { - // 将一个对象放入释放池中 - pool.push_back(nptr); + pool.push_back(nptr); // 将一个对象放入释放池中 } diff --git a/Easy2D/Msg/MouseMsg.cpp b/Easy2D/Msg/MouseMsg.cpp index 8b725f25..98b8de6a 100644 --- a/Easy2D/Msg/MouseMsg.cpp +++ b/Easy2D/Msg/MouseMsg.cpp @@ -15,7 +15,7 @@ void easy2d::MouseMsg::__exec() // 转换鼠标消息 ConvertMsg(GetMouseMsg()); // 执行场景程序 - Application::get()->getCurrentScene()->_exec(); + App::get()->getCurrentScene()->_exec(); } } @@ -24,17 +24,17 @@ MouseMsg MouseMsg::getMsg() return s_mouseMsg; // 获取当前鼠标消息 } -bool MouseMsg::getLButtonDown() +bool MouseMsg::isLButtonDown() { return s_mouseMsg.mkLButton; } -bool MouseMsg::getRButtonDown() +bool MouseMsg::isRButtonDown() { return s_mouseMsg.mkRButton; } -bool MouseMsg::getMButtonDown() +bool MouseMsg::isMButtonDown() { return s_mouseMsg.mkMButton; } @@ -54,57 +54,57 @@ int MouseMsg::getMouseWheel() return s_mouseMsg.wheel; } -bool MouseMsg::getMouseMovedMsg() +bool MouseMsg::isOnMouseMoved() { return s_mouseMsg.uMsg == WM_MOUSEMOVE; } -bool MouseMsg::getLButtonDBClickedMsg() +bool MouseMsg::isOnLButtonDBClicked() { return s_mouseMsg.uMsg == WM_LBUTTONDBLCLK; } -bool MouseMsg::getLButtonDownMsg() +bool MouseMsg::isOnLButtonDown() { return s_mouseMsg.uMsg == WM_LBUTTONDOWN; } -bool MouseMsg::getLButtonUpMsg() +bool MouseMsg::isOnLButtonUp() { return s_mouseMsg.uMsg == WM_LBUTTONUP; } -bool MouseMsg::getRButtonDBClicked() +bool MouseMsg::isOnRButtonDBClicked() { return s_mouseMsg.uMsg == WM_RBUTTONDBLCLK; } -bool MouseMsg::getRButtonDownMsg() +bool MouseMsg::isOnRButtonDown() { return s_mouseMsg.uMsg == WM_RBUTTONDOWN; } -bool MouseMsg::getRButtonUpMsg() +bool MouseMsg::isOnRButtonUp() { return s_mouseMsg.uMsg == WM_LBUTTONUP; } -bool MouseMsg::getMButtonDBClicked() +bool MouseMsg::isOnMButtonDBClicked() { return s_mouseMsg.uMsg == WM_MBUTTONDBLCLK; } -bool MouseMsg::getMButtonDownMsg() +bool MouseMsg::isOnMButtonDown() { return s_mouseMsg.uMsg == WM_MBUTTONDOWN; } -bool MouseMsg::getMButtonUpMsg() +bool MouseMsg::isOnMButtonUp() { return s_mouseMsg.uMsg == WM_MBUTTONUP; } -bool MouseMsg::getWheelMsg() +bool MouseMsg::isOnWheel() { return s_mouseMsg.uMsg == WM_MOUSEWHEEL; } @@ -118,8 +118,7 @@ void ConvertMsg(MOUSEMSG msg) { // 将 MOUSEMSG 转换为 MouseMsg /// 虽然 MOUSEMSG 和 MouseMsg 本质上是一样的 - /// 但是为了实现 Easy2D 与 EasyX 的相对隔离,所以定义了新的 MouseMsg - /// 将来 Msg 对消息的处理会统一用 WinAPI实现,而不再用 EasyX 的函数 + /// 但是为了实现 Easy2D 与 EasyX 的分离,所以定义了新的 MouseMsg s_mouseMsg.uMsg = msg.uMsg; s_mouseMsg.mkLButton = msg.mkLButton; s_mouseMsg.mkMButton = msg.mkMButton; diff --git a/Easy2D/Node/BatchNode.cpp b/Easy2D/Node/BatchNode.cpp index 57f507e0..10d2a6ac 100644 --- a/Easy2D/Node/BatchNode.cpp +++ b/Easy2D/Node/BatchNode.cpp @@ -41,13 +41,13 @@ void BatchNode::_onDraw() } // 在相对位置绘制子节点 - Application::setOrigin(Application::getOriginX() + m_nX, Application::getOriginY() + m_nY); + App::setOrigin(App::getOriginX() + m_nX, App::getOriginY() + m_nY); for (auto child : m_vChildren) { assert(child); child->_onDraw(); } - Application::setOrigin(Application::getOriginX() - m_nX, Application::getOriginY() - m_nY); + App::setOrigin(App::getOriginX() - m_nX, App::getOriginY() - m_nY); } void BatchNode::add(Node * child, int z_Order) diff --git a/Easy2D/Node/Button/Button.cpp b/Easy2D/Node/Button/Button.cpp index 256166a6..8c52a4ca 100644 --- a/Easy2D/Node/Button/Button.cpp +++ b/Easy2D/Node/Button/Button.cpp @@ -43,7 +43,7 @@ void Button::_judge() _setMouseIn(); // 若鼠标在按钮上,且鼠标左键按下 - if (MouseMsg::getLButtonDownMsg()) + if (MouseMsg::isLButtonDown()) { _setSelected(); } diff --git a/Easy2D/Node/Button/ImageButton.cpp b/Easy2D/Node/Button/ImageButton.cpp index 79733a98..08fe608c 100644 --- a/Easy2D/Node/Button/ImageButton.cpp +++ b/Easy2D/Node/Button/ImageButton.cpp @@ -14,7 +14,7 @@ ImageButton::ImageButton() : ImageButton::ImageButton(Image * image) : ImageButton() { - setNormalImage(image); // 设置按钮在正常状态时的图片 + setNormal(image); // 设置按钮在正常状态时的图片 } ImageButton::~ImageButton() @@ -70,7 +70,7 @@ void ImageButton::_onDisable() } } -void ImageButton::setNormalImage(Image * image) +void ImageButton::setNormal(Image * image) { if (image) { @@ -85,7 +85,7 @@ void ImageButton::setNormalImage(Image * image) } } -void ImageButton::setMouseInImage(Image * image) +void ImageButton::setMouseIn(Image * image) { if (image) { @@ -96,7 +96,7 @@ void ImageButton::setMouseInImage(Image * image) } } -void ImageButton::setSelectedImage(Image * image) +void ImageButton::setSelected(Image * image) { if (image) { @@ -107,7 +107,7 @@ void ImageButton::setSelectedImage(Image * image) } } -void ImageButton::setUnableImage(Image * image) +void ImageButton::setUnable(Image * image) { if (image) { diff --git a/Easy2D/Node/Button/TextButton.cpp b/Easy2D/Node/Button/TextButton.cpp index fb6ce9d9..941f18ac 100644 --- a/Easy2D/Node/Button/TextButton.cpp +++ b/Easy2D/Node/Button/TextButton.cpp @@ -14,7 +14,7 @@ TextButton::TextButton() : TextButton::TextButton(Text * text) : TextButton() { - setNormalText(text); // 设置按钮在正常状态时的文字 + setNormal(text); // 设置按钮在正常状态时的文字 } TextButton::~TextButton() @@ -70,7 +70,7 @@ void TextButton::_onDisable() } } -void TextButton::setNormalText(Text * text) +void TextButton::setNormal(Text * text) { if (text) { @@ -85,7 +85,7 @@ void TextButton::setNormalText(Text * text) } } -void TextButton::setMouseInText(Text * text) +void TextButton::setMouseIn(Text * text) { if (text) { @@ -96,7 +96,7 @@ void TextButton::setMouseInText(Text * text) } } -void TextButton::setSelectedText(Text * text) +void TextButton::setSelected(Text * text) { if (text) { @@ -107,7 +107,7 @@ void TextButton::setSelectedText(Text * text) } } -void TextButton::setUnableText(Text * text) +void TextButton::setUnable(Text * text) { if (text) { diff --git a/Easy2D/Node/Image.cpp b/Easy2D/Node/Image.cpp index bc9f84db..3b4a48fc 100644 --- a/Easy2D/Node/Image.cpp +++ b/Easy2D/Node/Image.cpp @@ -159,7 +159,7 @@ void Image::screenshot() { // 保存窗口截图 IMAGE image; - getimage(&image, 0, 0, Application::get()->getWidth(), Application::get()->getHeight()); + getimage(&image, 0, 0, App::get()->getWidth(), App::get()->getHeight()); saveimage(savePath.c_str(), &image); } } diff --git a/Easy2D/Node/MouseNode.cpp b/Easy2D/Node/MouseNode.cpp index 089b7ec6..c70c870b 100644 --- a/Easy2D/Node/MouseNode.cpp +++ b/Easy2D/Node/MouseNode.cpp @@ -25,7 +25,7 @@ bool MouseNode::_exec(bool active) if (m_eStatus == MOUSEIN || m_eStatus == SELECTED) { // 节点被鼠标选中,且鼠标左键抬起 - if (m_bTarget && MouseMsg::getLButtonUpMsg()) + if (m_bTarget && MouseMsg::isOnLButtonUp()) { onClicked(); // 执行回调函数 } diff --git a/Easy2D/Node/Shape/Shape.cpp b/Easy2D/Node/Shape/Shape.cpp index 7258439d..daf6bd61 100644 --- a/Easy2D/Node/Shape/Shape.cpp +++ b/Easy2D/Node/Shape/Shape.cpp @@ -1,7 +1,9 @@ #include "..\..\Easy2d.h" #include "..\..\EasyX\easyx.h" -Shape::Shape() +Shape::Shape() : + lineColor(Color::black), + fillColor(Color::white) { } diff --git a/Easy2D/easy2d.h b/Easy2D/easy2d.h index e3471e81..1b0125fe 100644 --- a/Easy2D/easy2d.h +++ b/Easy2D/easy2d.h @@ -11,6 +11,10 @@ #error Easy2D is only for C++ #endif +#if _MSC_VER < 1600 + #error Do Visual Studio 2010/2013/2015/2017 specific stuff +#endif + // String macros @@ -52,7 +56,7 @@ namespace easy2d { // 基础类 -class Application; +class App; class Scene; class KeyMsg; class MouseMsg; @@ -85,7 +89,7 @@ typedef std::function TIMER_CALLBACK; typedef std::function KEY_CALLBACK; -class Application +class App { protected: tstring m_sTitle; @@ -106,13 +110,13 @@ protected: void _enterNextScene(); public: - Application(); - ~Application(); + App(); + ~App(); // 窗口可选模式 enum { SHOW_CONSOLE = 1, NO_CLOSE = 2, NO_MINI_MIZE = 4 }; // 获取程序实例 - static Application * get(); + static App * get(); // 设置坐标原点 static void setOrigin(int originX, int originY); // 获取坐标原点的物理横坐标 @@ -131,12 +135,12 @@ public: void createWindow(int width, int height, int mode = 0); // 定义绘图窗口 void createWindow(tstring title, int width, int height, int mode = 0); + // 关闭窗口 + void close(); // 修改窗口大小 void setWindowSize(int width, int height); // 设置窗口标题 void setWindowText(tstring title); - // 关闭窗口 - void close(); // 获取窗口宽度 int getWidth() const; // 获取窗口高度 @@ -145,6 +149,8 @@ public: void enterScene(Scene *scene, bool save = true); // 返回上一场景 void backScene(); + // 修改窗口背景色 + void setBkColor(COLORREF color); // 游戏是否正在运行 bool isRunning(); // 设置帧率 @@ -163,7 +169,7 @@ public: class FreePool { - friend class Application; + friend class App; private: static void __flush(); @@ -175,7 +181,7 @@ public: class Scene { - friend class Application; + friend class App; friend class MouseMsg; protected: @@ -200,7 +206,7 @@ public: class MouseMsg { - friend class Application; + friend class App; private: static void __exec(); @@ -218,11 +224,11 @@ public: // 获取当前鼠标消息 static MouseMsg getMsg(); // 左键是否按下 - static bool getLButtonDown(); + static bool isLButtonDown(); // 右键是否按下 - static bool getRButtonDown(); + static bool isRButtonDown(); // 中键是否按下 - static bool getMButtonDown(); + static bool isMButtonDown(); // 获取鼠标X坐标 static int getMouseX(); // 获取鼠标Y坐标 @@ -230,27 +236,27 @@ public: // 获取鼠标滚轮值 static int getMouseWheel(); // 鼠标移动消息 - static bool getMouseMovedMsg(); + static bool isOnMouseMoved(); // 左键双击消息 - static bool getLButtonDBClickedMsg(); + static bool isOnLButtonDBClicked(); // 右键按下消息 - static bool getLButtonDownMsg(); + static bool isOnLButtonDown(); // 左键弹起消息 - static bool getLButtonUpMsg(); + static bool isOnLButtonUp(); // 右键双击消息 - static bool getRButtonDBClicked(); + static bool isOnRButtonDBClicked(); // 右键按下消息 - static bool getRButtonDownMsg(); + static bool isOnRButtonDown(); // 右键弹起消息 - static bool getRButtonUpMsg(); + static bool isOnRButtonUp(); // 中键双击消息 - static bool getMButtonDBClicked(); + static bool isOnMButtonDBClicked(); // 中键按下消息 - static bool getMButtonDownMsg(); + static bool isOnMButtonDown(); // 中键弹起消息 - static bool getMButtonUpMsg(); + static bool isOnMButtonUp(); // 鼠标滚轮拨动消息 - static bool getWheelMsg(); + static bool isOnWheel(); // 清空鼠标消息 static void resetMouseMsg(); }; @@ -258,7 +264,7 @@ public: class KeyMsg { - friend class Application; + friend class App; public: // 字母键值 @@ -352,7 +358,7 @@ public: class Timer { - friend class Application; + friend class App; protected: bool m_bRunning; @@ -798,13 +804,13 @@ public: virtual ~TextButton(); // 设置按钮文字 - void setNormalText(Text * text); + void setNormal(Text * text); // 设置鼠标移入时的按钮文字 - void setMouseInText(Text * text); + void setMouseIn(Text * text); // 设置鼠标选中时的按钮文字 - void setSelectedText(Text * text); + void setSelected(Text * text); // 设置按钮禁用时的按钮文字 - void setUnableText(Text * text); + void setUnable(Text * text); // 设置按钮横坐标 virtual void setX(int x) override; @@ -840,13 +846,13 @@ public: virtual ~ImageButton(); // 设置按钮图片 - void setNormalImage(Image * image); + void setNormal(Image * image); // 设置鼠标移入时的按钮图片 - void setMouseInImage(Image * image); + void setMouseIn(Image * image); // 设置鼠标选中时的按钮图片 - void setSelectedImage(Image * image); + void setSelected(Image * image); // 设置按钮禁用时的按钮图片 - void setUnableImage(Image * image); + void setUnable(Image * image); // 设置按钮横坐标 virtual void setX(int x) override; @@ -863,8 +869,8 @@ class Shape : protected: enum STYLE { round, solid, fill }; // 形状填充样式 STYLE _style; - COLORREF fillColor = 0; - COLORREF lineColor = 0; + COLORREF fillColor; + COLORREF lineColor; protected: virtual void _onDraw() override;