Thread: [Saggui-svn] SF.net SVN: saggui: [47] trunk
Status: Beta
Brought to you by:
juvinious
From: <sag...@li...> - 2006-06-21 21:34:06
|
Revision: 47 Author: juvinious Date: 2006-06-21 14:33:52 -0700 (Wed, 21 Jun 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=47&view=rev Log Message: ----------- Added openlayer headers, build data, and additional build options Modified Paths: -------------- trunk/default.cbd trunk/include/saggui.h trunk/src/library_factory.cpp Added Paths: ----------- trunk/include/saggui/openlayer/ol_factory.h trunk/include/saggui/openlayer/ol_fonts.h trunk/include/saggui/openlayer/ol_gfx.h trunk/include/saggui/openlayer/ol_mouse.h trunk/include/saggui/openlayer/ol_system.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-06-22 16:01:34
|
Revision: 50 Author: juvinious Date: 2006-06-22 09:01:18 -0700 (Thu, 22 Jun 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=50&view=rev Log Message: ----------- Fixed demo from crashing Modified Paths: -------------- trunk/default.cbd trunk/include/saggui/graphics.h trunk/include/saggui/resource_manager.h trunk/src/allegro/al_gfx.cpp trunk/src/graphic_manager.cpp trunk/src/graphics.cpp trunk/src/gui_manager.cpp trunk/src/resource_manager.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-06-22 16:32:25
|
Revision: 51 Author: juvinious Date: 2006-06-22 09:32:13 -0700 (Thu, 22 Jun 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=51&view=rev Log Message: ----------- Removed demo/Alleg_def{cpp|h} not needed Modified Paths: -------------- trunk/default.cbd trunk/demo/include/Main.h trunk/demo/src/Main.cpp Removed Paths: ------------- trunk/demo/include/Alleg_def.h trunk/demo/src/Alleg_def.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-06-23 05:12:02
|
Revision: 56 Author: juvinious Date: 2006-06-22 22:11:46 -0700 (Thu, 22 Jun 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=56&view=rev Log Message: ----------- Cleaned up some code Modified Paths: -------------- trunk/INSTALL trunk/README trunk/default.cbd trunk/include/saggui/fonts.h trunk/include/saggui/mouse_manager.h trunk/include/saggui/widgets/win.h trunk/src/resource_manager.cpp trunk/src/widgets/win.cpp Removed Paths: ------------- trunk/src/allegro/al_fonts.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-06-23 09:06:48
|
Revision: 59 Author: juvinious Date: 2006-06-23 02:06:26 -0700 (Fri, 23 Jun 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=59&view=rev Log Message: ----------- Fixed demo to be one file Modified Paths: -------------- trunk/default.cbd trunk/demo/include/Main.h trunk/demo/include/line.h trunk/demo/src/Main.cpp trunk/demo/src/line.cpp trunk/include/saggui/widgets/win.h trunk/include/saggui.h trunk/src/widgets/win.cpp Added Paths: ----------- trunk/include/saggui/font.h trunk/src/font.cpp Removed Paths: ------------- trunk/include/saggui/fonts.h trunk/src/fonts.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-06-24 10:53:52
|
Revision: 61 Author: juvinious Date: 2006-06-24 03:52:19 -0700 (Sat, 24 Jun 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=61&view=rev Log Message: ----------- Font rendering system online, semi working Modified Paths: -------------- trunk/default.cbd trunk/demo/src/Main.cpp trunk/include/saggui/font.h trunk/include/saggui/graphics.h trunk/include/saggui/gui_manager.h trunk/include/saggui/resource_manager.h trunk/include/saggui/rgba.h trunk/include/saggui.h trunk/src/font.cpp trunk/src/gui_manager.cpp trunk/src/resource_manager.cpp trunk/src/rgba.cpp trunk/src/widgets/input_box.cpp trunk/src/widgets/text_box.cpp trunk/src/widgets/win.cpp Added Paths: ----------- trunk/demo/serif.ttf trunk/demo/verase.ttf trunk/include/saggui/font_manager.h trunk/src/font_manager.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-06-25 17:48:13
|
Revision: 66 Author: juvinious Date: 2006-06-25 10:47:53 -0700 (Sun, 25 Jun 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=66&view=rev Log Message: ----------- Optimized font rendering and implemented system font Modified Paths: -------------- trunk/default.cbd trunk/demo/src/Main.cpp trunk/include/saggui/font.h trunk/include/saggui/font_manager.h trunk/src/font.cpp trunk/src/font_manager.cpp trunk/src/resource_manager.cpp Added Paths: ----------- trunk/include/saggui/system_font.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-07-01 02:01:44
|
Revision: 76 Author: juvinious Date: 2006-06-30 19:01:22 -0700 (Fri, 30 Jun 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=76&view=rev Log Message: ----------- Improved loading time for fonts and added ascii enums for keys Modified Paths: -------------- trunk/default.cbd trunk/include/saggui/keys.h trunk/include/saggui/system_font.h trunk/src/font.cpp trunk/src/widgets/input_box.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-07-04 06:25:20
|
Revision: 83 Author: juvinious Date: 2006-07-03 23:24:51 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=83&view=rev Log Message: ----------- Updated default.cbd and the demo Modified Paths: -------------- trunk/default.cbd trunk/demo/src/Main.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-07-04 06:47:50
|
Revision: 84 Author: juvinious Date: 2006-07-03 23:47:38 -0700 (Mon, 03 Jul 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=84&view=rev Log Message: ----------- Updated the default.cbd with lots of fixes this time and upgraded cbuild.c Modified Paths: -------------- trunk/cbuild.c trunk/default.cbd This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-07-06 07:27:40
|
Revision: 87 Author: juvinious Date: 2006-07-06 00:27:31 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=87&view=rev Log Message: ----------- Updated cbuild.c with the latest, which fixes OSX issues Modified Paths: -------------- trunk/cbuild.c trunk/default.cbd This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-07-06 08:33:46
|
Revision: 88 Author: juvinious Date: 2006-07-06 01:33:22 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=88&view=rev Log Message: ----------- Added SDL headers to accomodate the drivers which will be added soon by mokkan \o/ Modified Paths: -------------- trunk/default.cbd trunk/include/saggui/allegro/al_gfx.h trunk/include/saggui/openlayer/ol_factory.h trunk/include/saggui/openlayer/ol_gfx.h trunk/include/saggui/openlayer/ol_mouse.h trunk/include/saggui/openlayer/ol_system.h trunk/src/library_factory.cpp Added Paths: ----------- trunk/include/saggui/openlayer/ol_keyinput.h trunk/include/saggui/sdl/ trunk/include/saggui/sdl/sdl_factory.h trunk/include/saggui/sdl/sdl_gfx.h trunk/include/saggui/sdl/sdl_keyinput.h trunk/include/saggui/sdl/sdl_mouse.h trunk/include/saggui/sdl/sdl_system.h trunk/src/sdl/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-07-06 10:59:07
|
Revision: 91 Author: juvinious Date: 2006-07-06 03:58:52 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=91&view=rev Log Message: ----------- Added timer class, updated rgba to privatize the font required method Modified Paths: -------------- trunk/demo/src/Main.cpp trunk/include/saggui/rgba.h trunk/include/saggui.h trunk/src/rgba.cpp Added Paths: ----------- trunk/LICENSE trunk/include/saggui/timer.h trunk/src/timer.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-09-15 07:51:19
|
Revision: 204 http://svn.sourceforge.net/saggui/?rev=204&view=rev Author: juvinious Date: 2006-09-15 00:51:12 -0700 (Fri, 15 Sep 2006) Log Message: ----------- Some changes to the produced header and to systemFont Modified Paths: -------------- trunk/default.cbd trunk/include/saggui/system_font.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-09-16 00:35:30
|
Revision: 205 http://svn.sourceforge.net/saggui/?rev=205&view=rev Author: juvinious Date: 2006-09-15 17:35:06 -0700 (Fri, 15 Sep 2006) Log Message: ----------- Removed the physical bitmaps in the demo/data dir. Added routine to graphic to load an image from a char array for internal/default graphics. Fixed other issues which graphic and it's derivitives. Modified Paths: -------------- trunk/demo/src/Main.cpp trunk/include/saggui/graphics.h trunk/include/saggui/gui_manager.h trunk/include/saggui/sdl/sdl_system.h trunk/src/allegro/al_gfx.cpp trunk/src/graphics.cpp trunk/src/gui_manager.cpp trunk/src/openlayer/ol_gfx.cpp trunk/src/resource_manager.cpp trunk/src/sdl/sdl_gfx.cpp trunk/src/sdl/sdl_system.cpp Added Paths: ----------- trunk/include/saggui/system_graphics.h Removed Paths: ------------- trunk/demo/data/arrow.bmp trunk/demo/data/cross.bmp trunk/demo/data/leftright.bmp trunk/demo/data/updown.bmp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-11-14 01:44:31
|
Revision: 260 http://svn.sourceforge.net/saggui/?rev=260&view=rev Author: juvinious Date: 2006-11-13 17:44:26 -0800 (Mon, 13 Nov 2006) Log Message: ----------- Corrected typo in checkBox Modified Paths: -------------- trunk/demo/src/Main.cpp trunk/include/saggui/widgets/checkbox.h trunk/src/widgets/checkbox.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-12-23 00:43:56
|
Revision: 292 http://svn.sourceforge.net/saggui/?rev=292&view=rev Author: juvinious Date: 2006-12-22 16:43:54 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Updated the default font renderer to better handle larger bitmaps Modified Paths: -------------- trunk/include/saggui/system_graphics.h trunk/src/bitmap_font.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-01-05 06:33:19
|
Revision: 309 http://svn.sourceforge.net/saggui/?rev=309&view=rev Author: juvinious Date: 2007-01-04 22:33:16 -0800 (Thu, 04 Jan 2007) Log Message: ----------- More prep for module relocation Modified Paths: -------------- trunk/CMakeLists.txt trunk/examples/demo/CMakeLists.txt trunk/utils/bmpdump/bmpdump-alleg.cpp trunk/utils/bmpdump/bmpdump-sdl.cpp Added Paths: ----------- trunk/cmake/ trunk/modules/agl/include/ trunk/modules/agl/src/ trunk/modules/allegro/include/ trunk/modules/allegro/src/ trunk/modules/freetype/CMakeLists.txt trunk/modules/freetype/include/ trunk/modules/freetype/include/ft_default.h trunk/modules/freetype/include/ft_font.h trunk/modules/freetype/src/ trunk/modules/freetype/src/ft_font.cpp trunk/modules/openlayer/include/ trunk/modules/openlayer/src/ trunk/modules/sdl/include/ trunk/modules/sdl/src/ trunk/modules/sdlgl/include/ trunk/modules/sdlgl/src/ trunk/utils/bmpdump/CMakeLists.txt Removed Paths: ------------- trunk/build/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-01-06 06:43:40
|
Revision: 316 http://svn.sourceforge.net/saggui/?rev=316&view=rev Author: juvinious Date: 2007-01-05 22:43:37 -0800 (Fri, 05 Jan 2007) Log Message: ----------- Moved the module headers into their respective directories. Added in a changelog to track progress, cleaned up the file installation portions. Modified Paths: -------------- trunk/CMakeLists.txt trunk/examples/demo/CMakeLists.txt trunk/modules/agl/CMakeLists.txt trunk/modules/allegro/CMakeLists.txt trunk/modules/freetype/CMakeLists.txt trunk/modules/openlayer/CMakeLists.txt trunk/modules/sdl/CMakeLists.txt trunk/modules/sdlgl/CMakeLists.txt Added Paths: ----------- trunk/CHANGELOG trunk/modules/agl/saggui_agl.h trunk/modules/allegro/saggui_alleg.h trunk/modules/freetype/saggui_freetype.h trunk/modules/openlayer/saggui_ol.h trunk/modules/sdl/saggui_sdl.h trunk/modules/sdlgl/saggui_sdlgl.h Removed Paths: ------------- trunk/include/saggui_agl.h trunk/include/saggui_alleg.h trunk/include/saggui_freetype.h trunk/include/saggui_ol.h trunk/include/saggui_sdl.h trunk/include/saggui_sdlgl.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-03-06 22:40:33
|
Revision: 401 http://svn.sourceforge.net/saggui/?rev=401&view=rev Author: juvinious Date: 2007-03-06 14:40:28 -0800 (Tue, 06 Mar 2007) Log Message: ----------- check changelog ;O Modified Paths: -------------- trunk/CHANGELOG trunk/include/saggui/graphics.h trunk/include/saggui/mouse_manager.h trunk/modules/opengl/src/opengl_gfx.cpp trunk/src/graphics.cpp trunk/src/mouse_manager.cpp trunk/src/style.cpp trunk/src/widgets/button.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-08-26 12:05:00
|
Revision: 463 http://saggui.svn.sourceforge.net/saggui/?rev=463&view=rev Author: juvinious Date: 2007-08-26 03:53:51 -0700 (Sun, 26 Aug 2007) Log Message: ----------- Some minor fixes and added the rest of the widget set to creationEngine Modified Paths: -------------- trunk/include/saggui/common.h trunk/include/saggui/creationengine.h trunk/modules/sagguixml/include/sagguixml.h trunk/modules/sagguixml/src/sagguixml.cpp trunk/src/creationengine.cpp trunk/src/widgets/label.cpp trunk/src/widgets/listbox.cpp Modified: trunk/include/saggui/common.h =================================================================== --- trunk/include/saggui/common.h 2007-08-26 07:56:51 UTC (rev 462) +++ trunk/include/saggui/common.h 2007-08-26 10:53:51 UTC (rev 463) @@ -300,6 +300,7 @@ * T_Editable - widget set editable if applicable \n * T_Off - widget off if applicable \n * T_On - widget on if applicable \n + * T_Color - color if applicable \n */ enum typeInfo { @@ -323,7 +324,8 @@ T_Modal, T_Editable, T_Off, - T_On + T_On, + T_Color }; } Modified: trunk/include/saggui/creationengine.h =================================================================== --- trunk/include/saggui/creationengine.h 2007-08-26 07:56:51 UTC (rev 462) +++ trunk/include/saggui/creationengine.h 2007-08-26 10:53:51 UTC (rev 463) @@ -59,7 +59,6 @@ { public: static const std::string BOX; - static const std::string BUTTONGROUP; static const std::string CHECKBOX; static const std::string DIALOG; static const std::string INPUTBOX; Modified: trunk/modules/sagguixml/include/sagguixml.h =================================================================== --- trunk/modules/sagguixml/include/sagguixml.h 2007-08-26 07:56:51 UTC (rev 462) +++ trunk/modules/sagguixml/include/sagguixml.h 2007-08-26 10:53:51 UTC (rev 463) @@ -70,14 +70,17 @@ //! Create windows from xml virtual void parseWindows(TiXmlElement *element, window *parent) throw (sagguiException); - - //! Do window specific things if required - virtual void windowExtra(TiXmlElement *element, window *win); protected: //! Document TiXmlDocument *doc; + //! Do windows children + virtual void children(TiXmlElement *element, window *parent); + + //! Specific to listbox + virtual void listbox(TiXmlElement *element, window *parent); + }; } Modified: trunk/modules/sagguixml/src/sagguixml.cpp =================================================================== --- trunk/modules/sagguixml/src/sagguixml.cpp 2007-08-26 07:56:51 UTC (rev 462) +++ trunk/modules/sagguixml/src/sagguixml.cpp 2007-08-26 10:53:51 UTC (rev 463) @@ -39,6 +39,7 @@ #include "sagguixml.h" #include "tinyxml.h" #include "window.h" +#include "widgets/listbox.h" namespace saggui { @@ -155,6 +156,10 @@ { temp.addInfo(T_On,element->Attribute("on")); } + if(element->Attribute("color")) + { + temp.addInfo(T_Color,element->Attribute("color")); + } } catch(const sagguiException &e) { @@ -166,27 +171,52 @@ if(!tempWin)throw sagguiException("Failed to load window: " + std::string(element->Value()) + "!"); - // Do other requirements for window - windowExtra(element, tempWin); + // Do specific child related elements + if(temp.getType() == windowMarkup::LISTBOX) + { + listbox(element, tempWin); + } + else + { + children(element, tempWin); + } - //parsing child elements + // Finally add this to the parent + if(parent)parent->addChild(tempWin); + } + + void xmlEngine::children(TiXmlElement *element, window *parent) + { TiXmlNode *child = element->FirstChild(); while(child != NULL) { TiXmlElement *elem = child->ToElement(); - parseWindows(elem,tempWin); - //child = doc->IterateChildren(child); + parseWindows(elem,parent); child = child->NextSibling(); } - - if(parent)parent->addChild(tempWin); } - - //! Do window specific things if required - void xmlEngine::windowExtra(TiXmlElement *element, window *win) + + void xmlEngine::listbox(TiXmlElement *element, window *parent) { - + TiXmlNode *child = element->FirstChild(); + listBox *temp = dynamic_cast<listBox *>(parent); + if(!temp)return; + bool hasItems = false; + while(child != NULL) + { + TiXmlElement *elem = child->ToElement(); + if(elem->Value() == std::string("li")) + { + if(!hasItems) + { + hasItems=true; + temp->clearItems(); + } + temp->addItem(elem->FirstChild()->Value()); + } + child = child->NextSibling(); + } } } Modified: trunk/src/creationengine.cpp =================================================================== --- trunk/src/creationengine.cpp 2007-08-26 07:56:51 UTC (rev 462) +++ trunk/src/creationengine.cpp 2007-08-26 10:53:51 UTC (rev 463) @@ -55,7 +55,6 @@ namespace saggui { const std::string windowMarkup::BOX = "box"; - const std::string windowMarkup::BUTTONGROUP = "buttongroup"; const std::string windowMarkup::CHECKBOX = "checkbox"; const std::string windowMarkup::DIALOG = "dialog"; const std::string windowMarkup::INPUTBOX = "inputbox"; @@ -67,6 +66,29 @@ const std::string windowMarkup::SCROLLBAR = "scrollbar"; const std::string windowMarkup::TEXTBOX = "textbox"; + rgba getColor(const std::string &color) + { + if(color == "black")return rgba::BLACK; + if(color == "white")return rgba::WHITE; + if(color == "darkgray")return rgba::DARKGRAY; + if(color == "gray")return rgba::GRAY; + if(color == "darkred")return rgba::DARKRED; + if(color == "red")return rgba::RED; + if(color == "darkblue")return rgba::DARKBLUE; + if(color == "blue")return rgba::BLUE; + if(color == "darkgreen")return rgba::DARKGREEN; + if(color == "green")return rgba::GREEN; + if(color == "darkyellow")return rgba::DARKYELLOW; + if(color == "yellow")return rgba::YELLOW; + if(color == "darkteal")return rgba::DARKTEAL; + if(color == "teal")return rgba::TEAL; + if(color == "darkpink")return rgba::DARKPINK; + if(color == "pink")return rgba::PINK; + if(color == "darkorange")return rgba::DARKORANGE; + if(color == "orange")return rgba::ORANGE; + return rgba(); + } + windowMarkup::windowMarkup(const std::string &type) { addInfo(T_Type, type); @@ -146,20 +168,32 @@ } try { - if(win.getType() == windowMarkup::BUTTONGROUP) - { - - } - } - catch(const sagguiException &e) - { - // Nothing - } - try - { if(win.getType() == windowMarkup::CHECKBOX) { - + temp = new checkBox(); + try + { + setWindowDefaults(temp,win); + try + { + checkBox *t = dynamic_cast<checkBox *>(temp); + if(t) + { + t->setEnabled(win.getBool(T_Checked)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -170,7 +204,17 @@ { if(win.getType() == windowMarkup::DIALOG) { - + temp = new dialog(); + try + { + setWindowDefaults(temp,win); + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -181,7 +225,30 @@ { if(win.getType() == windowMarkup::INPUTBOX) { - + temp = new inputBox(); + try + { + setWindowDefaults(temp,win); + try + { + inputBox *t = dynamic_cast<inputBox *>(temp); + if(t) + { + t->setText(win.getString(T_Text)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -192,7 +259,30 @@ { if(win.getType() == windowMarkup::LABEL) { - + temp = new label(); + try + { + setWindowDefaults(temp,win); + try + { + label *t = dynamic_cast<label *>(temp); + if(t) + { + t->setText(win.getString(T_Text)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -204,7 +294,19 @@ { if(win.getType() == windowMarkup::LISTBOX) { - + temp = new listBox(); + try + { + setWindowDefaults(temp,win); + listBox *t = dynamic_cast<listBox *>(temp); + if(t)t->addItem("EmptyList"); + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -216,7 +318,54 @@ { if(win.getType() == windowMarkup::PROGRESSBAR) { - + temp = new progressBar(); + try + { + setWindowDefaults(temp,win); + try + { + progressBar *t = dynamic_cast<progressBar *>(temp); + if(t) + { + t->setMax(win.getDouble(T_Max)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + try + { + progressBar *t = dynamic_cast<progressBar *>(temp); + if(t) + { + t->setProgress(win.getDouble(T_Index)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + try + { + progressBar *t = dynamic_cast<progressBar *>(temp); + if(t) + { + t->setColor(getColor(win.getString(T_Color))); + } + } + catch(const sagguiException &e) + { + // Nothing + } + + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -228,7 +377,44 @@ { if(win.getType() == windowMarkup::PUSHBUTTON) { - + temp = new pushButton(); + try + { + setWindowDefaults(temp,win); + try + { + pushButton *t = dynamic_cast<pushButton *>(temp); + if(t) + { + graphic *bmp = resourceManager::createGraphic(); + bmp->loadBmp(win.getString(T_Image)); + t->setIcon(bmp); + } + } + catch(const sagguiException &e) + { + // Nothing + } + + try + { + pushButton *t = dynamic_cast<pushButton *>(temp); + if(t) + { + t->setText(win.getString(T_Text)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -240,7 +426,30 @@ { if(win.getType() == windowMarkup::RADIAL) { - + temp = new radial(); + try + { + setWindowDefaults(temp,win); + try + { + radial *t = dynamic_cast<radial *>(temp); + if(t) + { + t->setEnabled(win.getBool(T_Checked)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -252,7 +461,42 @@ { if(win.getType() == windowMarkup::SCROLLBAR) { - + temp = new scrollBar(); + try + { + setWindowDefaults(temp,win); + try + { + scrollBar *t = dynamic_cast<scrollBar *>(temp); + if(t) + { + t->setMaxSize(win.getInt(T_Max)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + try + { + scrollBar *t = dynamic_cast<scrollBar *>(temp); + if(t) + { + t->setIndex(win.getInt(T_Index)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) @@ -263,7 +507,30 @@ { if(win.getType() == windowMarkup::TEXTBOX) { - + temp = new textBox(); + try + { + setWindowDefaults(temp,win); + try + { + textBox *t = dynamic_cast<textBox *>(temp); + if(t) + { + t->setText(win.getString(T_Text)); + } + } + catch(const sagguiException &e) + { + // Nothing + } + + addWindow(win.getString(T_Id),temp); + } + catch(const sagguiException &e) + { + if(temp)delete temp; + temp = 0; + } } } catch(const sagguiException &e) Modified: trunk/src/widgets/label.cpp =================================================================== --- trunk/src/widgets/label.cpp 2007-08-26 07:56:51 UTC (rev 462) +++ trunk/src/widgets/label.cpp 2007-08-26 10:53:51 UTC (rev 463) @@ -50,7 +50,8 @@ setFont(resourceManager::getFont()); textColor = rgba::BLACK; autoResizable = false; - hAlignment = vAlignment = MIDDLE; + hAlignment = LEFT; + vAlignment = MIDDLE; x1 = y1 =0; setAttribute(AT_Sunken, true); onPaint.connect(this,&label::draw); Modified: trunk/src/widgets/listbox.cpp =================================================================== --- trunk/src/widgets/listbox.cpp 2007-08-26 07:56:51 UTC (rev 462) +++ trunk/src/widgets/listbox.cpp 2007-08-26 10:53:51 UTC (rev 463) @@ -71,7 +71,7 @@ highlightedItem=0; } - listBox::~listBox() { } + listBox::~listBox() { clearItems(); } // Add item void listBox::addItem(const std::string &text) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-08-31 14:48:59
|
Revision: 469 http://saggui.svn.sourceforge.net/saggui/?rev=469&view=rev Author: juvinious Date: 2007-08-31 07:48:53 -0700 (Fri, 31 Aug 2007) Log Message: ----------- Finished changes for paintEvent Modified Paths: -------------- trunk/CHANGELOG trunk/cmake/saggui.h.in trunk/examples/demo/include/test_classes.h trunk/examples/demo/src/test_classes.cpp trunk/examples/gamedemo/include/gamedemo.h trunk/examples/gamedemo/src/gamedemo.cpp trunk/include/saggui/schemes/defaultscheme.h trunk/include/saggui/style.h trunk/include/saggui/widgets/abstractbutton.h trunk/include/saggui/widgets/box.h trunk/include/saggui/widgets/button.h trunk/include/saggui/widgets/checkbox.h trunk/include/saggui/widgets/input_box.h trunk/include/saggui/widgets/listbox.h trunk/include/saggui/widgets/progress_bar.h trunk/include/saggui/widgets/pushbutton.h trunk/include/saggui/widgets/radial.h trunk/include/saggui/widgets/scroll_bar.h trunk/include/saggui/widgets/text_box.h trunk/src/gui_manager.cpp trunk/src/schemes/defaultscheme.cpp trunk/src/style.cpp trunk/src/widgets/box.cpp trunk/src/widgets/button.cpp trunk/src/widgets/checkbox.cpp trunk/src/widgets/input_box.cpp trunk/src/widgets/listbox.cpp trunk/src/widgets/progress_bar.cpp trunk/src/widgets/pushbutton.cpp trunk/src/widgets/radial.cpp trunk/src/widgets/scroll_bar.cpp trunk/src/widgets/text_box.cpp Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/CHANGELOG 2007-08-31 14:48:53 UTC (rev 469) @@ -1,4 +1,5 @@ 0.50 +- Converted all paint signals to use the new paintEvent class - Added paintEvent class for passing paint info for onPaint events - Added xml demo for allegro to the repository - Completed some more widget information in sagguixml making it quite useable Modified: trunk/cmake/saggui.h.in =================================================================== --- trunk/cmake/saggui.h.in 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/cmake/saggui.h.in 2007-08-31 14:48:53 UTC (rev 469) @@ -72,6 +72,7 @@ #include "saggui/mouse_events.h" #include "saggui/mouse.h" #include "saggui/mouse_manager.h" +#include "saggui/paintevent.h" #include "saggui/resource_manager.h" #include "saggui/rgba.h" #include "saggui/scheme.h" Modified: trunk/examples/demo/include/test_classes.h =================================================================== --- trunk/examples/demo/include/test_classes.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/examples/demo/include/test_classes.h 2007-08-31 14:48:53 UTC (rev 469) @@ -77,9 +77,9 @@ ~testDecorator(); - void doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape); + void doBackground(saggui::paintEvent &e); - void doForeground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape); + void doForeground(saggui::paintEvent &e); lines *line; saggui::rgba circleColor1; Modified: trunk/examples/demo/src/test_classes.cpp =================================================================== --- trunk/examples/demo/src/test_classes.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/examples/demo/src/test_classes.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -163,33 +163,33 @@ // Nothing } - void testDecorator::doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape) + void testDecorator::doBackground(saggui::paintEvent &e) { line->update(); - bmp->doRectfill(size.x,size.y,size.width,size.height,colors[saggui::S_StandardBg]); - bmp->doCirclefill(size.x+100, size.y+100, 50,circleColor1); - bmp->doCirclefill(size.x+80, size.y+80, 5,circleColor2); - bmp->doCirclefill(size.x+110, size.y+80, 5,circleColor2); - bmp->doCirclefill(size.x+95, size.y+120, 15,circleColor3); - line->draw(bmp); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,e.getColors()[saggui::S_StandardBg]); + e.getGraphic()->doCirclefill(e.getPosition().x+100, e.getPosition().y+100, 50,circleColor1); + e.getGraphic()->doCirclefill(e.getPosition().x+80, e.getPosition().y+80, 5,circleColor2); + e.getGraphic()->doCirclefill(e.getPosition().x+110, e.getPosition().y+80, 5,circleColor2); + e.getGraphic()->doCirclefill(e.getPosition().x+95, e.getPosition().y+120, 15,circleColor3); + line->draw(e.getGraphic()); } - void testDecorator::doForeground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape) + void testDecorator::doForeground(saggui::paintEvent &e) { //foreground.set(rand()%255,rand()%255,rand()%255,rand()%255); // Do top - bmp->doRectfill(size.x,size.y,size.width-1,1+topPadding,colors[saggui::S_StandardFg]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width-1,1+topPadding,e.getColors()[saggui::S_StandardFg]); // Do left - bmp->doRectfill(size.x,size.y,1+leftPadding,size.height-1,colors[saggui::S_StandardFg]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,1+leftPadding,e.getPosition().height-1,e.getColors()[saggui::S_StandardFg]); // Do right - bmp->doRectfill(size.x+(size.width-1)-rightPadding,size.y+1,rightPadding+1,size.height-1,colors[saggui::S_StandardFg]); + e.getGraphic()->doRectfill(e.getPosition().x+(e.getPosition().width-1)-rightPadding,e.getPosition().y+1,rightPadding+1,e.getPosition().height-1,e.getColors()[saggui::S_StandardFg]); // Do bottom - bmp->doRectfill(size.x+1,size.y+(size.height-1)-bottomPadding,size.width-1,bottomPadding+1,colors[saggui::S_StandardFg]); + e.getGraphic()->doRectfill(e.getPosition().x+1,e.getPosition().y+(e.getPosition().height-1)-bottomPadding,e.getPosition().width-1,bottomPadding+1,e.getColors()[saggui::S_StandardFg]); } //Constructor Modified: trunk/examples/gamedemo/include/gamedemo.h =================================================================== --- trunk/examples/gamedemo/include/gamedemo.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/examples/gamedemo/include/gamedemo.h 2007-08-31 14:48:53 UTC (rev 469) @@ -98,7 +98,7 @@ ~blankDecor(); - void doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape); + void doBackground(paintEvent &e); }; class basicDecor : public saggui::style @@ -108,9 +108,9 @@ ~basicDecor(); - void doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape); + void doBackground(paintEvent &e); - void doForeground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape); + void doForeground(paintEvent &e); }; class filledDecor : public saggui::style @@ -120,9 +120,9 @@ ~filledDecor(); - void doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape); + void doBackground(paintEvent &e); - void doForeground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape); + void doForeground(paintEvent &e); }; class plainDecor : public saggui::style @@ -132,7 +132,7 @@ ~plainDecor(); - void doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape); + void doBackground(paintEvent &e); }; class icon : public has_slots<> Modified: trunk/examples/gamedemo/src/gamedemo.cpp =================================================================== --- trunk/examples/gamedemo/src/gamedemo.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/examples/gamedemo/src/gamedemo.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -182,9 +182,9 @@ { } -void blankDecor::doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape) +void blankDecor::doBackground(paintEvent &e) { - bmp->clearBmp(rgba::PINK); + e.getGraphic()->clearBmp(rgba::PINK); } basicDecor::basicDecor() @@ -200,37 +200,37 @@ { } -void basicDecor::doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape) +void basicDecor::doBackground(paintEvent &e) { - rgba temp(colors[saggui::S_StandardBg].red-40,colors[saggui::S_StandardBg].green-40,colors[saggui::S_StandardBg].blue-40,255); - bmp->doRectfill(size.x,size.y,size.width,size.height,temp); - bmp->doRectfill(size.x+5,size.y+5,size.width-10,size.height-10,colors[saggui::S_StandardBg]); - bmp->doRectfill(size.x,size.y,2,2,rgba::PINK); - bmp->doRectfill(size.x,size.y+size.height-2,2,2,rgba::PINK); - bmp->doRectfill(size.x+size.width-2,size.y,2,2,rgba::PINK); - bmp->doRectfill(size.x+size.width-2,size.y+size.height-2,2,2,rgba::PINK); - bmp->placePixel(size.x+2,size.y+2,temp); - bmp->placePixel(size.x+size.width-2,size.y+size.height-2,temp); - bmp->placePixel(size.x+2,size.y+size.height-2,temp); - bmp->placePixel(size.x+size.width-2,size.y+2,temp); + rgba temp(e.getColors()[saggui::S_StandardBg].red-40,e.getColors()[saggui::S_StandardBg].green-40,e.getColors()[saggui::S_StandardBg].blue-40,255); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,temp); + e.getGraphic()->doRectfill(e.getPosition().x+5,e.getPosition().y+5,e.getPosition().width-10,e.getPosition().height-10,e.getColors()[saggui::S_StandardBg]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,2,2,rgba::PINK); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y+e.getPosition().height-2,2,2,rgba::PINK); + e.getGraphic()->doRectfill(e.getPosition().x+e.getPosition().width-2,e.getPosition().y,2,2,rgba::PINK); + e.getGraphic()->doRectfill(e.getPosition().x+e.getPosition().width-2,e.getPosition().y+e.getPosition().height-2,2,2,rgba::PINK); + e.getGraphic()->placePixel(e.getPosition().x+2,e.getPosition().y+2,temp); + e.getGraphic()->placePixel(e.getPosition().x+e.getPosition().width-2,e.getPosition().y+e.getPosition().height-2,temp); + e.getGraphic()->placePixel(e.getPosition().x+2,e.getPosition().y+e.getPosition().height-2,temp); + e.getGraphic()->placePixel(e.getPosition().x+e.getPosition().width-2,e.getPosition().y+2,temp); } -void basicDecor::doForeground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape) +void basicDecor::doForeground(paintEvent &e) { - bmp->doLine(size.x+3,size.y,size.x+size.width-3,size.y,colors[saggui::S_StandardFg]); - bmp->doLine(size.x,size.y+3,size.x,size.y+size.height-3,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+3,size.y+size.height,size.x+size.width-3,size.y+size.height,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+size.width,size.y+3,size.x+size.width,size.y+size.height-3,colors[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+3,e.getPosition().y,e.getPosition().x+e.getPosition().width-3,e.getPosition().y,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+3,e.getPosition().x,e.getPosition().y+e.getPosition().height-3,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+3,e.getPosition().y+e.getPosition().height,e.getPosition().x+e.getPosition().width-3,e.getPosition().y+e.getPosition().height,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width,e.getPosition().y+3,e.getPosition().x+e.getPosition().width,e.getPosition().y+e.getPosition().height-3,e.getColors()[saggui::S_StandardFg]); - bmp->doLine(size.x,size.y+3,size.x+3,size.y,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+size.width-3,size.y,size.x+size.width,size.y+3,colors[saggui::S_StandardFg]); - bmp->doLine(size.x,size.y+size.height-3,size.x+3,size.y+size.height,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+size.width-3,size.y+size.height,size.x+size.width,size.y+size.height-3,colors[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+3,e.getPosition().x+3,e.getPosition().y,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width-3,e.getPosition().y,e.getPosition().x+e.getPosition().width,e.getPosition().y+3,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+e.getPosition().height-3,e.getPosition().x+3,e.getPosition().y+e.getPosition().height,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width-3,e.getPosition().y+e.getPosition().height,e.getPosition().x+e.getPosition().width,e.getPosition().y+e.getPosition().height-3,e.getColors()[saggui::S_StandardFg]); - bmp->doLine(size.x+4,size.y+4,size.x+size.width-4,size.y+4,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+4,size.y+4,size.x+4,size.y+size.height-4,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+4,size.y+size.height-4,size.x+size.width-4,size.y+size.height-4,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+size.width-4,size.y+4,size.x+size.width-4,size.y+size.height-4,colors[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+4,e.getPosition().y+4,e.getPosition().x+e.getPosition().width-4,e.getPosition().y+4,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+4,e.getPosition().y+4,e.getPosition().x+4,e.getPosition().y+e.getPosition().height-4,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+4,e.getPosition().y+e.getPosition().height-4,e.getPosition().x+e.getPosition().width-4,e.getPosition().y+e.getPosition().height-4,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width-4,e.getPosition().y+4,e.getPosition().x+e.getPosition().width-4,e.getPosition().y+e.getPosition().height-4,e.getColors()[saggui::S_StandardFg]); } filledDecor::filledDecor() @@ -246,30 +246,30 @@ { } -void filledDecor::doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape) +void filledDecor::doBackground(paintEvent &e) { - bmp->doRectfill(size.x,size.y,size.width,size.height,colors[saggui::S_StandardBg]); - bmp->doRectfill(size.x,size.y,2,2,rgba::PINK); - bmp->doRectfill(size.x,size.y+size.height-2,2,2,rgba::PINK); - bmp->doRectfill(size.x+size.width-2,size.y,2,2,rgba::PINK); - bmp->doRectfill(size.x+size.width-2,size.y+size.height-2,2,2,rgba::PINK); - bmp->placePixel(size.x+2,size.y+2,colors[saggui::S_StandardBg]); - bmp->placePixel(size.x+size.width-2,size.y+size.height-2,colors[saggui::S_StandardBg]); - bmp->placePixel(size.x+2,size.y+size.height-2,colors[saggui::S_StandardBg]); - bmp->placePixel(size.x+size.width-2,size.y+2,colors[saggui::S_StandardBg]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,e.getColors()[saggui::S_StandardBg]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,2,2,rgba::PINK); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y+e.getPosition().height-2,2,2,rgba::PINK); + e.getGraphic()->doRectfill(e.getPosition().x+e.getPosition().width-2,e.getPosition().y,2,2,rgba::PINK); + e.getGraphic()->doRectfill(e.getPosition().x+e.getPosition().width-2,e.getPosition().y+e.getPosition().height-2,2,2,rgba::PINK); + e.getGraphic()->placePixel(e.getPosition().x+2,e.getPosition().y+2,e.getColors()[saggui::S_StandardBg]); + e.getGraphic()->placePixel(e.getPosition().x+e.getPosition().width-2,e.getPosition().y+e.getPosition().height-2,e.getColors()[saggui::S_StandardBg]); + e.getGraphic()->placePixel(e.getPosition().x+2,e.getPosition().y+e.getPosition().height-2,e.getColors()[saggui::S_StandardBg]); + e.getGraphic()->placePixel(e.getPosition().x+e.getPosition().width-2,e.getPosition().y+2,e.getColors()[saggui::S_StandardBg]); } -void filledDecor::doForeground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape) +void filledDecor::doForeground(paintEvent &e) { - bmp->doLine(size.x+3,size.y,size.x+size.width-3,size.y,colors[saggui::S_StandardFg]); - bmp->doLine(size.x,size.y+3,size.x,size.y+size.height-3,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+3,size.y+size.height,size.x+size.width-3,size.y+size.height,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+size.width,size.y+3,size.x+size.width,size.y+size.height-3,colors[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+3,e.getPosition().y,e.getPosition().x+e.getPosition().width-3,e.getPosition().y,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+3,e.getPosition().x,e.getPosition().y+e.getPosition().height-3,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+3,e.getPosition().y+e.getPosition().height,e.getPosition().x+e.getPosition().width-3,e.getPosition().y+e.getPosition().height,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width,e.getPosition().y+3,e.getPosition().x+e.getPosition().width,e.getPosition().y+e.getPosition().height-3,e.getColors()[saggui::S_StandardFg]); - bmp->doLine(size.x,size.y+3,size.x+3,size.y,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+size.width-3,size.y,size.x+size.width,size.y+3,colors[saggui::S_StandardFg]); - bmp->doLine(size.x,size.y+size.height-3,size.x+3,size.y+size.height,colors[saggui::S_StandardFg]); - bmp->doLine(size.x+size.width-3,size.y+size.height,size.x+size.width,size.y+size.height-3,colors[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+3,e.getPosition().x+3,e.getPosition().y,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width-3,e.getPosition().y,e.getPosition().x+e.getPosition().width,e.getPosition().y+3,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+e.getPosition().height-3,e.getPosition().x+3,e.getPosition().y+e.getPosition().height,e.getColors()[saggui::S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width-3,e.getPosition().y+e.getPosition().height,e.getPosition().x+e.getPosition().width,e.getPosition().y+e.getPosition().height-3,e.getColors()[saggui::S_StandardFg]); } plainDecor::plainDecor() @@ -283,9 +283,9 @@ { } -void plainDecor::doBackground(const saggui::coord &size, saggui::graphic *bmp, const std::vector<saggui::rgba> &colors, const uint32_t &flags, const saggui::shapeType &shape) +void plainDecor::doBackground(paintEvent &e) { - bmp->doRectfill(size.x,size.y,size.width,size.height,rgba::PINK); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,rgba::PINK); } void icon::showText(const coord &c) Modified: trunk/include/saggui/schemes/defaultscheme.h =================================================================== --- trunk/include/saggui/schemes/defaultscheme.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/schemes/defaultscheme.h 2007-08-31 14:48:53 UTC (rev 469) @@ -88,10 +88,10 @@ ~basicStyle(); //! Allows us to draw both to the actual widget - void drawBackground(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + void drawBackground(paintEvent &e); //! Allows us to draw both to the parent graphic for bordering - void drawForeground(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + void drawForeground(paintEvent &e); }; //! The Button window style @@ -106,10 +106,10 @@ ~buttonStyle(); //! Allows us to draw both to the actual widget - void drawBackground(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + void drawBackground(paintEvent &e); //! Allows us to draw both to the parent graphic for bordering - void drawForeground(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + void drawForeground(paintEvent &e); }; } Modified: trunk/include/saggui/style.h =================================================================== --- trunk/include/saggui/style.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/style.h 2007-08-31 14:48:53 UTC (rev 469) @@ -42,6 +42,7 @@ #include "common.h" #include "sigslot.h" #include "dllspec.h" +#include "paintevent.h" #include <vector> //! Simplified All Gaming Graphical User Interface @@ -69,8 +70,8 @@ friend class guiManager; protected: //! \name SIGNALS - signal5<const coord &, graphic *, const std::vector<rgba> &, const uint32_t &, const shapeType &> onPaintBackground; - signal5<const coord &, graphic *, const std::vector<rgba> &, const uint32_t &, const shapeType &> onPaintForeground; + signal1<paintEvent &> onPaintBackground; + signal1<paintEvent &> onPaintForeground; public: //! Constructor @@ -108,10 +109,10 @@ ~defaultStyle(); //! Allows us to draw both to the actual widget - slot drawBackground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + slot drawBackground(paintEvent &e); //! Allows us to draw both to the parent graphic for bordering - slot drawForeground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + slot drawForeground(paintEvent &e); }; //! The Dialog style Class @@ -129,10 +130,10 @@ ~defaultDialogStyle(); //! Allows us to draw both to the actual widget - slot drawBackground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + slot drawBackground(paintEvent &e); //! Allows us to draw both to the parent graphic for bordering - slot drawForeground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + slot drawForeground(paintEvent &e); }; } Modified: trunk/include/saggui/widgets/abstractbutton.h =================================================================== --- trunk/include/saggui/widgets/abstractbutton.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/abstractbutton.h 2007-08-31 14:48:53 UTC (rev 469) @@ -148,7 +148,7 @@ rgba fontColor; //! \name PROTECTED SLOTS - virtual slot paintEvent(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) = 0; + virtual slot paint(paintEvent &e) = 0; virtual slot setClickSystem(mouseButtons type); //! \name PROTECTED SIGNALS Modified: trunk/include/saggui/widgets/box.h =================================================================== --- trunk/include/saggui/widgets/box.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/box.h 2007-08-31 14:48:53 UTC (rev 469) @@ -63,7 +63,7 @@ bool connected; //! \name Slots - virtual void render(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + virtual void render(paintEvent &e); public: //! Constructor box(); Modified: trunk/include/saggui/widgets/button.h =================================================================== --- trunk/include/saggui/widgets/button.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/button.h 2007-08-31 14:48:53 UTC (rev 469) @@ -84,7 +84,7 @@ coord textPosition; //! \name Slots - virtual void render(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + virtual void render(paintEvent &e); //! on Resize virtual void resize(); Modified: trunk/include/saggui/widgets/checkbox.h =================================================================== --- trunk/include/saggui/widgets/checkbox.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/checkbox.h 2007-08-31 14:48:53 UTC (rev 469) @@ -66,7 +66,7 @@ void setClickSystem(mouseButtons type); //! \name Slots - virtual void render(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + virtual void render(paintEvent &e); virtual void clicked(const coord &c); public: //! Constructor Modified: trunk/include/saggui/widgets/input_box.h =================================================================== --- trunk/include/saggui/widgets/input_box.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/input_box.h 2007-08-31 14:48:53 UTC (rev 469) @@ -126,7 +126,7 @@ void update(); //! Draw - void draw(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + void draw(paintEvent &e); //! Keypresses void keyPress(const keys &k); Modified: trunk/include/saggui/widgets/listbox.h =================================================================== --- trunk/include/saggui/widgets/listbox.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/listbox.h 2007-08-31 14:48:53 UTC (rev 469) @@ -74,7 +74,7 @@ protected: slot resized(); - slot drawOnButton(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + slot drawOnButton(paintEvent &e); slot showPopUp(); @@ -84,7 +84,7 @@ slot onHoverItem(const coord &pos); - slot onHoverDraw(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + slot onHoverDraw(paintEvent &e); slot onSelectItem(const coord &pos); Modified: trunk/include/saggui/widgets/progress_bar.h =================================================================== --- trunk/include/saggui/widgets/progress_bar.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/progress_bar.h 2007-08-31 14:48:53 UTC (rev 469) @@ -71,7 +71,7 @@ rgba color; //! draw the progress bar - void draw(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + void draw(paintEvent &e); //! round a number inline double round(double t); Modified: trunk/include/saggui/widgets/pushbutton.h =================================================================== --- trunk/include/saggui/widgets/pushbutton.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/pushbutton.h 2007-08-31 14:48:53 UTC (rev 469) @@ -67,7 +67,7 @@ protected: //! \name PROTECTED SLOTS - virtual slot paintEvent(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + virtual slot paint(paintEvent &e); private: //! Text location coord textPosition; Modified: trunk/include/saggui/widgets/radial.h =================================================================== --- trunk/include/saggui/widgets/radial.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/radial.h 2007-08-31 14:48:53 UTC (rev 469) @@ -67,7 +67,7 @@ void setClickSystem(mouseButtons type); //! \name Slots - virtual void render(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + virtual void render(paintEvent &e); virtual void clicked(const coord &c); public: //! Constructor Modified: trunk/include/saggui/widgets/scroll_bar.h =================================================================== --- trunk/include/saggui/widgets/scroll_bar.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/scroll_bar.h 2007-08-31 14:48:53 UTC (rev 469) @@ -158,9 +158,9 @@ virtual void middleButtonMove(); virtual void middleButtonUp(const coord &c); virtual void resizeButtons(); - virtual void drawButtonTop(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); - virtual void drawButtonBottom(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); - virtual void drawButtonMiddle(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + virtual void drawButtonTop(paintEvent &e); + virtual void drawButtonBottom(paintEvent &e); + virtual void drawButtonMiddle(paintEvent &e); public: //! Constructor scrollBar(); Modified: trunk/include/saggui/widgets/text_box.h =================================================================== --- trunk/include/saggui/widgets/text_box.h 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/include/saggui/widgets/text_box.h 2007-08-31 14:48:53 UTC (rev 469) @@ -116,7 +116,7 @@ void formatText(); //! Render text - void render(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + void render(paintEvent &e); //! Resize viewport void resizeViewPort(int layout, bool enable=false); Modified: trunk/src/gui_manager.cpp =================================================================== --- trunk/src/gui_manager.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/gui_manager.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -249,13 +249,13 @@ paintInfo.setPosition(temp); if((*i)->wStyle) { - (*i)->wStyle->onPaintBackground.emit(temp,(*i)->background,(*i)->wColors, (*i)->attributes, (*i)->shape); + (*i)->wStyle->onPaintBackground.emit(paintInfo); (*i)->onPaint.emit(paintInfo); if(!(*i)->children.empty()) { doWindowRender((*i)->children,(*i)->background); } - (*i)->wStyle->onPaintForeground.emit(temp,(*i)->background,(*i)->wColors, (*i)->attributes, (*i)->shape); + (*i)->wStyle->onPaintForeground.emit(paintInfo); (*i)->background->renderBmp(0,0,(*i)->position.x, (*i)->position.y,(*i)->background->getBmpWidth(), (*i)->background->getBmpHeight(), rgba::NOCOLOR, bmp); } else @@ -277,13 +277,13 @@ paintInfo.setPosition(temp); if((*i)->wStyle) { - (*i)->wStyle->onPaintBackground.emit(temp,bmp,(*i)->wColors, (*i)->attributes, (*i)->shape); + (*i)->wStyle->onPaintBackground.emit(paintInfo); (*i)->onPaint.emit(paintInfo); if(!(*i)->children.empty()) { doWindowRender((*i)->children,bmp); } - (*i)->wStyle->onPaintForeground.emit(temp,bmp,(*i)->wColors, (*i)->attributes, (*i)->shape); + (*i)->wStyle->onPaintForeground.emit(paintInfo); } else { Modified: trunk/src/schemes/defaultscheme.cpp =================================================================== --- trunk/src/schemes/defaultscheme.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/schemes/defaultscheme.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -122,31 +122,31 @@ } - void basicStyle::drawBackground(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void basicStyle::drawBackground(paintEvent &e) { - bmp->doRectfill(pos.x+1,pos.y+1,pos.width-2,pos.height-2,colors[S_StandardBg]); + e.getGraphic()->doRectfill(e.getPosition().x+1,e.getPosition().y+1,e.getPosition().width-2,e.getPosition().height-2,e.getColors()[S_StandardBg]); // Seperate implementation depending on whether its buffered or not //if(bmp::isBuffered()) //{ - if(flags & AT_Filled) + if(e.getAttributes() & AT_Filled) { bool even=true; - for(double y = pos.y+1;y<pos.y+pos.height;++y) + for(double y = e.getPosition().y+1;y<e.getPosition().y+e.getPosition().height;++y) { if(even) { - for(double x = pos.x+2;x<=pos.x+pos.width;x+=2) + for(double x = e.getPosition().x+2;x<=e.getPosition().x+e.getPosition().width;x+=2) { - bmp->placePixel(x,y,rgba::GRAY); + e.getGraphic()->placePixel(x,y,rgba::GRAY); } even=!even; } else { - for(double x = pos.x+1;x<=pos.x+pos.width;x+=2) + for(double x = e.getPosition().x+1;x<=e.getPosition().x+e.getPosition().width;x+=2) { - bmp->placePixel(x,y,rgba::GRAY); + e.getGraphic()->placePixel(x,y,rgba::GRAY); } even=!even; } @@ -160,9 +160,9 @@ } - void basicStyle::drawForeground(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void basicStyle::drawForeground(paintEvent &e) { - bmp->doRect(pos.x,pos.y,pos.width,pos.height,colors[S_StandardFg]); + e.getGraphic()->doRect(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,e.getColors()[S_StandardFg]); } buttonStyle::buttonStyle() @@ -176,31 +176,31 @@ } - void buttonStyle::drawBackground(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void buttonStyle::drawBackground(paintEvent &e) { - bmp->doRectfill(pos.x+1,pos.y+1,pos.width-2,pos.height-2,colors[S_StandardBg]); + e.getGraphic()->doRectfill(e.getPosition().x+1,e.getPosition().y+1,e.getPosition().width-2,e.getPosition().height-2,e.getColors()[S_StandardBg]); // Seperate implementation depending on whether its buffered or not //if(bmp::isBuffered()) //{ - if(flags & AT_Filled) + if(e.getAttributes() & AT_Filled) { bool even=true; - for(double y = pos.y+1;y<pos.y+pos.height;++y) + for(double y = e.getPosition().y+1;y<e.getPosition().y+e.getPosition().height;++y) { if(even) { - for(double x = pos.x+2;x<=pos.x+pos.width;x+=2) + for(double x = e.getPosition().x+2;x<=e.getPosition().x+e.getPosition().width;x+=2) { - bmp->placePixel(x,y,rgba::GRAY); + e.getGraphic()->placePixel(x,y,rgba::GRAY); } even=!even; } else { - for(double x = pos.x+1;x<=pos.x+pos.width;x+=2) + for(double x = e.getPosition().x+1;x<=e.getPosition().x+e.getPosition().width;x+=2) { - bmp->placePixel(x,y,rgba::GRAY); + e.getGraphic()->placePixel(x,y,rgba::GRAY); } even=!even; } @@ -214,9 +214,9 @@ } - void buttonStyle::drawForeground(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void buttonStyle::drawForeground(paintEvent &e) { - bmp->doRect(pos.x,pos.y,pos.width,pos.height,colors[S_StandardFg]); + e.getGraphic()->doRect(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,e.getColors()[S_StandardFg]); } } Modified: trunk/src/style.cpp =================================================================== --- trunk/src/style.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/style.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -68,60 +68,60 @@ } - slot defaultStyle::drawBackground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + slot defaultStyle::drawBackground(paintEvent &e) { - if(shape != S_Circle) + if(e.getShape() != S_Circle) { - if((!(flags & AT_On)) && (flags & AT_Filled))bmp->doDottedRectfill(size.x,size.y,size.width,size.height,2,colors[S_StandardBg],rgba::BLACK); - else if((flags & AT_On) && (flags & AT_Filled))bmp->doDottedRectfill(size.x,size.y,size.width,size.height,2,rgba::GRAY,rgba::BLACK); - else if((flags & AT_Sunken)) + if((!(e.getAttributes() & AT_On)) && (e.getAttributes() & AT_Filled))e.getGraphic()->doDottedRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,2,e.getColors()[S_StandardBg],rgba::BLACK); + else if((e.getAttributes() & AT_On) && (e.getAttributes() & AT_Filled))e.getGraphic()->doDottedRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,2,rgba::GRAY,rgba::BLACK); + else if((e.getAttributes() & AT_Sunken)) { - if((flags & AT_Editable))bmp->doRectfill(size.x,size.y,size.width,size.height,rgba::WHITE); - else if((flags & AT_Pressed))bmp->doRectfill(size.x,size.y,size.width,size.height,rgba::GRAY); - else bmp->doRectfill(size.x,size.y,size.width,size.height,colors[S_WindowBg]); - bmp->doLine(size.x+1,size.y+1,size.x+size.width-1,size.y+1,rgba::BLACK); - bmp->doLine(size.x+1,size.y+1,size.x+1,size.y+size.height-1,rgba::BLACK); + if((e.getAttributes() & AT_Editable))e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,rgba::WHITE); + else if((e.getAttributes() & AT_Pressed))e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,rgba::GRAY); + else e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,e.getColors()[S_WindowBg]); + e.getGraphic()->doLine(e.getPosition().x+1,e.getPosition().y+1,e.getPosition().x+e.getPosition().width-1,e.getPosition().y+1,rgba::BLACK); + e.getGraphic()->doLine(e.getPosition().x+1,e.getPosition().y+1,e.getPosition().x+1,e.getPosition().y+e.getPosition().height-1,rgba::BLACK); } - else if((flags & AT_Horizontal) || (flags & AT_Vertical)) bmp->doRectfill(size.x,size.y,size.width,size.height,colors[S_StandardBg]); - else bmp->doRectGradientV(size.x,size.y,size.width,size.height,size.width,colors[S_StandardBg],colors[S_StandardBgBlend]); + else if((e.getAttributes() & AT_Horizontal) || (e.getAttributes() & AT_Vertical)) e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,e.getColors()[S_StandardBg]); + else e.getGraphic()->doRectGradientV(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,e.getPosition().width,e.getColors()[S_StandardBg],e.getColors()[S_StandardBgBlend]); } - else bmp->doCirclefill(size.x+(size.width/2), size.y+(size.height/2), size.width/2,rgba::GRAY); + else e.getGraphic()->doCirclefill(e.getPosition().x+(e.getPosition().width/2), e.getPosition().y+(e.getPosition().height/2), e.getPosition().width/2,rgba::GRAY); } - slot defaultStyle::drawForeground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + slot defaultStyle::drawForeground(paintEvent &e) { - if(shape != S_Circle) + if(e.getShape() != S_Circle) { - if(flags & AT_Sunken) + if(e.getAttributes() & AT_Sunken) { - bmp->doLine(size.x,size.y,size.x,size.y+size.height,colors[S_StandardFg]); - bmp->doLine(size.x+size.width,size.y,size.x+size.width,size.y+size.height,colors[S_StandardFgBlend]); - bmp->doLine(size.x,size.y,size.x+size.width,size.y,colors[S_StandardFg]); - bmp->doLine(size.x,size.y+size.height,size.x+size.width,size.y+size.height,colors[S_StandardFgBlend]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y,e.getPosition().x,e.getPosition().y+e.getPosition().height,e.getColors()[S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width,e.getPosition().y,e.getPosition().x+e.getPosition().width,e.getPosition().y+e.getPosition().height,e.getColors()[S_StandardFgBlend]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y,e.getPosition().x+e.getPosition().width,e.getPosition().y,e.getColors()[S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+e.getPosition().height,e.getPosition().x+e.getPosition().width,e.getPosition().y+e.getPosition().height,e.getColors()[S_StandardFgBlend]); } else { - bmp->doLine(size.x,size.y,size.x,size.y+size.height,colors[S_StandardFgBlend]); - bmp->doLine(size.x+size.width,size.y,size.x+size.width,size.y+size.height,colors[S_StandardFg]); - if((flags & AT_MouseOver) && (flags && AT_Raised)) + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y,e.getPosition().x,e.getPosition().y+e.getPosition().height,e.getColors()[S_StandardFgBlend]); + e.getGraphic()->doLine(e.getPosition().x+e.getPosition().width,e.getPosition().y,e.getPosition().x+e.getPosition().width,e.getPosition().y+e.getPosition().height,e.getColors()[S_StandardFg]); + if((e.getAttributes() & AT_MouseOver) && (e.getAttributes() && AT_Raised)) { - bmp->doLine(size.x,size.y,size.x + size.width, size.y,rgba::GRAY); - bmp->doLine(size.x,size.y+size.height,size.x + size.width,size.y+size.height,rgba::GRAY); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y,e.getPosition().x + e.getPosition().width, e.getPosition().y,rgba::GRAY); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+e.getPosition().height,e.getPosition().x + e.getPosition().width,e.getPosition().y+e.getPosition().height,rgba::GRAY); } else { - bmp->doLine(size.x,size.y,size.x + size.width,size.y,colors[S_StandardFgBlend]); - bmp->doLine(size.x,size.y+size.height,size.x + size.width,size.y+size.height,colors[S_StandardFg]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y,e.getPosition().x + e.getPosition().width,e.getPosition().y,e.getColors()[S_StandardFgBlend]); + e.getGraphic()->doLine(e.getPosition().x,e.getPosition().y+e.getPosition().height,e.getPosition().x + e.getPosition().width,e.getPosition().y+e.getPosition().height,e.getColors()[S_StandardFg]); } } } else { - bmp->doCircle(size.x+(size.width/2), size.y+(size.height/2), size.width/2,colors[S_StandardFg]); - if((flags & AT_MouseOver) && (flags & AT_Raised))bmp->doCircle(size.x+(size.width/2), size.y+(size.height/2), size.width/2-1,rgba::WHITE); + e.getGraphic()->doCircle(e.getPosition().x+(e.getPosition().width/2), e.getPosition().y+(e.getPosition().height/2), e.getPosition().width/2,e.getColors()[S_StandardFg]); + if((e.getAttributes() & AT_MouseOver) && (e.getAttributes() & AT_Raised))e.getGraphic()->doCircle(e.getPosition().x+(e.getPosition().width/2), e.getPosition().y+(e.getPosition().height/2), e.getPosition().width/2-1,rgba::WHITE); } } @@ -137,26 +137,26 @@ } - slot defaultDialogStyle::drawBackground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + slot defaultDialogStyle::drawBackground(paintEvent &e) { - bmp->doRectfill(size.x,size.y,size.width,size.height,rgba::WHITE); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y,e.getPosition().width,e.getPosition().height,rgba::WHITE); } - slot defaultDialogStyle::drawForeground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + slot defaultDialogStyle::drawForeground(paintEvent &e) { - if(flags & AT_Active) + if(e.getAttributes() & AT_Active) { - bmp->doRectGradientH(size.x,size.y,size.width,topPadding,topPadding,colors[S_ActiveTitleFg],colors[S_ActiveTitleFgBlend]); - bmp->doRectfill(size.x,size.y + topPadding,leftPadding,size.height - topPadding,colors[S_ActiveTitleFg]); - bmp->doRectfill(size.x,size.getY2() - bottomPadding,size.width,bottomPadding,colors[S_ActiveTitleFg]); - bmp->doRectfill(size.getX2()-rightPadding,size.y + topPadding,rightPadding,size.height - topPadding,colors[S_ActiveTitleFg]); + e.getGraphic()->doRectGradientH(e.getPosition().x,e.getPosition().y,e.getPosition().width,topPadding,topPadding,e.getColors()[S_ActiveTitleFg],e.getColors()[S_ActiveTitleFgBlend]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y + topPadding,leftPadding,e.getPosition().height - topPadding,e.getColors()[S_ActiveTitleFg]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().getY2() - bottomPadding,e.getPosition().width,bottomPadding,e.getColors()[S_ActiveTitleFg]); + e.getGraphic()->doRectfill(e.getPosition().getX2()-rightPadding,e.getPosition().y + topPadding,rightPadding,e.getPosition().height - topPadding,e.getColors()[S_ActiveTitleFg]); } else { - bmp->doRectGradientH(size.x,size.y,size.width,topPadding,topPadding,colors[S_InactiveTitleFg],colors[S_InactiveTitleFgBlend]); - bmp->doRectfill(size.x,size.y + topPadding,leftPadding,size.height - topPadding,colors[S_InactiveTitleFg]); - bmp->doRectfill(size.x,size.getY2() - bottomPadding,size.width,bottomPadding,colors[S_InactiveTitleFg]); - bmp->doRectfill(size.getX2()-rightPadding,size.y + topPadding,rightPadding,size.height - topPadding,colors[S_InactiveTitleFg]); + e.getGraphic()->doRectGradientH(e.getPosition().x,e.getPosition().y,e.getPosition().width,topPadding,topPadding,e.getColors()[S_InactiveTitleFg],e.getColors()[S_InactiveTitleFgBlend]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().y + topPadding,leftPadding,e.getPosition().height - topPadding,e.getColors()[S_InactiveTitleFg]); + e.getGraphic()->doRectfill(e.getPosition().x,e.getPosition().getY2() - bottomPadding,e.getPosition().width,bottomPadding,e.getColors()[S_InactiveTitleFg]); + e.getGraphic()->doRectfill(e.getPosition().getX2()-rightPadding,e.getPosition().y + topPadding,rightPadding,e.getPosition().height - topPadding,e.getColors()[S_InactiveTitleFg]); } } } Modified: trunk/src/widgets/box.cpp =================================================================== --- trunk/src/widgets/box.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/widgets/box.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -52,15 +52,15 @@ { } - void box::render(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void box::render(paintEvent &e) { if(connected) { if(position.width != (bitmap->getBmpWidth())+(leftPadding+rightPadding)+2)position.width = (bitmap->getBmpWidth())+(leftPadding+rightPadding)+2; if(position.height != (bitmap->getBmpHeight())+(topPadding+bottomPadding)+2)position.height = (bitmap->getBmpHeight())+(topPadding+bottomPadding)+2; } - if(wStyle)bitmap->renderBmp(0,0,pos.x+leftPadding+1, pos.y+topPadding+1,bitmap->getBmpWidth(),bitmap->getBmpHeight(),colors[S_StandardBg], background); - else bitmap->renderBmp(0,0,pos.x+leftPadding+1, pos.y+topPadding+1,bitmap->getBmpWidth(),bitmap->getBmpHeight(), rgba::NOCOLOR, background); + if(wStyle)bitmap->renderBmp(0,0,e.getPosition().x+leftPadding+1, e.getPosition().y+topPadding+1,bitmap->getBmpWidth(),bitmap->getBmpHeight(),e.getColors()[S_StandardBg], background); + else bitmap->renderBmp(0,0,e.getPosition().x+leftPadding+1, e.getPosition().y+topPadding+1,bitmap->getBmpWidth(),bitmap->getBmpHeight(), rgba::NOCOLOR, background); } void box::setBitmap(graphic *bmp) Modified: trunk/src/widgets/button.cpp =================================================================== --- trunk/src/widgets/button.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/widgets/button.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -58,14 +58,14 @@ { } - void button::render(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void button::render(paintEvent &e) { - if(connected)bitmap->renderBmp(0,0,pos.x + bmpPosition.x, pos.y + bmpPosition.y,bitmap->getBmpWidth(),bitmap->getBmpHeight(), rgba::NOCOLOR, background); + if(connected)bitmap->renderBmp(0,0,e.getPosition().x + bmpPosition.x, e.getPosition().y + bmpPosition.y,bitmap->getBmpWidth(),bitmap->getBmpHeight(), rgba::NOCOLOR, background); if(!currentSetText.empty()) { - currentSetFont->render(pos.x + textPosition.x,pos.y + textPosition.y,textColor,background,0,currentSetText); + currentSetFont->render(e.getPosition().x + textPosition.x,e.getPosition().y + textPosition.y,textColor,background,0,currentSetText); } - //if((flags & AT_Focused) && !(flags & AT_Sunken))bmp->doDottedRect(pos.x+2,pos.y+2,pos.width-4,pos.height-4,2,rgba::BLACK,rgba::INVISIBLE); + //if((flags & AT_Focused) && !(flags & AT_Sunken))bmp->doDottedRect(e.getPosition().x+2,e.getPosition().y+2,e.getPosition().width-4,e.getPosition().height-4,2,rgba::BLACK,rgba::INVISIBLE); } void button::resize() Modified: trunk/src/widgets/checkbox.cpp =================================================================== --- trunk/src/widgets/checkbox.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/widgets/checkbox.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -54,7 +54,7 @@ { } - void checkBox::render(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void checkBox::render(paintEvent &e) { if(status) { @@ -62,20 +62,20 @@ { case C_CheckTick: { - const double min1 = pos.width/7; - const double min2 = pos.width/6; - const double min3 = pos.width/5; - const double min4 = pos.width/4; - bmp->doLine(pos.x+leftPadding+min2, pos.y+topPadding+min4, pos.x+leftPadding+min2, pos.y + pos.height - bottomPadding - min2,rgba::BLACK); - bmp->doLine(pos.x+leftPadding+min3, pos.y+topPadding+min4, pos.x+leftPadding+min3, pos.y + pos.height - bottomPadding - min2,rgba::BLACK); - bmp->doLine(pos.x+leftPadding+min4, pos.y + pos.height - bottomPadding - min3, pos.x + pos.width - rightPadding - min1, pos.y + topPadding+ min2,rgba::BLACK); - bmp->doLine(pos.x+leftPadding+min4, pos.y + pos.height - bottomPadding - min4, pos.x + pos.width - rightPadding - min3, pos.y + topPadding+min3,rgba::BLACK); + const double min1 = e.getPosition().width/7; + const double min2 = e.getPosition().width/6; + const double min3 = e.getPosition().width/5; + const double min4 = e.getPosition().width/4; + e.getGraphic()->doLine(e.getPosition().x+leftPadding+min2, e.getPosition().y+topPadding+min4, e.getPosition().x+leftPadding+min2, e.getPosition().y + e.getPosition().height - bottomPadding - min2,rgba::BLACK); + e.getGraphic()->doLine(e.getPosition().x+leftPadding+min3, e.getPosition().y+topPadding+min4, e.getPosition().x+leftPadding+min3, e.getPosition().y + e.getPosition().height - bottomPadding - min2,rgba::BLACK); + e.getGraphic()->doLine(e.getPosition().x+leftPadding+min4, e.getPosition().y + e.getPosition().height - bottomPadding - min3, e.getPosition().x + e.getPosition().width - rightPadding - min1, e.getPosition().y + topPadding+ min2,rgba::BLACK); + e.getGraphic()->doLine(e.getPosition().x+leftPadding+min4, e.getPosition().y + e.getPosition().height - bottomPadding - min4, e.getPosition().x + e.getPosition().width - rightPadding - min3, e.getPosition().y + topPadding+min3,rgba::BLACK); break; } case C_XTick: { - bmp->doLine(pos.x+leftPadding,pos.y+rightPadding,pos.x+pos.width-rightPadding,pos.y+pos.height-bottomPadding,rgba::BLACK); - bmp->doLine(pos.x+leftPadding,pos.y+pos.height-bottomPadding,pos.x+pos.width-rightPadding,pos.y+topPadding,rgba::BLACK); + e.getGraphic()->doLine(e.getPosition().x+leftPadding,e.getPosition().y+rightPadding,e.getPosition().x+e.getPosition().width-rightPadding,e.getPosition().y+e.getPosition().height-bottomPadding,rgba::BLACK); + e.getGraphic()->doLine(e.getPosition().x+leftPadding,e.getPosition().y+e.getPosition().height-bottomPadding,e.getPosition().x+e.getPosition().width-rightPadding,e.getPosition().y+topPadding,rgba::BLACK); break; } } Modified: trunk/src/widgets/input_box.cpp =================================================================== --- trunk/src/widgets/input_box.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/widgets/input_box.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -142,16 +142,16 @@ } // Draw - void inputBox::draw(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void inputBox::draw(paintEvent &e) { if(attributes & AT_Visible) { - currentSetFont->render(pos.x + textX,pos.y + textY,colors[S_WindowText],background,hAlignment,currentSetText); + currentSetFont->render(e.getPosition().x + textX,e.getPosition().y + textY,e.getColors()[S_WindowText],background,hAlignment,currentSetText); if(attributes & AT_Focused) { if(cursorTime.msecs()<=blinkRate) { - background->doLine(pos.x + cursorX,pos.y + cursorY,pos.x + cursorX,pos.y + cursorY+textSizeH,colors[S_Other1]); + background->doLine(e.getPosition().x + cursorX,e.getPosition().y + cursorY,e.getPosition().x + cursorX,e.getPosition().y + cursorY+textSizeH,e.getColors()[S_Other1]); } } } Modified: trunk/src/widgets/listbox.cpp =================================================================== --- trunk/src/widgets/listbox.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/widgets/listbox.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -117,22 +117,22 @@ showListButton.position.set((position.width*.80),0,(position.width*.20)-1,position.height-1); } - slot listBox::drawOnButton(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + slot listBox::drawOnButton(paintEvent &e) { double movex = 0; double movey = 0; - if(flags & AT_Sunken) + if(e.getAttributes() & AT_Sunken) { - movex = 1;//pos.width * 0.10; - movey = 1;//pos.height * 0.10; + movex = 1;//e.getPosition().width * 0.10; + movey = 1;//e.getPosition().height * 0.10; } - const double width = pos.width/3; - const double height = pos.height/3; - bmp->doTriangle(movex + pos.x+((pos.width/2)-(width/2)),movey + pos.y+((pos.height/2)-(height/2)), - movex + pos.x+(pos.width/2),movey + pos.y+((pos.height/2)+(height/2)), - movex + pos.x+((pos.width/2)+(width/2)),movey + pos.y+((pos.height/2)-(height/2)), + const double width = e.getPosition().width/3; + const double height = e.getPosition().height/3; + e.getGraphic()->doTriangle(movex + e.getPosition().x+((e.getPosition().width/2)-(width/2)),movey + e.getPosition().y+((e.getPosition().height/2)-(height/2)), + movex + e.getPosition().x+(e.getPosition().width/2),movey + e.getPosition().y+((e.getPosition().height/2)+(height/2)), + movex + e.getPosition().x+((e.getPosition().width/2)+(width/2)),movey + e.getPosition().y+((e.getPosition().height/2)-(height/2)), rgba::BLACK); } @@ -231,9 +231,9 @@ } } - slot listBox::onHoverDraw(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + slot listBox::onHoverDraw(paintEvent &e) { - bmp->doRectfill(0,0,pos.width,pos.height,rgba(50,50,50,100)); + e.getGraphic()->doRectfill(0,0,e.getPosition().width,e.getPosition().height,rgba(50,50,50,100)); } slot listBox::onSelectItem(const coord &pos) Modified: trunk/src/widgets/progress_bar.cpp =================================================================== --- trunk/src/widgets/progress_bar.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/widgets/progress_bar.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -68,25 +68,25 @@ { } - void progressBar::draw(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + void progressBar::draw(paintEvent &e) { - color.alpha = colors[S_StandardBg].alpha; + color.alpha = e.getColors()[S_StandardBg].alpha; if (type == HORIZONTAL && style == BOTTOM) - background->doRectfill(pos.x, pos.y, round((pos.width/maxProgress)*progress), pos.height, color); + background->doRectfill(e.getPosition().x, e.getPosition().y, round((e.getPosition().width/maxProgress)*progress), e.getPosition().height, color); else if (type == HORIZONTAL && style == TOP) - background->doRectfill(pos.x + round((pos.width/maxProgress)*(maxProgress-progress)), - pos.y, pos.width-1, pos.height-1, color); + background->doRectfill(e.getPosition().x + round((e.getPosition().width/maxProgress)*(maxProgress-progress)), + e.getPosition().y, e.getPosition().width-1, e.getPosition().height-1, color); else if (type == VERTICAL && style == BOTTOM) - background->doRectfill(pos.x, pos.y + round((pos.height/maxProgress)*(maxProgress-progress)), - pos.width-1, pos.height-1, color); + background->doRectfill(e.getPosition().x, e.getPosition().y + round((e.getPosition().height/maxProgress)*(maxProgress-progress)), + e.getPosition().width-1, e.getPosition().height-1, color); else if (type == VERTICAL && style == TOP) - background->doRectfill(pos.x , pos.y, pos.width-1, round(((pos.height-1)/maxProgress)*progress), color); + background->doRectfill(e.getPosition().x , e.getPosition().y, e.getPosition().width-1, round(((e.getPosition().height-1)/maxProgress)*progress), color); else if (type == HORIZONTAL && style == MIDDLE) - background->doRectfill(pos.x + round((pos.width/maxProgress)*(maxProgress-progress)/2), pos.y, - round((pos.width/maxProgress)*progress), pos.height-1, color); + background->doRectfill(e.getPosition().x + round((e.getPosition().width/maxProgress)*(maxProgress-progress)/2), e.getPosition().y, + round((e.getPosition().width/maxProgress)*progress), e.getPosition().height-1, color); else if (type == VERTICAL && style == MIDDLE) - background->doRectfill(pos.x,pos.y + round((pos.height/maxProgress)*(maxProgress-progress)/2), - pos.width, round(((pos.height-1)/maxProgress)*progress), color); + background->doRectfill(e.getPosition().x,e.getPosition().y + round((e.getPosition().height/maxProgress)*(maxProgress-progress)/2), + e.getPosition().width, round(((e.getPosition().height-1)/maxProgress)*progress), color); } Modified: trunk/src/widgets/pushbutton.cpp =================================================================== --- trunk/src/widgets/pushbutton.cpp 2007-08-31 13:24:58 UTC (rev 468) +++ trunk/src/widgets/pushbutton.cpp 2007-08-31 14:48:53 UTC (rev 469) @@ -46,7 +46,7 @@ { pushButton::pushButton() { - onPaint.connect(this, &pushButton::paintEvent); + onPaint.connect(this, &pushButton::paint); textChanged.connect(this,&pushButton::onTextChanged); iconChanged.connect(this,&pushButton::onIconChanged); pressed.connect(this,&pushButton::depress); @@ -56,20 +56,20 @@ pushButton::pushButton(const std::string &text) { - onPaint.connect(this, &pushButton::paintEvent); + onPaint.connect(this, &pushButton::paint); setText(text); } pushButton::pushButton(const std::string &text, graphic *icon) { - onPaint.connect(this, &pushButton::paintEvent); + onPaint.connect(this, &pushButton::paint); setText(text); setIcon(icon); } pushButton::pushButton(graphic *icon) { - onPaint.connect(this, &pushButton::paintEvent); + onPaint.connect(this, &pushButton::paint); setIcon(icon); } @@ -77,15 +77,15 @@ { } - slot pushButton::paintEvent(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + slot pushButton::paint(paintEvent &e) { if(!this->getText().empty()) { - buttonFont->render(pos.x + textPosition.x,pos.y + textPosition.y,fontColor,bmp,0,getText()); + buttonFont->render(e.getPosition().x + textPosition.x,e.getPosition().y + textPosition.y,fontColor,e.getGraphic(),0,getText()); } if(this->getIcon()) { - this->getIcon()->renderBmp(0, 0, pos.x + iconPosition.x, pos.y + iconPosition.y, iconPosition.width, iconPosition.height, rgba::NOCOLOR, bmp); + this->getIcon()->renderBmp(0, 0, e.getPosition().x + iconPosition.x, e.getPosition().y + iconPosition.y, iconPosition.width, iconPosition.height, rgba::NOCOLOR, e.getGraphic()); } } Modified: trunk/src/widgets/radial.cpp =================================================================== --- trunk/... [truncated message content] |
From: <sag...@li...> - 2007-12-18 03:17:25
|
Revision: 475 http://saggui.svn.sourceforge.net/saggui/?rev=475&view=rev Author: juvinious Date: 2007-12-17 19:17:22 -0800 (Mon, 17 Dec 2007) Log Message: ----------- Moved xml module into main module. Fixed typos in CMakeLists.txt regarding install Modified Paths: -------------- trunk/CHANGELOG trunk/CMakeLists.txt trunk/cmake/saggui.h.in trunk/examples/xml/CMakeLists.txt Added Paths: ----------- trunk/include/saggui/xml/ trunk/include/saggui/xml/sagguixml.h trunk/include/saggui/xml/tinystr.h trunk/include/saggui/xml/tinyxml.h trunk/src/xml/ trunk/src/xml/sagguixml.cpp trunk/src/xml/tinystr.cpp trunk/src/xml/tinyxml.cpp trunk/src/xml/tinyxmlerror.cpp trunk/src/xml/tinyxmlparser.cpp Removed Paths: ------------- trunk/modules/sagguixml/ Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-12-14 14:20:39 UTC (rev 474) +++ trunk/CHANGELOG 2007-12-18 03:17:22 UTC (rev 475) @@ -1,4 +1,6 @@ 0.50 +- Fixed some install issues in CMakeLists.txt +- Moved over sagguixml into the main module since it reality doesn't need to be seperated as a module - Fixed roundRect so that it's accurate - Changed arc to be more accurate, borrowed read in comments - Fixed gamedemo's buttons and other visual elements Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2007-12-14 14:20:39 UTC (rev 474) +++ trunk/CMakeLists.txt 2007-12-18 03:17:22 UTC (rev 475) @@ -216,16 +216,17 @@ aux_source_directory(src BASE_SRC) aux_source_directory(src/widgets WIDGET_SRC) aux_source_directory(src/schemes SCHEME_SRC) +aux_source_directory(src/xml XML_SRC) # ------------------------------------------------------- # Include directory # ------------------------------------------------------- -include_directories(include ${CMAKE_BINARY_DIR}/include include/saggui include/saggui/widgets include/saggui/schemes ${FREETYPE_INCLUDE}) +include_directories(include ${CMAKE_BINARY_DIR}/include include/saggui include/saggui/widgets include/saggui/schemes include/saggui/xml ${FREETYPE_INCLUDE}) # ------------------------------------------------------- # SAGGUI Library # ------------------------------------------------------- -add_library (saggui ${CREATE_STATIC_LIB} ${BASE_SRC} ${WIDGET_SRC} ${SCHEME_SRC}) +add_library (saggui ${CREATE_STATIC_LIB} ${BASE_SRC} ${WIDGET_SRC} ${SCHEME_SRC} ${XML_SRC}) target_link_libraries(saggui ${REQUIRED_LIBS}) # ------------------------------------------------------- @@ -261,7 +262,6 @@ endif(ENABLE_SDLGL) add_subdirectory(${CMAKE_SOURCE_DIR}/modules/profiler) -add_subdirectory(${CMAKE_SOURCE_DIR}/modules/sagguixml) add_subdirectory(${CMAKE_SOURCE_DIR}/examples/demo) add_subdirectory(${CMAKE_SOURCE_DIR}/examples/gamedemo) add_subdirectory(${CMAKE_SOURCE_DIR}/examples/widgets) @@ -280,22 +280,14 @@ if(CMAKE_PATCH_VERSION EQUAL 3 OR CMAKE_PATCH_VERSION LESS 3) file(GLOB BASE_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/*.h) file(GLOB WIDGET_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/widgets/*.h) - file(GLOB SCHEMES_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/widgets/*.h) + file(GLOB SCHEMES_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/schemes/*.h) + file(GLOB SCHEMES_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/xml/*.h) install(FILES ${BASE_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/saggui) install(FILES ${WIDGET_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/saggui/widgets) install(FILES ${SCHEMES_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/saggui/schemes) + install(FILES ${XML_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/saggui/xml) else(CMAKE_PATCH_VERSION EQUAL 3 OR CMAKE_PATCH_VERSION LESS 3) install(DIRECTORY include/saggui DESTINATION ${CMAKE_INSTALL_PREFIX}/include PATTERN ".svn" EXCLUDE PATTERN "*~" EXCLUDE) endif(CMAKE_PATCH_VERSION EQUAL 3 OR CMAKE_PATCH_VERSION LESS 3) install(TARGETS saggui DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) endif(NOT MSVC) - - - file(GLOB ALLEGRO_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/allegro/*.h) - install(FILES ${ALLEGRO_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/saggui/allegro) - file(GLOB OPENLAYER_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/openlayer/*.h) - install(FILES ${OPENLAYER_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/saggui/openlayer) - file(GLOB SDL_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/sdl/*.h) - install(FILES ${SDL_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/saggui/sdl) - file(GLOB SDLGL_HEADERS ${CMAKE_SOURCE_DIR}/include/saggui/sdlgl/*.h) - install(FILES ${SDLGL_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/saggui/sdlgl) \ No newline at end of file Modified: trunk/cmake/saggui.h.in =================================================================== --- trunk/cmake/saggui.h.in 2007-12-14 14:20:39 UTC (rev 474) +++ trunk/cmake/saggui.h.in 2007-12-18 03:17:22 UTC (rev 475) @@ -103,6 +103,9 @@ //! Headers for included schemes #include "saggui/schemes/defaultscheme.h" +//! Header for xml creational engine +#include "saggui/xml/sagguixml.h" + #endif Modified: trunk/examples/xml/CMakeLists.txt =================================================================== --- trunk/examples/xml/CMakeLists.txt 2007-12-14 14:20:39 UTC (rev 474) +++ trunk/examples/xml/CMakeLists.txt 2007-12-18 03:17:22 UTC (rev 475) @@ -26,34 +26,34 @@ if(ENABLE_ALLEGRO) include_directories(${ALLEGRO_INCLUDE_DIR}) add_executable(xml-allegro src/allegro.cpp) - target_link_libraries(xml-allegro saggui-xml saggui-alleg saggui) - add_dependencies(xml-allegro saggui-xml saggui-alleg saggui) + target_link_libraries(xml-allegro saggui-alleg saggui) + add_dependencies(xml-allegro saggui-alleg saggui) endif(ENABLE_ALLEGRO) if(ENABLE_ALLEGROGL) include_directories(${ALLEGRO_INCLUDE_DIR}) add_executable(xml-allegrogl src/allegrogl.cpp) - target_link_libraries(xml-allegrogl saggui-xml saggui-agl saggui-alleg saggui) - add_dependencies(xml-allegrogl saggui-xml saggui-agl saggui-alleg saggui) + target_link_libraries(xml-allegrogl saggui-agl saggui-alleg saggui) + add_dependencies(xml-allegrogl saggui-agl saggui-alleg saggui) endif(ENABLE_ALLEGROGL) if(ENABLE_OPENLAYER) include_directories(${FREETYPE_INCLUDE_DIR} ${ALLEGRO_INCLUDE_DIR} ${ALLEGROGL_INCLUDE_DIR} ${OPENLAYER_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}) add_executable(xml-openlayer src/openlayer.cpp) - target_link_libraries(xml-openlayer saggui-xml saggui-ol saggui-agl saggui-alleg saggui) - add_dependencies(xml-openlayer ${FREETYPE_LIBRARIES} saggui-xml saggui-ol saggui-agl saggui-alleg saggui) + target_link_libraries(xml-openlayer saggui-ol saggui-agl saggui-alleg saggui) + add_dependencies(xml-openlayer ${FREETYPE_LIBRARIES} saggui-ol saggui-agl saggui-alleg saggui) endif(ENABLE_OPENLAYER) if(ENABLE_SDL) include_directories(${SDL_INCLUDE_DIR}) add_executable(xml-sdl src/sdl.cpp) - target_link_libraries(xml-sdl saggui-xml saggui-sdl saggui) - add_dependencies(xml-sdl saggui-xml saggui-sdl saggui) + target_link_libraries(xml-sdl saggui-sdl saggui) + add_dependencies(xml-sdl saggui-sdl saggui) endif(ENABLE_SDL) if(ENABLE_SDLGL) include_directories(${SDL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}) add_executable(xml-sdlgl src/sdlgl.cpp) - target_link_libraries(xml-sdlgl saggui-xml saggui-sdlgl saggui-sdl saggui) - add_dependencies(xml-sdlgl saggui-xml saggui-sdlgl saggui-sdl saggui) + target_link_libraries(xml-sdlgl saggui-sdlgl saggui-sdl saggui) + add_dependencies(xml-sdlgl saggui-sdlgl saggui-sdl saggui) endif(ENABLE_SDLGL) Added: trunk/include/saggui/xml/sagguixml.h =================================================================== --- trunk/include/saggui/xml/sagguixml.h (rev 0) +++ trunk/include/saggui/xml/sagguixml.h 2007-12-18 03:17:22 UTC (rev 475) @@ -0,0 +1,114 @@ +/* +SAGGUI (Simplified All Gaming Graphical User Interface) +Copyright (c) 2005-2007, Miguel A. Gavidia +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + * Neither the name of the "SAGGUI" nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef XML_ENGINE_H +#define XML_ENGINE_H + +#include "saggui/creationengine.h" + + +class TiXmlElement; +class TiXmlNode; +class TiXmlDocument; + +//! Simplified All Gaming Graphical User Interface +/*! + This is the naming convention for this SAGGUI lib. +*/ +namespace saggui +{ + //! The XML Creational Engine Class + /*! + * Create widgets utilizing XML. + */ + class SAGGUI_EXT_EXPORT xmlEngine : public creationEngine + { + public: + //! constructor + xmlEngine(); + + //! destructor + virtual ~xmlEngine(); + + //! load data + virtual void load(const std::string &filename) throw (sagguiException); + + //! Create windows from xml + virtual void parseWindows(TiXmlElement *element, window *parent) throw (sagguiException); + + protected: + //! Document + TiXmlDocument *doc; + + //! Do windows children + virtual void children(TiXmlElement *element, window *parent); + + //! Specific to checkbox + virtual void checkbox(TiXmlElement *element, window *parent); + + //! Specific to dialog + virtual void doDialog(TiXmlElement *element, window *parent); + + //! Specific to inputbox + virtual void inputbox(TiXmlElement *element, window *parent); + + //! Specific to label + virtual void doLabel(TiXmlElement *element, window *parent); + + //! Specific to listbox + virtual void listbox(TiXmlElement *element, window *parent); + + //! Specific to progressbar + virtual void progressbar(TiXmlElement *element, window *parent); + + //! Specific to pushbutton + virtual void pushbutton(TiXmlElement *element, window *parent); + + //! Specific to radial + virtual void doRadial(TiXmlElement *element, window *parent); + + //! Specific to scrollbar + virtual void scrollbar(TiXmlElement *element, window *parent); + + //! Specific to textbox + virtual void textbox(TiXmlElement *element, window *parent); + + }; +} + +#endif Added: trunk/include/saggui/xml/tinystr.h =================================================================== --- trunk/include/saggui/xml/tinystr.h (rev 0) +++ trunk/include/saggui/xml/tinystr.h 2007-12-18 03:17:22 UTC (rev 475) @@ -0,0 +1,319 @@ +/* +www.sourceforge.net/projects/tinyxml +Original file by Yves Berquin. + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +/* + * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005. + * + * - completely rewritten. compact, clean, and fast implementation. + * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems) + * - fixed reserve() to work as per specification. + * - fixed buggy compares operator==(), operator<(), and operator>() + * - fixed operator+=() to take a const ref argument, following spec. + * - added "copy" constructor with length, and most compare operators. + * - added swap(), clear(), size(), capacity(), operator+(). + */ + +#ifndef TIXML_USE_STL + +#ifndef TIXML_STRING_INCLUDED +#define TIXML_STRING_INCLUDED + +#include <assert.h> +#include <string.h> + +/* The support for explicit isn't that universal, and it isn't really + required - it is used to check that the TiXmlString class isn't incorrectly + used. Be nice to old compilers and macro it here: +*/ +#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + #define TIXML_EXPLICIT explicit +#elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + #define TIXML_EXPLICIT explicit +#else + #define TIXML_EXPLICIT +#endif + + +/* + TiXmlString is an emulation of a subset of the std::string template. + Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. + Only the member functions relevant to the TinyXML project have been implemented. + The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase + a string and there's no more room, we allocate a buffer twice as big as we need. +*/ +class TiXmlString +{ + public : + // The size type used + typedef size_t size_type; + + // Error value for find primitive + static const size_type npos; // = -1; + + + // TiXmlString empty constructor + TiXmlString () : rep_(&nullrep_) + { + } + + // TiXmlString copy constructor + TiXmlString ( const TiXmlString & copy) : rep_(0) + { + init(copy.length()); + memcpy(start(), copy.data(), length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) + { + init( static_cast<size_type>( strlen(copy) )); + memcpy(start(), copy, length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) + { + init(len); + memcpy(start(), str, len); + } + + // TiXmlString destructor + ~TiXmlString () + { + quit(); + } + + // = operator + TiXmlString& operator = (const char * copy) + { + return assign( copy, (size_type)strlen(copy)); + } + + // = operator + TiXmlString& operator = (const TiXmlString & copy) + { + return assign(copy.start(), copy.length()); + } + + + // += operator. Maps to append + TiXmlString& operator += (const char * suffix) + { + return append(suffix, static_cast<size_type>( strlen(suffix) )); + } + + // += operator. Maps to append + TiXmlString& operator += (char single) + { + return append(&single, 1); + } + + // += operator. Maps to append + TiXmlString& operator += (const TiXmlString & suffix) + { + return append(suffix.data(), suffix.length()); + } + + + // Convert a TiXmlString into a null-terminated char * + const char * c_str () const { return rep_->str; } + + // Convert a TiXmlString into a char * (need not be null terminated). + const char * data () const { return rep_->str; } + + // Return the length of a TiXmlString + size_type length () const { return rep_->size; } + + // Alias for length() + size_type size () const { return rep_->size; } + + // Checks if a TiXmlString is empty + bool empty () const { return rep_->size == 0; } + + // Return capacity of string + size_type capacity () const { return rep_->capacity; } + + + // single char extraction + const char& at (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // [] operator + char& operator [] (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // find a char in a string. Return TiXmlString::npos if not found + size_type find (char lookup) const + { + return find(lookup, 0); + } + + // find a char in a string from an offset. Return TiXmlString::npos if not found + size_type find (char tofind, size_type offset) const + { + if (offset >= length()) return npos; + + for (const char* p = c_str() + offset; *p != '\0'; ++p) + { + if (*p == tofind) return static_cast< size_type >( p - c_str() ); + } + return npos; + } + + void clear () + { + //Lee: + //The original was just too strange, though correct: + // TiXmlString().swap(*this); + //Instead use the quit & re-init: + quit(); + init(0,0); + } + + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function DOES NOT clear the content of the TiXmlString if any exists. + */ + void reserve (size_type cap); + + TiXmlString& assign (const char* str, size_type len); + + TiXmlString& append (const char* str, size_type len); + + void swap (TiXmlString& other) + { + Rep* r = rep_; + rep_ = other.rep_; + other.rep_ = r; + } + + private: + + void init(size_type sz) { init(sz, sz); } + void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } + char* start() const { return rep_->str; } + char* finish() const { return rep_->str + rep_->size; } + + struct Rep + { + size_type size, capacity; + char str[1]; + }; + + void init(size_type sz, size_type cap) + { + if (cap) + { + // Lee: the original form: + // rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap)); + // doesn't work in some cases of new being overloaded. Switching + // to the normal allocation, although use an 'int' for systems + // that are overly picky about structure alignment. + const size_type bytesNeeded = sizeof(Rep) + cap; + const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); + rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] ); + + rep_->str[ rep_->size = sz ] = '\0'; + rep_->capacity = cap; + } + else + { + rep_ = &nullrep_; + } + } + + void quit() + { + if (rep_ != &nullrep_) + { + // The rep_ is really an array of ints. (see the allocator, above). + // Cast it back before delete, so the compiler won't incorrectly call destructors. + delete [] ( reinterpret_cast<int*>( rep_ ) ); + } + } + + Rep * rep_; + static Rep nullrep_; + +} ; + + +inline bool operator == (const TiXmlString & a, const TiXmlString & b) +{ + return ( a.length() == b.length() ) // optimization on some platforms + && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare +} +inline bool operator < (const TiXmlString & a, const TiXmlString & b) +{ + return strcmp(a.c_str(), b.c_str()) < 0; +} + +inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } +inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } +inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } +inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } + +inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } +inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } +inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } +inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); +TiXmlString operator + (const TiXmlString & a, const char* b); +TiXmlString operator + (const char* a, const TiXmlString & b); + + +/* + TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. + Only the operators that we need for TinyXML have been developped. +*/ +class TiXmlOutStream : public TiXmlString +{ +public : + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const TiXmlString & in) + { + *this += in; + return *this; + } + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const char * in) + { + *this += in; + return *this; + } + +} ; + +#endif // TIXML_STRING_INCLUDED +#endif // TIXML_USE_STL Added: trunk/include/saggui/xml/tinyxml.h =================================================================== --- trunk/include/saggui/xml/tinyxml.h (rev 0) +++ trunk/include/saggui/xml/tinyxml.h 2007-12-18 03:17:22 UTC (rev 475) @@ -0,0 +1,1804 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#ifndef TINYXML_INCLUDED +#define TINYXML_INCLUDED + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4530 ) +#pragma warning( disable : 4786 ) +#endif + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#define TIXML_USE_STL + +// Help out windows: +#if defined( _DEBUG ) && !defined( DEBUG ) +#define DEBUG +#endif + +#ifdef TIXML_USE_STL + #include <string> + #include <iostream> + #include <sstream> + #define TIXML_STRING std::string +#else + #include "tinystr.h" + #define TIXML_STRING TiXmlString +#endif + +// Deprecated library function hell. Compilers want to use the +// new safe versions. This probably doesn't fully address the problem, +// but it gets closer. There are too many compilers for me to fully +// test. If you get compilation troubles, undefine TIXML_SAFE +#define TIXML_SAFE + +#ifdef TIXML_SAFE + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + // Microsoft visual studio, version 2005 and higher. + #define TIXML_SNPRINTF _snprintf_s + #define TIXML_SNSCANF _snscanf_s + #define TIXML_SSCANF sscanf_s + #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + //#pragma message( "Using _sn* functions." ) + #define TIXML_SNPRINTF _snprintf + #define TIXML_SNSCANF _snscanf + #define TIXML_SSCANF sscanf + #elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + //#warning( "Using sn* functions." ) + #define TIXML_SNPRINTF snprintf + #define TIXML_SNSCANF snscanf + #define TIXML_SSCANF sscanf + #else + #define TIXML_SSCANF sscanf + #endif +#endif + +class TiXmlDocument; +class TiXmlElement; +class TiXmlComment; +class TiXmlUnknown; +class TiXmlAttribute; +class TiXmlText; +class TiXmlDeclaration; +class TiXmlParsingData; + +const int TIXML_MAJOR_VERSION = 2; +const int TIXML_MINOR_VERSION = 5; +const int TIXML_PATCH_VERSION = 3; + +/* Internal structure for tracking location of items + in the XML file. +*/ +struct TiXmlCursor +{ + TiXmlCursor() { Clear(); } + void Clear() { row = col = -1; } + + int row; // 0 based. + int col; // 0 based. +}; + + +/** + If you call the Accept() method, it requires being passed a TiXmlVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves + are simple called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, <b>no children of this node or its sibilings</b> will be Visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. + + You should never change the document from a callback. + + @sa TiXmlNode::Accept() +*/ +class TiXmlVisitor +{ +public: + virtual ~TiXmlVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } + /// Visit a document. + virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } + + /// Visit an element. + virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } + /// Visit an element. + virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } + + /// Visit a declaration + virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } + /// Visit a text node + virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } + /// Visit a comment node + virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } + /// Visit an unknow node + virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } +}; + +// Only used by Attribute::Query functions +enum +{ + TIXML_SUCCESS, + TIXML_NO_ATTRIBUTE, + TIXML_WRONG_TYPE +}; + + +// Used by the parsing routines. +enum TiXmlEncoding +{ + TIXML_ENCODING_UNKNOWN, + TIXML_ENCODING_UTF8, + TIXML_ENCODING_LEGACY +}; + +const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; + +/** TiXmlBase is a base class for every class in TinyXml. + It does little except to establish that TinyXml classes + can be printed and provide some utility functions. + + In XML, the document and elements can contain + other elements and other types of nodes. + + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) + + A Decleration contains: Attributes (not on tree) + @endverbatim +*/ +class TiXmlBase +{ + friend class TiXmlNode; + friend class TiXmlElement; + friend class TiXmlDocument; + +public: + TiXmlBase() : userData(0) {} + virtual ~TiXmlBase() {} + + /** All TinyXml classes can print themselves to a filestream + or the string class (TiXmlString in non-STL mode, std::string + in STL mode.) Either or both cfile and str can be null. + + This is a formatted print, and will insert + tabs and newlines. + + (For an unformatted stream, use the << operator.) + */ + virtual void Print( FILE* cfile, int depth ) const = 0; + + /** The world does not agree on whether white space should be kept or + not. In order to make everyone happy, these global, static functions + are provided to set whether or not TinyXml will condense all white space + into a single space or not. The default is to condense. Note changing this + value is not thread safe. + */ + static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } + + /// Return the current white space setting. + static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } + + /** Return the position, in the original source file, of this node or attribute. + The row and column are 1-based. (That is the first row and first column is + 1,1). If the returns values are 0 or less, then the parser does not have + a row and column value. + + Generally, the row and column value will be set when the TiXmlDocument::Load(), + TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set + when the DOM was created from operator>>. + + The values reflect the initial load. Once the DOM is modified programmatically + (by adding or changing nodes and attributes) the new values will NOT update to + reflect changes in the document. + + There is a minor performance cost to computing the row and column. Computation + can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. + + @sa TiXmlDocument::SetTabSize() + */ + int Row() const { return location.row + 1; } + int Column() const { return location.col + 1; } ///< See Row() + + void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. + void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. + const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. + + // Table that returs, for a given lead byte, the total number of bytes + // in the UTF-8 sequence. + static const int utf8ByteTable[256]; + + virtual const char* Parse( const char* p, + TiXmlParsingData* data, + TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; + + /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, + or they will be transformed into entities! + */ + static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); + + enum + { + TIXML_NO_ERROR = 0, + TIXML_ERROR, + TIXML_ERROR_OPENING_FILE, + TIXML_ERROR_OUT_OF_MEMORY, + TIXML_ERROR_PARSING_ELEMENT, + TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, + TIXML_ERROR_READING_ELEMENT_VALUE, + TIXML_ERROR_READING_ATTRIBUTES, + TIXML_ERROR_PARSING_EMPTY, + TIXML_ERROR_READING_END_TAG, + TIXML_ERROR_PARSING_UNKNOWN, + TIXML_ERROR_PARSING_COMMENT, + TIXML_ERROR_PARSING_DECLARATION, + TIXML_ERROR_DOCUMENT_EMPTY, + TIXML_ERROR_EMBEDDED_NULL, + TIXML_ERROR_PARSING_CDATA, + TIXML_ERROR_DOCUMENT_TOP_ONLY, + + TIXML_ERROR_STRING_COUNT + }; + +protected: + + static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); + inline static bool IsWhiteSpace( char c ) + { + return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); + } + inline static bool IsWhiteSpace( int c ) + { + if ( c < 256 ) + return IsWhiteSpace( (char) c ); + return false; // Again, only truly correct for English/Latin...but usually works. + } + + #ifdef TIXML_USE_STL + static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); + static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); + #endif + + /* Reads an XML name into the string provided. Returns + a pointer just past the last character of the name, + or 0 if the function has an error. + */ + static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); + + /* Reads text. Returns a pointer past the given end tag. + Wickedly complex options, but it keeps the (sensitive) code in one place. + */ + static const char* ReadText( const char* in, // where to start + TIXML_STRING* text, // the string read + bool ignoreWhiteSpace, // whether to keep the white space + const char* endTag, // what ends this text + bool ignoreCase, // whether to ignore case in the end tag + TiXmlEncoding encoding ); // the current encoding + + // If an entity has been found, transform it into a character. + static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); + + // Get a character, while interpreting entities. + // The length can be from 0 to 4 bytes. + inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) + { + assert( p ); + if ( encoding == TIXML_ENCODING_UTF8 ) + { + *length = utf8ByteTable[ *((const unsigned char*)p) ]; + assert( *length >= 0 && *length < 5 ); + } + else + { + *length = 1; + } + + if ( *length == 1 ) + { + if ( *p == '&' ) + return GetEntity( p, _value, length, encoding ); + *_value = *p; + return p+1; + } + else if ( *length ) + { + //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), + // and the null terminator isn't needed + for( int i=0; p[i] && i<*length; ++i ) { + _value[i] = p[i]; + } + return p + (*length); + } + else + { + // Not valid text. + return 0; + } + } + + // Return true if the next characters in the stream are any of the endTag sequences. + // Ignore case only works for english, and should only be relied on when comparing + // to English words: StringEqual( p, "version", true ) is fine. + static bool StringEqual( const char* p, + const char* endTag, + bool ignoreCase, + TiXmlEncoding encoding ); + + static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; + + TiXmlCursor location; + + /// Field containing a generic user pointer + void* userData; + + // None of these methods are reliable for any language except English. + // Good for approximation, not great for accuracy. + static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); + static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); + inline static int ToLower( int v, TiXmlEncoding encoding ) + { + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( v < 128 ) return tolower( v ); + return v; + } + else + { + return tolower( v ); + } + } + static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + +private: + TiXmlBase( const TiXmlBase& ); // not implemented. + void operator=( const TiXmlBase& base ); // not allowed. + + struct Entity + { + const char* str; + unsigned int strLength; + char chr; + }; + enum + { + NUM_ENTITY = 5, + MAX_ENTITY_LENGTH = 6 + + }; + static Entity entity[ NUM_ENTITY ]; + static bool condenseWhiteSpace; +}; + + +/** The parent class for everything in the Document Object Model. + (Except for attributes). + Nodes have siblings, a parent, and children. A node can be + in a document, or stand on its own. The type of a TiXmlNode + can be queried, and it can be cast to its more defined type. +*/ +class TiXmlNode : public TiXmlBase +{ + friend class TiXmlDocument; + friend class TiXmlElement; + +public: + #ifdef TIXML_USE_STL + + /** An input stream operator, for every class. Tolerant of newlines and + formatting, but doesn't expect them. + */ + friend std::istream& operator >> (std::istream& in, TiXmlNode& base); + + /** An output stream operator, for every class. Note that this outputs + without any newlines or formatting, as opposed to Print(), which + includes tabs and new lines. + + The operator<< and operator>> are not completely symmetric. Writing + a node to a stream is very well defined. You'll get a nice stream + of output, without any extra whitespace or newlines. + + But reading is not as well defined. (As it always is.) If you create + a TiXmlElement (for example) and read that from an input stream, + the text needs to define an element or junk will result. This is + true of all input streams, but it's worth keeping in mind. + + A TiXmlDocument will read nodes until it reads a root element, and + all the children of that root element. + */ + friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); + + /// Appends the XML node or attribute to a std::string. + friend std::string& operator<< (std::string& out, const TiXmlNode& base ); + + #endif + + /** The types of XML nodes supported by TinyXml. (All the + unsupported types are picked up by UNKNOWN.) + */ + enum NodeType + { + DOCUMENT, + ELEMENT, + COMMENT, + UNKNOWN, + TEXT, + DECLARATION, + TYPECOUNT + }; + + virtual ~TiXmlNode(); + + /** The meaning of 'value' changes for the specific type of + TiXmlNode. + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + + The subclasses will wrap this function. + */ + const char *Value() const { return value.c_str (); } + + #ifdef TIXML_USE_STL + /** Return Value() as a std::string. If you only use STL, + this is more efficient than calling Value(). + Only available in STL mode. + */ + const std::string& ValueStr() const { return value; } + #endif + + const TIXML_STRING& ValueTStr() const { return value; } + + /** Changes the value of the node. Defined as: + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ + void SetValue(const char * _value) { value = _value;} + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Delete all the children of this node. Does not affect 'this'. + void Clear(); + + /// One step up the DOM. + TiXmlNode* Parent() { return parent; } + const TiXmlNode* Parent() const { return parent; } + + const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. + TiXmlNode* FirstChild() { return firstChild; } + const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + /// The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const char * _value ) { + // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) + // call the method, cast the return back to non-const. + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); + } + const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. + TiXmlNode* LastChild() { return lastChild; } + + const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const char * _value ) { + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. + #endif + + /** An alternate way to walk the children of a node. + One way to iterate over nodes is: + @verbatim + for( child = parent->FirstChild(); child; child = child->NextSibling() ) + @endverbatim + + IterateChildren does the same thing with the syntax: + @verbatim + child = 0; + while( child = parent->IterateChildren( child ) ) + @endverbatim + + IterateChildren takes the previous child as input and finds + the next one. If the previous child is null, it returns the + first. IterateChildren will return null when done. + */ + const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); + } + + /// This flavor of IterateChildren searches for children with a particular 'value' + const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + #endif + + /** Add a new node related to this. Adds a child past the LastChild. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); + + + /** Add a new node related to this. Adds a child past the LastChild. + + NOTE: the node to be added is passed by pointer, and will be + henceforth owned (and deleted) by tinyXml. This method is efficient + and avoids an extra copy, but should be used with care as it + uses a different memory model than the other insert functions. + + @sa InsertEndChild + */ + TiXmlNode* LinkEndChild( TiXmlNode* addThis ); + + /** Add a new node related to this. Adds a child before the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); + + /** Add a new node related to this. Adds a child after the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); + + /** Replace a child of this node. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); + + /// Delete a child of this node. + bool RemoveChild( TiXmlNode* removeThis ); + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling() const { return prev; } + TiXmlNode* PreviousSibling() { return prev; } + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling( const char * ) const; + TiXmlNode* PreviousSibling( const char *_prev ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Navigate to a sibling node. + const TiXmlNode* NextSibling() const { return next; } + TiXmlNode* NextSibling() { return next; } + + /// Navigate to a sibling node with the given 'value'. + const TiXmlNode* NextSibling( const char * ) const; + TiXmlNode* NextSibling( const char* _next ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement() const; + TiXmlElement* NextSiblingElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlElement* NextSiblingElement( const char *_next ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement() const; + TiXmlElement* FirstChildElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); + } + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement( const char * _value ) const; + TiXmlElement* FirstChildElement( const char * _value ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /** Query the type (as an enumerated value, above) of this node. + The possible types are: DOCUMENT, ELEMENT, COMMENT, + UNKNOWN, TEXT, and DECLARATION. + */ + int Type() const { return type; } + + /** Return a pointer to the Document this node lives in. + Returns null if not in a document. + */ + const TiXmlDocument* GetDocument() const; + TiXmlDocument* GetDocument() { + return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); + } + + /// Returns true if this node has no children. + bool NoChildren() const { return !firstChild; } + + virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + /** Create an exact duplicate of this node and return it. The memory must be deleted + by the caller. + */ + virtual TiXmlNode* Clone() const = 0; + + /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. + + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( TiXmlVisitor* visitor ) const = 0; + +protected: + TiXmlNode( NodeType _type ); + + // Copy to the allocated object. Shared functionality between Clone, Copy constructor, + // and the assignment operator. + void CopyTo( TiXmlNode* target ) const; + + #ifdef TIXML_USE_STL + // The real work of the input operator. + virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; + #endif + + // Figure out what is at *p, and parse it. Returns null if it is not an xml node. + TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); + + TiXmlNode* parent; + NodeType type; + + TiXmlNode* firstChild; + TiXmlNode* lastChild; + + TIXML_STRING value; + + TiXmlNode* prev; + TiXmlNode* next; + +private: + TiXmlNode( const TiXmlNode& ); // not implemented. + void operator=( const TiXmlNode& base ); // not allowed. +}; + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not TiXmlNodes, since they are not + part of the tinyXML document object model. There are other + suggested ways to look at this problem. +*/ +class TiXmlAttribute : public TiXmlBase +{ + friend class TiXmlAttributeSet; + +public: + /// Construct an empty attribute. + TiXmlAttribute() : TiXmlBase() + { + document = 0; + prev = next = 0; + } + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlAttribute( const std::string& _name, const std::string& _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + #endif + + /// Construct an attribute with a name and value. + TiXmlAttribute( const char * _name, const char * _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + + const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. + const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. + #ifdef TIXML_USE_STL + const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. + #endif + int IntValue() const; ///< Return the value of this attribute, converted to an integer. + double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + + // Get the tinyxml string representation + const TIXML_STRING& NameTStr() const { return name; } + + /** QueryIntValue examines the value string. It is an alternative to the + IntValue() method with richer error checking. + If the value is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. + + A specialized but useful call. Note that for success it returns 0, + which is the opposite of almost all other TinyXml calls. + */ + int QueryIntValue( int* _value ) const; + /// QueryDoubleValue examines the value string. See QueryIntValue(). + int QueryDoubleValue( double* _value ) const; + + void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const char* _value ) { value = _value; } ///< Set the value. + + void SetIntValue( int _value ); ///< Set the value from an integer. + void SetDoubleValue( double _value ); ///< Set the value from a double. + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetName( const std::string& _name ) { name = _name; } + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Get the next sibling attribute in the DOM. Returns null at end. + const TiXmlAttribute* Next() const; + TiXmlAttribute* Next() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); + } + + /// Get the previous sibling attribute in the DOM. Returns null at beginning. + const TiXmlAttribute* Previous() const; + TiXmlAttribute* Previous() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); + } + + bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } + bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } + bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } + + /* Attribute parsing starts: first letter of the name + returns: the next char after the value end quote + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + // Prints this Attribute to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + + // [internal use] + // Set the document pointer so the attribute can report errors. + void SetDocument( TiXmlDocument* doc ) { document = doc; } + +private: + TiXmlAttribute( const TiXmlAttribute& ); // not implemented. + void operator=( const TiXmlAttribute& base ); // not allowed. + + TiXmlDocument* document; // A pointer back to a document, for error reporting. + TIXML_STRING name; + TIXML_STRING value; + TiXmlAttribute* prev; + TiXmlAttribute* next; +}; + + +/* A class used to manage a group of attributes. + It is only used internally, both by the ELEMENT and the DECLARATION. + + The set can be changed transparent to the Element and Declaration + classes that use it, but NOT transparent to the Attribute + which has to implement a next() and previous() method. Which makes + it a bit problematic and prevents the use of STL. + + This version is implemented with circular lists because: + - I like circular lists + - it demonstrates some independence from the (typical) doubly linked list. +*/ +class TiXmlAttributeSet +{ +public: + TiXmlAttributeSet(); + ~TiXmlAttributeSet(); + + void Add( TiXmlAttribute* attribute ); + void Remove( TiXmlAttribute* attribute ); + + const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + + const TiXmlAttribute* Find( const char* _name ) const; + TiXmlAttribute* Find( const char* _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + #ifdef TIXML_USE_STL + const TiXmlAttribute* Find( const std::string& _name ) const; + TiXmlAttribute* Find( const std::string& _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + + #endif + +private: + //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), + //*ME: this class must be also use a hidden/disabled copy-constructor !!! + TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed + void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) + + TiXmlAttribute sentinel; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class TiXmlElement : public TiXmlNode +{ +public: + /// Construct an element. + TiXmlElement (const char * in_value); + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlElement( const std::string& _value ); + #endif + + TiXmlElement( const TiXmlElement& ); + + void operator=( const TiXmlElement& base ); + + virtual ~TiXmlElement(); + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + */ + const char* Attribute( const char* name ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an integer, + the integer value will be put in the return 'i', if 'i' + is non-null. + */ + const char* Attribute( const char* name, int* i ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an double, + the double value will be put in the return 'd', if 'd' + is non-null. + */ + const char* Attribute( const char* name, double* d ) const; + + /** QueryIntAttribute examines the attribute - it is an alternative to the + Attribute() method with richer error checking. + If the attribute is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. If the attribute + does not exist, then TIXML_NO_ATTRIBUTE is returned. + */ + int QueryIntAttribute( const char* name, int* _value ) const; + /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). + int QueryDoubleAttribute( const char* name, double* _value ) const; + /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). + int QueryFloatAttribute( const char* name, float* _value ) const { + double d; + int result = QueryDoubleAttribute( name, &d ); + if ( result == TIXML_SUCCESS ) { + *_value = (float)d; + } + return result; + } + + #ifdef TIXML_USE_STL + /** Template form of the attribute query which will try to read the + attribute into the specified type. Very easy, very powerful, but + be careful to make sure to call this with the correct type. + + NOTE: This method doesn't work correctly for 'string' types. + + @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE + */ + template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + std::stringstream sstream( node->ValueStr() ); + sstream >> *outValue; + if ( !sstream.fail() ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; + } + /* + This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" + but template specialization is hard to get working cross-compiler. Leaving the bug for now. + + // The above will fail for std::string because the space character is used as a seperator. + // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string + template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + *outValue = node->ValueStr(); + return TIXML_SUCCESS; + } + */ + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char* name, const char * _value ); + + #ifdef TIXML_USE_STL + const std::string* Attribute( const std::string& name ) const; + const std::string* Attribute( const std::string& name, int* i ) const; + const std::string* Attribute( const std::string& name, double* d ) const; + int QueryIntAttribute( const std::string& name, int* _value ) const; + int QueryDoubleAttribute( const std::string& name, double* _value ) const; + + /// STL std::string form. + void SetAttribute( const std::string& name, const std::string& _value ); + ///< STL std::string form. + void SetAttribute( const std::string& name, int _value ); + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or chan... [truncated message content] |
From: <sag...@li...> - 2006-07-08 08:51:31
|
Revision: 104 Author: juvinious Date: 2006-07-08 01:51:20 -0700 (Sat, 08 Jul 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=104&view=rev Log Message: ----------- Removed the classes from main.cpp and placed them into test_classes{.cpp/.h} Modified Paths: -------------- trunk/default.cbd trunk/demo/src/Main.cpp Added Paths: ----------- trunk/demo/include/test_classes.h trunk/demo/src/test_classes.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2006-07-11 01:56:20
|
Revision: 118 Author: juvinious Date: 2006-07-10 18:55:07 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/saggui/?rev=118&view=rev Log Message: ----------- Fixed some errors on the LICENSE Modified Paths: -------------- trunk/INSTALL trunk/LICENSE trunk/demo/src/Main.cpp trunk/demo/src/test_classes.cpp trunk/include/saggui/allegro/al_factory.h trunk/include/saggui/allegro/al_gfx.h trunk/include/saggui/allegro/al_keyinput.h trunk/include/saggui/allegro/al_mouse.h trunk/include/saggui/allegro/al_system.h trunk/include/saggui/animation.h trunk/include/saggui/coord.h trunk/include/saggui/debug.h trunk/include/saggui/decorator.h trunk/include/saggui/font.h trunk/include/saggui/font_manager.h trunk/include/saggui/graphic_manager.h trunk/include/saggui/graphics.h trunk/include/saggui/gui_manager.h trunk/include/saggui/key_events.h trunk/include/saggui/keyinput.h trunk/include/saggui/keyinput_manager.h trunk/include/saggui/keys.h trunk/include/saggui/library_factory.h trunk/include/saggui/mouse.h trunk/include/saggui/mouse_events.h trunk/include/saggui/mouse_manager.h trunk/include/saggui/openlayer/ol_factory.h trunk/include/saggui/openlayer/ol_gfx.h trunk/include/saggui/openlayer/ol_system.h trunk/include/saggui/resource_manager.h trunk/include/saggui/rgba.h trunk/include/saggui/sdl/sdl_factory.h trunk/include/saggui/sdl/sdl_gfx.h trunk/include/saggui/sdl/sdl_keyinput.h trunk/include/saggui/sdl/sdl_mouse.h trunk/include/saggui/sdl/sdl_system.h trunk/include/saggui/sprite.h trunk/include/saggui/system.h trunk/include/saggui/system_factory.h trunk/include/saggui/system_font.h trunk/include/saggui/timer.h trunk/include/saggui/widgets/input_box.h trunk/include/saggui/widgets/label.h trunk/include/saggui/widgets/text_box.h trunk/include/saggui/widgets/win.h trunk/include/saggui/window.h trunk/include/saggui.h trunk/src/allegro/al_factory.cpp trunk/src/allegro/al_gfx.cpp trunk/src/allegro/al_keyinput.cpp trunk/src/allegro/al_mouse.cpp trunk/src/allegro/al_system.cpp trunk/src/animation.cpp trunk/src/coord.cpp trunk/src/decorator.cpp trunk/src/font.cpp trunk/src/font_manager.cpp trunk/src/graphic_manager.cpp trunk/src/graphics.cpp trunk/src/gui_manager.cpp trunk/src/key_events.cpp trunk/src/keyinput.cpp trunk/src/keyinput_manager.cpp trunk/src/keys.cpp trunk/src/library_factory.cpp trunk/src/mouse.cpp trunk/src/mouse_events.cpp trunk/src/mouse_manager.cpp trunk/src/openlayer/ol_factory.cpp trunk/src/openlayer/ol_gfx.cpp trunk/src/openlayer/ol_system.cpp trunk/src/resource_manager.cpp trunk/src/rgba.cpp trunk/src/system.cpp trunk/src/system_factory.cpp trunk/src/timer.cpp trunk/src/widgets/input_box.cpp trunk/src/widgets/label.cpp trunk/src/widgets/text_box.cpp trunk/src/widgets/win.cpp trunk/src/window.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |