00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "ExCWindowMessageBoxQuestion.h"
00024
00025
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
00082
00083 void ExCWindowMessageBoxQuestion::Draw(void)
00084 {
00085 Guard(void ExCWindowMessageBoxQuestion::Draw(void))
00086
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
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
00157
00158
00159
00160
00161
00162
00163 return Action;
00164 UnGuard
00165 }
00166
00167