⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wg__dropdown_8cpp-source.html

📁 一个小巧的嵌入式图形系统wGUI, 可以用VC编译
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>wg_dropdown.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; </center><hr><h1>wg_dropdown.cpp</h1><div class="fragment"><pre>00001 <span class="comment">// wg_dropdown.cpp</span>00002 <span class="comment">//</span>00003 <span class="comment">// CDropDown class implementation</span>00004 <span class="comment">//</span>00005 <span class="comment">//</span>00006 <span class="comment">// Copyright (c) 2002 Rob Wiskow</span>00007 <span class="comment">// rob-dev@boxedchaos.com</span>00008 <span class="comment">//</span>00009 <span class="comment">// This library is free software; you can redistribute it and/or</span>00010 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span>00011 <span class="comment">// License as published by the Free Software Foundation; either</span>00012 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span>00013 <span class="comment">//</span>00014 <span class="comment">// This library is distributed in the hope that it will be useful,</span>00015 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>00016 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>00017 <span class="comment">// Lesser General Public License for more details.</span>00018 <span class="comment">//</span>00019 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span>00020 <span class="comment">// License along with this library; if not, write to the Free Software</span>00021 <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>00022 <span class="comment">//</span>00023 00024 00025 <span class="preprocessor">#include "wgui_include_config.h"</span>00026 <span class="preprocessor">#include "wg_dropdown.h"</span>00027 <span class="preprocessor">#include "wg_message_server.h"</span>00028 <span class="preprocessor">#include "wg_resources.h"</span>00029 00030 00031 <span class="keyword">namespace </span>wGui00032 {00033 <a name="l00034"></a><a class="code" href="classwGui_1_1CDropDown.html#a0">00034</a> CDropDown::CDropDown(<span class="keyword">const</span> <a class="code" href="classwGui_1_1CRect.html">CRect</a>&amp; WindowRect, <a class="code" href="classwGui_1_1CWindow.html">CWindow</a>* pParent, <span class="keywordtype">bool</span> bAllowEdit, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> iItemHeight, <a class="code" href="classwGui_1_1CFontEngine.html">CFontEngine</a>* pFontEngine) :00035      <a class="code" href="classwGui_1_1CWindow.html">CWindow</a>(WindowRect, pParent),00036      m_bAllowEdit(bAllowEdit)00037 {00038   <a class="code" href="classwGui_1_1CWindow.html#n8">m_sClassName</a> = <span class="stringliteral">"CDropDown"</span>;00039      <a class="code" href="classwGui_1_1CDropDown.html#n0">m_pEditBox</a> = <span class="keyword">new</span> <a class="code" href="classwGui_1_1CEditBox.html">CEditBox</a>(<a class="code" href="classwGui_1_1CRect.html">CRect</a>(WindowRect.<a class="code" href="classwGui_1_1CRect.html#a13">TopLeft</a>(), <a class="code" href="classwGui_1_1CPoint.html">CPoint</a>(WindowRect.<a class="code" href="classwGui_1_1CRect.html#a11">Right</a>() - WindowRect.<a class="code" href="classwGui_1_1CRect.html#a24">Height</a>(), WindowRect.<a class="code" href="classwGui_1_1CRect.html#a12">Bottom</a>())),00040           <span class="keyword">this</span>, pFontEngine);00041      <span class="keywordflow">if</span> (!<a class="code" href="classwGui_1_1CDropDown.html#n3">m_bAllowEdit</a>)00042      {00043           <a class="code" href="classwGui_1_1CDropDown.html#n0">m_pEditBox</a>-&gt;<a class="code" href="classwGui_1_1CEditBox.html#a4">SetReadOnly</a>(<span class="keyword">true</span>);00044           <span class="comment">// Override the normal read-only BG color</span>00045           <a class="code" href="classwGui_1_1CDropDown.html#n0">m_pEditBox</a>-&gt;<a class="code" href="classwGui_1_1CWindow.html#a6">SetBGColor</a>(COLOR_WHITE);00046      }00047 00048      <span class="comment">// We create the listbox with the root window (probably a CView object) as it's parent, so that it gets the OnMouseButtonDown/Up properly</span>00049      <a class="code" href="classwGui_1_1CDropDown.html#n1">m_pListBox</a> = <span class="keyword">new</span> <a class="code" href="classwGui_1_1CListBox.html">CListBox</a>(<a class="code" href="classwGui_1_1CRect.html">CRect</a>(WindowRect.<a class="code" href="classwGui_1_1CRect.html#a15">BottomLeft</a>(), <a class="code" href="classwGui_1_1CPoint.html">CPoint</a>(WindowRect.<a class="code" href="classwGui_1_1CRect.html#a11">Right</a>(), WindowRect.<a class="code" href="classwGui_1_1CRect.html#a12">Bottom</a>() + iItemHeight * 5 + 1)),00050           <a class="code" href="classwGui_1_1CWindow.html#a8">GetAncestor</a>(<a class="code" href="classwGui_1_1CWindow.html#s2s1">ROOT</a>), <span class="keyword">true</span>, iItemHeight, pFontEngine);00051      <a class="code" href="classwGui_1_1CDropDown.html#n1">m_pListBox</a>-&gt;<a class="code" href="classwGui_1_1CWindow.html#a11">SetVisible</a>(<span class="keyword">false</span>);00052      <a class="code" href="classwGui_1_1CDropDown.html#n1">m_pListBox</a>-&gt;<a class="code" href="classwGui_1_1CListBox.html#a12">SetDropDown</a>(<span class="keyword">this</span>);00053 00054      <a class="code" href="classwGui_1_1CDropDown.html#n2">m_pDropButton</a> = <span class="keyword">new</span> <a class="code" href="classwGui_1_1CPictureButton.html">CPictureButton</a>(00055           <a class="code" href="classwGui_1_1CRect.html">CRect</a>(<a class="code" href="classwGui_1_1CPoint.html">CPoint</a>(WindowRect.<a class="code" href="classwGui_1_1CRect.html#a11">Right</a>() - WindowRect.<a class="code" href="classwGui_1_1CRect.html#a24">Height</a>() + 1, WindowRect.<a class="code" href="classwGui_1_1CRect.html#a9">Top</a>()), WindowRect.<a class="code" href="classwGui_1_1CRect.html#a16">BottomRight</a>()),00056           <span class="keyword">this</span>, <a class="code" href="classwGui_1_1CwgBitmapResourceHandle.html">CwgBitmapResourceHandle</a>(WGRES_DOWN_ARROW_BITMAP));00057      CMessageServer::Instance().RegisterMessageClient(<span class="keyword">this</span>, CMessage::MOUSE_BUTTONDOWN);00058      CMessageServer::Instance().RegisterMessageClient(<span class="keyword">this</span>, CMessage::CTRL_LCLICK);00059      CMessageServer::Instance().RegisterMessageClient(<span class="keyword">this</span>, CMessage::CTRL_VALUECHANGE);00060 }00061 00062 <a name="l00063"></a><a class="code" href="classwGui_1_1CDropDown.html#a1">00063</a> CDropDown::~CDropDown(<span class="keywordtype">void</span>)00064 {00065      <span class="comment">// The listbox is parented by the root window, so we need to delete it by hand</span>00066      <span class="keyword">delete</span> <a class="code" href="classwGui_1_1CDropDown.html#n1">m_pListBox</a>;00067 }00068 00069 <a name="l00070"></a><a class="code" href="classwGui_1_1CDropDown.html#a2">00070</a> <span class="keywordtype">void</span> CDropDown::SetWindowText(std::string sWindowText)00071 {00072      <a class="code" href="classwGui_1_1CDropDown.html#n0">m_pEditBox</a>-&gt;<a class="code" href="classwGui_1_1CEditBox.html#a8">SetWindowText</a>(sWindowText);00073 }00074 00075 <a name="l00076"></a><a class="code" href="classwGui_1_1CDropDown.html#a11">00076</a> <span class="keywordtype">bool</span> CDropDown::HandleMessage(<a class="code" href="classwGui_1_1CMessage.html">CMessage</a>* pMessage)00077 {00078      <span class="keywordtype">bool</span> bHandled = <span class="keyword">false</span>;00079      <a class="code" href="classwGui_1_1CRect.html">CRect</a> SubRect(<a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>);00080      SubRect.<a class="code" href="classwGui_1_1CRect.html#a28">Grow</a>(-3);00081 00082      <span class="keywordflow">if</span> (pMessage)00083      {00084           <span class="keywordflow">switch</span>(pMessage-&gt;<a class="code" href="classwGui_1_1CMessage.html#a2">MessageType</a>())00085           {00086           <span class="keywordflow">case</span> CMessage::MOUSE_BUTTONDOWN:00087           {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -