📄 fg__button_8cpp-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=gb2312"><title>FishGUI: FG_Button.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- 制作者 Doxygen 1.3.6 --><div class="qindex"><a class="qindex" href="main.html">首页</a> | <a class="qindex" href="modules.html">模块</a> | <a class="qindex" href="hierarchy.html">类继承关系</a> | <a class="qindex" href="classes.html">按字典顺序排序的列表</a> | <a class="qindex" href="annotated.html">组合类型列表</a> | <a class="qindex" href="files.html">文件列表</a> | <a class="qindex" href="functions.html">组合类型成员</a> | <a class="qindex" href="globals.html">文件成员</a></div><h1>FG_Button.cpp</h1><a href="FG__Button_8cpp.html">浏览该文件的文档。</a><div class="fragment"><pre>00001 <span class="comment">/*--------------------------------------------------------------------------</span>00002 <span class="comment"></span>00003 <span class="comment"> FG_Button.cpp - 按钮控件类的实现文件</span>00004 <span class="comment"></span>00005 <span class="comment"> 本程序是FishGUI软件的一部分</span>00006 <span class="comment"></span>00007 <span class="comment"> 版权所有 (C) 2003,2004 王咏武</span>00008 <span class="comment"> http://www.contextfree.net/wangyw/</span>00009 <span class="comment"></span>00010 <span class="comment">----------------------------------------------------------------------------</span>00011 <span class="comment"></span>00012 <span class="comment"> 作者对 FishGUI 软件及其所有源代码授权如下:</span>00013 <span class="comment"></span>00014 <span class="comment"> 允许任何个人、组织、机构、企业无偿获得、修改、使用、重新发布 FishGUI 软</span>00015 <span class="comment"> 件及其源代码,或按照有偿或者无偿的方式发行基于 FishGUI 源代码的全部或部</span>00016 <span class="comment"> 分内容开发的软件产品,——但行使以上权利时,须遵守以下约定:</span>00017 <span class="comment"></span>00018 <span class="comment"> 1、重新发布 FishGUI 软件及其源代码时,不得隐去软件及其源代码中原有的版</span>00019 <span class="comment"> 权信息和开发者标识。</span>00020 <span class="comment"></span>00021 <span class="comment"> 2、发行基于 FishGUI 源代码的全部或部分内容开发的软件产品时,必须在产品</span>00022 <span class="comment"> 的显著位置标明以下字样:</span>00023 <span class="comment"></span>00024 <span class="comment"> 【本产品的一部分功能是基于王咏武在 FishGUI 软件中的工作完成的】</span>00025 <span class="comment"></span>00026 <span class="comment"> 3、在正式出版物中引用 FishGUI 的文档、源代码或注释内容的,应注明软件的</span>00027 <span class="comment"> 原作者为王咏武。</span>00028 <span class="comment"></span>00029 <span class="comment">--------------------------------------------------------------------------*/</span>00040 <span class="preprocessor">#include "../OSAdaptor/FG_OSAdaptor.h"</span>00041 <span class="preprocessor">#include "<a class="code" href="FG__Button_8h.html">FG_Button.h</a>"</span>00042 <a name="l00043"></a><a class="code" href="classFG__Button.html#b6">00043</a> <a class="code" href="group__MsgMap__Define.html#ga1">BEGIN_MESSAGE_MAP</a>(<a class="code" href="classFG__Button.html">FG_Button</a>, <a class="code" href="classFG__TextWidget.html">FG_TextWidget</a>)00044 <a class="code" href="group__MsgMap__Define.html#ga2">ON_DRAW</a> (FG_Button::OnDraw)00045 <a class="code" href="group__MsgMap__Define.html#ga5">ON_KEYDOWN</a> (FG_Button::OnKeyDown)00046 <a class="code" href="group__MsgMap__Define.html#ga6">ON_KEYUP</a> (FG_Button::OnKeyUp)00047 <a class="code" href="group__MsgMap__Define.html#ga8">ON_LBUTTONDOWN</a> (FG_Button::OnLButtonDown)00048 <a class="code" href="group__MsgMap__Define.html#ga9">ON_LBUTTONUP</a> (FG_Button::OnLButtonUp)00049 <a class="code" href="group__MsgMap__Define.html#ga10">ON_TIMER</a> (FG_Button::TIMERID_UP, FG_Button::OnTimerUp)00050 <a class="code" href="group__MsgMap__Define.html#ga15">END_MESSAGE_MAP</a>()00051 00052 <span class="comment">//##ModelId=3F71AE3103C2</span><a name="l00053"></a><a class="code" href="classFG__Button.html#b0">00053</a> <span class="keywordtype">void</span> <a class="code" href="classFG__Button.html#b0">FG_Button::OnDraw</a>(<a class="code" href="classFG__OSAdaptor.html">FG_OSAdaptor</a> * pAdaptor)00054 {00055 pAdaptor-><a class="code" href="classFG__OSAdaptor.html#a3">BeginDraw</a>(m_Rect);00056 00057 <a class="code" href="classFG__Object.html#b6">FG_TextWidget::OnDraw</a>(pAdaptor);00058 00059 <span class="keywordflow">if</span> (<a class="code" href="classFG__TextWidget.html#a3">TextLength</a>())00060 {00061 <span class="comment">// 绘制按钮文本</span>00062 <a class="code" href="group__Utility.html#ga1">WORD</a> x = m_Rect.<a class="code" href="structFG__Rect.html#o0">wLeft</a> + (m_Rect.<a class="code" href="structFG__Rect.html#o2">wRight</a> - m_Rect.<a class="code" href="structFG__Rect.html#o0">wLeft</a> + 1 - pAdaptor-><a class="code" href="classFG__OSAdaptor.html#a8">GetTextWidth</a>(<a class="code" href="classFG__TextWidget.html#a1">GetText</a>())) / 2;00063 <a class="code" href="group__Utility.html#ga1">WORD</a> y = m_Rect.<a class="code" href="structFG__Rect.html#o1">wTop</a> + (m_Rect.<a class="code" href="structFG__Rect.html#o3">wBottom</a> - m_Rect.<a class="code" href="structFG__Rect.html#o1">wTop</a> + 1 - pAdaptor-><a class="code" href="classFG__OSAdaptor.html#a9">GetTextHeight</a>(<a class="code" href="classFG__TextWidget.html#a1">GetText</a>())) / 2;00064 pAdaptor-><a class="code" href="classFG__OSAdaptor.html#a7">DrawText</a>(<a class="code" href="classFG__TextWidget.html#a1">GetText</a>(), x, y, m_ForeColor);00065 <span class="keywordflow">if</span> (<a class="code" href="classFG__Object.html#a19">IsFocus</a>())00066 {00067 <a class="code" href="structFG__Rect.html">FG_Rect</a> rect;00068 <a class="code" href="classFG__Object.html#a3">GetClientRect</a>(rect);00069 rect -= 1;00070 pAdaptor-><a class="code" href="classFG__OSAdaptor.html#a12">DrawDotRect</a>(rect, <a class="code" href="FG__X11Adaptor_8cpp.html#a0">COLOR_BLACK</a>);00071 }00072 }00073 00074 pAdaptor-><a class="code" href="classFG__OSAdaptor.html#a4">EndDraw</a>();00075 }00076 00077 <span class="comment">//##ModelId=3F71AE3103D6</span><a name="l00078"></a><a class="code" href="classFG__Button.html#b1">00078</a> <span class="keywordtype">bool</span> <a class="code" href="classFG__Button.html#b1">FG_Button::OnKeyDown</a>(<a class="code" href="structFG__Message.html">FG_Message</a> * pMsg)00079 {00080 <span class="keywordflow">if</span> (pMsg-><a class="code" href="structFG__Message.html#o4">lData</a> == <a class="code" href="group__Virtual__Key.html#ga12">FVK_ENTER</a>)00081 {00082 <span class="keywordflow">if</span> (<a class="code" href="classFG__Object.html#a14">FrameStyle</a>() == <a class="code" href="group__Frame__Style.html#ga2">FS_RAISED</a>)00083 {00084 <a class="code" href="classFG__Object.html#a14">FrameStyle</a>(<a class="code" href="group__Frame__Style.html#ga3">FS_RECESSED</a>);00085 <a class="code" href="classFG__Object.html#b4">RequestDraw</a>();00086 }00087 <span class="keywordflow">return</span> <span class="keyword">true</span>;00088 }00089 <span class="keywordflow">return</span> <span class="keyword">false</span>;00090 }00091 00092 <span class="comment">//##ModelId=3F71AE320002</span><a name="l00093"></a><a class="code" href="classFG__Button.html#b2">00093</a> <span class="keywordtype">bool</span> <a class="code" href="classFG__Button.html#b2">FG_Button::OnKeyUp</a>(<a class="code" href="structFG__Message.html">FG_Message</a> * pMsg)00094 {00095 <span class="keywordflow">if</span> (pMsg-><a class="code" href="structFG__Message.html#o4">lData</a> == <a class="code" href="group__Virtual__Key.html#ga12">FVK_ENTER</a>)00096 {00097 <span class="keywordflow">if</span> (<a class="code" href="classFG__Object.html#a14">FrameStyle</a>() == <a class="code" href="group__Frame__Style.html#ga3">FS_RECESSED</a>)00098 {00099 <a class="code" href="classFG__Object.html#a14">FrameStyle</a>(<a class="code" href="group__Frame__Style.html#ga2">FS_RAISED</a>);00100 <a class="code" href="classFG__Object.html#b4">RequestDraw</a>();00101 <a class="code" href="classFG__Object.html#b3">NotifyParent</a>(<a class="code" href="group__Utility.html#gga16a38">FBN_PRESSED</a>);00102 }00103 <span class="keywordflow">return</span> <span class="keyword">true</span>;00104 }00105 <span class="keywordflow">return</span> <span class="keyword">false</span>;00106 }00107 00108 <span class="comment">//##ModelId=3F71AE320016</span><a name="l00109"></a><a class="code" href="classFG__Button.html#b3">00109</a> <span class="keywordtype">bool</span> <a class="code" href="classFG__Button.html#b3">FG_Button::OnLButtonDown</a>(<a class="code" href="structFG__Message.html">FG_Message</a> * pMsg)00110 {00111 <span class="keywordflow">if</span> (<a class="code" href="classFG__Object.html#a14">FrameStyle</a>() == <a class="code" href="group__Frame__Style.html#ga2">FS_RAISED</a>)00112 {00113 <a class="code" href="classFG__Object.html#a14">FrameStyle</a>(<a class="code" href="group__Frame__Style.html#ga3">FS_RECESSED</a>);00114 <a class="code" href="classFG__Object.html#b4">RequestDraw</a>();00115 <a class="code" href="classFG__Object.html#b0">StartTimer</a>(<a class="code" href="classFG__Button.html#y1y0">TIMERID_UP</a>, <a class="code" href="group__Utility.html#ga6">BUTTON_UP_INTERVAL</a>);00116 }00117 <span class="keywordflow">return</span> <span class="keyword">true</span>;00118 }00119 00120 <span class="comment">//##ModelId=3F71AE32002A</span><a name="l00121"></a><a class="code" href="classFG__Button.html#b4">00121</a> <span class="keywordtype">bool</span> <a class="code" href="classFG__Button.html#b4">FG_Button::OnLButtonUp</a>(<a class="code" href="structFG__Message.html">FG_Message</a> * pMsg)00122 {00123 <span class="keywordflow">if</span> (<a class="code" href="classFG__Object.html#a14">FrameStyle</a>() == <a class="code" href="group__Frame__Style.html#ga3">FS_RECESSED</a>)00124 {00125 <a class="code" href="classFG__Object.html#a14">FrameStyle</a>(<a class="code" href="group__Frame__Style.html#ga2">FS_RAISED</a>);00126 <a class="code" href="classFG__Object.html#b4">RequestDraw</a>();00127 <a class="code" href="classFG__Object.html#b1">KillTimer</a>(<a class="code" href="classFG__Button.html#y1y0">TIMERID_UP</a>);00128 <a class="code" href="classFG__Object.html#b3">NotifyParent</a>(<a class="code" href="group__Utility.html#gga16a38">FBN_PRESSED</a>);00129 }00130 <span class="keywordflow">return</span> <span class="keyword">true</span>;00131 }00132 00133 <span class="comment">//##ModelId=3F71AE32003E</span><a name="l00134"></a><a class="code" href="classFG__Button.html#b5">00134</a> <span class="keywordtype">void</span> <a class="code" href="classFG__Button.html#b5">FG_Button::OnTimerUp</a>()00135 {00136 <a class="code" href="classFG__Object.html#a14">FrameStyle</a>(<a class="code" href="group__Frame__Style.html#ga2">FS_RAISED</a>);00137 <a class="code" href="classFG__Object.html#b4">RequestDraw</a>();00138 <a class="code" href="classFG__Object.html#b1">KillTimer</a>(<a class="code" href="classFG__Button.html#y1y0">TIMERID_UP</a>);00139 <a class="code" href="classFG__Object.html#b3">NotifyParent</a>(<a class="code" href="group__Utility.html#gga16a38">FBN_PRESSED</a>);00140 }00141 </pre></div><hr><center>由 DoxyGen 1.3.6 于 Wed Jun 9 22:34:40 2004 生成<br>版权所有 (C) 2003,2004 王咏武</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -