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

📄 wg__rect_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_rect.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_rect.cpp</h1><div class="fragment"><pre>00001 <span class="comment">// wg_rect.cpp</span>00002 <span class="comment">//</span>00003 <span class="comment">// CRect 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_rect.h"</span>00027 <span class="preprocessor">#include "wg_error.h"</span>00028 <span class="preprocessor">#include &lt;algorithm&gt;</span>00029 <span class="preprocessor">#ifdef WIN32</span>00030 <span class="preprocessor"></span><span class="preprocessor">#include &lt;limits&gt;</span>00031 <span class="preprocessor">#endif // WIN32</span>00032 <span class="preprocessor"></span>00033 00034 <span class="keyword">namespace </span>wGui00035 {00036 00037 <a name="l00038"></a><a class="code" href="classwGui_1_1CRect.html#a22">00038</a> SDL_Rect CRect::SDLRect(<span class="keywordtype">void</span>)<span class="keyword"> const</span>00039 <span class="keyword"></span>{00040 <span class="preprocessor">#ifdef WIN32</span>00041 <span class="preprocessor"></span><span class="preprocessor">#ifndef MSVC6  // There are problems with VC6 and these std lib template classes</span>00042 <span class="preprocessor"></span>     <span class="keywordflow">if</span> (m_Left &lt; std::numeric_limits&lt;short int&gt;::min() ||<a class="code" href="classwGui_1_1CRect.html#n0">m_Left</a> &gt; std::numeric_limits&lt;short int&gt;::max()00043           || m_Top &lt; std::numeric_limits&lt;short int&gt;::min() ||<a class="code" href="classwGui_1_1CRect.html#n2">m_Top</a> &gt; std::numeric_limits&lt;short int&gt;::max()00044           || m_Right &lt; std::numeric_limits&lt;short int&gt;::min() ||<a class="code" href="classwGui_1_1CRect.html#n1">m_Right</a> &gt; std::numeric_limits&lt;short int&gt;::max()00045           || m_Bottom &lt; std::numeric_limits&lt;short int&gt;::min() ||<a class="code" href="classwGui_1_1CRect.html#n3">m_Bottom</a> &gt; std::numeric_limits&lt;short int&gt;::max())00046      {00047           <span class="keywordflow">throw</span>(<a class="code" href="classwGui_1_1Wg__Ex__Range.html">Wg_Ex_Range</a>(<span class="stringliteral">"CRect::SDLRect : Out of range - converting int to short int!"</span>));00048      }00049 <span class="preprocessor">#endif // MSVC6</span>00050 <span class="preprocessor"></span><span class="preprocessor">#endif // WIN32</span>00051 <span class="preprocessor"></span>     SDL_Rect sdlRect;00052      <span class="comment">//Normalize the rect...</span>00053      sdlRect.x = static_cast&lt;short int&gt;(std::min(<a class="code" href="classwGui_1_1CRect.html#n0">m_Left</a>, <a class="code" href="classwGui_1_1CRect.html#n1">m_Right</a>));00054      sdlRect.y = static_cast&lt;short int&gt;(std::min(<a class="code" href="classwGui_1_1CRect.html#n2">m_Top</a>, <a class="code" href="classwGui_1_1CRect.html#n3">m_Bottom</a>));00055      sdlRect.w = static_cast&lt;short int&gt;(<a class="code" href="classwGui_1_1CRect.html#a23">Width</a>());00056      sdlRect.h = static_cast&lt;short int&gt;(<a class="code" href="classwGui_1_1CRect.html#a24">Height</a>());00057 00058      <span class="keywordflow">return</span> sdlRect;00059 }00060 00061 00062 <span class="comment">// assignment operator</span><a name="l00063"></a><a class="code" href="classwGui_1_1CRect.html#a25">00063</a> <a class="code" href="classwGui_1_1CRect.html">CRect</a>&amp; CRect::operator=(<span class="keyword">const</span> <a class="code" href="classwGui_1_1CRect.html">CRect</a>&amp; r)00064 {00065      <a class="code" href="classwGui_1_1CRect.html#n2">m_Top</a> = r.<a class="code" href="classwGui_1_1CRect.html#a9">Top</a>();00066      <a class="code" href="classwGui_1_1CRect.html#n0">m_Left</a> = r.<a class="code" href="classwGui_1_1CRect.html#a10">Left</a>();00067      <a class="code" href="classwGui_1_1CRect.html#n1">m_Right</a> = r.<a class="code" href="classwGui_1_1CRect.html#a11">Right</a>();00068      <a class="code" href="classwGui_1_1CRect.html#n3">m_Bottom</a> = r.<a class="code" href="classwGui_1_1CRect.html#a12">Bottom</a>();00069 00070      <span class="keywordflow">return</span> *<span class="keyword">this</span>;00071 }00072 00073 <a name="l00074"></a><a class="code" href="classwGui_1_1CRect.html#a26">00074</a> <a class="code" href="classwGui_1_1CRect.html">CRect</a> CRect::operator+(<span class="keyword">const</span> <a class="code" href="classwGui_1_1CPoint.html">CPoint</a>&amp; p)<span class="keyword"> const</span>00075 <span class="keyword"></span>{00076      <a class="code" href="classwGui_1_1CRect.html">CRect</a> result(<a class="code" href="classwGui_1_1CRect.html#n0">m_Left</a> + p.<a class="code" href="classwGui_1_1CPoint.html#a6">XPos</a>(), <a class="code" href="classwGui_1_1CRect.html#n2">m_Top</a> + p.<a class="code" href="classwGui_1_1CPoint.html#a7">YPos</a>(), <a class="code" href="classwGui_1_1CRect.html#n1">m_Right</a> + p.<a class="code" href="classwGui_1_1CPoint.html#a6">XPos</a>(), <a class="code" href="classwGui_1_1CRect.html#n3">m_Bottom</a> + p.<a class="code" href="classwGui_1_1CPoint.html#a7">YPos</a>());00077 00078      <span class="keywordflow">return</span> result;00079 }00080 00081 <a name="l00082"></a><a class="code" href="classwGui_1_1CRect.html#a27">00082</a> <a class="code" href="classwGui_1_1CRect.html">CRect</a> CRect::operator-(<span class="keyword">const</span> <a class="code" href="classwGui_1_1CPoint.html">CPoint</a>&amp; p)<span class="keyword"> const</span>00083 <span class="keyword"></span>{00084      <a class="code" href="classwGui_1_1CRect.html">CRect</a> result(<a class="code" href="classwGui_1_1CRect.html#n0">m_Left</a> - p.<a class="code" href="classwGui_1_1CPoint.html#a6">XPos</a>(), <a class="code" href="classwGui_1_1CRect.html#n2">m_Top</a> - p.<a class="code" href="classwGui_1_1CPoint.html#a7">YPos</a>(), <a class="code" href="classwGui_1_1CRect.html#n1">m_Right</a> - p.<a class="code" href="classwGui_1_1CPoint.html#a6">XPos</a>(), <a class="code" href="classwGui_1_1CRect.html#n3">m_Bottom</a> - p.<a class="code" href="classwGui_1_1CPoint.html#a7">YPos</a>());00085 00086      <span class="keywordflow">return</span> result;00087 }00088 00089 <a name="l00090"></a><a class="code" href="classwGui_1_1CRect.html#a28">00090</a> <a class="code" href="classwGui_1_1CRect.html">CRect</a>&amp; CRect::Grow(<span class="keywordtype">int</span> iGrowAmount)00091 {

⌨️ 快捷键说明

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