Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Output.cpp

Go to the documentation of this file.
00001 00006 /* 00007 Copyright (C) 2004 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 #include <SDL.h> 00024 #include "guitypedefs.h" 00025 #ifdef _WIN32 00026 #pragma warning(push) 00027 00028 #include <yvals.h> // warning numbers get enabled in yvals.h 00029 00030 #pragma warning(disable: 4251) 00031 #pragma warning(disable: 4786) // identifier was truncated to 'number' characters in the debug information 00032 00033 // BUG: C4786 Warning Is Not Disabled with #pragma Warning 00034 // STATUS: Microsoft has confirmed this to be a bug in the Microsoft product. This warning can be ignored. 00035 // This occured only in the <map> container. 00036 00037 #include <sge.h> 00038 00039 #pragma warning(pop) 00040 #else 00041 #include <sge.h> 00042 #endif 00043 //#include <iotm/Mutex.h> // iotm 00044 00045 #include "TTFont.h" 00046 #include "SDLControl.h" 00047 #include "Surface.h" 00048 #include "Output.h" 00049 00050 00051 namespace gui 00052 { 00053 00054 00055 Output::Output(Surface *s,coord_t x,coord_t y,coord_t w,coord_t h,SurfaceHelper *pclHelper) 00056 :Surface(s,x,y,w,h,pclHelper) 00057 { 00058 } 00059 00060 00061 Output::~Output() 00062 { 00063 } 00064 00065 00066 void Output::AddLine(const string &str) 00067 { 00068 TTFont *font = GetTTFont(); 00069 stringvector_t::iterator it; 00070 00071 // m_mutex.Lock(); 00072 m_lines = GetH() / font -> GetH(); 00073 while (m_strings.size() < (unsigned)m_lines) 00074 { 00075 m_strings.insert(m_strings.end(), ""); 00076 } 00077 00078 m_strings.insert(m_strings.end(), str); 00079 while (m_strings.size() > (unsigned)m_lines) 00080 { 00081 m_strings.erase(m_strings.begin()); 00082 } 00083 // m_mutex.Unlock(); 00084 SetDirty(true); 00085 // DrawAll(); 00086 // RedrawEv(); 00087 // m_mutex.Lock(); 00088 SDL_Rect r = GetAbsoluteRect(); 00089 r.w = 0; 00090 for (it = m_strings.begin(); it != m_strings.end(); it++) 00091 { 00092 SDL_Rect rect = sge_TTF_TextSize(font -> GetFont(), (char *)(*it).c_str() ); 00093 if (rect.w > r.w) 00094 { 00095 r.w = rect.w; 00096 } 00097 } 00098 // m_mutex.Unlock(); 00099 DEB(printf("InvalidateRectEv(%d,%d,%d,%d)\n",r.x,r.y,r.w,r.h);) 00100 InvalidateRectEv(r); 00101 } 00102 00103 00104 void Output::Draw() 00105 { 00106 stringvector_t::iterator it; 00107 SDL_Rect *area = GetClientRectPtr(); 00108 Uint32 color; 00109 TTFont *font = GetTTFont(); 00110 SDL_Color fg; 00111 SDL_Color bg; 00112 coord_t x = 0; 00113 coord_t y = font -> GetH(); 00114 00115 color = GetFgColor(); 00116 memmove(&fg,&color,4); 00117 color = GetBgColor(); 00118 memmove(&bg,&color,4); 00119 00120 SDL_FillRect(m_screen, area, color ); 00121 // m_mutex.Lock(); 00122 for (it = m_strings.begin(); it != m_strings.end(); it++) 00123 { 00124 sge_tt_textoutf(m_screen, font -> GetFont(), 00125 x,y, 00126 fg.r,fg.g,fg.b, 00127 bg.r,bg.g,bg.b, 00128 SDL_ALPHA_OPAQUE, 00129 "%s",(*it).c_str()); 00130 y += font -> GetH(); 00131 } 00132 // m_mutex.Unlock(); 00133 } 00134 00135 00136 } // namespace

Generated for My SDL C++ Gui by doxygen 1.3.6

www.TV-friendship.com
The matchmaking service with an all new twist.

Quantum 'Teleportation'
Some thoughts
Page, code, and content Copyright (C) 2004 by Anders Hedström