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

# ExCWindowTitleBar.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 "ExCWindowTitleBar.h"
    00024 //--------------------------------
    00025 // Constructor // Destructor
    00026 //--------------------------------
    00027 ExCWindowTitleBar::ExCWindowTitleBar(void)
    00028 {
    00029 Guard(ExCWindowTitleBar::ExCWindowTitleBar(void))
    00030         SetName("ExCWindowTitleBar");
    00031         SetType(typeid(this).name());
    00032         m_TitleBarSize=20;
    00033         Init();
    00034 UnGuard
    00035 }
    00036
    00037 ExCWindowTitleBar::~ExCWindowTitleBar(void)
    00038 {
    00039 }
    00040 //--------------------------------
    00041 // Methode
    00042 //--------------------------------
    00043 void ExCWindowTitleBar::Init(void)
    00044 {
    00045 Guard(void ExCWindowTitleBar::Init(void))
    00046         ExCWindowObject::Init();
    00047         //-----------------------------
    00048         //Create Bar
    00049         //-----------------------------
    00050         SetName("BarWindow"+GetWindowTitle());
    00051         ShowWindowTitle(true);
    00052         SetWindowTitle(GetWindowTitle());
    00053         SetWindowTitleColor(ExCVec3D(0.5f,0.0f,0.0f));
    00054         SetBackroundTexturing1(true,"bar");
    00055         SetBackroundTexturing2(true,"back3");
    00056         SetTextureIsMouving(true);
    00057         SetTextureMouvingVec(ExCVec2D(0.0001f,0.0f));
    00058         SetBackroundColor(ExCVec3D(1.0f,1.0f,1.0f));
    00059         SetCanMouve(true);
    00060         SetBorderColor(ExCVec3D(0.5f,0.5f,0.5f));
    00061         //------------------------------
    00062         m_CloseButton = new ExCWindowButton;
    00063         m_MaximizeButton = new ExCWindowButton;
    00064         m_MinimizeButton = new ExCWindowButton;
    00065         m_MinimizeToBarButton = new ExCWindowButton;
    00066         //------------------------------
    00067         m_CloseButton->SetName("CloseButton");
    00068         m_CloseButton->SetBackroundTexturing1(true,"ButtClose.bmp");
    00069         m_CloseButton->SetBackroundTexturing2(false,"NONE");
    00070         m_CloseButton->SetBackroundColor(ExCVec3D(0.5f,0.5f,0.5f));
    00071         m_CloseButton->AddActionCommand(ExCAction(CLOSE_OBJECT_WINDOW),ExCCommand(MOUSE_LEFT_BUTTON_DOWN));
    00072         //------------------------------
    00073         m_MaximizeButton->SetName("ButtMax");
    00074         m_MaximizeButton->SetBackroundTexturing1(true,"ButtMax.bmp");
    00075         m_MaximizeButton->SetBackroundTexturing2(false,"NONE");
    00076         m_MaximizeButton->SetBackroundColor(ExCVec3D(0.5f,0.5f,0.5f));
    00077         m_MaximizeButton->AddActionCommand(ExCAction(MAXIMIZE_OBJECT_WINDOW),ExCCommand(MOUSE_LEFT_BUTTON_DOWN));
    00078         //------------------------------
    00079         m_MinimizeButton->SetName("ButtMin");
    00080         m_MinimizeButton->SetBackroundTexturing1(true,"ButtMin.bmp");
    00081         m_MinimizeButton->SetBackroundTexturing2(false,"NONE");
    00082         m_MinimizeButton->SetBackroundColor(ExCVec3D(0.5f,0.5f,0.5f));
    00083         m_MinimizeButton->AddActionCommand(ExCAction(MINIMIZE_OBJECT_WINDOW),ExCCommand(MOUSE_LEFT_BUTTON_DOWN));
    00084         //------------------------------
    00085         m_MinimizeToBarButton->SetName("ButtBar");
    00086         m_MinimizeToBarButton->SetBackroundTexturing1(true,"ButtBar.bmp");
    00087         m_MinimizeToBarButton->SetBackroundTexturing2(false,"NONE");
    00088         m_MinimizeToBarButton->SetBackroundColor(ExCVec3D(0.5f,0.5f,0.5f));
    00089         m_MinimizeToBarButton->AddActionCommand(ExCAction(MINIMIZE_TO_BAR_OBJECT_WINDOW),ExCCommand(MOUSE_LEFT_BUTTON_DOWN));
    00090
    00091         m_CloseButton->SetWindowSize(ExCVec2D(m_TitleBarSize-3,m_TitleBarSize-4));
    00092         m_MaximizeButton->SetWindowSize(ExCVec2D(m_TitleBarSize-3,m_TitleBarSize-4));
    00093         m_MinimizeButton->SetWindowSize(ExCVec2D(m_TitleBarSize-3,m_TitleBarSize-4));
    00094         m_MinimizeToBarButton->SetWindowSize(ExCVec2D(m_TitleBarSize-3,m_TitleBarSize-4));
    00095
    00096         m_CloseButton->SetPosition(ExCVec2D(GetPosition().GetX()+m_WindowSize.GetX()-m_TitleBarSize,GetPosition().GetY()+2));
    00097         m_MaximizeButton->SetPosition(ExCVec2D(GetPosition().GetX()+m_WindowSize.GetX()-m_TitleBarSize*2,GetPosition().GetY()+2));
    00098         m_MinimizeButton->SetPosition(ExCVec2D(GetPosition().GetX()+m_WindowSize.GetX()-m_TitleBarSize*3,GetPosition().GetY()+2));
    00099         m_MinimizeToBarButton->SetPosition(ExCVec2D(GetPosition().GetX()+m_WindowSize.GetX()-m_TitleBarSize*4,GetPosition().GetY()+2));
    00100
    00101
    00102         AddObjectControl(m_CloseButton);
    00103         AddObjectControl(m_MaximizeButton);
    00104         AddObjectControl(m_MinimizeButton);
    00105         AddObjectControl(m_MinimizeToBarButton);
    00106
    00107 UnGuard
    00108 }
    00109
    00110 void ExCWindowTitleBar::Draw(void)
    00111 {
    00112 Guard(void ExCWindowTitleBar::Draw(void))
    00113         ExCWindowObject::Draw();
    00114 UnGuard
    00115 }
    00116
    00117 bool ExCWindowTitleBar::LoadFile(std::string FileName)
    00118 {
    00119 Guard(void ExCWindowTitleBar::LoadFile(std::string FileName))
    00120         /*char                  buffer[255],b[255];
    00121         std::string buffstring;
    00122         std::ifstream file,fileButton,fileControl;
    00123         #ifdef UNIX_SRC
    00124         sprintf(buffer, PREFIX "/ExNihilo/Data/Window/%s", FileName.data());
    00125         #else
    00126         sprintf(buffer, "../Data/Window/%s", FileName.data());
    00127         #endif
    00128         std::cout<<buffer<<std::endl;
    00129         file.open(buffer,std::ios::in);
    00130         if(file.is_open())
    00131         {
    00132                 memset(b,0,255);file.getline(b,256,'\n');
    00133                 try
    00134                 {
    00135                         buffstring=ExNihilo::ExtracValueFromSring(b,"<WindowHeader>","<#WindowHeader>");
    00136                         Load(&file);
    00137                         //READ CLOSE BUTTON
    00138                         memset(b,0,255);file.getline(b,256,'\n');
    00139                         buffstring=ExNihilo::ExtracValueFromSring(b,"<FileForButtonClose>","<#FileForButtonClose>");
    00140                         #ifdef UNIX_SRC
    00141                         sprintf(buffer, PREFIX "/ExNihilo/Data/Window/%s", buffstring.data());
    00142                         #else
    00143                         sprintf(buffer, "../Data/Window/%s", buffstring.data());
    00144                         #endif
    00145                         fileButton.open(buffer,std::ios::in);
    00146                         if(fileButton.is_open())
    00147                         {
    00148                                 memset(b,0,255);fileButton.getline(b,256,'\n');
    00149                                 buffstring=ExNihilo::ExtracValueFromSring(b,"<WindowHeader>","<#WindowHeader>");
    00150                                 m_CloseButton->Load(&fileButton);
    00151                                 m_CloseButton->SetBackroundColor(ExCVec3D(1.0f,1.0f,1.0f));
    00152                         }fileButton.close();
    00153                         //READ Maximize BUTTON
    00154                         memset(b,0,255);file.getline(b,256,'\n');
    00155                         buffstring=ExNihilo::ExtracValueFromSring(b,"<FileForButtonMaximize>","<#FileForButtonMaximize>");
    00156 #ifdef UNIX_SRC
    00157                         sprintf(buffer, PREFIX "/ExNihilo/Data/Window/%s", buffstring.data());
    00158 #else
    00159                         sprintf(buffer, "../Data/Window/%s", buffstring.data());
    00160 #endif
    00161                         fileButton.open(buffer,std::ios::in);
    00162                         if(fileButton.is_open())
    00163                         {
    00164                                 memset(b,0,255);fileButton.getline(b,256,'\n');
    00165                                 buffstring=ExNihilo::ExtracValueFromSring(b,"<WindowHeader>","<#WindowHeader>");
    00166                                 m_MaximizeButton->Load(&fileButton);
    00167                                 m_MaximizeButton->SetBackroundColor(ExCVec3D(1.0f,1.0f,1.0f));
    00168                         }fileButton.close();
    00169                         //READ Minimize BUTTON
    00170                         memset(b,0,255);file.getline(b,256,'\n');
    00171                         buffstring=ExNihilo::ExtracValueFromSring(b,"<FileForButtonMinimize>","<#FileForButtonMinimize>");
    00172 #ifdef UNIX_SRC
    00173                         sprintf(buffer, PREFIX "/ExNihilo/Data/Window/%s", buffstring.data());
    00174 #else
    00175                         sprintf(buffer, "../Data/Window/%s", buffstring.data());
    00176 #endif
    00177                         fileButton.open(buffer,std::ios::in);
    00178                         if(fileButton.is_open())
    00179                         {
    00180                                 memset(b,0,255);fileButton.getline(b,256,'\n');
    00181                                 buffstring=ExNihilo::ExtracValueFromSring(b,"<WindowHeader>","<#WindowHeader>");
    00182                                 m_MinimizeButton->Load(&fileButton);
    00183                                 m_MinimizeButton->SetBackroundColor(ExCVec3D(1.0f,1.0f,1.0f));
    00184                         }fileButton.close();
    00185                         //READ MinimizeToBar BUTTON
    00186                         memset(b,0,255);file.getline(b,256,'\n');
    00187                         buffstring=ExNihilo::ExtracValueFromSring(b,"<FileForButtonMinimizeToBar>","<#FileForButtonMinimizeToBar>");
    00188 #ifdef UNIX_SRC
    00189                         sprintf(buffer, PREFIX "/ExNihilo/Data/Window/%s", buffstring.data());
    00190 #else
    00191                         sprintf(buffer, "../Data/Window/%s", buffstring.data());
    00192 #endif
    00193                         fileButton.open(buffer,std::ios::in);
    00194                         if(fileButton.is_open())
    00195                         {
    00196                                 memset(b,0,255);fileButton.getline(b,256,'\n');
    00197                                 buffstring=ExNihilo::ExtracValueFromSring(b,"<WindowHeader>","<#WindowHeader>");
    00198                                 //ReadWindowObject(win->GetButtonMinimizeToBar(),&fileButton);
    00199                                 m_MinimizeToBarButton->Load(&fileButton);
    00200                                 m_MinimizeToBarButton->SetBackroundColor(ExCVec3D(1.0f,1.0f,1.0f));
    00201                         }fileButton.close();
    00202
    00203
    00204                 }catch(ExCExpStringNotFound)
    00205                 {
    00206                         std::cout<<"ReadWindowSubObject::ExCExpStringNotFound";
    00207                 }
    00208         }else throw   ExCExpFileNotFound();
    00209         file.close();
    00210                 */
    00211 UnGuard
    00212 }