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

📄 wg__view_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_view.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_view.cpp</h1><div class="fragment"><pre>00001 <span class="comment">// wg_view.cpp</span>00002 <span class="comment">//</span>00003 <span class="comment">// CView 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_view.h"</span>00027 <span class="preprocessor">#include "wg_error.h"</span>00028 <span class="preprocessor">#include "wg_painter.h"</span>00029 <span class="preprocessor">#include "wg_message_server.h"</span>00030 <span class="preprocessor">#include "wg_application.h"</span>00031 00032 00033 <span class="keyword">namespace </span>wGui00034 {00035 00036 CView* CView::m_pInstance = 0;00037 00038 <a name="l00039"></a><a class="code" href="classwGui_1_1CView.html#a0">00039</a> CView::CView(<span class="keyword">const</span> <a class="code" href="classwGui_1_1CRect.html">CRect</a>&amp; WindowRect, std::string sTitle, <span class="keywordtype">bool</span> bResizable, <span class="keywordtype">bool</span> bFullScreen) :00040      <a class="code" href="classwGui_1_1CWindow.html">CWindow</a>(WindowRect, 0),00041      m_bResizable(bResizable),00042      m_bFullScreen(bFullScreen),00043      m_pMenu(0)00044 {00045   <a class="code" href="classwGui_1_1CWindow.html#n8">m_sClassName</a> = <span class="stringliteral">"CView"</span>;00046      <span class="keywordflow">if</span> (m_pInstance)00047      {00048           <span class="keywordflow">throw</span>(<a class="code" href="classwGui_1_1Wg__Ex__App.html">Wg_Ex_App</a>(<span class="stringliteral">"Cannot have more than one view at a time!"</span>));00049      }00050      m_pInstance = <span class="keyword">this</span>;00051      <a class="code" href="classwGui_1_1CWindow.html#n0">m_sWindowText</a> = sTitle;00052      Uint32 iFlags = SDL_HWSURFACE | SDL_ANYFORMAT;00053      <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CView.html#n0">m_bResizable</a> &amp;&amp; !<a class="code" href="classwGui_1_1CView.html#n1">m_bFullScreen</a>)00054      {00055           iFlags |= SDL_RESIZABLE;00056      }00057      <span class="keywordflow">if</span> (m_bFullScreen)00058      {00059           iFlags |= SDL_FULLSCREEN;00060           <a class="code" href="classwGui_1_1CView.html#n0">m_bResizable</a> = <span class="keyword">false</span>;00061      }00062      <a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a> = SDL_SetVideoMode(<a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a23">Width</a>(), <a class="code" href="classwGui_1_1CWindow.html#n1">m_WindowRect</a>.<a class="code" href="classwGui_1_1CRect.html#a24">Height</a>(), DEFAULT_BPP, iFlags);00063      <span class="keywordflow">if</span> (<a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a> == NULL)00064      {00065           <span class="keywordflow">throw</span>(<a class="code" href="classwGui_1_1Wg__Ex__SDL.html">Wg_Ex_SDL</a>(std::string(<span class="stringliteral">"Could not set video mode : "</span>) + SDL_GetError()));00066      }00067      SDL_WM_SetCaption(<a class="code" href="classwGui_1_1CWindow.html#n0">m_sWindowText</a>.c_str(), <span class="stringliteral">""</span>);00068      CMessageServer::Instance().RegisterMessageClient(<span class="keyword">this</span>, CMessage::APP_PAINT);00069      CMessageServer::Instance().RegisterMessageClient(<span class="keyword">this</span>, CMessage::CTRL_RESIZE);00070      CMessageServer::Instance().RegisterMessageClient(<span class="keyword">this</span>, CMessage::MOUSE_BUTTONDOWN, CMessageServer::PRIORITY_FIRST);00071      CMessageServer::Instance().RegisterMessageClient(<span class="keyword">this</span>, CMessage::MOUSE_BUTTONUP, CMessageServer::PRIORITY_FIRST);00072      <span class="comment">// Send a message to the queue so that the view gets painted as soon as the app starts up</span>00073      CMessageServer::Instance().QueueMessage(<span class="keyword">new</span> <a class="code" href="classwGui_1_1CMessage.html">CMessage</a>(CMessage::APP_PAINT, <span class="keyword">this</span>, <span class="keyword">this</span>));00074 }00075 00076 <a name="l00077"></a><a class="code" href="classwGui_1_1CView.html#a1">00077</a> CView::~CView(<span class="keywordtype">void</span>)00078 {00079      <span class="keyword">delete</span> <a class="code" href="classwGui_1_1CView.html#n2">m_pMenu</a>;00080      SDL_FreeSurface(<a class="code" href="classwGui_1_1CWindow.html#n6">m_pSDLSurface</a>);00081      <span class="keywordflow">if</span> (m_pInstance == <span class="keyword">this</span>)00082      {00083           m_pInstance = 0;00084      }00085 }00086 00087 

⌨️ 快捷键说明

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