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

📄 wg__timer_8cpp-source.html

📁 一个小巧的嵌入式图形系统wGUI, 可以用VC编译
💻 HTML
字号:
<!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_timer.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_timer.cpp</h1><div class="fragment"><pre>00001 <span class="comment">// wg_timer.cpp</span>00002 <span class="comment">//</span>00003 <span class="comment">// CTimer 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_timer.h"</span>00027 <span class="preprocessor">#include "wg_message_server.h"</span>00028 00029 00030 <span class="keyword">namespace </span>wGui00031 {00032 00033 Uint32 TimerCallback(Uint32 Interval, <span class="keywordtype">void</span>* param)00034 {00035      <span class="keywordflow">return</span> static_cast&lt;CTimer*&gt;(param)-&gt;TimerHit(Interval);00036 }00037 00038 <a name="l00039"></a><a class="code" href="classwGui_1_1CTimer.html#a0">00039</a> CTimer::CTimer(<a class="code" href="classwGui_1_1CMessageClient.html">CMessageClient</a>* pOwner) :00040      m_TimerID(0),00041      m_bAutoRestart(false),00042      m_iCounter(0),00043      m_pOwner(pOwner)00044 {00045 00046 }00047 00048 <a name="l00049"></a><a class="code" href="classwGui_1_1CTimer.html#a1">00049</a> CTimer::~CTimer(<span class="keywordtype">void</span>)00050 {00051      <a class="code" href="classwGui_1_1CTimer.html#a3">StopTimer</a>();00052 }00053 00054 <a name="l00055"></a><a class="code" href="classwGui_1_1CTimer.html#a2">00055</a> <span class="keywordtype">void</span> CTimer::StartTimer(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> Interval, <span class="keywordtype">bool</span> bAutoRestart)00056 {00057      <a class="code" href="classwGui_1_1CTimer.html#n1">m_bAutoRestart</a> = bAutoRestart;00058      <span class="keywordflow">if</span> (!<a class="code" href="classwGui_1_1CTimer.html#n0">m_TimerID</a>)00059      {00060           <a class="code" href="classwGui_1_1CTimer.html#n0">m_TimerID</a> = SDL_AddTimer(Interval, &amp;TimerCallback, <span class="keyword">this</span>);00061      }00062 }00063 00064 <a name="l00065"></a><a class="code" href="classwGui_1_1CTimer.html#a3">00065</a> <span class="keywordtype">void</span> CTimer::StopTimer(<span class="keywordtype">void</span>)00066 {00067      <span class="keywordflow">if</span> (m_TimerID)00068      {00069           SDL_RemoveTimer(<a class="code" href="classwGui_1_1CTimer.html#n0">m_TimerID</a>);00070           <a class="code" href="classwGui_1_1CTimer.html#n0">m_TimerID</a> = 0;00071      }00072 }00073 00074 <a name="l00075"></a><a class="code" href="classwGui_1_1CTimer.html#a7">00075</a> Uint32 CTimer::TimerHit(Uint32 Interval)00076 {00077      <a class="code" href="classwGui_1_1CTimer.html#n2">m_iCounter</a>++;00078      CMessageServer::Instance().QueueMessage(<span class="keyword">new</span> TIntMessage(CMessage::CTRL_TIMER, <a class="code" href="classwGui_1_1CTimer.html#n3">m_pOwner</a>, <span class="keyword">this</span>, <a class="code" href="classwGui_1_1CTimer.html#n2">m_iCounter</a>));00079      <span class="keywordflow">if</span> (!<a class="code" href="classwGui_1_1CTimer.html#n1">m_bAutoRestart</a>)00080      {00081           <a class="code" href="classwGui_1_1CTimer.html#a3">StopTimer</a>();00082      }00083 00084      <span class="keywordflow">return</span> Interval;00085 }00086 00087 <a name="l00088"></a><a class="code" href="classwGui_1_1CTimer.html#a8">00088</a> <span class="keywordtype">bool</span> CTimer::HandleMessage(<a class="code" href="classwGui_1_1CMessage.html">CMessage</a>* <span class="comment">/*pMessage*/</span>)00089 {00090      <span class="keywordtype">bool</span> bHandled = <span class="keyword">false</span>;00091 00092      <span class="keywordflow">return</span> bHandled;00093 }00094 00095 }00096 </pre></div><hr><address style="align: right;"><small>Generated on Sat Oct 25 12:43:25 2003 for wGui by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53></a>1.2.18 </small></address></body></html>

⌨️ 快捷键说明

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