Thread: [Saggui-svn] SF.net SVN: saggui: [406] trunk (Page 8)
Status: Beta
Brought to you by:
juvinious
From: <sag...@li...> - 2007-03-15 09:51:08
|
Revision: 406 http://svn.sourceforge.net/saggui/?rev=406&view=rev Author: juvinious Date: 2007-03-15 02:51:07 -0700 (Thu, 15 Mar 2007) Log Message: ----------- Oops forgot to add common.h to the repository, some changes on scrollBar Modified Paths: -------------- trunk/src/widgets/scroll_bar.cpp Added Paths: ----------- trunk/include/saggui/common.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-04-28 06:46:59
|
Revision: 408 http://svn.sourceforge.net/saggui/?rev=408&view=rev Author: juvinious Date: 2007-04-27 23:46:58 -0700 (Fri, 27 Apr 2007) Log Message: ----------- Updated dates used in BSD License in each file that has had recent changes Modified Paths: -------------- trunk/examples/demo/include/test_classes.h trunk/examples/demo/src/allegro.cpp trunk/examples/demo/src/allegrogl.cpp trunk/examples/demo/src/openlayer.cpp trunk/examples/demo/src/sdl.cpp trunk/examples/demo/src/sdlgl.cpp trunk/examples/demo/src/test_classes.cpp trunk/examples/gamedemo/src/allegro.cpp trunk/examples/gamedemo/src/allegrogl.cpp trunk/examples/gamedemo/src/openlayer.cpp trunk/examples/gamedemo/src/sdl.cpp trunk/examples/gamedemo/src/sdlgl.cpp trunk/include/saggui/animation.h trunk/include/saggui/bitmap_font.h trunk/include/saggui/debug.h trunk/include/saggui/dllspec.h trunk/include/saggui/font.h trunk/include/saggui/font_base.h trunk/include/saggui/font_manager.h trunk/include/saggui/graphic_manager.h trunk/include/saggui/graphics.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/resource_manager.h trunk/include/saggui/rgba.h trunk/include/saggui/sprite.h trunk/include/saggui/system.h trunk/include/saggui/system_factory.h trunk/include/saggui/widgets/box.h trunk/include/saggui/widgets/button.h trunk/include/saggui/widgets/checkbox.h trunk/include/saggui/widgets/dialog.h trunk/include/saggui/widgets/input_box.h trunk/include/saggui/widgets/label.h trunk/include/saggui/widgets/progress_bar.h trunk/include/saggui/widgets/radial.h trunk/include/saggui/widgets/scroll_bar.h trunk/include/saggui/widgets/text_box.h trunk/modules/agl/include/agl_factory.h trunk/modules/agl/include/agl_system.h trunk/modules/agl/saggui_agl.h trunk/modules/agl/src/agl_factory.cpp trunk/modules/agl/src/agl_system.cpp trunk/modules/allegro/include/al_factory.h trunk/modules/allegro/include/al_font.h trunk/modules/allegro/include/al_gfx.h trunk/modules/allegro/include/al_keyinput.h trunk/modules/allegro/include/al_mouse.h trunk/modules/allegro/include/al_system.h trunk/modules/allegro/saggui_alleg.h trunk/modules/allegro/src/al_factory.cpp trunk/modules/allegro/src/al_font.cpp trunk/modules/allegro/src/al_gfx.cpp trunk/modules/allegro/src/al_keyinput.cpp trunk/modules/allegro/src/al_mouse.cpp trunk/modules/allegro/src/al_system.cpp trunk/modules/freetype/include/ft_default.h trunk/modules/freetype/include/ft_font.h trunk/modules/freetype/saggui_freetype.h trunk/modules/freetype/src/ft_font.cpp trunk/modules/openlayer/include/ol_factory.h trunk/modules/openlayer/include/ol_font.h trunk/modules/openlayer/include/ol_gfx.h trunk/modules/openlayer/include/ol_system.h trunk/modules/openlayer/saggui_ol.h trunk/modules/openlayer/src/ol_factory.cpp trunk/modules/openlayer/src/ol_font.cpp trunk/modules/openlayer/src/ol_gfx.cpp trunk/modules/openlayer/src/ol_system.cpp trunk/modules/palib/include/saggui/saggui.h trunk/modules/sdl/include/sdl_factory.h trunk/modules/sdl/include/sdl_gfx.h trunk/modules/sdl/include/sdl_keyinput.h trunk/modules/sdl/include/sdl_mouse.h trunk/modules/sdl/include/sdl_system.h trunk/modules/sdl/saggui_sdl.h trunk/modules/sdl/src/sdl_factory.cpp trunk/modules/sdl/src/sdl_gfx.cpp trunk/modules/sdl/src/sdl_keyinput.cpp trunk/modules/sdl/src/sdl_mouse.cpp trunk/modules/sdl/src/sdl_system.cpp trunk/modules/sdlgl/include/sdlgl_factory.h trunk/modules/sdlgl/include/sdlgl_gfx.h trunk/modules/sdlgl/include/sdlgl_system.h trunk/modules/sdlgl/saggui_sdlgl.h trunk/modules/sdlgl/src/sdlgl_factory.cpp trunk/modules/sdlgl/src/sdlgl_gfx.cpp trunk/modules/sdlgl/src/sdlgl_system.cpp trunk/src/animation.cpp trunk/src/bitmap_font.cpp trunk/src/coord.cpp trunk/src/font.cpp trunk/src/font_base.cpp trunk/src/font_manager.cpp trunk/src/graphic_manager.cpp trunk/src/graphics.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/resource_manager.cpp trunk/src/rgba.cpp trunk/src/system.cpp trunk/src/system_factory.cpp trunk/src/widgets/box.cpp trunk/src/widgets/button.cpp trunk/src/widgets/checkbox.cpp trunk/src/widgets/dialog.cpp trunk/src/widgets/input_box.cpp trunk/src/widgets/label.cpp trunk/src/widgets/progress_bar.cpp trunk/src/widgets/radial.cpp trunk/src/widgets/scroll_bar.cpp trunk/src/widgets/text_box.cpp trunk/utils/bmpdump/bmpdump-alleg.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-04-28 23:02:36
|
Revision: 410 http://svn.sourceforge.net/saggui/?rev=410&view=rev Author: juvinious Date: 2007-04-28 16:02:35 -0700 (Sat, 28 Apr 2007) Log Message: ----------- Fixed incompatibilities with different cmake patch versions Modified Paths: -------------- trunk/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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-04-28 23:48:15
|
Revision: 413 http://svn.sourceforge.net/saggui/?rev=413&view=rev Author: kazzmir Date: 2007-04-28 16:48:13 -0700 (Sat, 28 Apr 2007) Log Message: ----------- use saggui/blah in includes. fix a compiler warning or two Modified Paths: -------------- trunk/SConstruct trunk/src/animation.cpp trunk/src/bitmap_font.cpp trunk/src/coord.cpp trunk/src/font.cpp trunk/src/font_base.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/resource_manager.cpp trunk/src/rgba.cpp trunk/src/scheme.cpp trunk/src/schemes/defaultscheme.cpp trunk/src/style.cpp trunk/src/system.cpp trunk/src/system_factory.cpp trunk/src/timer.cpp trunk/src/widgets/box.cpp trunk/src/widgets/button.cpp trunk/src/widgets/checkbox.cpp trunk/src/widgets/dialog.cpp trunk/src/widgets/input_box.cpp trunk/src/widgets/label.cpp trunk/src/widgets/progress_bar.cpp trunk/src/widgets/radial.cpp trunk/src/widgets/scroll_bar.cpp trunk/src/widgets/text_box.cpp trunk/src/window.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-04-29 03:45:18
|
Revision: 416 http://saggui.svn.sourceforge.net/saggui/?rev=416&view=rev Author: kazzmir Date: 2007-04-28 20:45:12 -0700 (Sat, 28 Apr 2007) Log Message: ----------- build allegro module Modified Paths: -------------- trunk/SConstruct trunk/modules/allegro/src/al_system.cpp Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2007-04-29 00:39:41 UTC (rev 415) +++ trunk/SConstruct 2007-04-29 03:45:12 UTC (rev 416) @@ -17,6 +17,8 @@ source += map(lambda x: root + '/' + x, filter(isCpp, files)) return source -source = findSource( 'src' ) +env.StaticLibrary('lib/saggui', findSource( 'src' ) ) -env.StaticLibrary('lib/saggui', source ) +allegroEnv = Environment( ENV = os.environ ) +allegroEnv.Append( CPPPATH = ['modules/allegro/include','include'] ) +allegroEnv.StaticLibrary('lib/alleg', findSource('modules/allegro')) Modified: trunk/modules/allegro/src/al_system.cpp =================================================================== --- trunk/modules/allegro/src/al_system.cpp 2007-04-29 00:39:41 UTC (rev 415) +++ trunk/modules/allegro/src/al_system.cpp 2007-04-29 03:45:12 UTC (rev 416) @@ -40,7 +40,7 @@ #define AL_SYSTEM_CPP #include "al_system.h" -#include "resource_manager.h" +#include "saggui/resource_manager.h" #include "al_font.h" namespace saggui This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-04-29 15:36:15
|
Revision: 419 http://saggui.svn.sourceforge.net/saggui/?rev=419&view=rev Author: kazzmir Date: 2007-04-29 08:36:12 -0700 (Sun, 29 Apr 2007) Log Message: ----------- fix compiler warnings Modified Paths: -------------- trunk/SConstruct trunk/src/widgets/input_box.cpp Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2007-04-29 03:56:44 UTC (rev 418) +++ trunk/SConstruct 2007-04-29 15:36:12 UTC (rev 419) @@ -1,12 +1,5 @@ import os -env = Environment( ENV = os.environ ) - -env.BuildDir('build','src') - -env.Append( CPPPATH = 'include' ) -env.Append( CCFLAGS = '-Wall' ) - def isCpp( file ): return '.cpp' in file @@ -24,6 +17,13 @@ replacer = replace('^src','build') +env = Environment( ENV = os.environ ) + +env.BuildDir('build','src') + +env.Append( CPPPATH = 'include' ) +env.Append( CCFLAGS = '-Wall' ) + env.StaticLibrary('lib/saggui', map(replacer, findSource( 'src' ) )) allegroEnv = Environment( ENV = os.environ ) Modified: trunk/src/widgets/input_box.cpp =================================================================== --- trunk/src/widgets/input_box.cpp 2007-04-29 03:56:44 UTC (rev 418) +++ trunk/src/widgets/input_box.cpp 2007-04-29 15:36:12 UTC (rev 419) @@ -112,6 +112,9 @@ textX = (position.width - rightPadding)-2; cursorX = textX - currentSetFont->getLength(currentSetText.substr(0,currentSetText.length()-cursorIndex)); break; + case T_Bottom: + case T_Top: + break; } switch(vAlignment) @@ -127,6 +130,9 @@ textY = (position.height - bottomPadding) - textSizeH - 1; cursorY = textY - textSizeH; break; + case T_Right: + case T_Left: + break; } textY++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-04-29 23:16:31
|
Revision: 421 http://saggui.svn.sourceforge.net/saggui/?rev=421&view=rev Author: juvinious Date: 2007-04-29 16:16:28 -0700 (Sun, 29 Apr 2007) Log Message: ----------- Added in two new widgets to improve existing button & radial widgets as well as accomodate newer button type widgets. Modified Paths: -------------- trunk/CHANGELOG trunk/cmake/saggui.h.in trunk/include/saggui/window.h Added Paths: ----------- trunk/include/saggui/widgets/abstractbutton.h trunk/include/saggui/widgets/buttongroup.h trunk/src/widgets/abstractbutton.cpp trunk/src/widgets/buttongroup.cpp Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-04-29 22:54:05 UTC (rev 420) +++ trunk/CHANGELOG 2007-04-29 23:16:28 UTC (rev 421) @@ -1,4 +1,6 @@ -0.40 +0.42 +- Added in two new button type (buttonGroup & abstractButton) classes to improve the existing button and radial widgets and accomodate newer ones +- Added in scons build SConstruct file (kazzmir) - Added doDottedLine and doDottedRectfill for graphics class - Modified coord pointInside to accomodate shapes, making hovering over widgets correct now - Modified paint signals on window to include shapes for drawing properly Modified: trunk/cmake/saggui.h.in =================================================================== --- trunk/cmake/saggui.h.in 2007-04-29 22:54:05 UTC (rev 420) +++ trunk/cmake/saggui.h.in 2007-04-29 23:16:28 UTC (rev 421) @@ -82,8 +82,10 @@ #include "saggui/window.h" //! Headers for included widgets +#include "saggui/widgets/abstractbutton.h" #include "saggui/widgets/box.h" #include "saggui/widgets/button.h" +#include "saggui/widgets/buttongroup.h" #include "saggui/widgets/checkbox.h" #include "saggui/widgets/dialog.h" #include "saggui/widgets/input_box.h" Added: trunk/include/saggui/widgets/abstractbutton.h =================================================================== --- trunk/include/saggui/widgets/abstractbutton.h (rev 0) +++ trunk/include/saggui/widgets/abstractbutton.h 2007-04-29 23:16:28 UTC (rev 421) @@ -0,0 +1,132 @@ +/* +SAGGUI (Simplified Allegro 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 ABSTRACTBUTTON_H +#define ABSTRACTBUTTON_H + +#include "saggui/window.h" +#include "saggui/graphics.h" +#include "saggui/mouse_events.h" +#include "saggui/key_events.h" + +namespace saggui +{ + //! abstractButton + /*! + * An abstract button representing different types of buttons, radials, etc + */ + + + class buttonGroup; + + class SAGGUI_EXPORT abstractButton : public window, mouseEvents, keyEvents + { + public: + explicit abstractButton(); + virtual ~abstractButton(); + + void setText(const std::string &text); + std::string getText() const; + + void setIcon(graphic *icon); + graphic *getIcon() const; + + coord iconSize() const; + + void setCheckable(bool); + bool isCheckable() const; + + bool isChecked() const; + + void setDown(bool); + bool isDown() const; + + void setAutoRepeat(bool); + bool getAutoRepeat() const; + + void setAutoRepeatDelay(int); + int getAutoRepeatDelay() const; + + void setAutoRepeatInterval(int); + int getAutoRepeatInterval() const; + + void setAutoExclusive(bool); + bool isAutoExclusive() const; + + void setGroup(buttonGroup *group); + buttonGroup *getGroup() const; + + //public Q_SLOTS: + slot animateClick(int msec = 100); + slot click(const coord &pos); + slot toggle(); + slot setChecked(bool); + + //Q_SIGNALS: + signal0<> pressed; + signal0<> released; + signal0<> clicked; + signal0<> toggled; + + protected: + virtual slot paintEvent(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) = 0; + + virtual slot setClickSystem(mouseButtons type); + private: + bool autoExclusive; + bool autoRepeat; + int autoRepeatDelay; + int autoRepeatInterval; + bool checkable; + bool checked; + bool down; + graphic *icon; + /* coord iconSize; */ + /* shortcut : QKeySequence */ + std::string text; + + buttonGroup *bGroup; + slot onClicked(const coord &pos); + slot onPressed(const coord &pos); + slot onReleased(const coord &pos); + + friend class buttonGroup; + }; +} + +#endif // ABSTRACTBUTTON_H Added: trunk/include/saggui/widgets/buttongroup.h =================================================================== --- trunk/include/saggui/widgets/buttongroup.h (rev 0) +++ trunk/include/saggui/widgets/buttongroup.h 2007-04-29 23:16:28 UTC (rev 421) @@ -0,0 +1,85 @@ +/* +SAGGUI (Simplified Allegro 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 BUTTONGROUP_H +#define BUTTONGROUP_H + +#include <list> +#include "saggui/widgets/abstractbutton.h" + +namespace saggui +{ + class SAGGUI_EXPORT buttonGroup + { + public: + explicit buttonGroup(); + ~buttonGroup(); + + void setExclusive(bool); + bool isExclusive() const; + + void addButton(abstractButton *); + /*void addButton(abstractButton *, int id);*/ + void removeButton(abstractButton *); + + std::list<abstractButton*> buttons() const; + + abstractButton * checkedButton() const; + // no setter on purpose! + + abstractButton *button(int id) const; + /*void setId(abstractButton *button, int id);*/ + int id(abstractButton *button) const; + int checkedId() const; + + //Q_SIGNALS: + signal1<abstractButton *> buttonClickedObj; + signal1<int> buttonClickedID; + signal1<abstractButton *> buttonPressedObj; + signal1<int> buttonPressedID; + signal1<abstractButton *> buttonReleasedObj; + signal1<int> buttonReleasedID; + + private: + bool exclusive; + std::list<abstractButton*> group; + friend class abstractButton; + }; +} + +#endif // BUTTONGROUP_H Modified: trunk/include/saggui/window.h =================================================================== --- trunk/include/saggui/window.h 2007-04-29 22:54:05 UTC (rev 420) +++ trunk/include/saggui/window.h 2007-04-29 23:16:28 UTC (rev 421) @@ -82,70 +82,11 @@ //! Window colors so that styles can utilize to color themselves std::vector<rgba> wColors; - //! Window shape shapeType shape; + + //! \name Constructor & Destructor - private: - friend class guiManager; - friend class mouseManager; - - //! Window ID - int ID; - - //! Override == to check ID's between windows - bool operator==(window *w); - - //! Recursively check point to topmost parent - bool checkParentPos(const coord & pos); - - //! Check a point against the window plus it's style - bool checkPointPos(const coord & pos); - - //! Get parent position (need a recursive call) - coord getPosition(); - - //! Get parent position if not return this->position - coord getParentClipped(coord c); - - //! Get top most parent - window *getAbsoluteParent(); - - //! click system type - static mouseButtons clickType; - - protected: - //! Controlling window - window *parent; - - //! Children windows - std::vector<window*>children; - - //! Background Buffer - graphic *background; - - //! style - style *wStyle; - - //! Window type so that the guiManager can classify it using the below enums - winType windowType; - - //! Top Padding provided by styles - double topPadding; - //! Left Padding provided by styles - double leftPadding; - //! Bottom Padding provided by styles - double bottomPadding; - //! Right Padding provided by styles - double rightPadding; - - //! Set clickable system - virtual void setClickSystem(mouseButtons type); - - public: - - //! \name Constructor & Destructor - //! Constructor window(winType wt=W_Basic, winAttributeFlags flags= AT_Default | AT_Enabled | AT_Visible | AT_DefaultStyle, shapeType sh = S_Rectangle); @@ -211,6 +152,63 @@ //! Set attribute(s) inline void setAttribute(winAttributeFlags w, bool tf){ if(tf){attributes |= w;}else{attributes &= ~w;}} + + protected: + //! Controlling window + window *parent; + + //! Children windows + std::vector<window*>children; + + //! Background Buffer + graphic *background; + + //! style + style *wStyle; + + //! Window type so that the guiManager can classify it using the below enums + winType windowType; + + //! Top Padding provided by styles + double topPadding; + //! Left Padding provided by styles + double leftPadding; + //! Bottom Padding provided by styles + double bottomPadding; + //! Right Padding provided by styles + double rightPadding; + + //! Set clickable system + virtual slot setClickSystem(mouseButtons type); + + private: + + //! Window ID + int ID; + + //! Override == to check ID's between windows + bool operator==(window *w); + + //! Recursively check point to topmost parent + bool checkParentPos(const coord & pos); + + //! Check a point against the window plus it's style + bool checkPointPos(const coord & pos); + + //! Get parent position (need a recursive call) + coord getPosition(); + + //! Get parent position if not return this->position + coord getParentClipped(coord c); + + //! Get top most parent + window *getAbsoluteParent(); + + //! click system type + static mouseButtons clickType; + + friend class guiManager; + friend class mouseManager; }; } Added: trunk/src/widgets/abstractbutton.cpp =================================================================== --- trunk/src/widgets/abstractbutton.cpp (rev 0) +++ trunk/src/widgets/abstractbutton.cpp 2007-04-29 23:16:28 UTC (rev 421) @@ -0,0 +1,267 @@ +/* +SAGGUI (Simplified Allegro 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 ABSTRACTBUTTON_CPP +#define ABSTRACTBUTTON_CPP + +#include "saggui/widgets/abstractbutton.h" +#include "saggui/widgets/buttongroup.h" + +namespace saggui +{ + abstractButton::abstractButton() : window(W_Basic), mouseEvents(this), keyEvents(this) + { + setAttribute(AT_Raised,true); + autoExclusive=false; + autoRepeat=false; + autoRepeatDelay=0; + autoRepeatInterval=0; + checkable=false; + checked=false; + down=false; + icon=0; + text=""; + bGroup=0; + } + abstractButton::~abstractButton() + { + } + + void abstractButton::setText(const std::string &text) + { + this->text = text; + } + std::string abstractButton::getText() const + { + return this->text; + } + + void abstractButton::setIcon(graphic *icon) + { + this->icon = icon; + } + + graphic *abstractButton::getIcon() const + { + return this->icon; + } + + coord abstractButton::iconSize() const + { + coord temp; + temp.width = icon->getBmpWidth(); + temp.height = icon->getBmpHeight(); + return temp; + } + + void abstractButton::setCheckable(bool checkable) + { + this->checkable= checkable; + } + + bool abstractButton::isCheckable() const + { + return this->checkable; + } + + bool abstractButton::isChecked() const + { + return this->checked; + } + + void abstractButton::setDown(bool) + { + + } + + bool abstractButton::isDown() const + { + return this->down; + } + + void abstractButton::setAutoRepeat(bool) + { + } + + bool abstractButton::getAutoRepeat() const + { + } + + void abstractButton::setAutoRepeatDelay(int) + { + } + + int abstractButton::getAutoRepeatDelay() const + { + } + + void abstractButton::setAutoRepeatInterval(int) + { + } + int abstractButton::getAutoRepeatInterval() const + { + } + + void abstractButton::setAutoExclusive(bool) + { + } + + bool abstractButton::isAutoExclusive() const + { + } + + void abstractButton::setGroup(buttonGroup *group) + { + } + + buttonGroup *abstractButton::getGroup() const + { + } + + slot abstractButton::animateClick(int msec) + { + } + + slot abstractButton::click(const coord &pos) + { + } + + slot abstractButton::toggle() + { + + } + + slot abstractButton::setChecked(bool) + { + + } + + // Set click system + slot abstractButton::setClickSystem(mouseButtons type) + { + switch(type) + { + case M_Left: + { + onRightClick.disconnect_slot(this,&abstractButton::click); + onMiddleClick.disconnect_slot(this,&abstractButton::click); + + onLeftClick.connect(this,&abstractButton::click); + + onRightDown.disconnect_slot(this,&abstractButton::onPressed); + onRightUp.disconnect_slot(this,&abstractButton::onReleased); + onRightClick.disconnect_slot(this,&abstractButton::onClicked); + onMiddleDown.disconnect_slot(this,&abstractButton::onPressed); + onMiddleUp.disconnect_slot(this,&abstractButton::onReleased); + onMiddleClick.disconnect_slot(this,&abstractButton::onClicked); + + onLeftDown.connect(this,&abstractButton::onPressed); + onLeftUp.connect(this,&abstractButton::onReleased); + onLeftClick.connect(this,&abstractButton::onClicked); + break; + } + case M_Right: + { + onLeftClick.disconnect_slot(this,&abstractButton::click); + onMiddleClick.disconnect_slot(this,&abstractButton::click); + + onRightClick.connect(this,&abstractButton::click); + + onLeftDown.disconnect_slot(this,&abstractButton::onPressed); + onLeftUp.disconnect_slot(this,&abstractButton::onReleased); + onLeftClick.disconnect_slot(this,&abstractButton::onClicked); + onMiddleDown.disconnect_slot(this,&abstractButton::onPressed); + onMiddleUp.disconnect_slot(this,&abstractButton::onReleased); + onMiddleClick.disconnect_slot(this,&abstractButton::onClicked); + + onRightDown.connect(this,&abstractButton::onPressed); + onRightUp.connect(this,&abstractButton::onReleased); + onRightClick.connect(this,&abstractButton::onClicked); + break; + } + case M_Middle: + { + onRightClick.disconnect_slot(this,&abstractButton::click); + onLeftClick.disconnect_slot(this,&abstractButton::click); + + onMiddleClick.connect(this,&abstractButton::click); + + onRightDown.disconnect_slot(this,&abstractButton::onPressed); + onRightUp.disconnect_slot(this,&abstractButton::onReleased); + onRightClick.disconnect_slot(this,&abstractButton::onClicked); + onLeftDown.disconnect_slot(this,&abstractButton::onPressed); + onLeftUp.disconnect_slot(this,&abstractButton::onReleased); + onLeftClick.disconnect_slot(this,&abstractButton::onClicked); + + onMiddleDown.connect(this,&abstractButton::onPressed); + onMiddleUp.connect(this,&abstractButton::onReleased); + onMiddleClick.connect(this,&abstractButton::onClicked); + break; + } + } + } + + slot abstractButton::onClicked(const coord &pos) + { + if(bGroup) + { + bGroup->buttonClickedObj(this); + bGroup->buttonClickedID(getID()); + } + } + + slot abstractButton::onPressed(const coord &pos) + { + if(bGroup) + { + bGroup->buttonPressedObj(this); + bGroup->buttonPressedID(getID()); + } + } + + slot abstractButton::onReleased(const coord &pos) + { + if(bGroup) + { + bGroup->buttonReleasedObj(this); + bGroup->buttonReleasedID(getID()); + } + } +} + +#endif Added: trunk/src/widgets/buttongroup.cpp =================================================================== --- trunk/src/widgets/buttongroup.cpp (rev 0) +++ trunk/src/widgets/buttongroup.cpp 2007-04-29 23:16:28 UTC (rev 421) @@ -0,0 +1,133 @@ +/* +SAGGUI (Simplified Allegro 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 BUTTONGROUP_CPP +#define BUTTONGROUP_CPP + +#include "saggui/widgets/buttongroup.h" + +namespace saggui +{ + buttonGroup::buttonGroup() + { + exclusive = true; + } + + buttonGroup::~buttonGroup() + { + } + + void buttonGroup::setExclusive(bool ex) + { + this->exclusive = ex; + } + bool buttonGroup::isExclusive() const + { + return this->exclusive; + } + + void buttonGroup::addButton(abstractButton *button) + { + this->group.push_back(button); + } + + /*void addButton(abstractButton *, int id);*/ + void buttonGroup::removeButton(abstractButton *button) + { + this->group.remove(button); + } + + std::list<abstractButton*> buttonGroup::buttons() const + { + return this->group; + } + + abstractButton *buttonGroup::checkedButton() const + { + std::list<abstractButton*>::const_iterator start = group.begin(); + std::list<abstractButton*>::const_iterator end = group.begin(); + for(std::list<abstractButton*>::const_iterator i= start;i!=end;++i) + { + if((*i)->isChecked() == true) + { + return (*i); + } + } + + return 0; + } + + abstractButton *buttonGroup::button(int id) const + { + std::list<abstractButton*>::const_iterator start = group.begin(); + std::list<abstractButton*>::const_iterator end = group.begin(); + for(std::list<abstractButton*>::const_iterator i= start;i!=end;++i) + { + if((*i)->getID() == id) + { + return (*i); + } + } + + return 0; + } + /*void setId(abstractButton *button, int id);*/ + int buttonGroup::id(abstractButton *button) const + { + if(button)return button->getID(); + else return 0; + } + + int buttonGroup::checkedId() const + { + std::list<abstractButton*>::const_iterator start = group.begin(); + std::list<abstractButton*>::const_iterator end = group.begin(); + for(std::list<abstractButton*>::const_iterator i= start;i!=end;++i) + { + if((*i)->isChecked() == true) + { + return (*i)->getID(); + } + } + + return 0; + } + +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-03 01:34:46
|
Revision: 425 http://saggui.svn.sourceforge.net/saggui/?rev=425&view=rev Author: kazzmir Date: 2007-05-02 18:34:24 -0700 (Wed, 02 May 2007) Log Message: ----------- add operator== for references and some consts Modified Paths: -------------- trunk/include/saggui/window.h trunk/src/window.cpp Modified: trunk/include/saggui/window.h =================================================================== --- trunk/include/saggui/window.h 2007-04-30 00:32:23 UTC (rev 424) +++ trunk/include/saggui/window.h 2007-05-03 01:34:24 UTC (rev 425) @@ -139,7 +139,7 @@ int childTotal(); //! Return window ID number - int getID(); + const int getID() const; //! Add style void setStyle(style *d); @@ -187,7 +187,8 @@ int ID; //! Override == to check ID's between windows - bool operator==(window *w); + bool operator==(const window * const w) const; + bool operator==(const window & w) const; //! Recursively check point to topmost parent bool checkParentPos(const coord & pos); Modified: trunk/src/window.cpp =================================================================== --- trunk/src/window.cpp 2007-04-30 00:32:23 UTC (rev 424) +++ trunk/src/window.cpp 2007-05-03 01:34:24 UTC (rev 425) @@ -79,12 +79,17 @@ // Do some shit } - bool window::operator==(window *w) + bool window::operator==(const window * const w) const { if(!w)return false; else if(ID==w->ID)return true; return false; } + + bool window::operator==(const window & w) const + { + return *this == &w; + } // Recursively check point to topmost parent bool window::checkParentPos(const coord & pos) @@ -154,7 +159,7 @@ return children; } - int window::getID() + const int window::getID() const { return ID; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-05 15:05:15
|
Revision: 429 http://saggui.svn.sourceforge.net/saggui/?rev=429&view=rev Author: juvinious Date: 2007-05-05 08:05:12 -0700 (Sat, 05 May 2007) Log Message: ----------- Added two more signals to window and enabled -Woverloaded-virtual in cmakelists.txt Modified Paths: -------------- trunk/CMakeLists.txt trunk/include/saggui/window.h trunk/src/window.cpp Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2007-05-05 15:03:13 UTC (rev 428) +++ trunk/CMakeLists.txt 2007-05-05 15:05:12 UTC (rev 429) @@ -79,7 +79,7 @@ option(ENABLE_FREETYPE_FONTS "Enables freetype font support" on) if(NOT MSVC) - set(CXXFLAGS "-O2 -Wall -funroll-loops -fexpensive-optimizations") + set(CXXFLAGS "-O2 -Wall -funroll-loops -fexpensive-optimizations -Woverloaded-virtual") else(NOT MSVC) set(CXXFLAGS "-O2") endif(NOT MSVC) Modified: trunk/include/saggui/window.h =================================================================== --- trunk/include/saggui/window.h 2007-05-05 15:03:13 UTC (rev 428) +++ trunk/include/saggui/window.h 2007-05-05 15:05:12 UTC (rev 429) @@ -98,7 +98,7 @@ //! Window Location coord position; - //! \name Signals + //! \name Public Signals signal0<> onOpen; signal0<> onClose; @@ -180,7 +180,13 @@ //! Set clickable system virtual slot setClickSystem(mouseButtons type); - + + //! Signal emitted when connected to a parent + signal1<window *>onParentConnect; + + //! Signal emitted when disconnected to a parent + signal1<window *>onParentDisconnect; + private: //! Window ID Modified: trunk/src/window.cpp =================================================================== --- trunk/src/window.cpp 2007-05-05 15:03:13 UTC (rev 428) +++ trunk/src/window.cpp 2007-05-05 15:05:12 UTC (rev 429) @@ -173,25 +173,24 @@ { parent = p; parent->children.push_back(this); + onParentConnect.emit(p); } void window::addChild(window *c) { children.push_back(c); c->parent = this; + c->onParentConnect.emit(this); guiManager::fixWindow(c); } void window::removeChild(window *c) { - for(unsigned int i=0;i<children.size();++i) + std::vector<window*>::iterator temp = std::find(children.begin(),children.end(),c); + if(temp!=children.end()) { - if(children[i]==c) - { - std::vector<window *>::iterator p = children.begin(); - p+=i; - children.erase(p); - } + (*temp)->onParentDisconnect.emit(this); + children.erase(temp); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-05 15:18:33
|
Revision: 431 http://saggui.svn.sourceforge.net/saggui/?rev=431&view=rev Author: kazzmir Date: 2007-05-05 08:18:32 -0700 (Sat, 05 May 2007) Log Message: ----------- compile agl and opengl modules. clean up module creation Modified Paths: -------------- trunk/SConstruct trunk/modules/agl/src/agl_factory.cpp trunk/modules/agl/src/agl_system.cpp Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2007-05-05 15:10:19 UTC (rev 430) +++ trunk/SConstruct 2007-05-05 15:18:32 UTC (rev 431) @@ -54,19 +54,35 @@ env.StaticLibrary('lib/saggui', map(replacer, findFiles( 'src', isCpp ) )) env.ParseHeader('include/saggui/saggui.h', 'cmake/saggui.h.in') -## probably put the below into a function if its generic enough -allegroEnv = Environment( ENV = os.environ ) -allegroEnv.Append( CPPPATH = ['modules/allegro/include','include'] ) -allegroEnv.Append( CCFLAGS = ['-Wall', '-Woverloaded-virtual'] ) -allegroEnv.StaticLibrary('lib/saggui-alleg', map(replacer, findFiles('modules/allegro',isCpp))) -for i in findFiles('modules/allegro/', isH): - allegroEnv.Install('include/saggui/%s' % dirname(i.replace('modules/allegro','').replace('include','allegro')),i) +def buildModule(directory, name, menv = Environment(ENV = os.environ)): + # moduleEnv = Environment( ENV = os.environ ) + menv.Append( CPPPATH = ['modules/%s/include' % directory,'include'] ) + menv.Append( CCFLAGS = ['-Wall', '-Woverloaded-virtual'] ) + menv.StaticLibrary('lib/%s' % name, map(replacer, findFiles('modules/%s' % directory,isCpp))) + for i in findFiles('modules/%s/' % directory, isH): + menv.Install('include/saggui/%s' % dirname(i.replace('modules/%s' % directory,'').replace('include','%s' % directory)),i) -sdlEnv = Environment( ENV = os.environ ) -sdlEnv.Append( CPPPATH = ['modules/sdl/include','include'] ) -sdlEnv.Append( CCFLAGS = ['-Wall', '-Woverloaded-virtual'] ) -sdlEnv.StaticLibrary('lib/saggui-sdl', map(replacer, findFiles('modules/sdl',isCpp))) -for i in findFiles('modules/sdl/', isH): - sdlEnv.Install('include/saggui/%s' % dirname(i.replace('modules/sdl','').replace('include','sdl')),i) +buildModule('allegro','saggui-alleg') +aglEnv = Environment(ENV = os.environ ) +# aglEnv.Append( CPPPATH = ['modules/opengl','modules/allegro/include'] ) +buildModule('agl','saggui-agl', aglEnv) +buildModule('sdl','saggui-sdl') +buildModule('opengl','saggui-opengl') +if False: + ## probably put the below into a function if its generic enough + allegroEnv = Environment( ENV = os.environ ) + allegroEnv.Append( CPPPATH = ['modules/allegro/include','include'] ) + allegroEnv.Append( CCFLAGS = ['-Wall', '-Woverloaded-virtual'] ) + allegroEnv.StaticLibrary('lib/saggui-alleg', map(replacer, findFiles('modules/allegro',isCpp))) + for i in findFiles('modules/allegro/', isH): + allegroEnv.Install('include/saggui/%s' % dirname(i.replace('modules/allegro','').replace('include','allegro')),i) + sdlEnv = Environment( ENV = os.environ ) + sdlEnv.Append( CPPPATH = ['modules/sdl/include','include'] ) + sdlEnv.Append( CCFLAGS = ['-Wall', '-Woverloaded-virtual'] ) + sdlEnv.StaticLibrary('lib/saggui-sdl', map(replacer, findFiles('modules/sdl',isCpp))) + for i in findFiles('modules/sdl/', isH): + sdlEnv.Install('include/saggui/%s' % dirname(i.replace('modules/sdl','').replace('include','sdl')),i) + + Modified: trunk/modules/agl/src/agl_factory.cpp =================================================================== --- trunk/modules/agl/src/agl_factory.cpp 2007-05-05 15:10:19 UTC (rev 430) +++ trunk/modules/agl/src/agl_factory.cpp 2007-05-05 15:18:32 UTC (rev 431) @@ -40,10 +40,10 @@ #define AGL_FACTORY_CPP #include "agl_factory.h" -#include "al_gfx.h" +#include "saggui/allegro/al_gfx.h" //#include "agl_gfx.h" -#include "al_mouse.h" -#include "al_keyinput.h" +#include "saggui/allegro/al_mouse.h" +#include "saggui/allegro/al_keyinput.h" namespace saggui { Modified: trunk/modules/agl/src/agl_system.cpp =================================================================== --- trunk/modules/agl/src/agl_system.cpp 2007-05-05 15:10:19 UTC (rev 430) +++ trunk/modules/agl/src/agl_system.cpp 2007-05-05 15:18:32 UTC (rev 431) @@ -40,9 +40,9 @@ #define AGL_SYSTEM_CPP #include "agl_system.h" -#include "resource_manager.h" -#include "al_font.h" -#include "al_gfx.h" +#include "saggui/resource_manager.h" +#include "saggui/allegro/al_font.h" +#include "saggui/allegro/al_gfx.h" //#include "agl_gfx.h" namespace saggui This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-05 15:23:42
|
Revision: 433 http://saggui.svn.sourceforge.net/saggui/?rev=433&view=rev Author: kazzmir Date: 2007-05-05 08:23:38 -0700 (Sat, 05 May 2007) Log Message: ----------- compile freetype and openlayer Modified Paths: -------------- trunk/SConstruct trunk/modules/openlayer/src/ol_factory.cpp Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2007-05-05 15:21:37 UTC (rev 432) +++ trunk/SConstruct 2007-05-05 15:23:38 UTC (rev 433) @@ -70,8 +70,10 @@ buildModule('sdl','saggui-sdl') buildModule('sdlgl','saggui-sdlgl') buildModule('opengl','saggui-opengl') -# buildModule('freetype','saggui-freetype') -# buildModule('openlayer','saggui-openlayer') +freeTypeEnv = Environment( ENV = os.environ ) +freeTypeEnv.ParseConfig('freetype-config --cflags') +buildModule('freetype','saggui-freetype', freeTypeEnv) +buildModule('openlayer','saggui-openlayer', freeTypeEnv) if hasNintendoDS: buildModule('palib','saggui-palib') Modified: trunk/modules/openlayer/src/ol_factory.cpp =================================================================== --- trunk/modules/openlayer/src/ol_factory.cpp 2007-05-05 15:21:37 UTC (rev 432) +++ trunk/modules/openlayer/src/ol_factory.cpp 2007-05-05 15:23:38 UTC (rev 433) @@ -40,8 +40,8 @@ #include <winalleg.h> #endif #include "ol_factory.h" -#include "al_mouse.h" -#include "al_keyinput.h" +#include "saggui/allegro/al_mouse.h" +#include "saggui/allegro/al_keyinput.h" namespace saggui { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-05 15:46:10
|
Revision: 434 http://saggui.svn.sourceforge.net/saggui/?rev=434&view=rev Author: kazzmir Date: 2007-05-05 08:46:06 -0700 (Sat, 05 May 2007) Log Message: ----------- make compiler happy about virtual functions Modified Paths: -------------- trunk/SConstruct trunk/modules/allegro/include/al_gfx.h Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2007-05-05 15:23:38 UTC (rev 433) +++ trunk/SConstruct 2007-05-05 15:46:06 UTC (rev 434) @@ -70,10 +70,12 @@ buildModule('sdl','saggui-sdl') buildModule('sdlgl','saggui-sdlgl') buildModule('opengl','saggui-opengl') + freeTypeEnv = Environment( ENV = os.environ ) freeTypeEnv.ParseConfig('freetype-config --cflags') buildModule('freetype','saggui-freetype', freeTypeEnv) buildModule('openlayer','saggui-openlayer', freeTypeEnv) + if hasNintendoDS: buildModule('palib','saggui-palib') Modified: trunk/modules/allegro/include/al_gfx.h =================================================================== --- trunk/modules/allegro/include/al_gfx.h 2007-05-05 15:23:38 UTC (rev 433) +++ trunk/modules/allegro/include/al_gfx.h 2007-05-05 15:46:06 UTC (rev 434) @@ -99,10 +99,12 @@ // Bitmap Routines - + // make the compiler happy about overloaded functions + using graphic::loadBmp; + //! Load bitmap from file (and save filename) - void loadBmp(const std::string & filename, const rgba & color=rgba::NOCOLOR); - + virtual void loadBmp(const std::string & filename, const rgba & color=rgba::NOCOLOR); + //! Create bitmap void createBmp(double width, double height, double depth=32); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-05 16:17:38
|
Revision: 435 http://saggui.svn.sourceforge.net/saggui/?rev=435&view=rev Author: juvinious Date: 2007-05-05 09:17:34 -0700 (Sat, 05 May 2007) Log Message: ----------- Fixed all warnings Modified Paths: -------------- trunk/examples/demo/include/test_classes.h trunk/examples/demo/src/test_classes.cpp trunk/modules/agl/include/agl_gfx.h trunk/modules/openlayer/include/ol_gfx.h trunk/modules/sdl/include/sdl_gfx.h trunk/modules/sdlgl/include/sdlgl_gfx.h Modified: trunk/examples/demo/include/test_classes.h =================================================================== --- trunk/examples/demo/include/test_classes.h 2007-05-05 15:46:06 UTC (rev 434) +++ trunk/examples/demo/include/test_classes.h 2007-05-05 16:17:34 UTC (rev 435) @@ -112,7 +112,7 @@ void out(const saggui::coord &c); void moving(); // Set clickable system - void setClickSystem(int type); + void setClickSystem(saggui::mouseButtons type); }; class testProgress : public saggui::progressBar Modified: trunk/examples/demo/src/test_classes.cpp =================================================================== --- trunk/examples/demo/src/test_classes.cpp 2007-05-05 15:46:06 UTC (rev 434) +++ trunk/examples/demo/src/test_classes.cpp 2007-05-05 16:17:34 UTC (rev 435) @@ -288,22 +288,24 @@ } // Set click system - void win::setClickSystem(int type) + void win::setClickSystem(saggui::mouseButtons type) { switch(type) { - case 0: + case saggui::M_Left: { break; } - case 1: + case saggui::M_Right: { break; } - case 2: + case saggui::M_Middle: { break; } + default: + break; } } Modified: trunk/modules/agl/include/agl_gfx.h =================================================================== --- trunk/modules/agl/include/agl_gfx.h 2007-05-05 15:46:06 UTC (rev 434) +++ trunk/modules/agl/include/agl_gfx.h 2007-05-05 16:17:34 UTC (rev 435) @@ -99,6 +99,8 @@ // Bitmap Routines + // make the compiler happy about overloaded functions + using graphic::loadBmp; //! Load bitmap from from memory void loadBmp(char *data[], int width, int height); Modified: trunk/modules/openlayer/include/ol_gfx.h =================================================================== --- trunk/modules/openlayer/include/ol_gfx.h 2007-05-05 15:46:06 UTC (rev 434) +++ trunk/modules/openlayer/include/ol_gfx.h 2007-05-05 16:17:34 UTC (rev 435) @@ -105,6 +105,9 @@ // Bitmap Routines + // make the compiler happy about overloaded functions + using graphic::loadBmp; + //! Load bitmap from from memory void loadBmp(char *data[], int width, int height); Modified: trunk/modules/sdl/include/sdl_gfx.h =================================================================== --- trunk/modules/sdl/include/sdl_gfx.h 2007-05-05 15:46:06 UTC (rev 434) +++ trunk/modules/sdl/include/sdl_gfx.h 2007-05-05 16:17:34 UTC (rev 435) @@ -94,6 +94,8 @@ // Bitmap Routines + // make the compiler happy about overloaded functions + using graphic::loadBmp; //! Load bitmap from file (and save filename) void loadBmp(const std::string & filename, const rgba &color=0); Modified: trunk/modules/sdlgl/include/sdlgl_gfx.h =================================================================== --- trunk/modules/sdlgl/include/sdlgl_gfx.h 2007-05-05 15:46:06 UTC (rev 434) +++ trunk/modules/sdlgl/include/sdlgl_gfx.h 2007-05-05 16:17:34 UTC (rev 435) @@ -102,6 +102,8 @@ // Bitmap Routines + // make the compiler happy about overloaded functions + using graphic::loadBmp; //! Load bitmap from from memory void loadBmp(char *data[], int width, int height); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-05 20:00:20
|
Revision: 437 http://saggui.svn.sourceforge.net/saggui/?rev=437&view=rev Author: juvinious Date: 2007-05-05 13:00:18 -0700 (Sat, 05 May 2007) Log Message: ----------- Added -Werror to catch all errors and correct problems Modified Paths: -------------- trunk/CMakeLists.txt trunk/utils/bmpdump/bmpdump-alleg.cpp trunk/utils/bmpdump/bmpdump-sdl.cpp Modified: trunk/CMakeLists.txt =================================================================== --- trunk/CMakeLists.txt 2007-05-05 16:31:15 UTC (rev 436) +++ trunk/CMakeLists.txt 2007-05-05 20:00:18 UTC (rev 437) @@ -79,7 +79,7 @@ option(ENABLE_FREETYPE_FONTS "Enables freetype font support" on) if(NOT MSVC) - set(CXXFLAGS "-O2 -Wall -funroll-loops -fexpensive-optimizations -Woverloaded-virtual") + set(CXXFLAGS "-O2 -Wall -funroll-loops -fexpensive-optimizations -Woverloaded-virtual -Werror") else(NOT MSVC) set(CXXFLAGS "-O2") endif(NOT MSVC) Modified: trunk/utils/bmpdump/bmpdump-alleg.cpp =================================================================== --- trunk/utils/bmpdump/bmpdump-alleg.cpp 2007-05-05 16:31:15 UTC (rev 436) +++ trunk/utils/bmpdump/bmpdump-alleg.cpp 2007-05-05 20:00:18 UTC (rev 437) @@ -99,7 +99,7 @@ char workStr[256]; sprintf(workStr,"\"#%2x%2x%2x\"",getr(pixel),getg(pixel),getb(pixel)); string workStrTmp = workStr; - for(int i = 0; i < workStrTmp.length();++i) + for(unsigned int i = 0; i < workStrTmp.length();++i) { if(workStrTmp[i]==' ')workStrTmp[i]='0'; } Modified: trunk/utils/bmpdump/bmpdump-sdl.cpp =================================================================== --- trunk/utils/bmpdump/bmpdump-sdl.cpp 2007-05-05 16:31:15 UTC (rev 436) +++ trunk/utils/bmpdump/bmpdump-sdl.cpp 2007-05-05 20:00:18 UTC (rev 437) @@ -127,7 +127,7 @@ char workStr[256]; sprintf(workStr,"\"#%2x%2x%2x\"",red,green,blue); string workStrTmp = workStr; - for(int i = 0; i < workStrTmp.length();++i) + for(unsigned int i = 0; i < workStrTmp.length();++i) { if(workStrTmp[i]==' ')workStrTmp[i]='0'; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-06 02:30:13
|
Revision: 439 http://saggui.svn.sourceforge.net/saggui/?rev=439&view=rev Author: kazzmir Date: 2007-05-05 19:30:11 -0700 (Sat, 05 May 2007) Log Message: ----------- only use -Woverloaded-virtual for c++ files. fix some include paths Modified Paths: -------------- trunk/SConstruct trunk/modules/sdlgl/src/sdlgl_factory.cpp trunk/modules/sdlgl/src/sdlgl_gfx.cpp Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2007-05-05 21:13:58 UTC (rev 438) +++ trunk/SConstruct 2007-05-06 02:30:11 UTC (rev 439) @@ -57,19 +57,23 @@ env.StaticLibrary('lib/saggui', map(replacer, findFiles( 'src', isCpp ) )) env.ParseHeader('include/saggui/saggui.h', 'cmake/saggui.h.in') -def buildModule(directory, name, menv = Environment(ENV = os.environ)): +def newEnv(): + return Environment( ENV = os.environ ) + +def buildModule(directory, name, menv ): # moduleEnv = Environment( ENV = os.environ ) menv.Append( CPPPATH = ['modules/%s/include' % directory,'include'] ) - menv.Append( CCFLAGS = ['-Wall', '-Woverloaded-virtual','-Werror'] ) + menv.Append( CCFLAGS = ['-Wall','-Werror'] ) + menv.Append( CXXFLAGS = ['-Woverloaded-virtual'] ) menv.StaticLibrary('lib/%s' % name, map(replacer, findFiles('modules/%s' % directory,isCpp))) for i in findFiles('modules/%s/' % directory, isH): menv.Install('include/saggui/%s' % dirname(i.replace('modules/%s' % directory,'').replace('include','%s' % directory)),i) -buildModule('allegro','saggui-alleg') -buildModule('agl','saggui-agl') -buildModule('sdl','saggui-sdl') -buildModule('sdlgl','saggui-sdlgl') -buildModule('opengl','saggui-opengl') +buildModule('allegro','saggui-alleg',newEnv()) +buildModule('agl','saggui-agl', newEnv()) +buildModule('sdl','saggui-sdl', newEnv()) +buildModule('sdlgl','saggui-sdlgl', newEnv()) +buildModule('opengl','saggui-opengl', newEnv()) freeTypeEnv = Environment( ENV = os.environ ) freeTypeEnv.ParseConfig('freetype-config --cflags') @@ -78,21 +82,3 @@ if hasNintendoDS: buildModule('palib','saggui-palib') - -if False: - ## probably put the below into a function if its generic enough - allegroEnv = Environment( ENV = os.environ ) - allegroEnv.Append( CPPPATH = ['modules/allegro/include','include'] ) - allegroEnv.Append( CCFLAGS = ['-Wall', '-Woverloaded-virtual'] ) - allegroEnv.StaticLibrary('lib/saggui-alleg', map(replacer, findFiles('modules/allegro',isCpp))) - for i in findFiles('modules/allegro/', isH): - allegroEnv.Install('include/saggui/%s' % dirname(i.replace('modules/allegro','').replace('include','allegro')),i) - - sdlEnv = Environment( ENV = os.environ ) - sdlEnv.Append( CPPPATH = ['modules/sdl/include','include'] ) - sdlEnv.Append( CCFLAGS = ['-Wall', '-Woverloaded-virtual'] ) - sdlEnv.StaticLibrary('lib/saggui-sdl', map(replacer, findFiles('modules/sdl',isCpp))) - for i in findFiles('modules/sdl/', isH): - sdlEnv.Install('include/saggui/%s' % dirname(i.replace('modules/sdl','').replace('include','sdl')),i) - - Modified: trunk/modules/sdlgl/src/sdlgl_factory.cpp =================================================================== --- trunk/modules/sdlgl/src/sdlgl_factory.cpp 2007-05-05 21:13:58 UTC (rev 438) +++ trunk/modules/sdlgl/src/sdlgl_factory.cpp 2007-05-06 02:30:11 UTC (rev 439) @@ -42,8 +42,8 @@ #include "sdlgl_system.h" #include "sdlgl_factory.h" #include "sdlgl_gfx.h" -#include "sdl_mouse.h" -#include "sdl_keyinput.h" +#include "saggui/sdl/sdl_mouse.h" +#include "saggui/sdl/sdl_keyinput.h" namespace saggui { Modified: trunk/modules/sdlgl/src/sdlgl_gfx.cpp =================================================================== --- trunk/modules/sdlgl/src/sdlgl_gfx.cpp 2007-05-05 21:13:58 UTC (rev 438) +++ trunk/modules/sdlgl/src/sdlgl_gfx.cpp 2007-05-06 02:30:11 UTC (rev 439) @@ -38,7 +38,7 @@ #include "sdlgl_gfx.h" #include <SDL/SDL.h> -#include "sdl_gfx_primitives.h" +#include "saggui/sdl/sdl_gfx_primitives.h" //! Simplified Allegro Gaming Graphical User Interface /*! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-07 00:54:16
|
Revision: 440 http://saggui.svn.sourceforge.net/saggui/?rev=440&view=rev Author: kazzmir Date: 2007-05-06 17:54:11 -0700 (Sun, 06 May 2007) Log Message: ----------- add getters for coord x/y/width/height Modified Paths: -------------- trunk/include/saggui/coord.h trunk/src/coord.cpp Modified: trunk/include/saggui/coord.h =================================================================== --- trunk/include/saggui/coord.h 2007-05-06 02:30:11 UTC (rev 439) +++ trunk/include/saggui/coord.h 2007-05-07 00:54:11 UTC (rev 440) @@ -68,6 +68,7 @@ //! Destructor ~coord(); + /* member variables should be private */ //! X position in coordinate system double x; @@ -119,13 +120,38 @@ //! Set height void setHeight(double h); + //! Get width + inline const double getWidth() const + { + return width; + } + + //! Get height + inline const double getHeight() const + { + return height; + } + + //! Returns x + /*! \return x */ + inline const double getX() const + { + return x; + } + + //! Returns y + /*! \return y */ + inline const double getY() const { + return y; + } + //! Returns x + width /*! \return x + width */ - double getX2() const; + const double getX2() const; //! Returns y + height /*! \return y + height */ - double getY2() const; + const double getY2() const; //! Is the given coord.x and coord.y inside this coord bool pointInside(const coord & c, shapeType type = S_Rectangle) const; Modified: trunk/src/coord.cpp =================================================================== --- trunk/src/coord.cpp 2007-05-06 02:30:11 UTC (rev 439) +++ trunk/src/coord.cpp 2007-05-07 00:54:11 UTC (rev 440) @@ -185,14 +185,14 @@ if(runResize)onResize.emit(); } - double coord::getX2() const + const double coord::getX2() const { - return (x+width); + return (getX()+getWidth()); } - double coord::getY2() const + const double coord::getY2() const { - return (y+height); + return (getY()+getHeight()); } bool coord::pointInside(const coord & c, shapeType type) const This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-09 03:27:30
|
Revision: 441 http://saggui.svn.sourceforge.net/saggui/?rev=441&view=rev Author: juvinious Date: 2007-05-08 20:27:25 -0700 (Tue, 08 May 2007) Log Message: ----------- Added new widget listbox - WIP Modified Paths: -------------- trunk/CHANGELOG trunk/cmake/saggui.h.in Added Paths: ----------- trunk/include/saggui/widgets/listbox.h trunk/src/widgets/listbox.cpp Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-05-07 00:54:11 UTC (rev 440) +++ trunk/CHANGELOG 2007-05-09 03:27:25 UTC (rev 441) @@ -1,4 +1,5 @@ -0.42 +0.43 +- Added new widget listbox - Added in two new button type (buttonGroup & abstractButton) classes to improve the existing button and radial widgets and accomodate newer ones (juvinious) - Added in scons build SConstruct file (kazzmir) - Added doDottedLine and doDottedRectfill for graphics class Modified: trunk/cmake/saggui.h.in =================================================================== --- trunk/cmake/saggui.h.in 2007-05-07 00:54:11 UTC (rev 440) +++ trunk/cmake/saggui.h.in 2007-05-09 03:27:25 UTC (rev 441) @@ -90,6 +90,7 @@ #include "saggui/widgets/dialog.h" #include "saggui/widgets/input_box.h" #include "saggui/widgets/label.h" +#include "saggui/widgets/listbox.h" #include "saggui/widgets/progress_bar.h" #include "saggui/widgets/radial.h" #include "saggui/widgets/scroll_bar.h" Copied: trunk/include/saggui/widgets/listbox.h (from rev 440, trunk/include/saggui/widgets/box.h) =================================================================== --- trunk/include/saggui/widgets/listbox.h (rev 0) +++ trunk/include/saggui/widgets/listbox.h 2007-05-09 03:27:25 UTC (rev 441) @@ -0,0 +1,92 @@ +/* +SAGGUI (Simplified Allegro 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 LISTBOX_H +#define LISTBOX_H + +#include "saggui/window.h" +#include "saggui/mouse_events.h" +#include "saggui/widgets/button.h" +#include "saggui/widgets/label.h" +#include "saggui/widgets/scroll_bar.h" + +namespace saggui +{ + //! List Box + /*! + * List Box is user selectable combo box. \n + */ + + class listBox : public window, public mouseEvents + { + public: + listBox(); + ~listBox(); + + // Add item + void addItem(const std::string &text); + + // Clear items + void clearItems(); + + protected: + slot resized(); + + slot drawOnButton(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + + slot showPopUp(); + + slot hidePopUp(); + + private: + // Items + //std::vector<std::string>itemList; + std::vector<label *>itemList; + + // Label to contain our chosen item + label chosen; + // Button for drop down + button showListButton; + + // Popup for selectable list + box popUp; + scrollBar sideBar; + }; +} + +#endif Copied: trunk/src/widgets/listbox.cpp (from rev 440, trunk/src/widgets/box.cpp) =================================================================== --- trunk/src/widgets/listbox.cpp (rev 0) +++ trunk/src/widgets/listbox.cpp 2007-05-09 03:27:25 UTC (rev 441) @@ -0,0 +1,154 @@ +/* +SAGGUI (Simplified Allegro 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 LISTBOX_CPP +#define LISTBOX_CPP + +#include "saggui/widgets/listbox.h" + +namespace saggui +{ + listBox::listBox() : mouseEvents(this) { + chosen.setHorizontalAlign(0); + addChild(&chosen); + + onResize.connect(this,&listBox::resized); + + addChild(&showListButton); + showListButton.onButtonClick.connect(this,&listBox::showPopUp); + showListButton.onPaint.connect(this,&listBox::drawOnButton); + //showListButton.onButtonClick.connect(this,&listBox::showPopUp); + + popUp.addChild(&sideBar); + popUp.setAttribute(AT_Visible | AT_Enabled, false); + popUp.onLostFocus.connect(this,&listBox::hidePopUp); + + sideBar.setAttribute(AT_Visible | AT_Enabled, false); + } + + listBox::~listBox() { } + +// Add item + void listBox::addItem(const std::string &text) + { + label *temp = new label(); + temp->setHorizontalAlign(0); + temp->setText(text); + if(itemList.empty()) + { + chosen.setText(text); + } + itemList.push_back(temp); + } + +// Clear items + void listBox::clearItems() + { + std::vector<label *>::iterator ibegin = itemList.begin(); + std::vector<label *>::iterator iend = itemList.end(); + for(std::vector<label *>::iterator i = ibegin;i!=iend;++i) + { + popUp.removeChild((*i)); + if((*i))delete (*i); + } + itemList.clear(); + chosen.setText(""); + } + + slot listBox::resized() + { + chosen.position.set(0,0,(position.width*.80)-1,position.height-1); + 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) + { + double movex = 0; + double movey = 0; + + if(flags & AT_Sunken) + { + movex = 1;//pos.width * 0.10; + movey = 1;//pos.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)), + rgba::BLACK); + } + + slot listBox::showPopUp() + { + guiManager::setWindowFocused(&popUp); + popUp.setAttribute(AT_Visible | AT_Enabled, true); + popUp.setAlwaysOnTop(true); + coord temp = getRelativePosition(); + temp.y += position.height; + temp.setWidth(position.width); + popUp.position = temp; + + std::vector<label *>::iterator ibegin = itemList.begin(); + std::vector<label *>::iterator iend = itemList.end(); + double listSize = 0; + for(std::vector<label *>::iterator i = ibegin;i!=iend;++i) + { + (*i)->position.set(0,listSize,position.width,position.height); + listSize+=position.height; + popUp.addChild((*i)); + } + popUp.position.setHeight(listSize); + } + + slot listBox::hidePopUp() + { + popUp.setAttribute(AT_Visible | AT_Enabled, false); + popUp.setAlwaysOnTop(false); + popUp.position.set(0,0,0,0); + std::vector<label *>::iterator ibegin = itemList.begin(); + std::vector<label *>::iterator iend = itemList.end(); + for(std::vector<label *>::iterator i = ibegin;i!=iend;++i) + { + popUp.removeChild((*i)); + } + } +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-09 06:18:56
|
Revision: 442 http://saggui.svn.sourceforge.net/saggui/?rev=442&view=rev Author: juvinious Date: 2007-05-08 23:18:54 -0700 (Tue, 08 May 2007) Log Message: ----------- Modified listbox to work a lot better. Modified Paths: -------------- trunk/include/saggui/widgets/listbox.h trunk/src/widgets/listbox.cpp Modified: trunk/include/saggui/widgets/listbox.h =================================================================== --- trunk/include/saggui/widgets/listbox.h 2007-05-09 03:27:25 UTC (rev 441) +++ trunk/include/saggui/widgets/listbox.h 2007-05-09 06:18:54 UTC (rev 442) @@ -41,6 +41,7 @@ #include "saggui/window.h" #include "saggui/mouse_events.h" +#include "saggui/key_events.h" #include "saggui/widgets/button.h" #include "saggui/widgets/label.h" #include "saggui/widgets/scroll_bar.h" @@ -52,17 +53,23 @@ * List Box is user selectable combo box. \n */ - class listBox : public window, public mouseEvents + class listBox : public window, public mouseEvents, public keyEvents { public: listBox(); ~listBox(); - // Add item + //! Add item void addItem(const std::string &text); + + //! Selected item + int selectedItem(); - // Clear items + //! Clear items void clearItems(); + + //! \name SIGNALS + signal1<int> itemSelected; protected: slot resized(); @@ -72,18 +79,39 @@ slot showPopUp(); slot hidePopUp(); + + 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 onSelectItem(const coord &pos); + + slot mainKeyPress(const keys &k); + + slot keyPress(const keys &k); + + slot setClickSystem(mouseButtons type); private: // Items //std::vector<std::string>itemList; std::vector<label *>itemList; + + //! Selected item if negative -1 no selection + int currentItem; + + //! Highlighted item + unsigned int highlightedItem; + + //! Current click system + mouseButtons currentType; - // Label to contain our chosen item + //! Label to contain our chosen item label chosen; - // Button for drop down + //! Button for drop down button showListButton; - // Popup for selectable list + //! Popup for selectable list box popUp; scrollBar sideBar; }; Modified: trunk/src/widgets/listbox.cpp =================================================================== --- trunk/src/widgets/listbox.cpp 2007-05-09 03:27:25 UTC (rev 441) +++ trunk/src/widgets/listbox.cpp 2007-05-09 06:18:54 UTC (rev 442) @@ -43,22 +43,28 @@ namespace saggui { - listBox::listBox() : mouseEvents(this) { + listBox::listBox() : mouseEvents(this), keyEvents(this) + { chosen.setHorizontalAlign(0); addChild(&chosen); onResize.connect(this,&listBox::resized); + + chosen.onKeyPress.connect(this,&listBox::mainKeyPress); addChild(&showListButton); showListButton.onButtonClick.connect(this,&listBox::showPopUp); showListButton.onPaint.connect(this,&listBox::drawOnButton); - //showListButton.onButtonClick.connect(this,&listBox::showPopUp); - + popUp.addChild(&sideBar); popUp.setAttribute(AT_Visible | AT_Enabled, false); popUp.onLostFocus.connect(this,&listBox::hidePopUp); + popUp.onKeyPress.connect(this,&listBox::keyPress); sideBar.setAttribute(AT_Visible | AT_Enabled, false); + + currentItem=-1; + highlightedItem=0; } listBox::~listBox() { } @@ -72,9 +78,16 @@ if(itemList.empty()) { chosen.setText(text); + currentItem = 0; } itemList.push_back(temp); } + + // Selected Item + int listBox::selectedItem() + { + return currentItem; + } // Clear items void listBox::clearItems() @@ -88,6 +101,7 @@ } itemList.clear(); chosen.setText(""); + currentItem = -1; } slot listBox::resized() @@ -117,6 +131,7 @@ slot listBox::showPopUp() { + if(itemList.empty())return; guiManager::setWindowFocused(&popUp); popUp.setAttribute(AT_Visible | AT_Enabled, true); popUp.setAlwaysOnTop(true); @@ -133,6 +148,25 @@ (*i)->position.set(0,listSize,position.width,position.height); listSize+=position.height; popUp.addChild((*i)); + (*i)->onHover.connect(this,&listBox::onHoverItem); + switch(currentType) + { + case M_Left: + { + (*i)->onLeftDown.connect(this,&listBox::onSelectItem); + break; + } + case M_Right: + { + (*i)->onRightDown.connect(this,&listBox::onSelectItem); + break; + } + case M_Middle: + { + (*i)->onRightDown.connect(this,&listBox::onSelectItem); + break; + } + } } popUp.position.setHeight(listSize); } @@ -149,6 +183,123 @@ popUp.removeChild((*i)); } } + + slot listBox::onHoverItem(const coord &pos) + { + int location = 0; + std::vector<label *>::const_iterator ibegin = itemList.begin(); + std::vector<label *>::const_iterator iend = itemList.end(); + for(std::vector<label *>::const_iterator i = ibegin;i!=iend;++i) + { + if((*i)->attributes & AT_Selected) + { + (*i)->onPaint.disconnect(this); + (*i)->setAttribute(AT_Selected,false); + } + if(((*i)->attributes & AT_MouseOver) || ((*i)->attributes & AT_On)) + { + (*i)->onPaint.connect(this,&listBox::onHoverDraw); + (*i)->setAttribute(AT_Selected,true); + (*i)->setAttribute(AT_On,false); + highlightedItem = location; + } + ++location; + } + } + + slot listBox::onHoverDraw(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + { + bmp->doRectfill(0,0,pos.width,pos.height,rgba(50,50,50,100)); + } + + slot listBox::onSelectItem(const coord &pos) + { + int location = 0; + std::vector<label *>::const_iterator ibegin = itemList.begin(); + std::vector<label *>::const_iterator iend = itemList.end(); + for(std::vector<label *>::const_iterator i = ibegin;i!=iend;++i) + { + if((*i)->attributes & AT_Selected) + { + (*i)->onPaint.disconnect(this); + (*i)->setAttribute(AT_Selected,false); + chosen.setText((*i)->getText()); + itemSelected.emit(location); + currentItem = location; + break; + } + ++location; + } + } + + slot listBox::mainKeyPress(const keys &k) + { + switch(k.getValue()) + { + case keys::UP: + showPopUp(); + if(!itemList.empty()) + { + itemList[currentItem]->setAttribute(AT_On,true); + itemList[currentItem]->onHover.emit(coord()); + } + break; + case keys::DOWN: + showPopUp(); + if(!itemList.empty()) + { + itemList[currentItem]->setAttribute(AT_On,true); + itemList[currentItem]->onHover.emit(coord()); + } + break; + } + } + + slot listBox::keyPress(const keys &k) + { + switch(k.getValue()) + { + case keys::UP: + if(highlightedItem>0)highlightedItem--; + else highlightedItem=itemList.size()-1; + itemList[highlightedItem]->setAttribute(AT_On,true); + itemList[highlightedItem]->onHover.emit(coord()); + break; + case keys::DOWN: + if(highlightedItem<itemList.size()-1)highlightedItem++; + else highlightedItem=0; + itemList[highlightedItem]->setAttribute(AT_On,true); + itemList[highlightedItem]->onHover.emit(coord()); + break; + case keys::ENTER: + { + int location = 0; + std::vector<label *>::const_iterator ibegin = itemList.begin(); + std::vector<label *>::const_iterator iend = itemList.end(); + for(std::vector<label *>::const_iterator i = ibegin;i!=iend;++i) + { + if((*i)->attributes & AT_Selected) + { + (*i)->onPaint.disconnect(this); + (*i)->setAttribute(AT_Selected,false); + chosen.setText((*i)->getText()); + itemSelected.emit(location); + currentItem = location; + break; + } + ++location; + } + hidePopUp(); + break; + } + } + } + + // Set click system + slot listBox::setClickSystem(mouseButtons type) + { + currentType = type; + } } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-09 20:56:32
|
Revision: 443 http://saggui.svn.sourceforge.net/saggui/?rev=443&view=rev Author: juvinious Date: 2007-05-09 13:56:24 -0700 (Wed, 09 May 2007) Log Message: ----------- Fixed up listbox to be useable. Added new members to mouse, mouseManager and window classes Modified Paths: -------------- trunk/CHANGELOG trunk/examples/widgets/src/widgets.cpp trunk/include/saggui/mouse.h trunk/include/saggui/mouse_manager.h trunk/include/saggui/widgets/listbox.h trunk/include/saggui/window.h trunk/modules/allegro/include/al_mouse.h trunk/modules/allegro/src/al_mouse.cpp trunk/modules/sdl/include/sdl_mouse.h trunk/modules/sdl/src/sdl_mouse.cpp trunk/src/mouse_manager.cpp trunk/src/scheme.cpp trunk/src/style.cpp trunk/src/widgets/listbox.cpp trunk/src/window.cpp Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/CHANGELOG 2007-05-09 20:56:24 UTC (rev 443) @@ -1,4 +1,6 @@ -0.43 +0.44 +- Fixed up listBox to work more like a real combo box +- Added setPosition to mouse and mouseManager to move the mouse - Added new widget listbox - Added in two new button type (buttonGroup & abstractButton) classes to improve the existing button and radial widgets and accomodate newer ones (juvinious) - Added in scons build SConstruct file (kazzmir) Modified: trunk/examples/widgets/src/widgets.cpp =================================================================== --- trunk/examples/widgets/src/widgets.cpp 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/examples/widgets/src/widgets.cpp 2007-05-09 20:56:24 UTC (rev 443) @@ -142,6 +142,8 @@ static textBox *textArea = 0; +static listBox *lb = 0; + widgetContainer::widgetContainer() { // Nothing @@ -214,6 +216,15 @@ text3->setText("Fullscreen"); text3->onLeftClick.connect(container,&widgetContainer::onLabel3Click); + lb = new listBox(); + lb->position.set(10,290,100,20); + lb->addItem("One"); + lb->addItem("Two"); + lb->addItem("Three"); + lb->addItem("Four"); + lb->addItem("Five"); + lb->addItem("Six"); + mainBox->addChild(logoBox); mainBox->addChild(textArea); mainBox->addChild(radial1); @@ -224,6 +235,7 @@ mainBox->addChild(pushButton1); mainBox->addChild(cb1); mainBox->addChild(text3); + mainBox->addChild(lb); } @@ -246,6 +258,8 @@ delete cb1; delete text3; + + delete lb; } void widgetContainer::textChange() Modified: trunk/include/saggui/mouse.h =================================================================== --- trunk/include/saggui/mouse.h 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/include/saggui/mouse.h 2007-05-09 20:56:24 UTC (rev 443) @@ -109,6 +109,9 @@ //! Updates the mouse ie polling and setting keys virtual void update()=0; + + //! Sets the mouse pointer to specific location + virtual void setPosition(int x, int y)=0; }; } #endif Modified: trunk/include/saggui/mouse_manager.h =================================================================== --- trunk/include/saggui/mouse_manager.h 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/include/saggui/mouse_manager.h 2007-05-09 20:56:24 UTC (rev 443) @@ -244,6 +244,9 @@ //! Get currentMousePosition static coord getPosition(); + //! Set currentMousePosition + static void setPosition(int x, int y); + //! \name Signals static signal1<const coord &> move; Modified: trunk/include/saggui/widgets/listbox.h =================================================================== --- trunk/include/saggui/widgets/listbox.h 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/include/saggui/widgets/listbox.h 2007-05-09 20:56:24 UTC (rev 443) @@ -69,7 +69,7 @@ void clearItems(); //! \name SIGNALS - signal1<int> itemSelected; + signal1<unsigned int> itemSelected; protected: slot resized(); @@ -77,6 +77,8 @@ slot drawOnButton(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); slot showPopUp(); + + slot showPopUp(const coord &c); slot hidePopUp(); Modified: trunk/include/saggui/window.h =================================================================== --- trunk/include/saggui/window.h 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/include/saggui/window.h 2007-05-09 20:56:24 UTC (rev 443) @@ -144,6 +144,9 @@ //! Add style void setStyle(style *d); + //! Set winType + void setWinType(winType wt); + //! Is the mouse over it? bool mouseOver(); Modified: trunk/modules/allegro/include/al_mouse.h =================================================================== --- trunk/modules/allegro/include/al_mouse.h 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/modules/allegro/include/al_mouse.h 2007-05-09 20:56:24 UTC (rev 443) @@ -69,6 +69,8 @@ ~allegroMouse(); //! Updates the mouse ie polling and setting keys void update(); + //! Sets the mouse Position + void setPosition(int x, int y); }; } Modified: trunk/modules/allegro/src/al_mouse.cpp =================================================================== --- trunk/modules/allegro/src/al_mouse.cpp 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/modules/allegro/src/al_mouse.cpp 2007-05-09 20:56:24 UTC (rev 443) @@ -95,6 +95,13 @@ lastScroll = mouse_z; } } + + + //! Sets mouse position + void allegroMouse::setPosition(int x, int y) + { + position_mouse(x,y); + } } #endif Modified: trunk/modules/sdl/include/sdl_mouse.h =================================================================== --- trunk/modules/sdl/include/sdl_mouse.h 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/modules/sdl/include/sdl_mouse.h 2007-05-09 20:56:24 UTC (rev 443) @@ -63,6 +63,8 @@ ~sdlMouse(); //! Updates the mouse ie polling and setting keys void update(); + //! Sets the mouse Position + void setPosition(int x, int y); }; } Modified: trunk/modules/sdl/src/sdl_mouse.cpp =================================================================== --- trunk/modules/sdl/src/sdl_mouse.cpp 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/modules/sdl/src/sdl_mouse.cpp 2007-05-09 20:56:24 UTC (rev 443) @@ -107,6 +107,12 @@ } } } + + //! Sets the mouse Position + void sdlMouse::setPosition(int x, int y) + { + SDL_WarpMouse(x,y); + } } #endif Modified: trunk/src/mouse_manager.cpp =================================================================== --- trunk/src/mouse_manager.cpp 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/src/mouse_manager.cpp 2007-05-09 20:56:24 UTC (rev 443) @@ -1059,6 +1059,15 @@ return coord(0,0,0,0); } + + //! Sets the mouse Position + void mouseManager::setPosition(int x, int y) + { + if((getInstance())->mousePointer) + { + (getInstance())->mousePointer->setPosition(x,y); + } + } } #endif /* MOUSE_MANAGER_CPP */ Modified: trunk/src/scheme.cpp =================================================================== --- trunk/src/scheme.cpp 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/src/scheme.cpp 2007-05-09 20:56:24 UTC (rev 443) @@ -66,10 +66,10 @@ colors[S_StandardFg] = rgba(85,85,85,255); colors[S_StandardFgBlend] = rgba(225,225,225,255); colors[S_StandardText] = rgba(0,0,0,255); - colors[S_WindowBg] = rgba(255,255,255,255); - colors[S_WindowBgBlend] = rgba(200,200,200,255); - colors[S_WindowFg] = rgba(128,128,128,255); - colors[S_WindowFgBlend] = rgba(100,100,100,255); + colors[S_WindowBg] = rgba(150,150,150,255); + colors[S_WindowBgBlend] = rgba(110,110,110,255); + colors[S_WindowFg] = rgba(85,85,85,255); + colors[S_WindowFgBlend] = rgba(255,255,255,255); colors[S_WindowText] = rgba(0,0,0,255); colors[S_ActiveTitleBg] = rgba(255,255,255,255); colors[S_ActiveTitleBgBlend] = rgba(255,255,255,255); Modified: trunk/src/style.cpp =================================================================== --- trunk/src/style.cpp 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/src/style.cpp 2007-05-09 20:56:24 UTC (rev 443) @@ -78,7 +78,7 @@ { 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,rgba(150,150,150,255)); + 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); } @@ -108,7 +108,7 @@ if((flags & AT_MouseOver) && (flags && AT_Raised)) { bmp->doLine(size.x,size.y,size.x + size.width,size.y,rgba::WHITE); - bmp->doLine(size.x,size.y+size.height,size.x + size.width,size.y+size.height,rgba::BLACK); + bmp->doLine(size.x,size.y+size.height,size.x + size.width,size.y+size.height,rgba::WHITE); } else { @@ -139,7 +139,7 @@ slot defaultDialogStyle::drawBackground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) { - bmp->doRectfill(size.x,size.y,size.width,size.height,colors[S_WindowBg]); + bmp->doRectfill(size.x,size.y,size.width,size.height,rgba::WHITE); } slot defaultDialogStyle::drawForeground(const coord &size, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) Modified: trunk/src/widgets/listbox.cpp =================================================================== --- trunk/src/widgets/listbox.cpp 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/src/widgets/listbox.cpp 2007-05-09 20:56:24 UTC (rev 443) @@ -40,11 +40,15 @@ #define LISTBOX_CPP #include "saggui/widgets/listbox.h" +#include "saggui/mouse_manager.h" namespace saggui { - listBox::listBox() : mouseEvents(this), keyEvents(this) + listBox::listBox() : window(W_ComboBox), mouseEvents(this), keyEvents(this) { + chosen.setWinType(W_ComboBox); + chosen.wColors[S_WindowBg] = rgba::WHITE; + chosen.wColors[S_WindowBgBlend] = rgba::WHITE; chosen.setHorizontalAlign(0); addChild(&chosen); @@ -75,6 +79,9 @@ label *temp = new label(); temp->setHorizontalAlign(0); temp->setText(text); + temp->setWinType(W_ComboBox); + temp->wColors[S_WindowBg] = rgba::WHITE; + temp->wColors[S_WindowBgBlend] = rgba::WHITE; if(itemList.empty()) { chosen.setText(text); @@ -149,61 +156,78 @@ listSize+=position.height; popUp.addChild((*i)); (*i)->onHover.connect(this,&listBox::onHoverItem); - switch(currentType) - { - case M_Left: - { - (*i)->onLeftDown.connect(this,&listBox::onSelectItem); - break; - } - case M_Right: - { - (*i)->onRightDown.connect(this,&listBox::onSelectItem); - break; - } - case M_Middle: - { - (*i)->onRightDown.connect(this,&listBox::onSelectItem); - break; - } - } } popUp.position.setHeight(listSize); + if(popUp.getRelativePosition().getY2() > guiManager::getScreen()->getBmpHeight()) + { + popUp.position.setY((position.y - listSize) - 1); + } + highlightedItem = currentItem; + itemList[currentItem]->setAttribute(AT_On,true); + mouseManager::setPosition(int(itemList[highlightedItem]->getRelativePosition().getX2() - (itemList[highlightedItem]->position.width/2)),int(itemList[highlightedItem]->getRelativePosition().getY2() - (itemList[highlightedItem]->position.height/2))); } + + slot listBox::showPopUp(const coord &c) + { + showPopUp(); + } slot listBox::hidePopUp() { popUp.setAttribute(AT_Visible | AT_Enabled, false); popUp.setAlwaysOnTop(false); popUp.position.set(0,0,0,0); + int location = 0; std::vector<label *>::iterator ibegin = itemList.begin(); std::vector<label *>::iterator iend = itemList.end(); for(std::vector<label *>::iterator i = ibegin;i!=iend;++i) { popUp.removeChild((*i)); + (*i)->onHover.disconnect(this); + (*i)->onPaint.disconnect(this); + if(((*i)->attributes & AT_Selected) && ((*i)->attributes & AT_On)) + { + (*i)->onPaint.disconnect(this); + (*i)->setAttribute(AT_Selected,false); + chosen.setText((*i)->getText()); + itemSelected.emit(location); + highlightedItem = currentItem = location; + guiManager::setWindowFocused(&chosen); + } + else if(((*i)->attributes & AT_Selected) && ((*i)->attributes & AT_MouseOver)) + { + (*i)->onPaint.disconnect(this); + (*i)->setAttribute(AT_Selected,false); + chosen.setText((*i)->getText()); + itemSelected.emit(location); + highlightedItem = currentItem = location; + } + ++location; } } slot listBox::onHoverItem(const coord &pos) { - int location = 0; - std::vector<label *>::const_iterator ibegin = itemList.begin(); - std::vector<label *>::const_iterator iend = itemList.end(); - for(std::vector<label *>::const_iterator i = ibegin;i!=iend;++i) + for(unsigned int i = 0;i<itemList.size();++i) { - if((*i)->attributes & AT_Selected) + if(itemList[i]->attributes & AT_Selected) { - (*i)->onPaint.disconnect(this); - (*i)->setAttribute(AT_Selected,false); + itemList[i]->onPaint.disconnect(this); + itemList[i]->setAttribute(AT_Selected,false); } - if(((*i)->attributes & AT_MouseOver) || ((*i)->attributes & AT_On)) + if((itemList[i]->attributes & AT_On)) { - (*i)->onPaint.connect(this,&listBox::onHoverDraw); - (*i)->setAttribute(AT_Selected,true); - (*i)->setAttribute(AT_On,false); - highlightedItem = location; + itemList[i]->onPaint.connect(this,&listBox::onHoverDraw); + itemList[i]->setAttribute(AT_Selected,true); + itemList[i]->setAttribute(AT_On,false); + highlightedItem = i; } - ++location; + else if((itemList[i]->attributes & AT_MouseOver)) + { + itemList[i]->onPaint.connect(this,&listBox::onHoverDraw); + itemList[i]->setAttribute(AT_Selected,true); + highlightedItem = i; + } } } @@ -214,21 +238,19 @@ slot listBox::onSelectItem(const coord &pos) { - int location = 0; - std::vector<label *>::const_iterator ibegin = itemList.begin(); - std::vector<label *>::const_iterator iend = itemList.end(); - for(std::vector<label *>::const_iterator i = ibegin;i!=iend;++i) + for(unsigned int i = 0;i<itemList.size();++i) { - if((*i)->attributes & AT_Selected) + if(itemList[i]->attributes & AT_Selected) { - (*i)->onPaint.disconnect(this); - (*i)->setAttribute(AT_Selected,false); - chosen.setText((*i)->getText()); - itemSelected.emit(location); - currentItem = location; + itemList[i]->onPaint.disconnect(this); + itemList[i]->setAttribute(AT_Selected,false); + chosen.setText(itemList[i]->getText()); + itemSelected.emit(i); + highlightedItem = currentItem = i; + guiManager::setWindowFocused(&chosen); + mouseManager::setPosition(int(chosen.getRelativePosition().getX2() - (chosen.position.width/2)),int(chosen.getRelativePosition().getY2() - (chosen.position.height/2))); break; } - ++location; } } @@ -238,19 +260,9 @@ { case keys::UP: showPopUp(); - if(!itemList.empty()) - { - itemList[currentItem]->setAttribute(AT_On,true); - itemList[currentItem]->onHover.emit(coord()); - } break; case keys::DOWN: showPopUp(); - if(!itemList.empty()) - { - itemList[currentItem]->setAttribute(AT_On,true); - itemList[currentItem]->onHover.emit(coord()); - } break; } } @@ -263,31 +275,28 @@ if(highlightedItem>0)highlightedItem--; else highlightedItem=itemList.size()-1; itemList[highlightedItem]->setAttribute(AT_On,true); - itemList[highlightedItem]->onHover.emit(coord()); + //itemList[highlightedItem]->onHover.emit(coord()); + mouseManager::setPosition(int(itemList[highlightedItem]->getRelativePosition().getX2() - (itemList[highlightedItem]->position.width/2)),int(itemList[highlightedItem]->getRelativePosition().getY2() - (itemList[highlightedItem]->position.height/2))); break; case keys::DOWN: if(highlightedItem<itemList.size()-1)highlightedItem++; else highlightedItem=0; itemList[highlightedItem]->setAttribute(AT_On,true); - itemList[highlightedItem]->onHover.emit(coord()); + //itemList[highlightedItem]->onHover.emit(coord()); + mouseManager::setPosition(int(itemList[highlightedItem]->getRelativePosition().getX2() - (itemList[highlightedItem]->position.width/2)),int(itemList[highlightedItem]->getRelativePosition().getY2() - (itemList[highlightedItem]->position.height/2))); break; case keys::ENTER: { - int location = 0; - std::vector<label *>::const_iterator ibegin = itemList.begin(); - std::vector<label *>::const_iterator iend = itemList.end(); - for(std::vector<label *>::const_iterator i = ibegin;i!=iend;++i) + onSelectItem(coord()); + hidePopUp(); + break; + } + case keys::ESC: + { + for(unsigned int i = 0;i<itemList.size();++i) { - if((*i)->attributes & AT_Selected) - { - (*i)->onPaint.disconnect(this); - (*i)->setAttribute(AT_Selected,false); - chosen.setText((*i)->getText()); - itemSelected.emit(location); - currentItem = location; - break; - } - ++location; + itemList[i]->onPaint.disconnect(this); + itemList[i]->setAttribute(AT_Selected,false); } hidePopUp(); break; @@ -299,6 +308,31 @@ slot listBox::setClickSystem(mouseButtons type) { currentType = type; + + switch(type) + { + case M_Left: + { + chosen.onMiddleClick.disconnect(this); + chosen.onRightClick.disconnect(this); + chosen.onLeftClick.connect(this,&listBox::showPopUp); + break; + } + case M_Right: + { + chosen.onMiddleClick.disconnect(this); + chosen.onLeftClick.disconnect(this); + chosen.onRightClick.connect(this,&listBox::showPopUp); + break; + } + case M_Middle: + { + chosen.onLeftClick.disconnect(this); + chosen.onRightClick.disconnect(this); + chosen.onMiddleClick.connect(this,&listBox::showPopUp); + break; + } + } } } Modified: trunk/src/window.cpp =================================================================== --- trunk/src/window.cpp 2007-05-09 06:18:54 UTC (rev 442) +++ trunk/src/window.cpp 2007-05-09 20:56:24 UTC (rev 443) @@ -207,6 +207,12 @@ onResize.emit(); } + + //! Set winType + void window::setWinType(winType wt) + { + windowType = wt; + } // bool window::mouseOver() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-05-15 21:51:55
|
Revision: 445 http://saggui.svn.sourceforge.net/saggui/?rev=445&view=rev Author: juvinious Date: 2007-05-15 14:51:43 -0700 (Tue, 15 May 2007) Log Message: ----------- Added member to window, worked on abstractButton and buttonGroup Modified Paths: -------------- trunk/CHANGELOG trunk/include/saggui/widgets/abstractbutton.h trunk/include/saggui/widgets/buttongroup.h trunk/include/saggui/window.h trunk/src/widgets/abstractbutton.cpp trunk/src/window.cpp Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-05-10 21:11:01 UTC (rev 444) +++ trunk/CHANGELOG 2007-05-15 21:51:43 UTC (rev 445) @@ -1,4 +1,5 @@ -0.44 +0.45 +- Added new member to window doParentConnectActions - Fixed up listBox to work more like a real combo box - Added setPosition to mouse and mouseManager to move the mouse - Added new widget listbox @@ -100,4 +101,4 @@ - Deprecated and removed cbuild build system 0.01 11-28-2006 -Initial official release of library \ No newline at end of file +Initial official release of library Modified: trunk/include/saggui/widgets/abstractbutton.h =================================================================== --- trunk/include/saggui/widgets/abstractbutton.h 2007-05-10 21:11:01 UTC (rev 444) +++ trunk/include/saggui/widgets/abstractbutton.h 2007-05-15 21:51:43 UTC (rev 445) @@ -46,67 +46,96 @@ namespace saggui { + //! Forward declaration + class buttonGroup; + //! abstractButton /*! * An abstract button representing different types of buttons, radials, etc */ - - - class buttonGroup; - class SAGGUI_EXPORT abstractButton : public window, mouseEvents, keyEvents { public: + //! Constructor explicit abstractButton(); + //! Destructor virtual ~abstractButton(); + //! Set current text of button void setText(const std::string &text); + + //! Get current text of button std::string getText() const; + //! Set icon if button makes use of icons void setIcon(graphic *icon); + + //! Get current set icon graphic *getIcon() const; + //! Returns the size of the icon coord iconSize() const; - + + //! Set whether button is checkable void setCheckable(bool); + //! Is button checkable? bool isCheckable() const; + //! Is button checked? bool isChecked() const; + //! Set button state down void setDown(bool); + //! Is button state down? bool isDown() const; + //! Set whether button auto repeats void setAutoRepeat(bool); + //! Is button auto repeatable? bool getAutoRepeat() const; + //! Set auto repeat delay (milliseconds) void setAutoRepeatDelay(int); + + //! Get auto repeat delay (milliseconds) int getAutoRepeatDelay() const; + //! Set auto repeat interval (milliseconds) void setAutoRepeatInterval(int); + //! Get auto repeat interval (milliseconds) int getAutoRepeatInterval() const; + //! Set whether button is auto exclusive void setAutoExclusive(bool); + + //! Is button auto exclusive bool isAutoExclusive() const; - void setGroup(buttonGroup *group); + //! Assign button to certain button group + void setGroup(buttonGroup *group); + + //! Get button group of button buttonGroup *getGroup() const; - //public Q_SLOTS: + //! \name PUBLIC SLOTS slot animateClick(int msec = 100); slot click(const coord &pos); slot toggle(); slot setChecked(bool); - //Q_SIGNALS: + //! \name SIGNALS signal0<> pressed; signal0<> released; signal0<> clicked; signal0<> toggled; protected: + //! \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 setClickSystem(mouseButtons type); + + //! Performs specific actions when this window is connected to a parent + virtual void doParentConnectActions(); private: bool autoExclusive; bool autoRepeat; Modified: trunk/include/saggui/widgets/buttongroup.h =================================================================== --- trunk/include/saggui/widgets/buttongroup.h 2007-05-10 21:11:01 UTC (rev 444) +++ trunk/include/saggui/widgets/buttongroup.h 2007-05-15 21:51:43 UTC (rev 445) @@ -44,30 +44,52 @@ namespace saggui { + + //! Button Group + /*! + * A button group houses a collection of buttons for + * relating and processing interactions between them + */ + class SAGGUI_EXPORT buttonGroup { public: + //! Constructor explicit buttonGroup(); + //! Destructor ~buttonGroup(); + //! Set exclusive property for buttons in group void setExclusive(bool); + + //! Set is button group exclusive? bool isExclusive() const; + //! Add a button to this button group void addButton(abstractButton *); /*void addButton(abstractButton *, int id);*/ - void removeButton(abstractButton *); + //! Remove button from this button group + void removeButton(abstractButton *); + + //! Get a list of existing buttons std::list<abstractButton*> buttons() const; + //! Return currently checked button (if exclusive) abstractButton * checkedButton() const; // no setter on purpose! + //! Returns a button according to its ID abstractButton *button(int id) const; /*void setId(abstractButton *button, int id);*/ - int id(abstractButton *button) const; - int checkedId() const; - //Q_SIGNALS: + //! returns the ID of the given button + int id(abstractButton *button) const; + + //! Returns the ID of the current checked button (if exclusive) + int checkedId() const; + + //! \name SIGNALS signal1<abstractButton *> buttonClickedObj; signal1<int> buttonClickedID; signal1<abstractButton *> buttonPressedObj; Modified: trunk/include/saggui/window.h =================================================================== --- trunk/include/saggui/window.h 2007-05-10 21:11:01 UTC (rev 444) +++ trunk/include/saggui/window.h 2007-05-15 21:51:43 UTC (rev 445) @@ -184,6 +184,9 @@ //! Set clickable system virtual slot setClickSystem(mouseButtons type); + //! Performs specific actions when this window is connected to a parent + virtual void doParentConnectActions(); + //! Signal emitted when connected to a parent signal1<window *>onParentConnect; Modified: trunk/src/widgets/abstractbutton.cpp =================================================================== --- trunk/src/widgets/abstractbutton.cpp 2007-05-10 21:11:01 UTC (rev 444) +++ trunk/src/widgets/abstractbutton.cpp 2007-05-15 21:51:43 UTC (rev 445) @@ -174,7 +174,7 @@ slot abstractButton::setChecked(bool) { - + } // Set click system @@ -242,6 +242,12 @@ } } + // Performs specific actions when this window is connected to a parent + void abstractButton::doParentConnectActions() + { + + } + slot abstractButton::onClicked(const coord &pos) { if(bGroup) Modified: trunk/src/window.cpp =================================================================== --- trunk/src/window.cpp 2007-05-10 21:11:01 UTC (rev 444) +++ trunk/src/window.cpp 2007-05-15 21:51:43 UTC (rev 445) @@ -149,6 +149,12 @@ //nothing we don't have mouse events } + // Performs specific actions when this window is connected to a parent + void window::doParentConnectActions() + { + // Nothing we are not connected to a parent + } + window *window::getParent() { return parent; @@ -173,6 +179,7 @@ { parent = p; parent->children.push_back(this); + doParentConnectActions(); onParentConnect.emit(p); } @@ -180,6 +187,7 @@ { children.push_back(c); c->parent = this; + c->doParentConnectActions(); c->onParentConnect.emit(this); guiManager::fixWindow(c); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-07-03 23:46:40
|
Revision: 446 http://saggui.svn.sourceforge.net/saggui/?rev=446&view=rev Author: juvinious Date: 2007-07-03 16:46:37 -0700 (Tue, 03 Jul 2007) Log Message: ----------- Added some fixes to abstractbutton and buttongroup as well as window Modified Paths: -------------- trunk/README trunk/include/saggui/widgets/abstractbutton.h trunk/include/saggui/widgets/buttongroup.h trunk/include/saggui/window.h trunk/src/widgets/abstractbutton.cpp trunk/src/window.cpp Modified: trunk/README =================================================================== --- trunk/README 2007-05-15 21:51:43 UTC (rev 445) +++ trunk/README 2007-07-03 23:46:37 UTC (rev 446) @@ -1,3 +1,9 @@ + ______ ______ ______ ______ __ __ __ +/\ ___\ /\ __ \ /\ ___\ /\ ___\ /\ \/\ \ /\ \ +\ \___ \\ \ __ \\ \ \__ \\ \ \__ \\ \ \_\ \\ \ \ + \/\_____\\ \_\ \_\\ \_____\\ \_____\\ \_____\\ \_\ + \/_____/ \/_/\/_/ \/_____/ \/_____/ \/_____/ \/_/ + Introduction This is a project aimed towards making a simplified GUI Library originally intended to be used Modified: trunk/include/saggui/widgets/abstractbutton.h =================================================================== --- trunk/include/saggui/widgets/abstractbutton.h 2007-05-15 21:51:43 UTC (rev 445) +++ trunk/include/saggui/widgets/abstractbutton.h 2007-07-03 23:46:37 UTC (rev 446) @@ -70,7 +70,7 @@ //! Set icon if button makes use of icons void setIcon(graphic *icon); - //! Get current set icon + //! Get current set icon graphic *getIcon() const; //! Returns the size of the icon @@ -78,6 +78,7 @@ //! Set whether button is checkable void setCheckable(bool); + //! Is button checkable? bool isCheckable() const; @@ -91,6 +92,7 @@ //! Set whether button auto repeats void setAutoRepeat(bool); + //! Is button auto repeatable? bool getAutoRepeat() const; @@ -102,6 +104,7 @@ //! Set auto repeat interval (milliseconds) void setAutoRepeatInterval(int); + //! Get auto repeat interval (milliseconds) int getAutoRepeatInterval() const; @@ -135,7 +138,7 @@ virtual slot setClickSystem(mouseButtons type); //! Performs specific actions when this window is connected to a parent - virtual void doParentConnectActions(); + virtual void doParentConnectActions(); private: bool autoExclusive; bool autoRepeat; Modified: trunk/include/saggui/widgets/buttongroup.h =================================================================== --- trunk/include/saggui/widgets/buttongroup.h 2007-05-15 21:51:43 UTC (rev 445) +++ trunk/include/saggui/widgets/buttongroup.h 2007-07-03 23:46:37 UTC (rev 446) @@ -62,7 +62,7 @@ //! Set exclusive property for buttons in group void setExclusive(bool); - //! Set is button group exclusive? + //! Set is button group exclusive? bool isExclusive() const; //! Add a button to this button group @@ -70,7 +70,7 @@ /*void addButton(abstractButton *, int id);*/ //! Remove button from this button group - void removeButton(abstractButton *); + void removeButton(abstractButton *); //! Get a list of existing buttons std::list<abstractButton*> buttons() const; @@ -84,10 +84,10 @@ /*void setId(abstractButton *button, int id);*/ //! returns the ID of the given button - int id(abstractButton *button) const; + int id(abstractButton *button) const; //! Returns the ID of the current checked button (if exclusive) - int checkedId() const; + int checkedId() const; //! \name SIGNALS signal1<abstractButton *> buttonClickedObj; Modified: trunk/include/saggui/window.h =================================================================== --- trunk/include/saggui/window.h 2007-05-15 21:51:43 UTC (rev 445) +++ trunk/include/saggui/window.h 2007-07-03 23:46:37 UTC (rev 446) @@ -125,6 +125,9 @@ //! Return this instances parent window *getParent(); + + //! Get top most parent + window *getAbsoluteParent(); //! Add child void addChild(window *c); @@ -214,9 +217,6 @@ //! Get parent position if not return this->position coord getParentClipped(coord c); - //! Get top most parent - window *getAbsoluteParent(); - //! click system type static mouseButtons clickType; Modified: trunk/src/widgets/abstractbutton.cpp =================================================================== --- trunk/src/widgets/abstractbutton.cpp 2007-05-15 21:51:43 UTC (rev 445) +++ trunk/src/widgets/abstractbutton.cpp 2007-07-03 23:46:37 UTC (rev 446) @@ -104,9 +104,9 @@ return this->checked; } - void abstractButton::setDown(bool) + void abstractButton::setDown(bool down) { - + this->down = down; } bool abstractButton::isDown() const @@ -114,8 +114,9 @@ return this->down; } - void abstractButton::setAutoRepeat(bool) + void abstractButton::setAutoRepeat(bool autoRepeat) { + this->autoRepeat = autoRepeat; } bool abstractButton::getAutoRepeat() const @@ -123,8 +124,9 @@ return this->autoRepeat; } - void abstractButton::setAutoRepeatDelay(int) + void abstractButton::setAutoRepeatDelay(int autoRepeatDelay) { + this->autoRepeatDelay = autoRepeatDelay; } int abstractButton::getAutoRepeatDelay() const @@ -132,16 +134,18 @@ return this->autoRepeatDelay; } - void abstractButton::setAutoRepeatInterval(int) + void abstractButton::setAutoRepeatInterval(int autoRepeatInterval) { + this->autoRepeatInterval = autoRepeatInterval; } int abstractButton::getAutoRepeatInterval() const { return this->autoRepeatInterval; } - void abstractButton::setAutoExclusive(bool) + void abstractButton::setAutoExclusive(bool autoExclusive) { + this->autoExclusive = autoExclusive; } bool abstractButton::isAutoExclusive() const @@ -151,6 +155,13 @@ void abstractButton::setGroup(buttonGroup *group) { + // need to setup groups + if(this->bGroup) + { + delete this->bGroup; + this->bGroup = group; + } + else this->bGroup = group; } buttonGroup *abstractButton::getGroup() const @@ -172,9 +183,9 @@ } - slot abstractButton::setChecked(bool) + slot abstractButton::setChecked(bool checkable) { - + this->checkable = checkable; } // Set click system @@ -245,7 +256,65 @@ // Performs specific actions when this window is connected to a parent void abstractButton::doParentConnectActions() { - + bool otherBtnGroup = false; + std::vector<window *> temp1 = this->getAbsoluteParent()->getChildren(); + std::vector<window *>::iterator pBegin = temp1.begin(); + std::vector<window *>::iterator pEnd = temp1.end(); + for(std::vector<window *>::iterator i = pBegin;i!=pEnd;++i) + { + std::vector<window *> temp2 = (*i)->getChildren(); + std::vector<window *>::iterator cBegin = temp2.begin(); + std::vector<window *>::iterator cEnd = temp2.end(); + for(std::vector<window *>::iterator j = cBegin;j!=cEnd;++j) + { + abstractButton *btn = dynamic_cast<abstractButton *>((*j)); + if(btn) + { + if(btn->bGroup) + { + this->setGroup(btn->bGroup); + otherBtnGroup = true; + break; + } + } + } + if(!otherBtnGroup) + { + abstractButton *btn = dynamic_cast<abstractButton *>((*i)); + if(btn) + { + if(btn->bGroup) + { + this->setGroup(btn->bGroup); + otherBtnGroup = true; + break; + } + } + } + } + if(!otherBtnGroup) + { + this->setGroup(new buttonGroup()); + for(std::vector<window *>::iterator i = pBegin;i!=pEnd;++i) + { + std::vector<window *> temp2 = (*i)->getChildren(); + std::vector<window *>::iterator cBegin = temp2.begin(); + std::vector<window *>::iterator cEnd = temp2.end(); + for(std::vector<window *>::iterator j = cBegin;j!=cEnd;++j) + { + abstractButton *btn = dynamic_cast<abstractButton *>((*j)); + if(btn) + { + btn->setGroup(this->bGroup); + } + } + abstractButton *btn = dynamic_cast<abstractButton *>((*i)); + if(btn) + { + btn->setGroup(this->bGroup); + } + } + } } slot abstractButton::onClicked(const coord &pos) Modified: trunk/src/window.cpp =================================================================== --- trunk/src/window.cpp 2007-05-15 21:51:43 UTC (rev 445) +++ trunk/src/window.cpp 2007-07-03 23:46:37 UTC (rev 446) @@ -153,7 +153,7 @@ void window::doParentConnectActions() { // Nothing we are not connected to a parent - } + } window *window::getParent() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-07-21 23:32:39
|
Revision: 448 http://saggui.svn.sourceforge.net/saggui/?rev=448&view=rev Author: juvinious Date: 2007-07-21 16:32:36 -0700 (Sat, 21 Jul 2007) Log Message: ----------- Fixed winMain@16 error due to the order of the libs in the SDL module as well as bmpdump-sdl Modified Paths: -------------- trunk/modules/sdl/CMakeLists.txt trunk/utils/bmpdump/CMakeLists.txt Modified: trunk/modules/sdl/CMakeLists.txt =================================================================== --- trunk/modules/sdl/CMakeLists.txt 2007-07-13 12:11:01 UTC (rev 447) +++ trunk/modules/sdl/CMakeLists.txt 2007-07-21 23:32:36 UTC (rev 448) @@ -12,7 +12,11 @@ src/sdl_gfx.cpp src/sdl_keyinput.cpp src/sdl_mouse.cpp src/sdl_system.cpp) add_library(saggui-sdl ${CREATE_STATIC_LIB} ${SDL_SRC}) -target_link_libraries(saggui-sdl ${SDL_LIBRARY}) +if(MINGW) + target_link_libraries(saggui-sdl ${SDL_LIBRARY} -lSDLmain) +else(MINGW) + target_link_libraries(saggui-sdl ${SDL_LIBRARY}) +endif(MINGW) file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/modules/sdl/include/*.h) foreach(f ${HEADERS}) Modified: trunk/utils/bmpdump/CMakeLists.txt =================================================================== --- trunk/utils/bmpdump/CMakeLists.txt 2007-07-13 12:11:01 UTC (rev 447) +++ trunk/utils/bmpdump/CMakeLists.txt 2007-07-21 23:32:36 UTC (rev 448) @@ -28,7 +28,11 @@ if(ENABLE_SDL) add_executable(bmpdump-sdl bmpdump-sdl.cpp) - target_link_libraries(bmpdump-sdl ${SDL_LIBRARY}) + if(MINGW) + target_link_libraries(bmpdump-sdl ${SDL_LIBRARY} -lSDLmain) + else(MINGW) + target_link_libraries(bmpdump-sdl ${SDL_LIBRARY}) + endif(MINGW) install(TARGETS bmpdump-sdl DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) endif(ENABLE_SDL) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-07-24 02:08:33
|
Revision: 449 http://saggui.svn.sourceforge.net/saggui/?rev=449&view=rev Author: juvinious Date: 2007-07-23 19:08:31 -0700 (Mon, 23 Jul 2007) Log Message: ----------- Removed unecessary connections and automations between buttonGroup and abstractButton Modified Paths: -------------- trunk/include/saggui/widgets/abstractbutton.h trunk/include/saggui/widgets/buttongroup.h trunk/src/widgets/abstractbutton.cpp trunk/src/widgets/buttongroup.cpp Modified: trunk/include/saggui/widgets/abstractbutton.h =================================================================== --- trunk/include/saggui/widgets/abstractbutton.h 2007-07-21 23:32:36 UTC (rev 448) +++ trunk/include/saggui/widgets/abstractbutton.h 2007-07-24 02:08:31 UTC (rev 449) @@ -115,9 +115,9 @@ bool isAutoExclusive() const; //! Assign button to certain button group - void setGroup(buttonGroup *group); - - //! Get button group of button + void setGroup(buttonGroup *group); + + //! Get button group of button buttonGroup *getGroup() const; //! \name PUBLIC SLOTS @@ -136,9 +136,6 @@ //! \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 setClickSystem(mouseButtons type); - - //! Performs specific actions when this window is connected to a parent - virtual void doParentConnectActions(); private: bool autoExclusive; bool autoRepeat; @@ -148,8 +145,6 @@ bool checked; bool down; graphic *icon; - /* coord iconSize; */ - /* shortcut : QKeySequence */ std::string text; buttonGroup *bGroup; Modified: trunk/include/saggui/widgets/buttongroup.h =================================================================== --- trunk/include/saggui/widgets/buttongroup.h 2007-07-21 23:32:36 UTC (rev 448) +++ trunk/include/saggui/widgets/buttongroup.h 2007-07-24 02:08:31 UTC (rev 449) @@ -67,7 +67,6 @@ //! Add a button to this button group void addButton(abstractButton *); - /*void addButton(abstractButton *, int id);*/ //! Remove button from this button group void removeButton(abstractButton *); @@ -77,11 +76,9 @@ //! Return currently checked button (if exclusive) abstractButton * checkedButton() const; - // no setter on purpose! //! Returns a button according to its ID abstractButton *button(int id) const; - /*void setId(abstractButton *button, int id);*/ //! returns the ID of the given button int id(abstractButton *button) const; Modified: trunk/src/widgets/abstractbutton.cpp =================================================================== --- trunk/src/widgets/abstractbutton.cpp 2007-07-21 23:32:36 UTC (rev 448) +++ trunk/src/widgets/abstractbutton.cpp 2007-07-24 02:08:31 UTC (rev 449) @@ -156,12 +156,7 @@ void abstractButton::setGroup(buttonGroup *group) { // need to setup groups - if(this->bGroup) - { - delete this->bGroup; - this->bGroup = group; - } - else this->bGroup = group; + this->bGroup = group; } buttonGroup *abstractButton::getGroup() const @@ -253,76 +248,12 @@ } } - // Performs specific actions when this window is connected to a parent - void abstractButton::doParentConnectActions() - { - bool otherBtnGroup = false; - std::vector<window *> temp1 = this->getAbsoluteParent()->getChildren(); - std::vector<window *>::iterator pBegin = temp1.begin(); - std::vector<window *>::iterator pEnd = temp1.end(); - for(std::vector<window *>::iterator i = pBegin;i!=pEnd;++i) - { - std::vector<window *> temp2 = (*i)->getChildren(); - std::vector<window *>::iterator cBegin = temp2.begin(); - std::vector<window *>::iterator cEnd = temp2.end(); - for(std::vector<window *>::iterator j = cBegin;j!=cEnd;++j) - { - abstractButton *btn = dynamic_cast<abstractButton *>((*j)); - if(btn) - { - if(btn->bGroup) - { - this->setGroup(btn->bGroup); - otherBtnGroup = true; - break; - } - } - } - if(!otherBtnGroup) - { - abstractButton *btn = dynamic_cast<abstractButton *>((*i)); - if(btn) - { - if(btn->bGroup) - { - this->setGroup(btn->bGroup); - otherBtnGroup = true; - break; - } - } - } - } - if(!otherBtnGroup) - { - this->setGroup(new buttonGroup()); - for(std::vector<window *>::iterator i = pBegin;i!=pEnd;++i) - { - std::vector<window *> temp2 = (*i)->getChildren(); - std::vector<window *>::iterator cBegin = temp2.begin(); - std::vector<window *>::iterator cEnd = temp2.end(); - for(std::vector<window *>::iterator j = cBegin;j!=cEnd;++j) - { - abstractButton *btn = dynamic_cast<abstractButton *>((*j)); - if(btn) - { - btn->setGroup(this->bGroup); - } - } - abstractButton *btn = dynamic_cast<abstractButton *>((*i)); - if(btn) - { - btn->setGroup(this->bGroup); - } - } - } - } - slot abstractButton::onClicked(const coord &pos) { if(bGroup) { - bGroup->buttonClickedObj(this); - bGroup->buttonClickedID(getID()); + bGroup->buttonClickedObj.emit(this); + bGroup->buttonClickedID.emit(getID()); } } @@ -330,8 +261,8 @@ { if(bGroup) { - bGroup->buttonPressedObj(this); - bGroup->buttonPressedID(getID()); + bGroup->buttonPressedObj.emit(this); + bGroup->buttonPressedID.emit(getID()); } } @@ -339,8 +270,8 @@ { if(bGroup) { - bGroup->buttonReleasedObj(this); - bGroup->buttonReleasedID(getID()); + bGroup->buttonReleasedObj.emit(this); + bGroup->buttonReleasedID.emit(getID()); } } } Modified: trunk/src/widgets/buttongroup.cpp =================================================================== --- trunk/src/widgets/buttongroup.cpp 2007-07-21 23:32:36 UTC (rev 448) +++ trunk/src/widgets/buttongroup.cpp 2007-07-24 02:08:31 UTC (rev 449) @@ -66,7 +66,6 @@ this->group.push_back(button); } - /*void addButton(abstractButton *, int id);*/ void buttonGroup::removeButton(abstractButton *button) { this->group.remove(button); @@ -106,7 +105,7 @@ return 0; } - /*void setId(abstractButton *button, int id);*/ + int buttonGroup::id(abstractButton *button) const { if(button)return button->getID(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-07-27 04:11:52
|
Revision: 450 http://saggui.svn.sourceforge.net/saggui/?rev=450&view=rev Author: juvinious Date: 2007-07-26 21:11:49 -0700 (Thu, 26 Jul 2007) Log Message: ----------- Updated abstractbutton and implemented a new pushbutton (incomplete) to evetually replace the current button implementation. Modified Paths: -------------- trunk/cmake/saggui.h.in trunk/examples/widgets/src/widgets.cpp trunk/include/saggui/widgets/abstractbutton.h trunk/src/widgets/abstractbutton.cpp Added Paths: ----------- trunk/include/saggui/widgets/pushbutton.h trunk/src/widgets/pushbutton.cpp Modified: trunk/cmake/saggui.h.in =================================================================== --- trunk/cmake/saggui.h.in 2007-07-24 02:08:31 UTC (rev 449) +++ trunk/cmake/saggui.h.in 2007-07-27 04:11:49 UTC (rev 450) @@ -92,6 +92,7 @@ #include "saggui/widgets/label.h" #include "saggui/widgets/listbox.h" #include "saggui/widgets/progress_bar.h" +#include "saggui/widgets/pushbutton.h" #include "saggui/widgets/radial.h" #include "saggui/widgets/scroll_bar.h" #include "saggui/widgets/text_box.h" Modified: trunk/examples/widgets/src/widgets.cpp =================================================================== --- trunk/examples/widgets/src/widgets.cpp 2007-07-24 02:08:31 UTC (rev 449) +++ trunk/examples/widgets/src/widgets.cpp 2007-07-27 04:11:49 UTC (rev 450) @@ -140,6 +140,8 @@ static button *pushButton1 = 0; +static pushButton *pushButton2 = 0; + static textBox *textArea = 0; static listBox *lb = 0; @@ -204,6 +206,11 @@ pushButton1->setText("Clear text!"); pushButton1->onButtonClick.connect(container,&widgetContainer::onButton1); + pushButton2 = new pushButton(); + pushButton2->position.setPosition(240,220); + //pushButton2->setIcon(logo); + pushButton2->setText("Clear text!"); + cb1 = new checkBox(); cb1->position.set(10,340,resourceManager::getFont()->getWidth()+4,resourceManager::getFont()->getWidth()+4); cb1->onEnable.connect(container,&widgetContainer::fullscreen); @@ -233,6 +240,7 @@ mainBox->addChild(text2); mainBox->addChild(input1); mainBox->addChild(pushButton1); + mainBox->addChild(pushButton2); mainBox->addChild(cb1); mainBox->addChild(text3); mainBox->addChild(lb); @@ -255,6 +263,7 @@ delete text2; delete input1; delete pushButton1; + delete pushButton2; delete cb1; delete text3; Modified: trunk/include/saggui/widgets/abstractbutton.h =================================================================== --- trunk/include/saggui/widgets/abstractbutton.h 2007-07-24 02:08:31 UTC (rev 449) +++ trunk/include/saggui/widgets/abstractbutton.h 2007-07-27 04:11:49 UTC (rev 450) @@ -48,6 +48,7 @@ { //! Forward declaration class buttonGroup; + class font; //! abstractButton /*! @@ -56,7 +57,7 @@ class SAGGUI_EXPORT abstractButton : public window, mouseEvents, keyEvents { public: - //! Constructor + //! Constructor explicit abstractButton(); //! Destructor virtual ~abstractButton(); @@ -87,6 +88,7 @@ //! Set button state down void setDown(bool); + //! Is button state down? bool isDown() const; @@ -120,6 +122,12 @@ //! Get button group of button buttonGroup *getGroup() const; + //! Set current font + void setFont(font *font); + + //! Set font color + void setFontColor(const rgba &color); + //! \name PUBLIC SLOTS slot animateClick(int msec = 100); slot click(const coord &pos); @@ -133,9 +141,20 @@ signal0<> toggled; protected: - //! \name PROTECTED SLOTS + //! Current set font + font *buttonFont; + + //! Font color + 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 setClickSystem(mouseButtons type); + + //! \name PROTECTED SIGNALS + signal0<> textChanged; + signal0<> iconChanged; + signal0<> fontChanged; private: bool autoExclusive; bool autoRepeat; Copied: trunk/include/saggui/widgets/pushbutton.h (from rev 449, trunk/include/saggui/widgets/abstractbutton.h) =================================================================== --- trunk/include/saggui/widgets/pushbutton.h (rev 0) +++ trunk/include/saggui/widgets/pushbutton.h 2007-07-27 04:11:49 UTC (rev 450) @@ -0,0 +1,84 @@ +/* +SAGGUI (Simplified Allegro 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 PUSHBUTTON_H +#define PUSHBUTTON_H + +#include "saggui/widgets/abstractbutton.h" + +namespace saggui +{ + //! pushButton + /*! + * A pushable button + */ + class SAGGUI_EXPORT pushButton : public abstractButton + { + public: + //! Default Constructor + explicit pushButton(); + + //! Constructor with text + explicit pushButton(const std::string &text); + + //! Constructor with text and icon + explicit pushButton(const std::string &text, graphic *icon); + + //! Constructor with icon + explicit pushButton(graphic *icon); + + //! Destructor + virtual ~pushButton(); + + protected: + //! \name PROTECTED SLOTS + virtual slot paintEvent(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape); + private: + //! Text location + coord textPosition; + + //! Icon location + coord iconPosition; + + //! \name PRIVATE SLOTS + slot onTextChanged(); + slot onIconChanged(); + }; +} + +#endif // PUSHBUTTON_H Modified: trunk/src/widgets/abstractbutton.cpp =================================================================== --- trunk/src/widgets/abstractbutton.cpp 2007-07-24 02:08:31 UTC (rev 449) +++ trunk/src/widgets/abstractbutton.cpp 2007-07-27 04:11:49 UTC (rev 450) @@ -39,14 +39,18 @@ #ifndef ABSTRACTBUTTON_CPP #define ABSTRACTBUTTON_CPP +#include "saggui/resource_manager.h" #include "saggui/widgets/abstractbutton.h" #include "saggui/widgets/buttongroup.h" +#include "saggui/font.h" namespace saggui { - abstractButton::abstractButton() : window(W_Basic), mouseEvents(this), keyEvents(this) + abstractButton::abstractButton() : window(W_PushButton), mouseEvents(this), keyEvents(this) { setAttribute(AT_Raised,true); + setFont(resourceManager::getFont()); + setFontColor(rgba::BLACK); autoExclusive=false; autoRepeat=false; autoRepeatDelay=0; @@ -65,6 +69,7 @@ void abstractButton::setText(const std::string &text) { this->text = text; + textChanged.emit(); } std::string abstractButton::getText() const { @@ -74,6 +79,7 @@ void abstractButton::setIcon(graphic *icon) { this->icon = icon; + iconChanged.emit(); } graphic *abstractButton::getIcon() const @@ -165,6 +171,18 @@ else return 0; } + void abstractButton::setFont(font *font) + { + if(!font)return; + this->buttonFont = font; + fontChanged.emit(); + } + + void abstractButton::setFontColor(const rgba &color) + { + fontColor = color; + } + slot abstractButton::animateClick(int msec) { } Copied: trunk/src/widgets/pushbutton.cpp (from rev 449, trunk/src/widgets/abstractbutton.cpp) =================================================================== --- trunk/src/widgets/pushbutton.cpp (rev 0) +++ trunk/src/widgets/pushbutton.cpp 2007-07-27 04:11:49 UTC (rev 450) @@ -0,0 +1,155 @@ +/* +SAGGUI (Simplified Allegro 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 PUSHBUTTON_CPP +#define PUSHBUTTON_CPP + +#include "saggui/widgets/pushbutton.h" +#include "saggui/font.h" + +namespace saggui +{ + pushButton::pushButton() + { + onPaint.connect(this, &pushButton::paintEvent); + textChanged.connect(this,&pushButton::onTextChanged); + iconChanged.connect(this,&pushButton::onIconChanged); + } + + pushButton::pushButton(const std::string &text) + { + onPaint.connect(this, &pushButton::paintEvent); + setText(text); + } + + pushButton::pushButton(const std::string &text, graphic *icon) + { + onPaint.connect(this, &pushButton::paintEvent); + setText(text); + setIcon(icon); + } + + pushButton::pushButton(graphic *icon) + { + onPaint.connect(this, &pushButton::paintEvent); + setIcon(icon); + } + + pushButton::~pushButton() + { + } + + slot pushButton::paintEvent(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) + { + + const bool hasText = !this->getText().empty(); + const bool hasIcon = (this->getIcon() ? true : false); + if(hasText) + { + buttonFont->render(pos.x + textPosition.x,pos.y + textPosition.y,fontColor,bmp,0,getText()); + } + if(hasIcon) + { + this->getIcon()->renderBmp(0, 0, pos.x + iconPosition.x, pos.y + iconPosition.y, iconPosition.width, iconPosition.height, rgba::NOCOLOR, bmp); + } + } + + slot pushButton::onTextChanged() + { + if(this->getText().empty()) + { + textPosition.set(0,0,0,0); + return; + } + + textPosition.setWidth(buttonFont->getLength(this->getText())); + textPosition.setHeight(buttonFont->getHeight()); + + const double totalWidth = iconPosition.width + textPosition.width + 2; + + position.setWidth(leftPadding + rightPadding + totalWidth); + + if(iconPosition.height <= textPosition.height) + { + position.setHeight(topPadding + bottomPadding + textPosition.height + 2); + textPosition.setY(topPadding + 1); + } + else + { + position.setHeight(topPadding + bottomPadding + iconPosition.height + 2); + textPosition.setY((position.height/2) - (textPosition.height/2)); + } + + textPosition.setX(leftPadding + iconPosition.width + 1); + } + + slot pushButton::onIconChanged() + { + if(!this->getIcon()) + { + iconPosition.set(0,0,0,0); + return; + } + + iconPosition.setWidth(this->getIcon()->getBmpWidth()); + iconPosition.setHeight(this->getIcon()->getBmpHeight()); + + const double totalWidth = iconPosition.width + textPosition.width + 2; + + position.setWidth(leftPadding + rightPadding + totalWidth); + + if(iconPosition.height <= textPosition.height) + { + position.setHeight(topPadding + bottomPadding + textPosition.height + 2); + iconPosition.setY((position.height/2) - (iconPosition.height/2)); + } + else + { + position.setHeight(topPadding + bottomPadding + iconPosition.height + 2); + iconPosition.setY(topPadding + 1); + } + + iconPosition.setX(leftPadding + 1); + iconPosition.setY(topPadding + 1); + + // This is to ensure that the text actually fixes itself + onTextChanged(); + } +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@li...> - 2007-07-27 17:38:39
|
Revision: 452 http://saggui.svn.sourceforge.net/saggui/?rev=452&view=rev Author: juvinious Date: 2007-07-27 10:38:34 -0700 (Fri, 27 Jul 2007) Log Message: ----------- New push button is completely useable and recommended to be used instead of the old button implementation Modified Paths: -------------- trunk/examples/widgets/include/widgets.h trunk/examples/widgets/src/widgets.cpp trunk/include/saggui/widgets/abstractbutton.h trunk/include/saggui/widgets/pushbutton.h trunk/src/widgets/abstractbutton.cpp trunk/src/widgets/pushbutton.cpp Modified: trunk/examples/widgets/include/widgets.h =================================================================== --- trunk/examples/widgets/include/widgets.h 2007-07-27 04:17:08 UTC (rev 451) +++ trunk/examples/widgets/include/widgets.h 2007-07-27 17:38:34 UTC (rev 452) @@ -68,6 +68,8 @@ void onEnter(const keys &k); void onButton1(); + + void onButton2(const coord &pos); }; #endif /* WIDGETS_H */ Modified: trunk/examples/widgets/src/widgets.cpp =================================================================== --- trunk/examples/widgets/src/widgets.cpp 2007-07-27 04:17:08 UTC (rev 451) +++ trunk/examples/widgets/src/widgets.cpp 2007-07-27 17:38:34 UTC (rev 452) @@ -210,6 +210,7 @@ pushButton2->position.setPosition(240,220); //pushButton2->setIcon(logo); pushButton2->setText("Clear text!"); + pushButton2->clicked.connect(container,&widgetContainer::onButton2); cb1 = new checkBox(); cb1->position.set(10,340,resourceManager::getFont()->getWidth()+4,resourceManager::getFont()->getWidth()+4); @@ -316,5 +317,10 @@ textArea->clearText(); } +void widgetContainer::onButton2(const coord &pos) +{ + textArea->clearText(); +} + #endif /* WIDGETS_CPP */ Modified: trunk/include/saggui/widgets/abstractbutton.h =================================================================== --- trunk/include/saggui/widgets/abstractbutton.h 2007-07-27 04:17:08 UTC (rev 451) +++ trunk/include/saggui/widgets/abstractbutton.h 2007-07-27 17:38:34 UTC (rev 452) @@ -54,7 +54,7 @@ /*! * An abstract button representing different types of buttons, radials, etc */ - class SAGGUI_EXPORT abstractButton : public window, mouseEvents, keyEvents + class SAGGUI_EXPORT abstractButton : public window, public mouseEvents, public keyEvents { public: //! Constructor @@ -129,15 +129,15 @@ void setFontColor(const rgba &color); //! \name PUBLIC SLOTS - slot animateClick(int msec = 100); - slot click(const coord &pos); - slot toggle(); - slot setChecked(bool); + virtual slot animateClick(int msec = 100); + virtual slot click(const coord &pos); + virtual slot toggle(); + virtual slot setChecked(bool); - //! \name SIGNALS - signal0<> pressed; - signal0<> released; - signal0<> clicked; + //! \name PUBLIC SIGNALS + signal1<const coord &> pressed; + signal1<const coord &> released; + signal1<const coord &> clicked; signal0<> toggled; protected: @@ -167,6 +167,8 @@ std::string text; buttonGroup *bGroup; + + //! \name PRIVATE SLOTS slot onClicked(const coord &pos); slot onPressed(const coord &pos); slot onReleased(const coord &pos); Modified: trunk/include/saggui/widgets/pushbutton.h =================================================================== --- trunk/include/saggui/widgets/pushbutton.h 2007-07-27 04:17:08 UTC (rev 451) +++ trunk/include/saggui/widgets/pushbutton.h 2007-07-27 17:38:34 UTC (rev 452) @@ -78,6 +78,8 @@ //! \name PRIVATE SLOTS slot onTextChanged(); slot onIconChanged(); + slot depress(const coord &pos); + slot release(const coord &pos); }; } Modified: trunk/src/widgets/abstractbutton.cpp =================================================================== --- trunk/src/widgets/abstractbutton.cpp 2007-07-27 04:17:08 UTC (rev 451) +++ trunk/src/widgets/abstractbutton.cpp 2007-07-27 17:38:34 UTC (rev 452) @@ -189,6 +189,7 @@ slot abstractButton::click(const coord &pos) { + } slot abstractButton::toggle() @@ -196,9 +197,9 @@ } - slot abstractButton::setChecked(bool checkable) + slot abstractButton::setChecked(bool checked) { - this->checkable = checkable; + this->checked = checked; } // Set click system @@ -208,11 +209,6 @@ { case M_Left: { - onRightClick.disconnect_slot(this,&abstractButton::click); - onMiddleClick.disconnect_slot(this,&abstractButton::click); - - onLeftClick.connect(this,&abstractButton::click); - onRightDown.disconnect_slot(this,&abstractButton::onPressed); onRightUp.disconnect_slot(this,&abstractButton::onReleased); onRightClick.disconnect_slot(this,&abstractButton::onClicked); @@ -227,11 +223,6 @@ } case M_Right: { - onLeftClick.disconnect_slot(this,&abstractButton::click); - onMiddleClick.disconnect_slot(this,&abstractButton::click); - - onRightClick.connect(this,&abstractButton::click); - onLeftDown.disconnect_slot(this,&abstractButton::onPressed); onLeftUp.disconnect_slot(this,&abstractButton::onReleased); onLeftClick.disconnect_slot(this,&abstractButton::onClicked); @@ -273,6 +264,8 @@ bGroup->buttonClickedObj.emit(this); bGroup->buttonClickedID.emit(getID()); } + + clicked.emit(pos); } slot abstractButton::onPressed(const coord &pos) @@ -282,6 +275,8 @@ bGroup->buttonPressedObj.emit(this); bGroup->buttonPressedID.emit(getID()); } + + pressed.emit(pos); } slot abstractButton::onReleased(const coord &pos) @@ -291,6 +286,8 @@ bGroup->buttonReleasedObj.emit(this); bGroup->buttonReleasedID.emit(getID()); } + + released.emit(pos); } } Modified: trunk/src/widgets/pushbutton.cpp =================================================================== --- trunk/src/widgets/pushbutton.cpp 2007-07-27 04:17:08 UTC (rev 451) +++ trunk/src/widgets/pushbutton.cpp 2007-07-27 17:38:34 UTC (rev 452) @@ -49,6 +49,9 @@ onPaint.connect(this, &pushButton::paintEvent); textChanged.connect(this,&pushButton::onTextChanged); iconChanged.connect(this,&pushButton::onIconChanged); + pressed.connect(this,&pushButton::depress); + released.connect(this,&pushButton::release); + setAttribute(AT_Raised | AT_Off,true); } pushButton::pushButton(const std::string &text) @@ -76,14 +79,11 @@ slot pushButton::paintEvent(const coord &pos, graphic *bmp, const std::vector<rgba> &colors, const uint32_t &flags, const shapeType &shape) { - - const bool hasText = !this->getText().empty(); - const bool hasIcon = (this->getIcon() ? true : false); - if(hasText) + if(!this->getText().empty()) { buttonFont->render(pos.x + textPosition.x,pos.y + textPosition.y,fontColor,bmp,0,getText()); } - if(hasIcon) + if(this->getIcon()) { this->getIcon()->renderBmp(0, 0, pos.x + iconPosition.x, pos.y + iconPosition.y, iconPosition.width, iconPosition.height, rgba::NOCOLOR, bmp); } @@ -150,6 +150,28 @@ // This is to ensure that the text actually fixes itself onTextChanged(); } + + slot pushButton::depress(const coord &pos) + { + setAttribute(AT_Raised,false); + setAttribute(AT_Sunken | AT_Pressed,true); + + textPosition.x++; + textPosition.y++; + iconPosition.x++; + iconPosition.y++; + } + + slot pushButton::release(const coord &pos) + { + setAttribute(AT_Raised,true); + setAttribute(AT_Sunken | AT_Pressed,false); + + textPosition.x--; + textPosition.y--; + iconPosition.x--; + iconPosition.y--; + } } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |