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

PopupMenuItem.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 #include "guicolors.h" 00026 #ifdef _WIN32 00027 #pragma warning(push) 00028 00029 #include <yvals.h> // warning numbers get enabled in yvals.h 00030 00031 #pragma warning(disable: 4251) 00032 #pragma warning(disable: 4786) // identifier was truncated to 'number' characters in the debug information 00033 00034 // BUG: C4786 Warning Is Not Disabled with #pragma Warning 00035 // STATUS: Microsoft has confirmed this to be a bug in the Microsoft product. This warning can be ignored. 00036 // This occured only in the <map> container. 00037 00038 #include <sge.h> 00039 00040 #pragma warning(pop) 00041 #else 00042 #include <sge.h> 00043 #endif 00044 //#include <iotm/Mutex.h> 00045 #include "SDL_prim.h" 00046 00047 #include "Surface.h" 00048 #include "MenuItem.h" 00049 #include "Menu.h" 00050 #include "SDLControl.h" 00051 #include "PopupMenuItem.h" 00052 #include "Xml.h" 00053 00054 using util::Xml; 00055 00056 00057 namespace gui 00058 { 00059 00060 00061 PopupMenuItem::PopupMenuItem(Surface *s,const string &str,TTFont *font,int id,SurfaceHelper *pclHelper) 00062 :MenuItem(s,str,font,pclHelper) 00063 ,m_id(id) 00064 ,m_pclSubmenu(NULL) 00065 { 00066 } 00067 00068 00069 PopupMenuItem::~PopupMenuItem() 00070 { 00071 if (m_pclSubmenu) 00072 { 00073 delete m_pclSubmenu; 00074 } 00075 } 00076 00077 00078 void PopupMenuItem::OnClick(coord_t xx,coord_t yy) 00079 { 00080 Menu *pclMenu = static_cast<Menu *>(GetParent()); 00081 Surface *pclParent = pclMenu -> GetParent(); 00082 coord_t x = pclMenu -> GetX() + pclMenu -> GetW(); 00083 coord_t y = pclMenu -> GetY() + GetY(); 00084 00085 DEB(printf("PopupMenuItem::OnClick()\n");) 00086 00087 if (!m_pclSubmenu) 00088 { 00089 m_pclSubmenu = pclMenu -> GetSubMenu(m_id); 00090 if (!m_pclSubmenu) 00091 { 00092 DEB(printf(" * m_pclSubmenu NULL\n");) 00093 return; 00094 } 00095 if (x + m_pclSubmenu -> GetW() >= GetSDLControl() -> GetScreen() -> w || 00096 y + m_pclSubmenu -> GetH() >= GetSDLControl() -> GetScreen() -> h) 00097 { 00098 DEB(printf(" * m_pclSubmenu offscreen\n");) 00099 delete m_pclSubmenu; 00100 m_pclSubmenu = NULL; 00101 return; 00102 } 00103 else 00104 { 00105 DEB(printf(" * m_pclSubmenu created\n");) 00106 pclParent -> AddChild(m_pclSubmenu); 00107 } 00108 } 00109 else 00110 { 00111 DEB(printf(" * m_pclSubmenu exists\n");) 00112 } 00113 m_pclSubmenu -> SetX(x); 00114 m_pclSubmenu -> SetY(y); 00115 pclParent -> CalculateAbsolute(); 00116 m_pclSubmenu -> InvalidateEv(); 00117 pclMenu -> ActivateSubMenu(m_pclSubmenu, x, y); 00118 } 00119 00120 00121 void PopupMenuItem::Draw() 00122 { 00123 SDL_Rect *a = GetClientRectPtr(); 00124 00125 MenuItem::Draw(); 00126 00127 #define DIST 3 00128 00129 coord_t x1 = a -> x + a -> w - a -> h + DIST; 00130 coord_t y1 = DIST; 00131 coord_t x2 = a -> x + a -> w - DIST; 00132 coord_t y2 = a -> h / 2; 00133 coord_t x3 = x1; 00134 coord_t y3 = a -> h - DIST; 00135 00136 SDL_fillTriangle(GetScreen(), x1,y1, x2,y2, x3,y3, GetFgColor()); 00137 } 00138 00139 00140 void PopupMenuItem::DumpMembers(FILE *fil) 00141 { 00142 Xml xml(fil); 00143 00144 MenuItem::DumpMembers(fil); 00145 00146 xml.Write("POPUPMENUID", (long)m_id); 00147 } 00148 00149 00150 } // namespace 00151

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