[Gcblue-commits] gcb_wx/src/graphics tcButton.cpp,1.8,1.9 tcConsoleBox.cpp,1.1,1.2 tcEditBox.cpp,1.3
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-03-24 21:20:10
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30331/src/graphics Modified Files: tcButton.cpp tcConsoleBox.cpp tcEditBox.cpp tcRadioButton.cpp tcStandardWindow.cpp Log Message: Replaced libxml2 with TinyXml to make Xml easier to use Index: tcRadioButton.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcRadioButton.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcRadioButton.cpp 20 Mar 2004 18:46:46 -0000 1.2 --- tcRadioButton.cpp 24 Mar 2004 21:09:26 -0000 1.3 *************** *** 31,35 **** #include "tcButton.h" #include "wxcommands.h" ! #include "tcXMLFile.h" #include <iostream> --- 31,35 ---- #include "tcButton.h" #include "wxcommands.h" ! #include "common/tinyxml.h" #include <iostream> *************** *** 195,199 **** * version to initialize from XML file */ ! tcRadioButton::tcRadioButton(tcWindow *parent, tcXMLNode *config) : tcWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLButton", parent), caption("NULL"), --- 195,199 ---- * version to initialize from XML file */ ! tcRadioButton::tcRadioButton(tcWindow *parent, TiXmlNode *config) : tcWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLButton", parent), caption("NULL"), *************** *** 209,230 **** wxASSERT(config); if (config == NULL) return; - - int x = config->GetChildMatching("X").GetAsInt(); - int y = config->GetChildMatching("Y").GetAsInt(); - int width = config->GetChildMatching("Width").GetAsInt(); - int height = config->GetChildMatching("Height").GetAsInt(); - caption = config->GetChildMatching("Caption").GetText(); - SetCommand(config->GetChildMatching("Command").GetAsInt()); wxWindow::SetSize(x, y, width, height); // add buttons ! tcXMLNode current = config->GetChildMatching("Button"); ! while (current.IsValid()) { ! tcButton *button = new tcButton(this, ¤t); buttons.push_back(button); ! current = current.GetNextMatching("Button"); } --- 209,244 ---- wxASSERT(config); if (config == NULL) return; + TiXmlElement* current = config->ToElement(); + wxASSERT(current); + if (current == NULL) return; + + int x; + int y; + int width; + int height; + int command; + + current->Attribute("X", &x); + current->Attribute("Y", &y); + current->Attribute("Width", &width); + current->Attribute("Height", &height); + + current->Attribute("Command", &command); + SetCommand(command); + + caption = current->Attribute("Caption"); + + wxWindow::SetSize(x, y, width, height); // add buttons ! TiXmlNode* buttonNode = config->FirstChild("Button"); ! while (buttonNode) { ! tcButton *button = new tcButton(this, buttonNode); buttons.push_back(button); ! buttonNode = buttonNode->NextSibling("Button"); } Index: tcStandardWindow.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcStandardWindow.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcStandardWindow.cpp 20 Mar 2004 18:46:46 -0000 1.5 --- tcStandardWindow.cpp 24 Mar 2004 21:09:26 -0000 1.6 *************** *** 30,34 **** #include "tcStandardWindow.h" #include "wxcommands.h" ! #include "tcXMLFile.h" #include "tcButton.h" #include "tcRadioButton.h" --- 30,34 ---- #include "tcStandardWindow.h" #include "wxcommands.h" ! #include "common/tinyxml.h" #include "tcButton.h" #include "tcRadioButton.h" *************** *** 55,59 **** void tcStandardWindow::AddXMLControls() { ! if ((config == NULL)||(!config->GetRootNode().IsValid())) { std::cerr << "Error - tcStandardWindow::AddXMLControls - Null or invalid xml file" --- 55,59 ---- void tcStandardWindow::AddXMLControls() { ! if ((config == NULL)||(config->Error())) { std::cerr << "Error - tcStandardWindow::AddXMLControls - Null or invalid xml file" *************** *** 61,80 **** return; } - tcXMLNode root = config->GetRootNode(); // add buttons ! tcXMLNode current = root.GetChildMatching("Button"); ! while (current.IsValid()) { ! tcButton *button = new tcButton(this, ¤t); ! current = current.GetNextMatching("Button"); } // add radio buttons ! current = root.GetChildMatching("RadioButton"); ! while (current.IsValid()) { ! tcRadioButton *radioButton = new tcRadioButton(this, ¤t); ! current = current.GetNextMatching("RadioButton"); } --- 61,88 ---- return; } + // config is also the root node + TiXmlNode* root = config->FirstChild("Window"); + + if (!root) + { + std::cerr << + "Error - tcStandardWindow::AddXMLControls - <Window> xml tag not found at doc top\n"; + return; + } // add buttons ! TiXmlNode* current = root->FirstChild("Button"); ! while (current) { ! tcButton *button = new tcButton(this, current); ! current = current->NextSibling("Button"); } // add radio buttons ! current = root->FirstChild("RadioButton"); ! while (current) { ! tcRadioButton *radioButton = new tcRadioButton(this, current); ! current = current->NextSibling("RadioButton"); } *************** *** 106,110 **** if (configFile.length() > 2) { ! config = new tcXMLFile(configFile.c_str()); } else --- 114,125 ---- if (configFile.length() > 2) { ! ! config = new TiXmlDocument(configFile.c_str()); ! if (!config->LoadFile()) ! { ! delete config; ! config = NULL; ! std::cerr << "Error loading XML file " << configFile.c_str() << std::endl; ! } } else Index: tcButton.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcButton.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcButton.cpp 20 Mar 2004 18:46:46 -0000 1.8 --- tcButton.cpp 24 Mar 2004 21:09:26 -0000 1.9 *************** *** 30,34 **** #include "tcButton.h" #include "wxcommands.h" ! #include "tcXMLFile.h" #include "tcSound.h" #include <iostream> --- 30,34 ---- #include "tcButton.h" #include "wxcommands.h" ! #include "common/tinyxml.h" #include "tcSound.h" #include <iostream> *************** *** 222,226 **** * version to initialize from XML file */ ! tcButton::tcButton(tcWindow *parent, tcXMLNode *config) : tcWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLButton", parent) { --- 222,226 ---- * version to initialize from XML file */ ! tcButton::tcButton(tcWindow *parent, TiXmlNode *config) : tcWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLButton", parent) { *************** *** 244,262 **** if (config == NULL) return; ! int x = config->GetChildMatching("X").GetAsInt(); ! int y = config->GetChildMatching("Y").GetAsInt(); ! int width = config->GetChildMatching("Width").GetAsInt(); ! int height = config->GetChildMatching("Height").GetAsInt(); ! caption = config->GetChildMatching("Caption").GetText(); ! SetCommand(config->GetChildMatching("Command").GetAsInt()); ! std::string offImageName = config->GetChildMatching("OffImage").GetText(); ! if (offImageName.length() > 3) { ! std::string onImageName = config->GetChildMatching("OnImage").GetText(); ! std::string overOnImageName = config->GetChildMatching("OverOnImage").GetText(); ! std::string overOffImageName = config->GetChildMatching("OverOffImage").GetText(); LoadImages(offImageName, onImageName, overOffImageName, overOnImageName); - if (offImage) { --- 244,276 ---- if (config == NULL) return; ! TiXmlElement* current = config->ToElement(); ! wxASSERT(current); ! if (current == NULL) return; ! int x; ! int y; ! int width; ! int height; ! int command; ! ! current->Attribute("X", &x); ! current->Attribute("Y", &y); ! current->Attribute("Width", &width); ! current->Attribute("Height", &height); ! ! current->Attribute("Command", &command); ! SetCommand(command); ! ! caption = current->Attribute("Caption"); ! ! TiXmlNode* childNode = config->FirstChild("Image"); ! if (childNode) { ! TiXmlElement* imageElement = childNode->ToElement(); ! std::string offImageName = imageElement->Attribute("Off"); ! std::string onImageName = imageElement->Attribute("On"); ! std::string overOnImageName = imageElement->Attribute("OverOn"); ! std::string overOffImageName = imageElement->Attribute("OverOff"); LoadImages(offImageName, onImageName, overOffImageName, overOnImageName); if (offImage) { Index: tcConsoleBox.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcConsoleBox.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcConsoleBox.cpp 23 Mar 2004 18:22:37 -0000 1.1 --- tcConsoleBox.cpp 24 Mar 2004 21:09:26 -0000 1.2 *************** *** 26,30 **** #include "tcConsoleBox.h" #include "aerror.h" ! #include "tcXMLFile.h" #include <stdio.h> #include <iostream> --- 26,30 ---- #include "tcConsoleBox.h" #include "aerror.h" ! #include "common/tinyxml.h" #include <stdio.h> #include <iostream> *************** *** 240,244 **** ////////////////////////////////////////////////////////////////////// ! tcConsoleBox::tcConsoleBox(tcWindow *parent, tcXMLNode *config) : tcWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLConsoleBox", parent), mbRedraw(true), --- 240,244 ---- ////////////////////////////////////////////////////////////////////// ! tcConsoleBox::tcConsoleBox(tcWindow *parent, TiXmlNode *config) : tcWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLConsoleBox", parent), mbRedraw(true), *************** *** 258,262 **** mpPen = NULL; ! if (!config->IsValid()) { std::cerr << "Error - bad xml config file for Console Box" << std::endl; --- 258,262 ---- mpPen = NULL; ! if (!config) { std::cerr << "Error - bad xml config file for Console Box" << std::endl; *************** *** 265,276 **** } ! int x = config->GetChildMatching("X").GetAsInt(); ! int y = config->GetChildMatching("Y").GetAsInt(); ! int width = config->GetChildMatching("Width").GetAsInt(); ! int height = config->GetChildMatching("Height").GetAsInt(); SetSize(x, y, width, height); // set all size params nyzero = height - 20; ! float fontSize = config->GetChildMatching("FontSize").GetAsFloat(); if (fontSize == 0) { --- 265,292 ---- } ! /* some of code below should be moved to a parent class so it isn't ! * repeated so much ! */ ! TiXmlElement* current = config->ToElement(); ! wxASSERT(current); ! if (current == NULL) return; ! ! // read window dimensions from XML ! int x; ! int y; ! int width; ! int height; ! ! current->Attribute("X", &x); ! current->Attribute("Y", &y); ! current->Attribute("Width", &width); ! current->Attribute("Height", &height); ! SetSize(x, y, width, height); // set all size params nyzero = height - 20; ! double fontSize; ! current->Attribute("FontSize", &fontSize); ! if (fontSize == 0) { Index: tcEditBox.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcEditBox.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcEditBox.cpp 20 Mar 2004 18:46:46 -0000 1.3 --- tcEditBox.cpp 24 Mar 2004 21:09:26 -0000 1.4 *************** *** 30,34 **** #include "tcEditBox.h" #include "tcTime.h" ! #include "tcXMLFile.h" #include "tcSound.h" #include <iostream> --- 30,34 ---- #include "tcEditBox.h" #include "tcTime.h" ! #include "common/tinyxml.h" #include "tcSound.h" #include <iostream> *************** *** 263,267 **** } ! tcEditBox::tcEditBox(tcWindow *parent, tcXMLNode *config) : tcWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLEditBox", parent), isMouseOver(false), --- 263,267 ---- } ! tcEditBox::tcEditBox(tcWindow *parent, TiXmlNode *config) : tcWindow(parent, wxPoint(0,0), wxSize(10,10), "XMLEditBox", parent), isMouseOver(false), *************** *** 285,303 **** mrectTextCaption.Offset(-2,-mrectTextBar.Height-2); ! if (!config->IsValid()) return; - int x = config->GetChildMatching("X").GetAsInt(); - int y = config->GetChildMatching("Y").GetAsInt(); - int width = config->GetChildMatching("Width").GetAsInt(); - int height = config->GetChildMatching("Height").GetAsInt(); SetSize(x, y, width, height); // set all size params ! std::string caption = config->GetChildMatching("Caption").GetText(); ! strcpy(mzCaption,caption.c_str()); ! mrectTextBar.X = config->GetChildMatching("BarX").GetAsFloat(); ! mrectTextBar.Y = config->GetChildMatching("BarY").GetAsFloat(); ! mrectTextBar.Width = config->GetChildMatching("BarWidth").GetAsFloat(); ! mrectTextBar.Height = config->GetChildMatching("BarHeight").GetAsFloat(); mrectTextCaption = mrectTextBar; --- 285,327 ---- mrectTextCaption.Offset(-2,-mrectTextBar.Height-2); ! if (!config) ! { ! std::cerr << "Error - tcEditBox::tcEditBox - Bad xml node\n"; ! return; ! } ! ! TiXmlElement* current = config->ToElement(); ! wxASSERT(current); ! if (current == NULL) return; ! ! // read window dimensions from XML ! int x; ! int y; ! int width; ! int height; ! ! current->Attribute("X", &x); ! current->Attribute("Y", &y); ! current->Attribute("Width", &width); ! current->Attribute("Height", &height); SetSize(x, y, width, height); // set all size params ! std::string caption = current->Attribute("Caption"); ! strcpy(mzCaption, caption.c_str()); ! // read text edit bar dimensions from XML ! double barx; ! double bary; ! double barwidth; ! double barheight; ! ! current->Attribute("BarX", &barx); ! current->Attribute("BarY", &bary); ! current->Attribute("BarWidth", &barwidth); ! current->Attribute("BarHeight", &barheight); ! ! RectF textBar(barx, bary, barwidth, barheight); ! mrectTextBar = textBar; mrectTextCaption = mrectTextBar; |