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

Menu.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 00045 #include "TTFont.h" 00046 #include "Surface.h" 00047 #include "Hotspot.h" 00048 #include "MenuItem.h" 00049 #include "Menu.h" 00050 00051 00052 namespace gui 00053 { 00054 00055 00056 Menu::Menu(Surface *s,SurfaceHelper *pclHelper) 00057 :Surface(s,pclHelper) 00058 ,m_w(0) 00059 ,m_h(0) 00060 ,m_pclSubMenu(NULL) 00061 { 00062 SetFrameWidth(DIALOG_DEFAULT_FW); 00063 } 00064 00065 00066 Menu::~Menu() 00067 { 00068 } 00069 00070 00071 void Menu::AddMenuItem(MenuItem *pclItem) 00072 { 00073 m_w = pclItem -> GetW() > m_w ? pclItem -> GetW() : m_w; 00074 pclItem -> SetY(m_h); 00075 m_h += pclItem -> GetH(); 00076 00077 // m_items.insert(m_items.end(), pclItem); 00078 AddChild(pclItem); 00079 } 00080 00081 00082 void Menu::CreateMenu() 00083 { 00084 surfacevector_t::iterator it; 00085 int fw = GetFrameWidth(); 00086 00087 for (it = m_ChildList.begin(); it != m_ChildList.end(); it++) 00088 { 00089 MenuItem *pclItem = static_cast<MenuItem *>(*it); 00090 pclItem -> SetW(m_w); 00091 pclItem -> CreateMenuItem(); 00092 } 00093 00094 SetW(m_w + fw * 2); 00095 SetH(m_h + fw * 2); 00096 00097 RecreateSurfaces(); 00098 00099 // SetBgColor(192,192,192); 00100 // SetFgColor(128,255,255); 00101 SetBgColor(DIALOG_DEFAULT_BG_R,DIALOG_DEFAULT_BG_G,DIALOG_DEFAULT_BG_B); 00102 SetFrameColor(DIALOG_DEFAULT_FC_R,DIALOG_DEFAULT_FC_G,DIALOG_DEFAULT_FC_B); 00103 } 00104 00105 00106 void Menu::Draw() 00107 { 00108 SDL_Rect *area = GetClientRectPtr(); 00109 Uint32 color = GetBgColor(); 00110 00111 SDL_FillRect(m_screen, area, color); 00112 } 00113 00114 00115 void Menu::OnRightClick(coord_t x,coord_t y) 00116 { 00117 Surface *head = this; 00118 00119 while (head -> GetBond()) 00120 { 00121 head = head -> GetBond(); 00122 } 00123 head -> CloseAll(); 00124 head -> RemoveAllBonds(); 00125 } 00126 00127 00128 void Menu::ActivateSubMenu(Menu *pclMenu,coord_t x,coord_t y) 00129 { 00130 if (m_pclSubMenu && m_pclSubMenu -> IsVisible()) 00131 { 00132 SDL_Rect a = m_pclSubMenu -> GetAbsoluteRect(); 00133 InvalidateRectEv(a); 00134 m_pclSubMenu -> SetVisible(false); 00135 Unbond(m_pclSubMenu); 00136 } 00137 m_pclSubMenu = pclMenu; 00138 m_pclSubMenu -> SetX(x); 00139 m_pclSubMenu -> SetY(y); 00140 GetParent() -> CalculateAbsolute(); 00141 m_pclSubMenu -> SetVisible(true); 00142 m_pclSubMenu -> SetDirty(true); 00143 m_pclSubMenu -> InvalidateEv(); 00144 Bond(m_pclSubMenu); 00145 } 00146 00147 00148 Menu *Menu::GetSubMenu(int id) 00149 { 00150 return NULL; 00151 } 00152 00153 00154 } // 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