Page principale | Liste des namespaces | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Membres des namespaces | Composants | Déclarations

ExCWindowMessageBoxQuestion.cpp

Aller à la documentation de ce fichier.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020  *
00021  */
00022 
00023 #include "ExCWindowMessageBoxQuestion.h"
00024 //--------------------------------
00025 // Constructor // Destructor
00026 //--------------------------------
00027 ExCWindowMessageBoxQuestion::ExCWindowMessageBoxQuestion(void)
00028 {
00029 Guard(ExCWindowMessageBoxQuestion::ExCWindowMessageBoxQuestion(void))
00030         Init();
00031 UnGuard
00032 }
00033 
00034 ExCWindowMessageBoxQuestion::ExCWindowMessageBoxQuestion(std::string Message,ExCAction Yes,ExCAction No)
00035 {
00036 Guard(ExCWindowMessageBoxQuestion::ExCWindowMessageBoxQuestion(std::string Message,ExCAction Yes,ExCAction No))
00037         m_Message=Message;
00038         m_YesAction=Yes;
00039         m_NoAction=No;
00040         Init();
00041         RefreshSize();
00042         RefreshPosotion();
00043 UnGuard
00044 }
00045 
00046 void ExCWindowMessageBoxQuestion::Init(void)
00047 {
00048 Guard(void ExCWindowMessageBoxQuestion::Init(void))
00049         ExCWindow::Init();
00050         SetName("ExCWindow");
00051         SetType(typeid(this).name());
00052         SetPosition(ExCVec2D(ExNihilo::GetResolutionX()/2-150,(ExNihilo::GetResolutionY()/2)-50));
00053         SetOldPosition(ExCVec2D(ExNihilo::GetResolutionX()/2-150,(ExNihilo::GetResolutionY()/2)-50));
00054         SetWindowSize(ExCVec2D(300,100));
00055         SetOldWindowSize(ExCVec2D(300,100));
00056         m_Window.SetBackroundColor(ExCVec3D(0.5f,0.5f,0.5f));
00057         m_Window.SetBorderColor(ExCVec3D(0.2f,0.2f,0.2f));
00058         m_YesButton = new ExCWindowButton;
00059         m_YesButton->SetWindowSize(ExCVec2D(50,20));
00060         m_YesButton->SetPosition(ExCVec2D(75,50));
00061         m_YesButton->SetWindowTitle("   YES   ");
00062         m_YesButton->ShowWindowTitle(true);
00063         m_YesButton->AddActionCommand(m_YesAction,ExCCommand(MOUSE_LEFT_BUTTON_DOWN));
00064         m_NoButton = new ExCWindowButton;
00065         m_NoButton->SetWindowSize(ExCVec2D(50,20));
00066         m_NoButton->SetPosition(ExCVec2D(175,50));
00067         m_NoButton->SetWindowTitle("   NO   ");
00068         m_NoButton->ShowWindowTitle(true);
00069         m_NoButton->AddActionCommand(m_NoAction,ExCCommand(MOUSE_LEFT_BUTTON_DOWN));
00070         m_Window.AddObjectControl(m_YesButton);
00071         m_Window.AddObjectControl(m_NoButton);
00072         m_CurrentSelection=true;
00073 UnGuard
00074 }
00075 
00076 ExCWindowMessageBoxQuestion::~ExCWindowMessageBoxQuestion(void)
00077 {
00078 }
00079 
00080 //--------------------------------
00081 // Methode
00082 //--------------------------------
00083 void ExCWindowMessageBoxQuestion::Draw(void)
00084 {
00085 Guard(void ExCWindowMessageBoxQuestion::Draw(void))
00086         //std::cout<<"Draw ExCWindowMessageBoxQuestion"<<std::endl;
00087         ExNihilo::EnterOrthoMode();
00088         glPushAttrib(GL_ALL_ATTRIB_BITS);
00089                 glDisable(GL_LIGHTING);
00090                 if(m_CurrentSelection)
00091                 {
00092                         m_YesButton->SetBorderColor(ExCVec3D(0.0f,0.0f,0.0f));
00093                         m_NoButton->SetBorderColor(ExCVec3D(0.4f,0.4f,0.4f));
00094                 }
00095                 else
00096                 {
00097                         m_YesButton->SetBorderColor(ExCVec3D(0.4f,0.4f,0.4f));
00098                         m_NoButton->SetBorderColor(ExCVec3D(0.0f,0.0f,0.0f));
00099                 }
00100                 m_Window.Draw();
00101                 glColor3f(0.0f,0.0f,0.0f);
00102                 ExNihilo::WriteToScreen(m_Position.GetX()+5,m_Position.GetY()+5+m_WindowSize.GetY()/2,m_Message);
00103         glPopAttrib();
00104         ExNihilo::LeaveOrthoMode();
00105 UnGuard
00106 }
00107 
00108 
00109 
00110 ExCAction ExCWindowMessageBoxQuestion::InputCommand(ExCCommand Command)
00111 {
00112 Guard(ExCAction ExCWindowMessageBoxQuestion::InputCommand(ExCCommand Command))
00113         //std::cout<<"ExCWindow::Input Command window:"<<Command.m_Command<<std::endl;
00114         switch(Command.m_Command)
00115         {
00116         case KEYBOARD_DOWN_ENTER:
00117                 m_BeClosed=true;
00118                 if(m_CurrentSelection)
00119                 {
00120                         std::cout<<"YesAction:"<<m_YesAction<<std::endl;
00121                         return m_YesAction;
00122                 }
00123                 else
00124                 {
00125                         
00126                         return m_NoAction;
00127                 }
00128                 return CLOSE_OBJECT_WINDOW;
00129         case KEYBOARD_DOWN_ARROW_LEFT:
00130         case KEYBOARD_DOWN_ARROW_RIGHT: 
00131                 if(m_CurrentSelection){m_CurrentSelection=false;}
00132                 else m_CurrentSelection=true;
00133                 break;
00134         case MOUSE_LEFT_BUTTON_DOWN:
00135                 if(m_TitleBar.PointInWindow(ExCVec2D(Command.m_MousePosx,Command.m_MousePosy)))
00136                 {
00137                         m_BeClosed=true;
00138                         return InputAction(m_TitleBar.InputCommand(Command));
00139                 }
00140                 if(m_Window.PointInWindow(ExCVec2D(Command.m_MousePosx,Command.m_MousePosy)))
00141                 {
00142                         m_BeClosed=true;
00143                         return InputAction(m_Window.InputCommand(Command));
00144                 }
00145 
00146                 break;
00147         }
00148         
00149         return NOTHING;
00150 UnGuard
00151 }
00152 
00153 ExCAction ExCWindowMessageBoxQuestion::InputAction(ExCAction Action)
00154 {
00155 Guard(ExCAction ExCWindowMessageBoxQuestion::InputAction(ExCAction Action))
00156         /*switch(Action.m_Action)
00157         {
00158         default:
00159                 return Action;
00160         }
00161         if(Action.m_NextAction){return *Action.m_NextAction;}
00162         else{return NOTHING;}*/
00163         return Action;
00164 UnGuard
00165 }
00166 
00167 

Généré le Tue Oct 28 12:43:34 2003 pour ExNihilo par doxygen 1.3.4