K3dGui.cpp

Go to the documentation of this file.
00001 
00011 /***************************************************************************
00012  *   Copyright (C) 2007 by Jan Koci   *
00013  *   honza.koci@email.cz   *
00014  *   http://kengine.sourceforge.net/tutorial/
00015  *                                                                         *
00016  *   This program is free software; you can redistribute it and/or modify  *
00017  *   it under the terms of the GNU General Public License as published by  *
00018  *   the Free Software Foundation; either version 2 of the License, or     *
00019  *   (at your option) any later version.                                   *
00020  *                                                                         *
00021  *   This program is distributed in the hope that it will be useful,       *
00022  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00024  *   GNU General Public License for more details.                          *
00025  *                                                                         *
00026  *   You should have received a copy of the GNU General Public License     *
00027  *   along with this program; if not, write to the                         *
00028  *   Free Software Foundation, Inc.,                                       *
00029  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00030  ***************************************************************************/
00031 
00032 #include "K3dGui.h"
00033 
00034 K3dGui::K3dGui(K3dGameData *_pGameData)
00035 {
00036         m_pGameData = _pGameData;
00037         m_pGui = NULL;
00038         m_pInput = NULL;
00039         m_pGraphics = NULL;
00040         m_pImageLoader = NULL;
00041         m_bIsLoadGui = false;
00042 }
00043 
00044 K3dGui::~K3dGui(void)
00045 {
00046         cout << "K3dGui::~K3dGui(void)" << endl;
00047         DeleteGui();
00048 }
00049 
00051 void K3dGui::DeleteGui()
00052 {
00053         cout << "K3dGui::DeleteGui()" << endl;
00054         if(m_bIsLoadGui == true)
00055         {
00056                 m_bIsGuiDeleted = true;
00057                 unsigned int i=0;
00058                 for(i=0; i<m_tGuiFontArray.size(); i++)
00059                 {
00060                         delete m_tGuiFontArray[i];
00061                 }
00062                 m_tGuiFontArray.clear();
00063                 for(i=0; i<m_tGuiWindowArray.size(); i++)
00064                 {
00065                         delete m_tGuiWindowArray[i];
00066                 }
00067                 m_tGuiWindowArray.clear();
00068                 for(i=0; i<m_tGuiLabelArray.size(); i++)
00069                 {
00070                         delete m_tGuiLabelArray[i];
00071                 }
00072                 m_tGuiLabelArray.clear();
00073                 for(i=0; i<m_tGuiIconArray.size(); i++)
00074                 {
00075                         delete m_tGuiIconArray[i];
00076                 }
00077                 m_tGuiIconArray.clear();
00078                 for(i=0; i<m_tGuiButtonArray.size(); i++)
00079                 {
00080                         delete m_tGuiButtonArray[i];
00081                 }
00082                 m_tGuiButtonArray.clear();
00083                 for(i=0; i<m_tGuiTextFieldArray.size(); i++)
00084                 {
00085                         delete m_tGuiTextFieldArray[i];
00086                 }
00087                 m_tGuiTextFieldArray.clear();
00088                 for(i=0; i<m_tGuiTextBoxArray.size(); i++)
00089                 {
00090                         delete m_tGuiTextBoxArray[i];
00091                 }
00092                 m_tGuiTextBoxArray.clear();
00093                 for(i=0; i<m_tGuiScrollAreaArray.size(); i++)
00094                 {
00095                         delete m_tGuiScrollAreaArray[i];
00096                 }
00097                 m_tGuiScrollAreaArray.clear();
00098                 for(i=0; i<m_tGuiListBoxArray.size(); i++)
00099                 {
00100                         delete m_tGuiListBoxArray[i];
00101                 }
00102                 m_tGuiListBoxArray.clear();
00103                 for(i=0; i<m_tGuiDropDownArray.size(); i++)
00104                 {
00105                         delete m_tGuiDropDownArray[i];
00106                 }
00107                 m_tGuiDropDownArray.clear();
00108                 for(i=0; i<m_tGuiCheckBoxArray.size(); i++)
00109                 {
00110                         delete m_tGuiCheckBoxArray[i];
00111                 }
00112                 m_tGuiCheckBoxArray.clear();
00113                 for(i=0; i<m_tGuiRadioButtonArray.size(); i++)
00114                 {
00115                         delete m_tGuiRadioButtonArray[i];
00116                 }
00117                 m_tGuiRadioButtonArray.clear();
00118                 for(i=0; i<m_tGuiSliderArray.size(); i++)
00119                 {
00120                         delete m_tGuiSliderArray[i];
00121                 }
00122                 m_tGuiSliderArray.clear();
00123                 for(i=0; i<m_tGuiImageArray.size(); i++)
00124                 {
00125                         delete m_tGuiImageArray[i];
00126                 }
00127                 m_tGuiImageArray.clear();
00128                 for(i=0; i<m_tGuiContainerArray.size(); i++)
00129                 {
00130                         delete m_tGuiContainerArray[i];
00131                 }
00132                 m_tGuiContainerArray.clear();
00133                 for(i=0; i<m_tGuiListModelArray.size(); i++)
00134                 {
00135                         delete m_tGuiListModelArray[i];
00136                 }
00137                 m_tGuiListModelArray.clear();
00138                 if(m_pInput)
00139                 {
00140                         delete m_pInput;
00141                         m_pInput = NULL;
00142                 }
00143                 if(m_pGraphics)
00144                 {
00145                         delete m_pGraphics;
00146                         m_pGraphics = NULL;
00147                 }
00148                 if(m_pImageLoader)
00149                 {
00150                         delete m_pImageLoader;
00151                         m_pImageLoader = NULL;
00152                 }
00153                 if(m_pGui)
00154                 {
00155                         delete m_pGui;
00156                         m_pGui = NULL;
00157                 }
00158         }
00159 }
00160 
00162 void K3dGui::DrawGui()
00163 {
00164         if(m_bIsLoadGui == true)
00165         {
00166                 if(m_bIsGuiDeleted == false)
00167                 {
00168                         // Let the gui perform it's logic (like handle input)
00169                         m_pGui->logic();
00170                         // Draw the gui
00171                         m_pGui->draw();
00172                 }
00173         }
00174 }
00175 
00177 void K3dGui::SetTargetPlane(const int _iWidth, const int _iHeight)
00178 {
00179         m_pGraphics->setTargetPlane(_iWidth, _iHeight);
00180 }
00181 
00183 void K3dGui::LoadGui()
00184 {
00185         cout << "void K3dGui::LoadGui()" << endl;
00186         m_strFc = "void K3dGui::LoadGui() -- ";
00187         // Check if is needed load gui
00188         m_bIsLoadGui = false;
00189         // Get virtual machine from global data
00190         m_pLua = m_pGameData->GetLua();
00191         m_pLua->LuaGetGlobal(K_STR_LOAD_GUI);
00192     if (!m_pLua->LuaIsBoolean(-1))
00193         {
00194         m_strOut = m_strFc + K_STR_LOAD_GUI;
00195                 m_strOut += " is not a boolean number";
00196                 m_pLua->LuaError(m_strOut.GetString().c_str());
00197     }
00198         m_bIsLoadGui = (bool) m_pLua->LuaToBoolean(-1);
00199         if(m_bIsLoadGui == true)
00200         {
00201                 if(m_pGui == NULL)
00202                 {
00203                         m_pGui = new gcn::Gui;
00204                 }
00205                 TGraphicOption *ptGOption = m_pGameData->GetGraphicOption();
00206                 int iWidth = ptGOption->iWidth;
00207                 int iHeight = ptGOption->iHeight;
00208                 // We want unicode
00209                 SDL_EnableUNICODE(1);
00210                 // We want to enable key repeat
00211                 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
00212                 m_pImageLoader = new gcn::OpenGLSDLImageLoader();
00213                 // The ImageLoader in use is static and must be set to be
00214                 // able to load images
00215                 gcn::Image::setImageLoader(m_pImageLoader);
00216                 m_pGraphics = new gcn::OpenGLGraphics();
00217                 // We need to tell OpenGL graphics how big the screen is.
00218                 //graphics->setTargetPlane(640, 480);
00219                 m_pGraphics->setTargetPlane(iWidth, iHeight);
00220                 m_pInput = new gcn::SDLInput();
00221                 // Set gui to use the SDLGraphics object.
00222                 m_pGui->setGraphics(m_pGraphics);
00223                 // Set gui to use the SDLInput object
00224                 m_pGui->setInput(m_pInput);
00225                 LoadGuiImages();
00226                 LoadGuiIcons();
00227                 LoadGuiFonts();
00228                 LoadGuiLabels();
00229                 LoadGuiButtons();
00230                 LoadGuiTextFields();
00231                 LoadGuiTextBoxes();
00232                 LoadGuiListModels();
00233                 LoadGuiListBoxes();
00234                 LoadGuiDropDown();
00235                 LoadGuiCheckBoxes();
00236                 LoadGuiRadioButtons();
00237                 LoadGuiSliders();
00238                 LoadGuiContainers();
00239                 LoadGuiScrollAreas();
00240                 LoadGuiWindows();
00241                 SetGuiDependencies();
00242                 m_bIsGuiDeleted = false;
00243         }
00244 }
00245 
00247 void K3dGui::LoadGuiImages()
00248 {
00249         cout << "void K3dGui::LoadGuiImages()" << endl;
00250         // Get number of gui images
00251         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_IMAGES);
00252     if (!m_pLua->LuaIsNumber(-1))
00253         {
00254         m_strOut = m_strFc + K_STR_NUM_GUI_IMAGES;
00255                 m_strOut += " is not a valid number";
00256                 m_pLua->LuaError(m_strOut.GetString().c_str());
00257     }
00258         int iNum = (int) m_pLua->LuaToNumber(-1);
00259         for(int i=0; i<iNum; i++)
00260         {
00261                 K3dString kString(K_STR_GUI_IMAGE);
00262                 // Add number behind string
00263                 kString.AddNumber(i);
00264                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00265                 if (!m_pLua->LuaIsTable(-1))
00266                 {
00267                         m_strOut = m_strFc + kString;
00268                         m_strOut += " is not a valid line table";
00269                         m_pLua->LuaError(m_strOut.GetString().c_str());
00270                 }
00271                 const char* strTexture = m_pLua->LuaGetFieldString(K_STR_TEXTURE_TABLE);
00272                 K3dString strTextureName = m_pGameData->GetPath(K_PATH_APP) + strTexture;
00273                 gcn::Image* pImage = gcn::Image::load(strTextureName.GetString().c_str());
00274                 //m_tGuiImageArray.push_back(pImage);
00275                 K3dGuiImage *pK3dImage = new K3dGuiImage();
00276                 m_tGuiImageArray.push_back(pK3dImage);
00277                 pK3dImage->SetImage(pImage);
00278                 pK3dImage->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00279                 pK3dImage->GetObjectType() = K3D_GUI_IMAGE_OBJ;
00280                 pK3dImage->GetObjectId() = (int) m_tGuiImageArray.size() -1;
00281         }
00282 }
00283 
00285 void K3dGui::LoadGuiIcons()
00286 {
00287         cout << "void K3dGui::LoadGuiIcons()" << endl;
00288         // Get number of gui icons
00289         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_ICONS);
00290     if (!m_pLua->LuaIsNumber(-1))
00291         {
00292         m_strOut = m_strFc + K_STR_NUM_GUI_ICONS;
00293                 m_strOut += " is not a valid number";
00294                 m_pLua->LuaError(m_strOut.GetString().c_str());
00295     }
00296         int iNum = (int) m_pLua->LuaToNumber(-1);
00297         for(int i=0; i<iNum; i++)
00298         {
00299                 K3dString kString(K_STR_GUI_ICON);
00300                 // Add number behind string
00301                 kString.AddNumber(i);
00302                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00303                 if (!m_pLua->LuaIsTable(-1))
00304                 {
00305                         m_strOut = m_strFc + kString;
00306                         m_strOut += " is not a valid line table";
00307                         m_pLua->LuaError(m_strOut.GetString().c_str());
00308                 }
00309                 const char* strImage = m_pLua->LuaGetFieldString(K_STR_IMAGE);
00310                 //int iImageId = (int) m_pLua->LuaGetFieldNumber(K_STR_GUI_IMAGE_ID);
00311                 K3dGuiImage *pImage = FindImage(strImage);
00312                 if(pImage)
00313                 {
00314                         //K3dGuiIcon* pIcon = new K3dGuiIcon(m_tGuiImageArray[iImageId]->GetImage());
00315                         K3dGuiIcon* pIcon = new K3dGuiIcon(pImage->GetImage());
00316                         m_tGuiIconArray.push_back(pIcon);
00317                         pIcon->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00318                         pIcon->GetIsResizeContent() = m_pLua->LuaGetFieldBool(K_STR_RESIZE_CONTENT);
00319                         pIcon->GetObjectType() = K3D_GUI_ICON_OBJ;
00320                         pIcon->GetObjectId() = (int) m_tGuiIconArray.size() -1;
00321                 }
00322                 else
00323                 {
00324                         cerr << "Error :: void K3dGui::LoadGuiIcons() - Image Object " << strImage << " doesn`t exists !!!" << endl;
00325                 }
00326         }
00327 }
00328 
00330 void K3dGui::LoadGuiFonts()
00331 {
00332         cout << "void K3dGui::LoadGuiFonts()" << endl;
00333         // Get number of gui fonts
00334         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_FONTS);
00335     if (!m_pLua->LuaIsNumber(-1))
00336         {
00337         m_strOut = m_strFc + K_STR_NUM_GUI_FONTS;
00338                 m_strOut += " is not a valid number";
00339                 m_pLua->LuaError(m_strOut.GetString().c_str());
00340     }
00341         int iNum = (int) m_pLua->LuaToNumber(-1);
00342         for(int i=0; i<iNum; i++)
00343         {
00344                 K3dString kString(K_STR_GUI_FONT);
00345                 // Add number behind string
00346                 kString.AddNumber(i);
00347                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00348                 if (!m_pLua->LuaIsTable(-1))
00349                 {
00350                         m_strOut = m_strFc + kString;
00351                         m_strOut += " is not a valid line table";
00352                         m_pLua->LuaError(m_strOut.GetString().c_str());
00353                 }
00354                 const char* strFont = m_pLua->LuaGetFieldString(K_STR_FONT_LOWER);
00355                 const char* strGlyph = m_pLua->LuaGetFieldString(K_STR_GLYPH);
00356                 K3dString strFontName = m_pGameData->GetPath(K_PATH_APP) + strFont;
00357                 // Load the image font.
00358                 K3dGuiImageFont *pFont = new K3dGuiImageFont(strFontName.GetString(), strGlyph);
00359                 m_tGuiFontArray.push_back(pFont);
00360                 // The global font is static and must be set.
00361                 gcn::Widget::setGlobalFont(pFont);
00362                 pFont->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00363                 pFont->GetObjectType() = K3D_GUI_FONT_OBJ;
00364                 pFont->GetObjectId() = (int) m_tGuiFontArray.size() -1;
00365         }
00366 }
00367 
00369 void K3dGui::LoadGuiLabels()
00370 {
00371         cout << "void K3dGui::LoadGuiLabels()" << endl;
00372         // Get number of gui labels
00373         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_LABELS);
00374     if (!m_pLua->LuaIsNumber(-1))
00375         {
00376         m_strOut = m_strFc + K_STR_NUM_GUI_LABELS;
00377                 m_strOut += " is not a valid number";
00378                 m_pLua->LuaError(m_strOut.GetString().c_str());
00379     }
00380         int iNum = (int) m_pLua->LuaToNumber(-1);
00381         for(int i=0; i<iNum; i++)
00382         {
00383                 K3dString kString(K_STR_GUI_LABEL);
00384                 // Add number behind string
00385                 kString.AddNumber(i);
00386                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00387                 if (!m_pLua->LuaIsTable(-1))
00388                 {
00389                         m_strOut = m_strFc + kString;
00390                         m_strOut += " is not a valid line table";
00391                         m_pLua->LuaError(m_strOut.GetString().c_str());
00392                 }
00393                 const char* strCaption = m_pLua->LuaGetFieldString(K_STR_CAPTION);
00394                 K3dGuiLabel *pLabel = new K3dGuiLabel(strCaption);
00395                 m_tGuiLabelArray.push_back(pLabel);
00396                 pLabel->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00397                 pLabel->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00398                 pLabel->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00399                 pLabel->GetObjectType() = K3D_GUI_LABEL_OBJ;
00400                 pLabel->GetObjectId() = (int) m_tGuiLabelArray.size() -1;
00401                 cout << "Label Name = " << m_tGuiLabelArray[pLabel->GetObjectId()]->GetName().GetString() << endl;
00402         }
00403 }
00404 
00406 void K3dGui::LoadGuiButtons()
00407 {
00408         cout << "void K3dGui::LoadGuiButtons()" << endl;
00409         // Get number of gui buttons
00410         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_BUTTONS);
00411     if (!m_pLua->LuaIsNumber(-1))
00412         {
00413         m_strOut = m_strFc + K_STR_NUM_GUI_BUTTONS;
00414                 m_strOut += " is not a valid number";
00415                 m_pLua->LuaError(m_strOut.GetString().c_str());
00416     }
00417         int iNum = (int) m_pLua->LuaToNumber(-1);
00418         for(int i=0; i<iNum; i++)
00419         {
00420                 K3dString kString(K_STR_GUI_BUTTON);
00421                 // Add number behind string
00422                 kString.AddNumber(i);
00423                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00424                 if (!m_pLua->LuaIsTable(-1))
00425                 {
00426                         m_strOut = m_strFc + kString;
00427                         m_strOut += " is not a valid line table";
00428                         m_pLua->LuaError(m_strOut.GetString().c_str());
00429                 }
00430                 const char* strCaption = m_pLua->LuaGetFieldString(K_STR_CAPTION);
00431                 K3dGuiButton *pButton = new K3dGuiButton(strCaption);
00432                 m_tGuiButtonArray.push_back(pButton);
00433                 pButton->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00434                 pButton->setWidth((int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH));
00435                 pButton->setHeight((int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT));
00436                 pButton->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00437                 pButton->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00438                 pButton->GetObjectType() = K3D_GUI_BUTTON_OBJ;
00439                 pButton->GetObjectId() = (int) m_tGuiButtonArray.size() -1;
00440         }
00441 }
00442 
00444 void K3dGui::LoadGuiTextFields()
00445 {
00446         cout << "void K3dGui::LoadGuiTextFields()" << endl;
00447         // Get number of gui text fields
00448         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_TEXT_FIELDS);
00449     if (!m_pLua->LuaIsNumber(-1))
00450         {
00451         m_strOut = m_strFc + K_STR_NUM_GUI_TEXT_FIELDS;
00452                 m_strOut += " is not a valid number";
00453                 m_pLua->LuaError(m_strOut.GetString().c_str());
00454     }
00455         int iNum = (int) m_pLua->LuaToNumber(-1);
00456         for(int i=0; i<iNum; i++)
00457         {
00458                 K3dString kString(K_STR_GUI_TEXT_FIELD);
00459                 // Add number behind string
00460                 kString.AddNumber(i);
00461                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00462                 if (!m_pLua->LuaIsTable(-1))
00463                 {
00464                         m_strOut = m_strFc + kString;
00465                         m_strOut += " is not a valid line table";
00466                         m_pLua->LuaError(m_strOut.GetString().c_str());
00467                 }
00468                 const char* strText = m_pLua->LuaGetFieldString(K_STR_TEXT);
00469                 K3dGuiTextField *pTextField = new K3dGuiTextField(strText);
00470                 m_tGuiTextFieldArray.push_back(pTextField);
00471                 pTextField->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00472                 pTextField->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00473                 pTextField->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00474                 pTextField->GetObjectType() = K3D_GUI_TEXT_FIELD_OBJ;
00475                 pTextField->GetObjectId() = (int) m_tGuiTextFieldArray.size() -1;
00476         }
00477 }
00478 
00480 void K3dGui::LoadGuiTextBoxes()
00481 {
00482         cout << "void K3dGui::LoadGuiTextBoxes()" << endl;
00483         // Get number of gui text boxes
00484         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_TEXT_BOXES);
00485     if (!m_pLua->LuaIsNumber(-1))
00486         {
00487         m_strOut = m_strFc + K_STR_NUM_GUI_TEXT_BOXES;
00488                 m_strOut += " is not a valid number";
00489                 m_pLua->LuaError(m_strOut.GetString().c_str());
00490     }
00491         int iNum = (int) m_pLua->LuaToNumber(-1);
00492         for(int i=0; i<iNum; i++)
00493         {
00494                 K3dString kString(K_STR_GUI_TEXT_BOX);
00495                 // Add number behind string
00496                 kString.AddNumber(i);
00497                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00498                 if (!m_pLua->LuaIsTable(-1))
00499                 {
00500                         m_strOut = m_strFc + kString;
00501                         m_strOut += " is not a valid line table";
00502                         m_pLua->LuaError(m_strOut.GetString().c_str());
00503                 }
00504                 const char* strText = m_pLua->LuaGetFieldString(K_STR_TEXT);
00505                 K3dGuiTextBox *pTextBox = new K3dGuiTextBox(strText);
00506                 m_tGuiTextBoxArray.push_back(pTextBox);
00507                 pTextBox->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00508                 pTextBox->GetObjectType() = K3D_GUI_TEXT_BOX_OBJ;
00509                 pTextBox->GetObjectId() = (int) m_tGuiTextBoxArray.size() -1;
00510         }
00511 }
00512 
00514 void K3dGui::LoadGuiScrollAreas()
00515 {
00516         cout << "void K3dGui::LoadGuiScrollAreas()" << endl;
00517         // Get number of gui text boxes
00518         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_SCROLL_AREAS);
00519     if (!m_pLua->LuaIsNumber(-1))
00520         {
00521         m_strOut = m_strFc + K_STR_NUM_GUI_SCROLL_AREAS;
00522                 m_strOut += " is not a valid number";
00523                 m_pLua->LuaError(m_strOut.GetString().c_str());
00524     }
00525         int iNum = (int) m_pLua->LuaToNumber(-1);
00526         for(int i=0; i<iNum; i++)
00527         {
00528                 K3dString kString(K_STR_GUI_SCROLL_AREA);
00529                 // Add number behind string
00530                 kString.AddNumber(i);
00531                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00532                 if (!m_pLua->LuaIsTable(-1))
00533                 {
00534                         m_strOut = m_strFc + kString;
00535                         m_strOut += " is not a valid line table";
00536                         m_pLua->LuaError(m_strOut.GetString().c_str());
00537                 }
00538                 const char* strContent = m_pLua->LuaGetFieldString(K_STR_CONTENT);
00539                 CreateScrollArea(strContent);
00540         }
00541 }
00542 
00544 void K3dGui::CreateScrollArea(const char* _strContent)
00545 {
00546         cout << "void K3dGui::CreateScrollArea(const char* _strContent)" << endl;
00547         K3dGuiScrollArea *pScrollArea;
00548 
00549         K3dGuiObject *pObject = (K3dGuiObject*) FindGuiObject(_strContent);
00550         if(pObject)
00551         {
00552                 EK3dGuiObjType eObjType = pObject->GetObjectType();
00553                 int iObjId = pObject->GetObjectId();
00554                 switch (eObjType)
00555                 {
00556                         case K3D_GUI_TEXT_BOX_OBJ:
00557                                 pScrollArea = new K3dGuiScrollArea(m_tGuiTextBoxArray[iObjId]);
00558                                 pScrollArea->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00559                                 pScrollArea->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00560                                 pScrollArea->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00561                                 m_tGuiScrollAreaArray.push_back(pScrollArea);
00562                                 pScrollArea->setWidth((int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH));
00563                                 pScrollArea->setHeight((int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT));
00564                                 pScrollArea->setBorderSize((int) m_pLua->LuaGetFieldNumber(K_STR_BORDER_SIZE));
00565                                 break;
00566                         case K3D_GUI_LIST_BOX_OBJ:
00567                                 pScrollArea = new K3dGuiScrollArea(m_tGuiListBoxArray[iObjId]);
00568                                 pScrollArea->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00569                                 pScrollArea->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00570                                 pScrollArea->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00571                                 m_tGuiScrollAreaArray.push_back(pScrollArea);
00572                                 pScrollArea->setWidth((int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH));
00573                                 pScrollArea->setHeight((int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT));
00574                                 pScrollArea->setBorderSize((int) m_pLua->LuaGetFieldNumber(K_STR_BORDER_SIZE));
00575                                 break;
00576                         case K3D_GUI_CONTAINER_OBJ:
00577                                 pScrollArea = new K3dGuiScrollArea(m_tGuiContainerArray[iObjId]);
00578                                 pScrollArea->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00579                                 pScrollArea->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00580                                 pScrollArea->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00581                                 m_tGuiScrollAreaArray.push_back(pScrollArea);
00582                                 pScrollArea->setWidth((int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH));
00583                                 pScrollArea->setHeight((int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT));
00584                                 pScrollArea->setBorderSize((int) m_pLua->LuaGetFieldNumber(K_STR_BORDER_SIZE));
00585                                 break;
00586                         default:
00587                                 break;
00588                 }
00589         }
00590         else    
00591         {
00592                 cerr << "Error in void K3dGui::CreateScrollArea(): Object " << _strContent << " doesn`t exist!!!" << endl;
00593         }
00594         
00595         
00596 /*
00597         K3dString kStr = _strContent;
00598         // Find text box
00599         K3dGuiScrollArea *pScrollArea;
00600         int iObjId = -1;
00601         K3dString kStrObj;
00602         if(kStr.Find(K_STR_GUI_TEXT_BOX))
00603         {
00604                 kStrObj = K_STR_GUI_TEXT_BOX;
00605                 // Get object index
00606                 kStr.Erase(0,kStrObj.GetSize());
00607                 iObjId = kStr.ToInt();
00608                 pScrollArea = new K3dGuiScrollArea(m_tGuiTextBoxArray[iObjId]);
00609                 pScrollArea->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00610                 pScrollArea->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00611                 pScrollArea->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00612                 m_tGuiScrollAreaArray.push_back(pScrollArea);
00613                 pScrollArea->setWidth((int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH));
00614                 pScrollArea->setHeight((int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT));
00615                 pScrollArea->setBorderSize((int) m_pLua->LuaGetFieldNumber(K_STR_BORDER_SIZE));
00616                 return;
00617         }
00618         // Find list box
00619         if(kStr.Find(K_STR_GUI_LIST_BOX))
00620         {
00621                 kStrObj = K_STR_GUI_LIST_BOX;
00622                 // Get object index
00623                 kStr.Erase(0,kStrObj.GetSize());
00624                 iObjId = kStr.ToInt();
00625                 pScrollArea = new K3dGuiScrollArea(m_tGuiListBoxArray[iObjId]);
00626                 pScrollArea->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00627                 pScrollArea->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00628                 pScrollArea->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00629                 m_tGuiScrollAreaArray.push_back(pScrollArea);
00630                 pScrollArea->setWidth((int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH));
00631                 pScrollArea->setHeight((int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT));
00632                 pScrollArea->setBorderSize((int) m_pLua->LuaGetFieldNumber(K_STR_BORDER_SIZE));
00633                 return;
00634         }
00635         // Find container
00636         if(kStr.Find(K_STR_GUI_CONTAINER))
00637         {
00638                 kStrObj = K_STR_GUI_CONTAINER;
00639                 // Get object index
00640                 kStr.Erase(0,kStrObj.GetSize());
00641                 iObjId = kStr.ToInt();
00642                 pScrollArea = new K3dGuiScrollArea(m_tGuiContainerArray[iObjId]);
00643                 pScrollArea->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00644                 pScrollArea->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00645                 pScrollArea->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00646                 m_tGuiScrollAreaArray.push_back(pScrollArea);
00647                 pScrollArea->setWidth((int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH));
00648                 pScrollArea->setHeight((int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT));
00649                 pScrollArea->setBorderSize((int) m_pLua->LuaGetFieldNumber(K_STR_BORDER_SIZE));
00650                 return;
00651         }       
00652 */
00653 }
00654 
00657 K3dGuiObject *K3dGui::FindGuiObject(const char* _strName)
00658 {
00659         K3dString kStr = _strName;
00660         unsigned int i=0;
00661         for(i=0; i<m_tGuiTextBoxArray.size(); i++)
00662         {
00663                 if(kStr == m_tGuiTextBoxArray[i]->GetName())
00664                 {
00665                         return m_tGuiTextBoxArray[i];
00666                 }
00667         }
00668         for(i=0; i<m_tGuiListModelArray.size(); i++)
00669         {
00670                 if(kStr == m_tGuiListModelArray[i]->GetName())
00671                 {
00672                         return m_tGuiListModelArray[i];
00673                 }
00674         }
00675         for(i=0; i<m_tGuiWindowArray.size(); i++)
00676         {
00677                 if(kStr == m_tGuiWindowArray[i]->GetName())
00678                 {
00679                         return m_tGuiWindowArray[i];
00680                 }
00681         }
00682         for(i=0; i<m_tGuiLabelArray.size(); i++)
00683         {
00684                 if(kStr == m_tGuiLabelArray[i]->GetName())
00685                 {
00686                         return m_tGuiLabelArray[i];
00687                 }
00688         }
00689         for(i=0; i<m_tGuiIconArray.size(); i++)
00690         {
00691                 if(kStr == m_tGuiIconArray[i]->GetName())
00692                 {
00693                         return m_tGuiIconArray[i];
00694                 }
00695         }
00696         for(i=0; i<m_tGuiButtonArray.size(); i++)
00697         {
00698                 if(kStr == m_tGuiButtonArray[i]->GetName())
00699                 {
00700                         return m_tGuiButtonArray[i];
00701                 }
00702         }
00703         for(i=0; i<m_tGuiFontArray.size(); i++)
00704         {
00705                 if(kStr == m_tGuiFontArray[i]->GetName())
00706                 {
00707                         return m_tGuiFontArray[i];
00708                 }
00709         }
00710         for(i=0; i<m_tGuiTextFieldArray.size(); i++)
00711         {
00712                 if(kStr == m_tGuiTextFieldArray[i]->GetName())
00713                 {
00714                         return m_tGuiTextFieldArray[i];
00715                 }
00716         }
00717         for(i=0; i<m_tGuiScrollAreaArray.size(); i++)
00718         {
00719                 if(kStr == m_tGuiScrollAreaArray[i]->GetName())
00720                 {
00721                         return m_tGuiScrollAreaArray[i];
00722                 }
00723         }
00724         for(i=0; i<m_tGuiListBoxArray.size(); i++)
00725         {
00726                 if(kStr == m_tGuiListBoxArray[i]->GetName())
00727                 {
00728                         return m_tGuiListBoxArray[i];
00729                 }
00730         }
00731         for(i=0; i<m_tGuiDropDownArray.size(); i++)
00732         {
00733                 if(kStr == m_tGuiDropDownArray[i]->GetName())
00734                 {
00735                         return m_tGuiDropDownArray[i];
00736                 }
00737         }
00738         for(i=0; i<m_tGuiCheckBoxArray.size(); i++)
00739         {
00740                 if(kStr == m_tGuiCheckBoxArray[i]->GetName())
00741                 {
00742                         return m_tGuiCheckBoxArray[i];
00743                 }
00744         }
00745         for(i=0; i<m_tGuiRadioButtonArray.size(); i++)
00746         {
00747                 if(kStr == m_tGuiRadioButtonArray[i]->GetName())
00748                 {
00749                         return m_tGuiRadioButtonArray[i];
00750                 }
00751         }
00752         for(i=0; i<m_tGuiSliderArray.size(); i++)
00753         {
00754                 if(kStr == m_tGuiSliderArray[i]->GetName())
00755                 {
00756                         return m_tGuiSliderArray[i];
00757                 }
00758         }
00759         for(i=0; i<m_tGuiImageArray.size(); i++)
00760         {
00761                 if(kStr == m_tGuiImageArray[i]->GetName())
00762                 {
00763                         return m_tGuiImageArray[i];
00764                 }
00765         }
00766         for(i=0; i<m_tGuiContainerArray.size(); i++)
00767         {
00768                 if(kStr == m_tGuiContainerArray[i]->GetName())
00769                 {
00770                         return m_tGuiContainerArray[i];
00771                 }
00772         }
00773         return NULL;
00774 }
00775 
00777 void K3dGui::LoadGuiListModels()
00778 {
00779         cout << "void K3dGui::LoadGuiListModels()" << endl;
00780         // Get number of gui list models
00781         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_LIST_MODELS);
00782     if (!m_pLua->LuaIsNumber(-1))
00783         {
00784         m_strOut = m_strFc + K_STR_NUM_GUI_LIST_MODELS;
00785                 m_strOut += " is not a valid number";
00786                 m_pLua->LuaError(m_strOut.GetString().c_str());
00787     }
00788         int iNum = (int) m_pLua->LuaToNumber(-1);
00789         for(int i=0; i<iNum; i++)
00790         {
00791                 K3dString kString(K_STR_GUI_LIST_MODEL);
00792                 // Add number behind string
00793                 kString.AddNumber(i);
00794                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00795                 if (!m_pLua->LuaIsTable(-1))
00796                 {
00797                         m_strOut = m_strFc + kString;
00798                         m_strOut += " is not a valid line table";
00799                         m_pLua->LuaError(m_strOut.GetString().c_str());
00800                 }
00801                 K3dGuiListModel *pListModel = new K3dGuiListModel;
00802                 m_tGuiListModelArray.push_back(pListModel);
00803                 pListModel->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00804                 pListModel->GetObjectType() = K3D_GUI_LIST_MODEL_OBJ;
00805                 pListModel->GetObjectId() = (int) m_tGuiListModelArray.size() -1;
00806                 int iNumElements = (int) m_pLua->LuaGetFieldNumber(K_STR_GUI_NUM_ELEMENTS);
00807                 for(int el=0; el<iNumElements; el++)
00808                 {
00809                         kString.GetString() = K_STR_ELEMENT;
00810                         // Add number behind string
00811                         kString.AddNumber(el);
00812                         // Get element string
00813                         const char* strEl = m_pLua->LuaGetFieldString(kString.GetString().c_str());
00814                         pListModel->AddElement(strEl);
00815                 }
00816         }
00817 }
00818 
00820 void K3dGui::LoadGuiListBoxes()
00821 {
00822         cout << "void K3dGui::LoadGuiListBoxes()" << endl;
00823         // Get number of gui list boxes
00824         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_LIST_BOXES);
00825     if (!m_pLua->LuaIsNumber(-1))
00826         {
00827         m_strOut = m_strFc + K_STR_NUM_GUI_LIST_BOXES;
00828                 m_strOut += " is not a valid number";
00829                 m_pLua->LuaError(m_strOut.GetString().c_str());
00830     }
00831         int iNum = (int) m_pLua->LuaToNumber(-1);
00832         for(int i=0; i<iNum; i++)
00833         {
00834                 K3dString kString(K_STR_GUI_LIST_BOX);
00835                 // Add number behind string
00836                 kString.AddNumber(i);
00837                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00838                 if (!m_pLua->LuaIsTable(-1))
00839                 {
00840                         m_strOut = m_strFc + kString;
00841                         m_strOut += " is not a valid line table";
00842                         m_pLua->LuaError(m_strOut.GetString().c_str());
00843                 }
00844                 const char* strContent = m_pLua->LuaGetFieldString(K_STR_CONTENT);
00845                 CreateListBox(strContent);
00846         }
00847 }
00848 
00850 void K3dGui::CreateListBox(const char* _strContent)
00851 {
00852         cout << "void K3dGui::CreateListBox(const char* _strContent)" << endl;
00853         K3dGuiListModel *pListModel = FindListModel(_strContent);
00854         if(pListModel)
00855         {
00856                 K3dGuiListBox *pListBox = new K3dGuiListBox(pListModel);
00857                 m_tGuiListBoxArray.push_back(pListBox);
00858                 pListBox->setBorderSize((int) m_pLua->LuaGetFieldNumber(K_STR_BORDER_SIZE));
00859                 pListBox->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00860                 pListBox->GetObjectType() = K3D_GUI_LIST_BOX_OBJ;
00861                 pListBox->setWidth((int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH));
00862                 pListBox->setHeight((int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT));
00863                 pListBox->GetObjectId() = (int) m_tGuiListBoxArray.size() -1;
00864         }
00865         else
00866         {
00867                 cerr << "Error in void K3dGui::CreateListBox(): Object " << _strContent << " doesn`t exist!!!" << endl;
00868         }
00869 }
00870 
00873 K3dGuiListModel *K3dGui::FindListModel(const char* _strName)
00874 {
00875         K3dString kStr = _strName;
00876         for(unsigned int i=0; i<m_tGuiListModelArray.size(); i++)
00877         {
00878                 if(kStr == m_tGuiListModelArray[i]->GetName())
00879                 {
00880                         return m_tGuiListModelArray[i];
00881                 }
00882         }
00883         return NULL;
00884 }
00885 
00887 void K3dGui::LoadGuiDropDown()
00888 {
00889         cout << "void K3dGui::LoadGuiDropDown()" << endl;
00890         // Get number of gui drop down
00891         m_pLua->LuaGetGlobal(K_STR_GUI_NUM_DROP_DOWN);
00892     if (!m_pLua->LuaIsNumber(-1))
00893         {
00894         m_strOut = m_strFc + K_STR_GUI_NUM_DROP_DOWN;
00895                 m_strOut += " is not a valid number";
00896                 m_pLua->LuaError(m_strOut.GetString().c_str());
00897     }
00898         int iNum = (int) m_pLua->LuaToNumber(-1);
00899         for(int i=0; i<iNum; i++)
00900         {
00901                 K3dString kString(K_STR_GUI_DROP_DOWN);
00902                 // Add number behind string
00903                 kString.AddNumber(i);
00904                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00905                 if (!m_pLua->LuaIsTable(-1))
00906                 {
00907                         m_strOut = m_strFc + kString;
00908                         m_strOut += " is not a valid line table";
00909                         m_pLua->LuaError(m_strOut.GetString().c_str());
00910                 }
00911                 const char* strContent = m_pLua->LuaGetFieldString(K_STR_CONTENT);
00912                 CreateDropDown(strContent);
00913         }
00914 }
00915 
00917 void K3dGui::CreateDropDown(const char* _strContent)
00918 {
00919         cout << "void K3dGui::CreateDropDown(const char* _strContent)" << endl;
00920         // Find gui list model from content string
00921         K3dGuiListModel *pListModel = FindListModel(_strContent);
00922         if(pListModel)
00923         {
00924                 K3dGuiDropDown *pDropDown = new K3dGuiDropDown(pListModel);
00925                 m_tGuiDropDownArray.push_back(pDropDown);
00926                 pDropDown->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00927                 pDropDown->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00928                 pDropDown->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00929                 pDropDown->GetObjectType() = K3D_GUI_DROP_DOWN_OBJ;
00930                 pDropDown->GetObjectId() = (int) m_tGuiDropDownArray.size() -1;
00931         }
00932         else
00933         {
00934                 cerr << "Error in void K3dGui::CreateDropDown(): Object " << _strContent << " doesn`t exist!!!" << endl;
00935         }
00936         /*
00937         K3dString kStr = _strContent;
00938         K3dString kStrObj = K_STR_GUI_LIST_MODEL;
00939         // Find list model
00940         if(kStr.Find(K_STR_GUI_LIST_MODEL))
00941         {
00942                 // Get object index
00943                 kStr.Erase(0,kStrObj.GetSize());
00944                 int iObjId = kStr.ToInt();
00945                 K3dGuiDropDown *pDropDown = new K3dGuiDropDown(m_tGuiListModelArray[iObjId]);
00946                 m_tGuiDropDownArray.push_back(pDropDown);
00947                 pDropDown->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00948                 pDropDown->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00949                 pDropDown->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00950                 pDropDown->GetObjectType() = K3D_GUI_DROP_DOWN_OBJ;
00951                 pDropDown->GetObjectId() = (int) m_tGuiDropDownArray.size() -1;
00952         }
00953 */
00954 }
00955 
00957 void K3dGui::LoadGuiCheckBoxes()
00958 {
00959         cout << "void K3dGui::LoadGuiCheckBoxes()" << endl;
00960         // Get number of gui check boxes
00961         m_pLua->LuaGetGlobal(K_STR_GUI_NUM_CHECK_BOXES);
00962     if (!m_pLua->LuaIsNumber(-1))
00963         {
00964         m_strOut = m_strFc + K_STR_GUI_NUM_CHECK_BOXES;
00965                 m_strOut += " is not a valid number";
00966                 m_pLua->LuaError(m_strOut.GetString().c_str());
00967     }
00968         int iNum = (int) m_pLua->LuaToNumber(-1);
00969         for(int i=0; i<iNum; i++)
00970         {
00971                 K3dString kString(K_STR_GUI_CHECK_BOX);
00972                 // Add number behind string
00973                 kString.AddNumber(i);
00974                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
00975                 if (!m_pLua->LuaIsTable(-1))
00976                 {
00977                         m_strOut = m_strFc + kString;
00978                         m_strOut += " is not a valid line table";
00979                         m_pLua->LuaError(m_strOut.GetString().c_str());
00980                 }
00981                 const char* strCaption = m_pLua->LuaGetFieldString(K_STR_CAPTION);
00982                 K3dGuiCheckBox *pCheckBox = new K3dGuiCheckBox(strCaption);
00983                 m_tGuiCheckBoxArray.push_back(pCheckBox);
00984                 pCheckBox->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
00985                 pCheckBox->setMarked(m_pLua->LuaGetFieldBool(K_STR_MARKED));
00986                 pCheckBox->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
00987                 pCheckBox->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
00988                 pCheckBox->GetObjectType() = K3D_GUI_CHECK_BOX_OBJ;
00989                 pCheckBox->GetObjectId() = (int) m_tGuiCheckBoxArray.size() -1;
00990         }
00991 }
00992 
00994 void K3dGui::LoadGuiRadioButtons()
00995 {
00996         cout << "void K3dGui::LoadGuiRadioButtons()" << endl;
00997         // Get number of gui radio buttons
00998         m_pLua->LuaGetGlobal(K_STR_GUI_NUM_RADIO_BUTTONS);
00999     if (!m_pLua->LuaIsNumber(-1))
01000         {
01001         m_strOut = m_strFc + K_STR_GUI_NUM_RADIO_BUTTONS;
01002                 m_strOut += " is not a valid number";
01003                 m_pLua->LuaError(m_strOut.GetString().c_str());
01004     }
01005         int iNum = (int) m_pLua->LuaToNumber(-1);
01006         for(int i=0; i<iNum; i++)
01007         {
01008                 K3dString kString(K_STR_GUI_RADIO_BUTTON);
01009                 // Add number behind string
01010                 kString.AddNumber(i);
01011                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
01012                 if (!m_pLua->LuaIsTable(-1))
01013                 {
01014                         m_strOut = m_strFc + kString;
01015                         m_strOut += " is not a valid line table";
01016                         m_pLua->LuaError(m_strOut.GetString().c_str());
01017                 }
01018                 const char* strCaption = m_pLua->LuaGetFieldString(K_STR_CAPTION);
01019                 const char* strGroup = m_pLua->LuaGetFieldString(K_STR_GROUP);
01020                 bool bIsMarked = m_pLua->LuaGetFieldBool(K_STR_MARKED);
01021                 K3dGuiRadioButton *pRadioButton = new K3dGuiRadioButton(strCaption, strGroup, bIsMarked);
01022                 m_tGuiRadioButtonArray.push_back(pRadioButton);
01023                 pRadioButton->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
01024                 pRadioButton->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
01025                 pRadioButton->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
01026                 pRadioButton->GetObjectType() = K3D_GUI_RADIO_BUTTON_OBJ;
01027                 pRadioButton->GetObjectId() = (int) m_tGuiRadioButtonArray.size() -1;
01028         }
01029 }
01030 
01032 void K3dGui::LoadGuiSliders()
01033 {
01034         cout << "void K3dGui::LoadGuiSliders()" << endl;
01035         // Get number of gui sliders
01036         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_SLIDERS);
01037     if (!m_pLua->LuaIsNumber(-1))
01038         {
01039         m_strOut = m_strFc + K_STR_NUM_SLIDERS;
01040                 m_strOut += " is not a valid number";
01041                 m_pLua->LuaError(m_strOut.GetString().c_str());
01042     }
01043         int iNum = (int) m_pLua->LuaToNumber(-1);
01044         for(int i=0; i<iNum; i++)
01045         {
01046                 K3dString kString(K_STR_GUI_SLIDER);
01047                 // Add number behind string
01048                 kString.AddNumber(i);
01049                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
01050                 if (!m_pLua->LuaIsTable(-1))
01051                 {
01052                         m_strOut = m_strFc + kString;
01053                         m_strOut += " is not a valid line table";
01054                         m_pLua->LuaError(m_strOut.GetString().c_str());
01055                 }
01056                 double dScaleStart = m_pLua->LuaGetFieldNumber(K_STR_SCALE_START);
01057                 double dScaleEnd = m_pLua->LuaGetFieldNumber(K_STR_SCALE_END);
01058                 int iWidth = (int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH);
01059                 int iHeight = (int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT);
01060                 K3dGuiSlider* pSlider = new K3dGuiSlider(dScaleStart, dScaleEnd);
01061                 m_tGuiSliderArray.push_back(pSlider);
01062                 pSlider->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
01063                 pSlider->setSize(iWidth, iHeight);
01064                 pSlider->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
01065                 pSlider->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
01066                 pSlider->GetObjectType() = K3D_GUI_SLIDER_OBJ;
01067                 pSlider->GetObjectId() = (int) m_tGuiSliderArray.size() -1;
01068         }       
01069 }
01070 
01071 
01073 void K3dGui::LoadGuiContainers()
01074 {
01075         cout << "void K3dGui::LoadGuiContainers()" << endl;
01076         // Get number of gui list boxes
01077         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_CONTAINERS);
01078     if (!m_pLua->LuaIsNumber(-1))
01079         {
01080         m_strOut = m_strFc + K_STR_NUM_GUI_CONTAINERS;
01081                 m_strOut += " is not a valid number";
01082                 m_pLua->LuaError(m_strOut.GetString().c_str());
01083     }
01084         int iNum = (int) m_pLua->LuaToNumber(-1);
01085         for(int i=0; i<iNum; i++)
01086         {
01087                 K3dString kString(K_STR_GUI_CONTAINER);
01088                 // Add number behind string
01089                 kString.AddNumber(i);
01090                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
01091                 if (!m_pLua->LuaIsTable(-1))
01092                 {
01093                         m_strOut = m_strFc + kString;
01094                         m_strOut += " is not a valid line table";
01095                         m_pLua->LuaError(m_strOut.GetString().c_str());
01096                 }
01097                 int x = (int) m_pLua->LuaGetFieldNumber(K_STR_X);
01098                 int y = (int) m_pLua->LuaGetFieldNumber(K_STR_Y);
01099                 int width = (int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH);
01100                 int height = (int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT);
01101                 K3dGuiContainer *pContainer = new K3dGuiContainer();
01102                 m_tGuiContainerArray.push_back(pContainer);
01103                 pContainer->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
01104                 pContainer->GetObjectType() = K3D_GUI_CONTAINER_OBJ;
01105                 pContainer->GetObjectId() = (int) m_tGuiContainerArray.size() -1;
01106         pContainer->setSize(width, height);
01107                 bool bTop = m_pLua->LuaGetFieldBool(K_STR_TOP);
01108                 // Set the dimension of the top container to match the screen.
01109                 pContainer->setDimension(gcn::Rectangle(x, y, width, height));
01110                 if(bTop)
01111                 {
01112                         // Set the top container
01113                         if(m_pGui->getTop() == NULL)
01114                         {
01115                                 m_pGui->setTop(pContainer);
01116                         }
01117                 }
01118                 // Get bumber of content sliders
01119                 int iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_SLIDERS);
01120                 for(int sl=0; sl<iNumObj; sl++)
01121                 {
01122                         // Get slider
01123                 kString.GetString() = K_STR_SLIDER;
01124                         // Add number behind string
01125                         kString.AddNumber(sl);
01126                         const char* strSliderName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01127                         K3dGuiSlider *pSlider = FindSlider(strSliderName);
01128                         pContainer->add(pSlider, pSlider->GetPosX(), pSlider->GetPosY());
01129                 }
01130                 // Get number of windows
01131                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_WINS);
01132                 const char* strName = "";
01133                 for(int iId = 0; iId<iNumObj; iId++)
01134                 {
01135                         kString.GetString() = K_STR_WIN;
01136                         // Add number behind string
01137                         kString.AddNumber(iId);
01138                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01139                         // Add window name to the array
01140                         pContainer->AddWinName(strName);
01141                 }
01142         }
01143 }
01144 
01147 K3dGuiSlider *K3dGui::FindSlider(const char* _strSliderName)
01148 {
01149         K3dString kStr = _strSliderName;
01150         for(unsigned int i=0; i<m_tGuiSliderArray.size(); i++)
01151         {
01152                 if(kStr == m_tGuiSliderArray[i]->GetName())
01153                 {
01154                         return m_tGuiSliderArray[i];
01155                 }
01156         }
01157         return NULL;
01158 }
01159 
01161 void K3dGui::LoadGuiWindows()
01162 {
01163         cout << "void K3dGui::LoadGuiWindows()" << endl;
01164         // Get number of gui windows
01165         m_pLua->LuaGetGlobal(K_STR_NUM_GUI_WINS);
01166     if (!m_pLua->LuaIsNumber(-1))
01167         {
01168         m_strOut = m_strFc + K_STR_NUM_GUI_WINS;
01169                 m_strOut += " is not a valid number";
01170                 m_pLua->LuaError(m_strOut.GetString().c_str());
01171     }
01172         int iNum = (int) m_pLua->LuaToNumber(-1);
01173         for(int i=0; i<iNum; i++)
01174         {
01175                 K3dString kString(K_STR_GUI_WIN);
01176                 // Add number behind string
01177                 kString.AddNumber(i);
01178                 m_pLua->LuaGetGlobal(kString.GetString().c_str());
01179                 if (!m_pLua->LuaIsTable(-1))
01180                 {
01181                         m_strOut = m_strFc + kString;
01182                         m_strOut += " is not a valid line table";
01183                         m_pLua->LuaError(m_strOut.GetString().c_str());
01184                 }
01185                 const char* strTitle = m_pLua->LuaGetFieldString(K_STR_TITLE);
01186                 K3dGuiWindow *pWin = new K3dGuiWindow(strTitle);
01187                 pWin->GetName() = m_pLua->LuaGetFieldString(K_STR_NAME);
01188                 m_tGuiWindowArray.push_back(pWin);
01189                 pWin->GetObjectType() = K3D_GUI_WIN_OBJ;
01190                 pWin->GetObjectId() = (int) m_tGuiWindowArray.size() -1;
01191                 int x = (int) m_pLua->LuaGetFieldNumber(K_STR_X);
01192                 int y = (int) m_pLua->LuaGetFieldNumber(K_STR_Y);
01193                 int width = (int) m_pLua->LuaGetFieldNumber(K_STR_WIDTH);
01194                 int height = (int) m_pLua->LuaGetFieldNumber(K_STR_HEIGHT);
01195                 bool bTop = m_pLua->LuaGetFieldBool(K_STR_TOP);
01196                 // Set the dimension of the top container to match the screen.
01197                 pWin->setDimension(gcn::Rectangle(x, y, width, height));
01198                 if(bTop)
01199                 {
01200                         // Set the top container
01201                         if(m_pGui->getTop() == NULL)
01202                         {
01203                                 m_pGui->setTop(pWin);
01204                         }
01205                 }
01206                 int r = (int) m_pLua->LuaGetFieldNumber(K_STR_R);
01207                 int g = (int) m_pLua->LuaGetFieldNumber(K_STR_G);
01208                 int b = (int) m_pLua->LuaGetFieldNumber(K_STR_B);
01209                 int a = (int) m_pLua->LuaGetFieldNumber(K_STR_A);
01210                 pWin->setBaseColor(gcn::Color(r, g, b, a));
01211                 pWin->GetPosX() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_X);
01212                 pWin->GetPosY() = (int) m_pLua->LuaGetFieldNumber(K_STR_POS_Y);
01213                 //pWin->setOpaque(false);
01214                 // Set window visibility
01215                 pWin->setVisible(m_pLua->LuaGetFieldBool(K_STR_VISIBLE));
01216                 // Get number of icons
01217                 int iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_ICONS);
01218                 int iId = 0;
01219                 const char* strName;
01220                 for(iId = 0; iId<iNumObj; iId++)
01221                 {
01222                         kString.GetString() = K_STR_ICON;
01223                         // Add number behind string
01224                         kString.AddNumber(iId);
01225                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01226                         K3dGuiIcon *pIcon = FindIcon(strName);
01227                         if(pIcon)
01228                         {
01229                                 // Add current icon
01230                                 pWin->add(pIcon);
01231                                 // Resize window by icon
01232                                 if(pIcon->GetIsResizeContent())
01233                                 {
01234                                         pWin->resizeToContent();
01235                                 }
01236                         }
01237                         else
01238                         {
01239                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Icon Object " << strName << " doesn`t exist !!!" << endl;
01240                         }
01241                 }
01242                 // Get number of labels
01243                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_LABELS);
01244                 for(iId = 0; iId<iNumObj; iId++)
01245                 {
01246                         kString.GetString() = K_STR_LABEL;
01247                         // Add number behind string
01248                         kString.AddNumber(iId);
01249                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01250                         K3dGuiLabel *pLabel = FindLabel(strName);
01251                         if(pLabel)
01252                         {
01253                                 // Add current label
01254                                 pWin->add(pLabel, pLabel->GetPosX(), pLabel->GetPosY());
01255                         }
01256                         else
01257                         {
01258                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Label Object " << strName << " doesn`t exist !!!" << endl;
01259                         }
01260                 }
01261                 // Get number of buttons
01262                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_BUTTONS);
01263                 for(iId = 0; iId<iNumObj; iId++)
01264                 {
01265                         kString.GetString() = K_STR_BUTTON;
01266                         // Add number behind string
01267                         kString.AddNumber(iId);
01268                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01269                         K3dGuiButton *pButton = FindButton(strName);
01270                         if(pButton)
01271                         {
01272                                 // Add current button
01273                                 pWin->add(pButton, pButton->GetPosX(), pButton->GetPosY());
01274                         }
01275                         else
01276                         {
01277                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Button Object " << strName << " doesn`t exist !!!" << endl;
01278                         }
01279                 }
01280                 // Get number of Text Fields
01281                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_TEXTFIELDS);
01282                 for(iId = 0; iId<iNumObj; iId++)
01283                 {
01284                         kString.GetString() = K_STR_TEXTFIELD;
01285                         // Add number behind string
01286                         kString.AddNumber(iId);
01287                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01288                         K3dGuiTextField *pTextField = FindTextField(strName);
01289                         if(pTextField)
01290                         {
01291                                 // Add current  Text Field
01292                                 pWin->add(pTextField, pTextField->GetPosX(), pTextField->GetPosY());
01293                         }
01294                         else
01295                         {
01296                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Text Field Object " << strName << " doesn`t exist !!!" << endl;
01297                         }
01298                 }
01299                 // Get number of Scroll Areas
01300                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_SCROLL_AREAS);
01301                 for(iId = 0; iId<iNumObj; iId++)
01302                 {
01303                         kString.GetString() = K_STR_SCROLL_AREA;
01304                         // Add number behind string
01305                         kString.AddNumber(iId);
01306                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01307                         K3dGuiScrollArea *pScrollArea = FindScrollArea(strName);
01308                         if(pScrollArea)
01309                         {
01310                                 // Add current Scroll Area
01311                                 pWin->add(pScrollArea, pScrollArea->GetPosX(), pScrollArea->GetPosY());
01312                         }
01313                         else
01314                         {
01315                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Scroll Area Object " << strName << " doesn`t exist !!!" << endl;
01316                         }
01317                 }
01318                 // Get number of Drop Downs
01319                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_DROP_DOWNS);
01320                 for(iId = 0; iId<iNumObj; iId++)
01321                 {
01322                         kString.GetString() = K_STR_DROP_DOWN;
01323                         // Add number behind string
01324                         kString.AddNumber(iId);
01325                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01326                         K3dGuiDropDown *pDropDown = FindDropDown(strName);
01327                         if(pDropDown)
01328                         {
01329                                 // Add current Drop Down
01330                                 pWin->add(pDropDown, pDropDown->GetPosX(), pDropDown->GetPosY());
01331                         }
01332                         else
01333                         {
01334                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Drop Down Object " << strName << " doesn`t exist !!!" << endl;
01335                         }
01336                 }
01337                 // Get number of Check Boxes
01338                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_CHECK_BOXES);
01339                 for(iId = 0; iId<iNumObj; iId++)
01340                 {
01341                         kString.GetString() = K_STR_CHECK_BOX;
01342                         // Add number behind string
01343                         kString.AddNumber(iId);
01344                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01345                         K3dGuiCheckBox *pCheckBox = FindCheckBox(strName);
01346                         if(pCheckBox)
01347                         {
01348                                 // Add current Check Box
01349                                 pWin->add(pCheckBox, pCheckBox->GetPosX(), pCheckBox->GetPosY());
01350                         }
01351                         else
01352                         {
01353                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Check Box Object " << strName << " doesn`t exist !!!" << endl;
01354                         }
01355                 }
01356                 // Get number of Radio buttons
01357                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_RADIO_BUTTONS);
01358                 for(iId = 0; iId<iNumObj; iId++)
01359                 {
01360                         kString.GetString() = K_STR_RADIO_BUTTON;
01361                         // Add number behind string
01362                         kString.AddNumber(iId);
01363                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01364                         K3dGuiRadioButton *pRadioButton = FindRadioButton(strName);
01365                         if(pRadioButton)
01366                         {
01367                                 // Add current Radio button
01368                                 pWin->add(pRadioButton, pRadioButton->GetPosX(), pRadioButton->GetPosY());
01369                         }
01370                         else
01371                         {
01372                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Radio Button Object " << strName << " doesn`t exist !!!" << endl;
01373                         }
01374                 }
01375                 // Get number of Sliders
01376                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_SLIDERS);
01377                 for(iId = 0; iId<iNumObj; iId++)
01378                 {
01379                         kString.GetString() = K_STR_SLIDER;
01380                         // Add number behind string
01381                         kString.AddNumber(iId);
01382                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01383                         K3dGuiSlider *pSlider = FindSlider(strName);
01384                         if(pSlider)
01385                         {
01386                                 // Add current Radio button
01387                                 pWin->add(pSlider, pSlider->GetPosX(), pSlider->GetPosY());
01388                         }
01389                         else
01390                         {
01391                                 cerr << "Error in void K3dGui::LoadGuiWindows() - Slider Object " << strName << " doesn`t exist !!!" << endl;
01392                         }
01393                 }
01394                 // Get number of child windows
01395                 iNumObj = (int) m_pLua->LuaGetFieldNumber(K_STR_NUM_WINS);
01396                 for(iId = 0; iId<iNumObj; iId++)
01397                 {
01398                         kString.GetString() = K_STR_WIN;
01399                         // Add number behind string
01400                         kString.AddNumber(iId);
01401                         strName = m_pLua->LuaGetFieldString(kString.GetString().c_str());
01402                         // Add child name to the array
01403                         pWin->AddChildName(strName);
01404                 }
01405         }
01406 }
01407 
01410 K3dGuiIcon *K3dGui::FindIcon(const char* _strName)
01411 {
01412         K3dString kStr = _strName;
01413         for(unsigned int i=0; i<m_tGuiIconArray.size(); i++)
01414         {
01415                 if(kStr == m_tGuiIconArray[i]->GetName())
01416                 {
01417                         return m_tGuiIconArray[i];
01418                 }
01419         }
01420         return NULL;
01421 }
01422 
01425 K3dGuiLabel *K3dGui::FindLabel(const char* _strName)
01426 {
01427         K3dString kStr = _strName;
01428         for(unsigned int i=0; i<m_tGuiLabelArray.size(); i++)
01429         {
01430                 if(kStr == m_tGuiLabelArray[i]->GetName())
01431                 {
01432                         return m_tGuiLabelArray[i];
01433                 }
01434         }
01435         return NULL;
01436 }
01437 
01440 K3dGuiButton *K3dGui::FindButton(const char* _strName)
01441 {
01442         K3dString kStr = _strName;
01443         for(unsigned int i=0; i<m_tGuiButtonArray.size(); i++)
01444         {
01445                 if(kStr == m_tGuiButtonArray[i]->GetName())
01446                 {
01447                         return m_tGuiButtonArray[i];
01448                 }
01449         }
01450         return NULL;
01451 }
01452 
01455 int K3dGui::FindButtonId(const char* _strName)
01456 {
01457         K3dString kStr = _strName;
01458         for(unsigned int i=0; i<m_tGuiButtonArray.size(); i++)
01459         {
01460                 if(kStr == m_tGuiButtonArray[i]->GetName())
01461                 {
01462                         return i;
01463                 }
01464         }
01465         return -1;
01466 }
01467 
01470 int K3dGui::FindWindowId(const char* _strName)
01471 {
01472         K3dString kStr = _strName;
01473         for(unsigned int i=0; i<m_tGuiWindowArray.size(); i++)
01474         {
01475                 if(kStr == m_tGuiWindowArray[i]->GetName())
01476                 {
01477                         return i;
01478                 }
01479         }
01480         return -1;
01481 }
01482 
01485 int K3dGui::FindContainerId(const char* _strName)
01486 {
01487         K3dString kStr = _strName;
01488         for(unsigned int i=0; i<m_tGuiContainerArray.size(); i++)
01489         {
01490                 if(kStr == m_tGuiContainerArray[i]->GetName())
01491                 {
01492                         return i;
01493                 }
01494         }
01495         return -1;
01496 }
01497 
01500 int K3dGui::FindListModelId(const char* _strName)
01501 {
01502         K3dString kStr = _strName;
01503         for(unsigned int i=0; i<m_tGuiListModelArray.size(); i++)
01504         {
01505                 if(kStr == m_tGuiListModelArray[i]->GetName())
01506                 {
01507                         return i;
01508                 }
01509         }
01510         return -1;
01511 }
01512 
01515 int K3dGui::FindListBoxId(const char* _strName)
01516 {
01517         K3dString kStr = _strName;
01518         for(unsigned int i=0; i<m_tGuiListBoxArray.size(); i++)
01519         {
01520                 if(kStr == m_tGuiListBoxArray[i]->GetName())
01521                 {
01522                         return i;
01523                 }
01524         }
01525         return -1;
01526 }
01527 
01532 int K3dGui::FindGuiObjectId(const char* _strName, const int _iObjType )
01533 {
01534         int iId = -1;
01535         switch (_iObjType)
01536         {
01537                 case K3D_GUI_IMAGE_OBJ:
01538                         break;
01539                 case K3D_GUI_WIN_OBJ:
01540                         iId = FindWindowId(_strName);
01541                         break;
01542                 case K3D_GUI_ICON_OBJ:
01543                         break;
01544                 case K3D_GUI_FONT_OBJ:
01545                         break;
01546                 case K3D_GUI_LABEL_OBJ:
01547                         break;
01548                 case K3D_GUI_BUTTON_OBJ:
01549                         iId = FindButtonId(_strName);
01550                         break;
01551                 case K3D_GUI_TEXT_FIELD_OBJ:
01552                         break;
01553                 case K3D_GUI_TEXT_BOX_OBJ:
01554                         break;
01555                 case K3D_GUI_LIST_MODEL_OBJ:
01556                         iId = FindListModelId(_strName);
01557                         break;
01558                 case K3D_GUI_LIST_BOX_OBJ:
01559                         iId = FindListBoxId(_strName);
01560                         break;
01561                 case K3D_GUI_DROP_DOWN_OBJ:
01562                         break;
01563                 case K3D_GUI_SCROLL_AREA_OBJ:
01564                         break;
01565                 case K3D_GUI_CHECK_BOX_OBJ:
01566                         break;
01567                 case K3D_GUI_RADIO_BUTTON_OBJ:
01568                         break;
01569                 case K3D_GUI_SLIDER_OBJ:
01570                         break;
01571                 case K3D_GUI_CONTAINER_OBJ:
01572                         iId = FindContainerId(_strName);
01573                         break;
01574                 default: 
01575                         break;
01576         }
01577         return iId;
01578 }
01579 
01583 void K3dGui::HideGui(const int _iObjId, const int _iObjType)
01584 {
01585         switch (_iObjType)
01586         {
01587                 case K3D_GUI_IMAGE_OBJ:
01588                         break;
01589                 case K3D_GUI_WIN_OBJ:
01590                         HideWindow(_iObjId);
01591                         break;
01592                 case K3D_GUI_ICON_OBJ:
01593                         break;
01594                 case K3D_GUI_FONT_OBJ:
01595                         break;
01596                 case K3D_GUI_LABEL_OBJ:
01597                         break;
01598                 case K3D_GUI_BUTTON_OBJ:
01599                         break;
01600                 case K3D_GUI_TEXT_FIELD_OBJ:
01601                         break;
01602                 case K3D_GUI_TEXT_BOX_OBJ:
01603                         break;
01604                 case K3D_GUI_LIST_MODEL_OBJ:
01605                         break;
01606                 case K3D_GUI_LIST_BOX_OBJ:
01607                         break;
01608                 case K3D_GUI_DROP_DOWN_OBJ:
01609                         break;
01610                 case K3D_GUI_SCROLL_AREA_OBJ:
01611                         break;
01612                 case K3D_GUI_CHECK_BOX_OBJ:
01613                         break;
01614                 case K3D_GUI_RADIO_BUTTON_OBJ:
01615                         break;
01616                 case K3D_GUI_SLIDER_OBJ:
01617                         break;
01618                 case K3D_GUI_CONTAINER_OBJ:
01619                         HideContainer(_iObjId);
01620                         break;
01621                 default: 
01622                         break;
01623         }
01624 }
01625 
01629 void K3dGui::ShowGui(const int _iObjId, const int _iObjType)
01630 {
01631         switch (_iObjType)
01632         {
01633                 case K3D_GUI_IMAGE_OBJ:
01634                         break;
01635                 case K3D_GUI_WIN_OBJ:
01636                         ShowWindow(_iObjId);
01637                         break;
01638                 case K3D_GUI_ICON_OBJ:
01639                         break;
01640                 case K3D_GUI_FONT_OBJ:
01641                         break;
01642                 case K3D_GUI_LABEL_OBJ:
01643                         break;
01644                 case K3D_GUI_BUTTON_OBJ:
01645                         break;
01646                 case K3D_GUI_TEXT_FIELD_OBJ:
01647                         break;
01648                 case K3D_GUI_TEXT_BOX_OBJ:
01649                         break;
01650                 case K3D_GUI_LIST_MODEL_OBJ:
01651                         break;
01652                 case K3D_GUI_LIST_BOX_OBJ:
01653                         break;
01654                 case K3D_GUI_DROP_DOWN_OBJ:
01655                         break;
01656                 case K3D_GUI_SCROLL_AREA_OBJ:
01657                         break;
01658                 case K3D_GUI_CHECK_BOX_OBJ:
01659                         break;
01660                 case K3D_GUI_RADIO_BUTTON_OBJ:
01661                         break;
01662                 case K3D_GUI_SLIDER_OBJ:
01663                         break;
01664                 case K3D_GUI_CONTAINER_OBJ:
01665                         break;
01666                 default: 
01667                         break;
01668         }
01669 }
01670 
01673 void K3dGui::HideWindow(const int _iObjId)
01674 {
01675         K3dGuiWindow *pWin = m_tGuiWindowArray[_iObjId];
01676         if(pWin)
01677         {
01678                 pWin->setVisible(false);
01679         }
01680         else
01681         {
01682                 cerr << "Error :: void HideWindow() -- pWin doesn`t allocated " << endl;
01683         }
01684 }
01685 
01688 void K3dGui::HideContainer(const int _iObjId)
01689 {
01690         K3dGuiContainer *pCont = m_tGuiContainerArray[_iObjId];
01691         if(pCont)
01692         {
01693                 pCont->setVisible(false);
01694         }
01695         else
01696         {
01697                 cerr << "Error -- K3dGui::HideContainer( -- pCont doesn`t allocated " << endl;
01698         }
01699 }
01700 
01703 void K3dGui::ShowWindow(const int _iObjId)
01704 {
01705         K3dGuiWindow *pWin = m_tGuiWindowArray[_iObjId];
01706         if(pWin)
01707         {
01708                 pWin->setVisible(true);
01709         }
01710         else
01711         {
01712                 cerr << "Error :: void ShowWindow() -- pWin doesn`t allocated " << endl;
01713         }
01714 }
01715 
01718 K3dGuiTextField *K3dGui::FindTextField(const char* _strName)
01719 {
01720         K3dString kStr = _strName;
01721         for(unsigned int i=0; i<m_tGuiTextFieldArray.size(); i++)
01722         {
01723                 if(kStr == m_tGuiTextFieldArray[i]->GetName())
01724                 {
01725                         return m_tGuiTextFieldArray[i];
01726                 }
01727         }
01728         return NULL;
01729 }
01730 
01733 K3dGuiScrollArea *K3dGui::FindScrollArea(const char* _strName)
01734 {
01735         K3dString kStr = _strName;
01736         for(unsigned int i=0; i<m_tGuiScrollAreaArray.size(); i++)
01737         {
01738                 if(kStr == m_tGuiScrollAreaArray[i]->GetName())
01739                 {
01740                         return m_tGuiScrollAreaArray[i];
01741                 }
01742         }
01743         return NULL;
01744 }
01745 
01746 
01749 K3dGuiDropDown *K3dGui::FindDropDown(const char* _strName)
01750 {
01751         K3dString kStr = _strName;
01752         for(unsigned int i=0; i<m_tGuiDropDownArray.size(); i++)
01753         {
01754                 if(kStr == m_tGuiDropDownArray[i]->GetName())
01755                 {
01756                         return m_tGuiDropDownArray[i];
01757                 }
01758         }
01759         return NULL;
01760 }
01761 
01762 
01765 K3dGuiCheckBox *K3dGui::FindCheckBox(const char* _strName)
01766 {
01767         K3dString kStr = _strName;
01768         for(unsigned int i=0; i<m_tGuiCheckBoxArray.size(); i++)
01769         {
01770                 if(kStr == m_tGuiCheckBoxArray[i]->GetName())
01771                 {
01772                         return m_tGuiCheckBoxArray[i];
01773                 }
01774         }
01775         return NULL;
01776 }
01777 
01780 K3dGuiRadioButton *K3dGui::FindRadioButton(const char* _strName)
01781 {
01782         K3dString kStr = _strName;
01783         for(unsigned int i=0; i<m_tGuiRadioButtonArray.size(); i++)
01784         {
01785                 if(kStr == m_tGuiRadioButtonArray[i]->GetName())
01786                 {
01787                         return m_tGuiRadioButtonArray[i];
01788                 }
01789         }
01790         return NULL;
01791 }
01792 
01795 K3dGuiImage *K3dGui::FindImage(const char* _strName)
01796 {
01797         K3dString kStr = _strName;
01798         for(unsigned int i=0; i<m_tGuiImageArray.size(); i++)
01799         {
01800                 if(kStr == m_tGuiImageArray[i]->GetName())
01801                 {
01802                         return m_tGuiImageArray[i];
01803                 }
01804         }
01805         return NULL;
01806 }
01807 
01809 void K3dGui::SetGuiDependencies()
01810 {
01811         cout << "void K3dGui::SetGuiDependencies())" << endl;
01812         // Get number of windows
01813         for(unsigned int i=0; i<m_tGuiWindowArray.size(); i++)
01814         {
01815                 K3dGuiWindow *pWinParent = m_tGuiWindowArray[i];
01816                 const char* strName = "";
01817                 if(pWinParent)
01818                 {
01819                         // Get number of child windows
01820                         for(int j=0; j<pWinParent->GetNumChildNames(); j++)
01821                         {
01822                                 strName = pWinParent->GetChildName(j);
01823                                 K3dGuiWindow *pWinChild = FindWindow(strName);
01824                                 if(pWinChild)
01825                                 {
01826                                         // Add current child window to the parent window
01827                                         pWinParent->add(pWinChild, pWinChild->GetPosX(), pWinChild->GetPosY());
01828                                 }
01829                                 else
01830                                 {
01831                                         cerr << "Error :: void K3dGui::SetGuiDependencies() -- Child window Object " << strName << " doesn`t exist !!!" << endl;
01832                                 }
01833                         }
01834                 }
01835                 else
01836                 {
01837                         cerr << "Error :: void K3dGui::SetGuiDependencies() -- Parent window Object " << strName << " doesn`t exist !!!" << endl;
01838                 }
01839         }
01840         // Get number of containers
01841         for(unsigned int i=0; i<m_tGuiContainerArray.size(); i++)
01842         {
01843                 K3dGuiContainer *pContainer = m_tGuiContainerArray[i];
01844                 const char* strName = "";
01845                 if(pContainer)
01846                 {
01847                         // Get number of window names
01848                         for( int j=0; j<pContainer->GetNumWinNames(); j++)
01849                         {
01850                                 strName = pContainer->GetWinName(j);
01851                                 K3dGuiWindow *pWinChild = FindWindow(strName);
01852                                 if(pWinChild)
01853                                 {
01854                                         // Add current window to the containter
01855                                         pContainer->add(pWinChild, pWinChild->GetPosX(), pWinChild->GetPosY());
01856                                 }
01857                                 else
01858                                 {
01859                                         cerr << "Error :: void K3dGui::SetGuiDependencies() -- Child window Object " << strName << " doesn`t exist !!!" << endl;
01860                                 }
01861                         }
01862                 }
01863                 else
01864                 {
01865                         cerr << "Error :: void K3dGui::SetGuiDependencies() -- Parent window Object " << strName << " doesn`t exist !!!" << endl;
01866                 }
01867         }
01868 }
01869 
01872 K3dGuiWindow *K3dGui::FindWindow(const char* _strName)
01873 {
01874         K3dString kStr = _strName;
01875         for(unsigned int i=0; i<m_tGuiWindowArray.size(); i++)
01876         {
01877                 if(kStr == m_tGuiWindowArray[i]->GetName())
01878                 {
01879                         return m_tGuiWindowArray[i];
01880                 }
01881         }
01882         return NULL;
01883 }
01884 
01885 
01886 
01887 
01888 
01889 

Generated on Thu Aug 16 23:53:26 2007 for K3dEngine by  doxygen 1.5.0